diff --git a/components/ChatWindow.tsx b/components/ChatWindow.tsx index f12141f85..470a5f9c1 100644 --- a/components/ChatWindow.tsx +++ b/components/ChatWindow.tsx @@ -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 = ( ); @@ -1464,6 +1470,7 @@ export function ChatWindow({ session, newSessionCwd, newSessionWorkspace, toolCa subagents={subagents} onSelectSubagent={setSelectedSubagent} btw={btwPanel} + liveStatus={composerStatusText} /> diff --git a/components/ComposerPanels.test.mjs b/components/ComposerPanels.test.mjs index 5c845abd2..1fc931534 100644 --- a/components/ComposerPanels.test.mjs +++ b/components/ComposerPanels.test.mjs @@ -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 { + 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/); +}); diff --git a/components/ComposerPanels.tsx b/components/ComposerPanels.tsx index f33ff6796..7d3c31187 100644 --- a/components/ComposerPanels.tsx +++ b/components/ComposerPanels.tsx @@ -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)); @@ -236,8 +239,19 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false } > {t("chatWindow.subagentsPanel")} + {liveStatus ? ( + + + {liveStatus} + + ) : null} @@ -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 (
{btw && } { saveCollapsed(TODO_COLLAPSED_STORAGE_KEY, collapsed); setTodoCollapsed(collapsed); }} /> - +
); } diff --git a/components/TodoList.test.mjs b/components/TodoList.test.mjs index 331336a6d..9886f945d 100644 --- a/components/TodoList.test.mjs +++ b/components/TodoList.test.mjs @@ -135,3 +135,14 @@ test("the scroll area is reachable by keyboard and named", () => { assert.match(html, /]*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"/); +}); diff --git a/components/TodoList.tsx b/components/TodoList.tsx index 4f6fb7a43..7ed5c91ed 100644 --- a/components/TodoList.tsx +++ b/components/TodoList.tsx @@ -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; @@ -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); @@ -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 ? ( + + + {liveStatus} + + ) : null; return (
{t("chatWindow.todoList")} - {progress} + {liveStatusNode} + {progress} {t("chatWindow.todoList")} - {progress} + {liveStatusNode} + {progress} )} {!collapsed && (