Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,12 @@ export function ChatWindow({ session, newSessionCwd, newSessionWorkspace, toolCa
const active = document.activeElement;
if (askOpen && active instanceof HTMLElement && hiddenComposerRef.current?.contains(active)) active.blur();
}, [askOpen]);
// The live status is merged into a ComposerPanels header row (#245)
// whenever one exists (todo or subagent row); only then is the
// standalone ChatInput status bar suppressed. With no host row, or in
// the minimized pill bar (which keeps composerStatusText below), the
// bar stays so the status is never hidden.
const hasStatusHostRow = todoPhases.length > 0 || subagents.length > 0;
const chatInputElement = (
<ChatInput
ref={chatInputRef}
Expand Down Expand Up @@ -1107,7 +1113,7 @@ export function ChatWindow({ session, newSessionCwd, newSessionWorkspace, toolCa
accept Escape-to-minimize in the fresh-chat branch where there is
nothing to collapse. */
onMinimize={isEmptyNew ? undefined : handleMinimize}
statusText={composerStatusText}
statusText={hasStatusHostRow ? null : composerStatusText}
onOpenProviders={onOpenProviders}
/>
);
Expand Down Expand Up @@ -1464,6 +1470,7 @@ export function ChatWindow({ session, newSessionCwd, newSessionWorkspace, toolCa
subagents={subagents}
onSelectSubagent={setSelectedSubagent}
btw={btwPanel}
liveStatus={composerStatusText}
/>
<ExtensionWidgets widgets={belowEditorWidgets} />
</div>
Expand Down
35 changes: 35 additions & 0 deletions components/ComposerPanels.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,38 @@ test("a side question keeps Copy for the earlier answer when its follow-up ended
assert.match(html, /Cancelled/);
assert.match(html, />Copy answer</);
});

test("merges live status into the todo header row when tasks exist (#245)", () => {
const html = renderToStaticMarkup(React.createElement(ComposerPanels, {
todoPhases: [{ name: "Implementation", tasks: [{ content: "Wire panels", status: "in_progress" }] }],
subagents: [{ id: "s1", agent: "scout", status: "started", task: "Map the surface", index: 0 }],
onSelectSubagent: noop,
liveStatus: "Waiting for model...",
}));
// Hosted exactly once: by the todo row, not duplicated in the subagent row.
// (The string itself appears twice in markup — text plus title — so count
// the role="status" host elements instead.)
assert.equal((html.match(/role="status"/g) || []).length, 1);
assert.match(html, /Tasks/);
});

test("merges live status into the subagent header row when no tasks exist (#245)", () => {
const html = renderToStaticMarkup(React.createElement(ComposerPanels, {
todoPhases: [],
subagents: [{ id: "s1", agent: "scout", status: "started", task: "Map the surface", index: 0 }],
onSelectSubagent: noop,
liveStatus: "Waiting for model...",
}));
assert.match(html, /Waiting for model\.\.\./);
assert.match(html, /Subagents/);
});

test("keeps panels unchanged when no live status is present (#245)", () => {
const html = renderToStaticMarkup(React.createElement(ComposerPanels, {
todoPhases: [{ name: "Implementation", tasks: [{ content: "Wire panels", status: "in_progress" }] }],
subagents: [],
onSelectSubagent: noop,
}));
assert.match(html, /Tasks/);
assert.doesNotMatch(html, /Waiting for model/);
});
30 changes: 26 additions & 4 deletions components/ComposerPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ function SubagentActivityLine({ subagent }: { subagent: SubagentInfo }) {
);
}

function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false }: {
function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false, liveStatus = null }: {
subagents: SubagentInfo[];
onSelectSubagent: (subagent: SubagentInfo) => void;
/** Initial expansion (default: collapsed — the header still shows the live summary). */
defaultExpanded?: boolean;
/** Transient live-agent status merged into this header row when no todo
* row exists to host it (#245). See TodoList's liveStatus. */
liveStatus?: string | null;
}) {
const { t } = useI18n();
const [collapsed, setCollapsed] = useState(() => loadCollapsed(SUBAGENTS_COLLAPSED_STORAGE_KEY, defaultExpanded));
Expand Down Expand Up @@ -236,8 +239,19 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false }
>
<Network size={14} strokeWidth={1.8} aria-hidden />
<strong className="font-medium text-text">{t("chatWindow.subagentsPanel")}</strong>
{liveStatus ? (
<span
role="status"
aria-live="polite"
title={liveStatus}
style={{ flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", display: "inline-flex", alignItems: "center", gap: 6, color: "var(--text-muted)" }}
>
<span aria-hidden className="live-status-dot live-pulse inline-block h-2 w-2 shrink-0 rounded-full bg-accent" />
<span style={{ minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{liveStatus}</span>
</span>
) : null}
<span
className="ml-auto inline-flex items-center gap-1.5"
className={`${liveStatus ? "" : "ml-auto "}inline-flex items-center gap-1.5`}
aria-label={t("chatWindow.subagentSummary", { running: runningCount, total: subagents.length })}
title={t("chatWindow.subagentSummary", { running: runningCount, total: subagents.length })}
>
Expand Down Expand Up @@ -299,27 +313,35 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false }
* via its header row (`chevron`); todo/subagents start collapsed (headers
* always show live progress / running-summary), a new side question starts
* expanded. Rendered pinned above the chat input. */
export function ComposerPanels({ todoPhases, subagents, onSelectSubagent, btw = null, defaultExpanded = false }: {
export function ComposerPanels({ todoPhases, subagents, onSelectSubagent, btw = null, defaultExpanded = false, liveStatus = null }: {
todoPhases: TodoPhase[];
subagents: SubagentInfo[];
onSelectSubagent: (subagent: SubagentInfo) => void;
btw?: BtwPanelProps | null;
/** Initial expansion of both panels (default: collapsed). */
defaultExpanded?: boolean;
/** Transient live-agent status (the ChatInput status bar's text) to merge
* into an existing panel header row instead of mounting as its own line
* (#245). Hosted by the todo row when one exists, else by the subagent
* row; when neither exists the caller keeps the standalone bar so the
* status is never hidden. */
liveStatus?: string | null;
}) {
const [todoCollapsed, setTodoCollapsed] = useState(() => loadCollapsed(TODO_COLLAPSED_STORAGE_KEY, defaultExpanded));
if (todoPhases.length === 0 && subagents.length === 0 && !btw) return null;
const todoHostsLiveStatus = todoPhases.length > 0;
return (
<div style={{ display: "grid", gap: 6, marginBottom: 8 }}>
{btw && <BtwPanel key={btw.record.id} {...btw} />}
<TodoList
phases={todoPhases}
liveStatus={todoHostsLiveStatus ? liveStatus : null}
collapsible
defaultExpanded={defaultExpanded}
collapsed={todoCollapsed}
onCollapsedChange={(collapsed) => { saveCollapsed(TODO_COLLAPSED_STORAGE_KEY, collapsed); setTodoCollapsed(collapsed); }}
/>
<SubagentsPanel subagents={subagents} onSelectSubagent={onSelectSubagent} defaultExpanded={defaultExpanded} />
<SubagentsPanel subagents={subagents} onSelectSubagent={onSelectSubagent} defaultExpanded={defaultExpanded} liveStatus={todoHostsLiveStatus ? null : liveStatus} />
</div>
);
}
Expand Down
11 changes: 11 additions & 0 deletions components/TodoList.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,14 @@ test("the scroll area is reachable by keyboard and named", () => {
assert.match(html, /<section[^>]*aria-label="Tasks"/);
assert.doesNotMatch(html, /role="group"[^>]*aria-label="Tasks"/);
});

test("merges live status into the tasks header row instead of a separate line (#245)", () => {
const html = renderToStaticMarkup(React.createElement(TodoList, {
phases: [{ name: "Implementation", tasks: [{ content: "Wire panels", status: "in_progress" }] }],
collapsible: true,
liveStatus: "Waiting for model...",
}));
assert.match(html, /Waiting for model\.\.\./);
assert.match(html, /0\/1 complete/);
assert.match(html, /role="status"/);
});
27 changes: 24 additions & 3 deletions components/TodoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function TodoStatusIcon({ status }: { status: TodoItem["status"] }) {

interface TodoListProps {
phases?: TodoPhase[];
/** Transient live-agent status (e.g. "Waiting for model...") merged into
* this header row instead of mounting as a separate line above the
* composer (#245). The row already exists whenever phases exist, so the
* status text changes in place rather than popping a line in and out. */
liveStatus?: string | null;
/** Render as a composer-attached panel: the header row becomes a
* collapse/expand toggle and the section margin is dropped. */
collapsible?: boolean;
Expand All @@ -35,7 +40,7 @@ function previewTaskOrder(status: TodoItem["status"]): number {
return 2;
}

export function TodoList({ phases = [], collapsible = false, defaultExpanded = false, collapsed: collapsedProp, onCollapsedChange }: TodoListProps) {
export function TodoList({ phases = [], liveStatus = null, collapsible = false, defaultExpanded = false, collapsed: collapsedProp, onCollapsedChange }: TodoListProps) {
const { t } = useI18n();
const [expanded, setExpanded] = useState(false);
const [collapsedState, setCollapsedState] = useState(collapsible ? !defaultExpanded : false);
Expand Down Expand Up @@ -65,6 +70,20 @@ export function TodoList({ phases = [], collapsible = false, defaultExpanded = f
const headerRowClass = "flex items-center gap-2 px-3 py-2 text-xs text-text-muted";
const headerBorderClass = collapsed ? "" : "border-b border-border";
const progress = t("chatWindow.todoProgress", { done, total: tasks.length });
// Merged live status (#245): sits in this already-present header row so
// it changes in place instead of mounting a separate line above the
// composer. role="status" keeps the live announcement the old bar had.
const liveStatusNode = liveStatus ? (
<span
role="status"
aria-live="polite"
title={liveStatus}
style={{ flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", display: "inline-flex", alignItems: "center", gap: 6, color: "var(--text-muted)" }}
>
<span aria-hidden className="live-status-dot live-pulse inline-block h-2 w-2 shrink-0 rounded-full bg-accent" />
<span style={{ minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{liveStatus}</span>
</span>
) : null;

return (
<section
Expand All @@ -83,7 +102,8 @@ export function TodoList({ phases = [], collapsible = false, defaultExpanded = f
>
<ListChecks size={15} strokeWidth={1.8} aria-hidden />
<strong className="font-medium text-text">{t("chatWindow.todoList")}</strong>
<span className="ml-auto">{progress}</span>
{liveStatusNode}
<span className={liveStatus ? "shrink-0" : "ml-auto"}>{progress}</span>
<ChevronDown
size={14}
strokeWidth={1.8}
Expand All @@ -99,7 +119,8 @@ export function TodoList({ phases = [], collapsible = false, defaultExpanded = f
<div className={`${headerRowClass} ${headerBorderClass}`}>
<ListChecks size={15} strokeWidth={1.8} aria-hidden />
<strong className="font-medium text-text">{t("chatWindow.todoList")}</strong>
<span className="ml-auto">{progress}</span>
{liveStatusNode}
<span className={liveStatus ? "shrink-0" : "ml-auto"}>{progress}</span>
</div>
)}
{!collapsed && (
Expand Down
Loading