Skip to content

The agent that grows with you

feat(desktop): live task progress on inbox cards

Brooklyn Nicholson92620e4ad327
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.tsx b/apps/desktop/src/app/chat/sidebar/session-row.tsx
index 672f92653dd..c02a9589cfb 100644
--- a/apps/desktop/src/app/chat/sidebar/session-row.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-row.tsx
@@ -29,6 +29,7 @@ import { $projects } from '@/store/projects'
import { $pullRequestsByBranch, sessionPrKey } from '@/store/pull-requests'
import { $sessionDotStateById, hasLiveTurn, showsRunningArc } from '@/store/session-dot-state'
import { sessionCostUsd } from '@/store/sidebar-archive'
+import { $todoProgressBySession } from '@/store/todos'
import { SessionStatusDot } from '../session-status-dot'
@@ -237,6 +238,9 @@ function SidebarSessionRowImpl({
// between them (HTML collapses runs of whitespace to one).
const model = card && session.model ? displayModelName(session.model) : ''
const size = card && session.message_count > 0 ? r.messageCount(session.message_count) : ''
+ // Live plan progress ("3/7"), far right of the footer. A selector keyed to
+ // this row: only rows whose own fraction changes repaint on todo events.
+ const todoProgress = useStoreSelector($todoProgressBySession, progress => (card ? progress[session.id] : undefined))
// An archived session has no live status to paint, so the archive glyph takes
// the lead slot the dot would occupy instead of adding a column of its own.
@@ -471,10 +475,15 @@ function SidebarSessionRowImpl({
</span>
) : null}
</div>
- {model || size ? (
+ {model || size || todoProgress ? (
<span className="flex min-w-0 items-baseline gap-2 text-[0.625rem] leading-none text-(--ui-text-tertiary)">
{model ? <span className="min-w-0 truncate">{model}</span> : null}
{size ? <span className="shrink-0 tabular-nums">{size}</span> : null}
+ {todoProgress ? (
+ <span className="ml-auto shrink-0 tabular-nums" title={r.todoProgress}>
+ {todoProgress}
+ </span>
+ ) : null}
</span>
) : null}
</>
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index ae483771151..acd60ae8ab2 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -1986,6 +1986,7 @@ export const en: Translations = {
untitledPlaceholder: 'Untitled session',
untitledChat: id => `Chat ${id}`,
messageCount: count => `${count} ${count === 1 ? 'message' : 'messages'}`,
+ todoProgress: 'Tasks completed',
ageNow: 'now',
ageDay: 'd',
ageHour: 'h',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 37bf9539820..83a5ba7ca9a 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1675,6 +1675,7 @@ export interface Translations {
untitledPlaceholder: string
untitledChat: (id: string) => string
messageCount: (count: number) => string
+ todoProgress: string
ageNow: string
ageDay: string
ageHour: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 701d7bff689..c6522754dff 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2177,6 +2177,7 @@ export const zh: Translations = {
untitledPlaceholder: '无标题会话',
untitledChat: id => `会话 ${id}`,
messageCount: count => `${count} 条消息`,
+ todoProgress: '任务完成度',
ageNow: '刚刚',
ageDay: '天',
ageHour: '时',
diff --git a/apps/desktop/src/store/todos.ts b/apps/desktop/src/store/todos.ts
index 31aed642f38..e63c4f67f55 100644
--- a/apps/desktop/src/store/todos.ts
+++ b/apps/desktop/src/store/todos.ts
@@ -1,7 +1,11 @@
-import { atom } from 'nanostores'
+import { atom, computed } from 'nanostores'
+import { stableRecord } from '@/lib/stable-array'
import type { TodoItem } from '@/lib/todos'
+import { $sessions, lineageAliases } from './session'
+import { $sessionStates } from './session-states'
+
/**
* Live todo list per runtime session, rendered by the composer status stack
* (the inline transcript panel is gone). Fed from two places:
@@ -16,6 +20,37 @@ export const $todosBySession = atom<Record<string, TodoItem[]>>({})
export const todoListActive = (todos: readonly TodoItem[]) =>
todos.some(t => t.status === 'pending' || t.status === 'in_progress')
+let todoProgress: Readonly<Record<string, string>> = {}
+
+/** Live "X/Y" per STORED session id, for the sidebar's inbox cards. The live
+ * map keys on runtime ids; this projects through the same storedSessionId +
+ * lineage-alias fallback as the working/attention projections, so the card
+ * finds its count under the id the sidebar knows. Cancelled items don't
+ * count toward either side of the fraction. Values are the rendered "X/Y"
+ * string — primitives, so stableRecord can suppress no-op emits. */
+export const $todoProgressBySession = computed(
+ [$todosBySession, $sessionStates, $sessions],
+ (todosMap, states, sessions) => {
+ const next: Record<string, string> = {}
+
+ for (const [runtimeId, todos] of Object.entries(todosMap)) {
+ const counted = todos.filter(t => t.status !== 'cancelled')
+
+ if (counted.length === 0) {
+ continue
+ }
+
+ const progress = `${counted.filter(t => t.status === 'completed').length}/${counted.length}`
+
+ for (const alias of lineageAliases(states[runtimeId]?.storedSessionId ?? runtimeId, sessions)) {
+ next[alias] = progress
+ }
+ }
+
+ return (todoProgress = stableRecord(todoProgress, next))
+ }
+)
+
// Decide which todo list to restore when rehydrating a session from stored
// history. Rehydration runs *after* a turn completes, so an active list (last
// item still pending/in_progress) is stale — the turn ended without a final