Skip to content

The agent that grows with you

feat(desktop): show collapsed todo running indicator

Pink6fcc202687dd
diff --git a/apps/desktop/src/app/chat/composer/status-stack/collapsed-indicator.test.tsx b/apps/desktop/src/app/chat/composer/status-stack/collapsed-indicator.test.tsx
new file mode 100644
index 00000000000..1b528d3827a
--- /dev/null
+++ b/apps/desktop/src/app/chat/composer/status-stack/collapsed-indicator.test.tsx
@@ -0,0 +1,63 @@
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+import { MemoryRouter } from 'react-router-dom'
+import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
+
+import { $todosBySession } from '@/store/todos'
+
+import { ComposerStatusStack } from './index'
+
+describe('ComposerStatusStack collapsed todo indicator', () => {
+ beforeAll(() => {
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ disconnect() {}
+ observe() {}
+ }
+ )
+ })
+
+ afterEach(() => {
+ cleanup()
+ $todosBySession.set({})
+ })
+
+ it('shows a running indicator next to the collapsed todo label', () => {
+ $todosBySession.set({
+ 'session-1': [{ content: 'Wire the status stack', id: '1', status: 'in_progress' }]
+ })
+
+ render(
+ <MemoryRouter>
+ <ComposerStatusStack queue={null} sessionId="session-1" />
+ </MemoryRouter>
+ )
+
+ const button = screen.getByRole('button', { name: /Tasks 0\/1/ })
+ fireEvent.click(button)
+
+ const label = screen.getByText('Tasks 0/1')
+ const indicator = screen.getByRole('status')
+
+ expect(screen.queryByText('Wire the status stack')).toBeNull()
+ expect(button.contains(indicator)).toBe(true)
+ expect(label.compareDocumentPosition(indicator) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
+ })
+
+ it('does not show a collapsed todo indicator when no todo is running', () => {
+ $todosBySession.set({
+ 'session-1': [{ content: 'Wire the status stack', id: '1', status: 'completed' }]
+ })
+
+ render(
+ <MemoryRouter>
+ <ComposerStatusStack queue={null} sessionId="session-1" />
+ </MemoryRouter>
+ )
+
+ fireEvent.click(screen.getByRole('button', { name: /Tasks 1\/1/ }))
+
+ expect(screen.queryByText('Wire the status stack')).toBeNull()
+ expect(screen.queryByRole('status')).toBeNull()
+ })
+})
diff --git a/apps/desktop/src/app/chat/composer/status-stack/index.tsx b/apps/desktop/src/app/chat/composer/status-stack/index.tsx
index de86ba14d0f..c6dd3ff7b7b 100644
--- a/apps/desktop/src/app/chat/composer/status-stack/index.tsx
+++ b/apps/desktop/src/app/chat/composer/status-stack/index.tsx
@@ -9,6 +9,7 @@ import { composerDockCard } from '@/components/chat/composer-dock'
import { StatusSection } from '@/components/chat/status-section'
import { Button } from '@/components/ui/button'
import { Codicon } from '@/components/ui/codicon'
+import { GlyphSpinner } from '@/components/ui/glyph-spinner'
import { Tip, TipKeybindLabel } from '@/components/ui/tooltip'
import { type Translations, useI18n } from '@/i18n'
import { useSessionSlice } from '@/lib/use-session-slice'
@@ -69,6 +70,9 @@ const groupLabel = (group: StatusGroup, s: Translations['statusStack']) => {
return group.type === 'subagent' ? s.subagents(group.items.length) : s.background(group.items.length)
}
+const hasRunningTodo = (group: StatusGroup) =>
+ group.type === 'todo' && group.items.some(item => item.todoStatus === 'in_progress' && item.state === 'running')
+
interface ComposerStatusStackProps {
/** The queue, built by the composer (it owns the queue's callbacks). Rendered
* as the last group so it stays fused to the composer like before. */
@@ -170,6 +174,15 @@ export function ComposerStatusStack({ queue, sessionId }: ComposerStatusStackPro
</Tip>
) : undefined
}
+ collapsedIndicator={
+ hasRunningTodo(group) ? (
+ <GlyphSpinner
+ ariaLabel={t.statusStack.running}
+ className="text-[0.8rem] leading-none text-muted-foreground/80"
+ spinner="braille"
+ />
+ ) : undefined
+ }
defaultCollapsed={group.type !== 'todo' && group.type !== 'goal'}
icon={<Codicon className="text-muted-foreground/70" name={GROUP_ICON[group.type]} size="0.8rem" />}
label={groupLabel(group, t.statusStack)}
diff --git a/apps/desktop/src/components/chat/status-section.tsx b/apps/desktop/src/components/chat/status-section.tsx
index 161cc6f6a69..ab9c1180503 100644
--- a/apps/desktop/src/components/chat/status-section.tsx
+++ b/apps/desktop/src/components/chat/status-section.tsx
@@ -7,6 +7,8 @@ interface StatusSectionProps {
* `Button` with `size="micro"` + `variant="text"` or `"link"`. */
accessory?: ReactNode
children: ReactNode
+ /** Optional inline status shown only while the group is collapsed. */
+ collapsedIndicator?: ReactNode
defaultCollapsed?: boolean
/** Optional glyph between the caret and the label (e.g. a `Codicon`). */
icon?: ReactNode
@@ -19,7 +21,14 @@ interface StatusSectionProps {
* (queue, subagents, background) reads as one piece. The stack supplies the
* outer card and the dividers between groups; this owns only its own collapse.
*/
-export function StatusSection({ accessory, children, defaultCollapsed = true, icon, label }: StatusSectionProps) {
+export function StatusSection({
+ accessory,
+ children,
+ collapsedIndicator,
+ defaultCollapsed = true,
+ icon,
+ label
+}: StatusSectionProps) {
const [collapsed, setCollapsed] = useState(defaultCollapsed)
return (
@@ -32,7 +41,10 @@ export function StatusSection({ accessory, children, defaultCollapsed = true, ic
>
<DisclosureCaret className="shrink-0" open={!collapsed} size="1em" />
{icon && <span className="flex shrink-0 items-center">{icon}</span>}
- <span className="truncate">{label}</span>
+ <span className="min-w-0 truncate">{label}</span>
+ {collapsed && collapsedIndicator && (
+ <span className="flex shrink-0 items-center">{collapsedIndicator}</span>
+ )}
</button>
{accessory && <div className="flex shrink-0 items-center gap-1">{accessory}</div>}
</div>