The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): surface live subagent work above each composer
Teknium092ed67532a4
diff --git a/apps/desktop/src/app/agents/index.tsx b/apps/desktop/src/app/agents/index.tsxindex cd3f36f168b..3921d5e98c6 100644--- a/apps/desktop/src/app/agents/index.tsx+++ b/apps/desktop/src/app/agents/index.tsx@@ -320,7 +320,7 @@ function StreamLine({)}-function SubagentRow({ node, depth = 0, nowMs }: { node: SubagentNode; depth?: number; nowMs: number }) {+export function SubagentRow({ node, depth = 0, nowMs }: { node: SubagentNode; depth?: number; nowMs: number }) {const { t } = useI18n()const running = node.status === 'running' || node.status === 'queued'const elapsed = useElapsedSeconds(running, `subagent:${node.id}`)diff --git a/apps/desktop/src/app/chat/composer/status-stack/index.tsx b/apps/desktop/src/app/chat/composer/status-stack/index.tsxindex 9c5b77dd3c0..c7a085450be 100644--- a/apps/desktop/src/app/chat/composer/status-stack/index.tsx+++ b/apps/desktop/src/app/chat/composer/status-stack/index.tsx@@ -34,6 +34,7 @@ import { PreviewStatusRow } from './preview-row'import { SessionControlSections } from './session-control'import { useSessionValue } from './session-control-utils'import { StatusItemRow } from './status-row'+import { SubagentSection } from './subagent-section'// Slow safety-net poll for silent exits (processes without notify_on_complete// emit no event when they die). Only armed while a running row is on screen.@@ -192,6 +193,12 @@ export function ComposerStatusStack({ onSubmit, queue, sessionId }: ComposerStat}for (const group of groups) {+ if (group.type === 'subagent' && sessionId) {+ sections.push({ key: group.type, node: <SubagentSection key={sessionId} sessionId={sessionId} /> })++ continue+ }+sections.push({key: group.type,node: (diff --git a/apps/desktop/src/app/chat/composer/status-stack/subagent-section.test.tsx b/apps/desktop/src/app/chat/composer/status-stack/subagent-section.test.tsxnew file mode 100644index 00000000000..98f120e121d--- /dev/null+++ b/apps/desktop/src/app/chat/composer/status-stack/subagent-section.test.tsx@@ -0,0 +1,38 @@+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'+import { MemoryRouter } from 'react-router'+import { afterEach, expect, it, vi } from 'vitest'++import { $subagentsBySession, upsertSubagent } from '@/store/subagents'++import { ComposerStatusStack } from './index'++vi.stubGlobal('ResizeObserver', class { disconnect() {} observe() {} })++afterEach(() => { cleanup(); $subagentsBySession.set({}) })++it('automatically previews bounded live work only from the composer session, including queued children', () => {+ for (let i = 0; i < 5; i++) {+ upsertSubagent('owner', { subagent_id: `child-${i}`, goal: `Task ${i}`, status: i ? 'queued' : 'running' })+ }++ upsertSubagent('other-profile', { subagent_id: 'foreign', goal: 'Private foreign task' })+ upsertSubagent('owner', { subagent_id: 'child-0', text: 'Reading actual source' }, false, 'subagent.progress')+ const view = render(<MemoryRouter><ComposerStatusStack queue={null} sessionId="owner" /></MemoryRouter>)+ expect(screen.getByText('Task 0')).toBeTruthy()+ expect(screen.getByText('Reading actual source')).toBeTruthy()+ expect(screen.queryByText('Task 4')).toBeNull()+ expect(screen.queryByText('Private foreign task')).toBeNull()+ expect(screen.getByRole('button', { name: /5 Subagents/ })).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: /5 Subagents/ }))+ expect(screen.getByText('Task 4')).toBeTruthy()+ view.rerender(<MemoryRouter><ComposerStatusStack queue={null} sessionId="empty" /></MemoryRouter>)+ expect(screen.queryByText('Task 0')).toBeNull()+})++it('retires the live frame only after every child settles, without depending on the parent busy state', () => {+ upsertSubagent('owner', { subagent_id: 'child', goal: 'Live task' })+ render(<MemoryRouter><ComposerStatusStack queue={null} sessionId="owner" /></MemoryRouter>)+ expect(screen.getByText('Live task')).toBeTruthy()+ act(() => upsertSubagent('owner', { subagent_id: 'child', status: 'completed' }, false, 'subagent.complete'))+ expect(screen.queryByText('Live task')).toBeNull()+})diff --git a/apps/desktop/src/app/chat/composer/status-stack/subagent-section.tsx b/apps/desktop/src/app/chat/composer/status-stack/subagent-section.tsxnew file mode 100644index 00000000000..fda6f4c4efa--- /dev/null+++ b/apps/desktop/src/app/chat/composer/status-stack/subagent-section.tsx@@ -0,0 +1,58 @@+import { useEffect, useState } from 'react'++import { SubagentRow } from '@/app/agents'+import { ActivityTimerText } from '@/components/chat/activity-timer-text'+import { StatusSection } from '@/components/chat/status-section'+import { Codicon } from '@/components/ui/codicon'+import { GlyphSpinner } from '@/components/ui/glyph-spinner'+import { useI18n } from '@/i18n'+import { useSessionSlice } from '@/lib/use-session-slice'+import { $subagentsBySession, type SubagentProgress } from '@/store/subagents'++interface SubagentSectionProps {+ sessionId: string+}++/** A composer-local roster: never borrow the global Agents panel's scope. */+export function SubagentSection({ sessionId }: SubagentSectionProps) {+ const { t } = useI18n()+ const items = useSessionSlice($subagentsBySession, sessionId)+ const live = items.filter(item => item.status === 'running' || item.status === 'queued')+ const [nowMs, setNowMs] = useState(Date.now)+ const [selected, setSelected] = useState<string | null>(null)+ const hasLive = live.length > 0++ useEffect(() => {+ if (!hasLive) { return }+ const timer = setInterval(() => setNowMs(Date.now()), 1000)++ return () => clearInterval(timer)+ }, [hasLive])++ if (!hasLive) { return null }++ const row = (item: SubagentProgress) => (+ <button aria-expanded={selected === item.id} className="flex w-full min-w-0 items-start gap-2 px-2 py-1 text-left"+ key={item.id} onClick={() => setSelected(selected === item.id ? null : item.id)} type="button">+ <GlyphSpinner ariaLabel={t.agents.running} className="mt-0.5 shrink-0 text-(--ui-purple)" spinner="braille" />+ <span className="min-w-0 flex-1">+ <span className="block truncate text-xs text-(--ui-text-primary)">{item.goal}</span>+ <span className="block truncate text-[0.68rem] text-(--ui-text-tertiary)">{item.stream.at(-1)?.text || (item.status === 'queued' ? t.agents.queued : t.agents.waitingActivity)}</span>+ </span>+ <ActivityTimerText className="shrink-0 text-[0.65rem]" seconds={Math.max(0, Math.floor((nowMs - item.startedAt) / 1000))} />+ </button>+ )++ const detail = items.find(item => item.id === selected)++ return <div className="composer-no-drag min-w-0" data-slot="composer-subagents">+ <StatusSection icon={<Codicon className="text-(--ui-purple)" name="agent" size="0.8rem" />}+ label={t.statusStack.subagents(live.length)}+ preview={<>{live.slice(0, 3).map(row)}{live.length > 3 && <p className="px-2 text-[0.68rem] text-(--ui-text-tertiary)">{t.agents.moreAgents(live.length - 3)}</p>}</>}>+ <div className="max-h-[25vh] overflow-y-auto overscroll-contain">{live.map(row)}</div>+ </StatusSection>+ {detail && <div className="max-h-[25vh] overflow-y-auto overscroll-contain px-3 py-2" data-slot="composer-subagent-detail">+ <SubagentRow node={{...detail, children: []}} nowMs={nowMs} />+ </div>}+ </div>+}diff --git a/apps/desktop/src/components/chat/status-section.tsx b/apps/desktop/src/components/chat/status-section.tsxindex 4fbf3152202..1a9847a83ca 100644--- a/apps/desktop/src/components/chat/status-section.tsx+++ b/apps/desktop/src/components/chat/status-section.tsx@@ -10,6 +10,8 @@ interface StatusSectionProps {/** Optional inline status next to the label (running spinner, etc). */collapsedIndicator?: ReactNodedefaultCollapsed?: boolean+ /** Compact live content stays visible while the full roster is collapsed. */+ preview?: ReactNode/** Optional glyph between the caret and the label (e.g. a `Codicon`). */icon?: ReactNodelabel: ReactNode@@ -27,7 +29,8 @@ export function StatusSection({collapsedIndicator,defaultCollapsed = true,icon,- label+ label,+ preview}: StatusSectionProps) {const [collapsed, setCollapsed] = useState(defaultCollapsed)@@ -35,6 +38,7 @@ export function StatusSection({<div><div className="flex items-center gap-1 pr-1"><button+ aria-expanded={!collapsed}className="flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1 text-left text-xs font-normal text-muted-foreground/92 transition-colors hover:text-foreground/90"onClick={() => setCollapsed(open => !open)}type="button"@@ -46,7 +50,7 @@ export function StatusSection({</button>{accessory && <div className="flex shrink-0 items-center gap-1">{accessory}</div>}</div>- {!collapsed && <div className="px-1 pb-0.5">{children}</div>}+ {(!collapsed || preview) && <div className="px-1 pb-0.5">{collapsed ? preview : children}</div>}</div>)}diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 06e0fe375b5..32ec296f75b 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -1080,6 +1080,14 @@ export const ar = defineLocale({streaming: 'جار البث',files: 'الملفات',moreFiles: count => `+${count} ملفات إضافية`,+ moreAgents: count => `${count} وكلاء إضافيون`,+ queued: 'في قائمة الانتظار',+ waitingActivity: 'بانتظار النشاط',+ steer: 'توجيه',+ steerPlaceholder: 'تعليمات لهذا الوكيل الفرعي',+ steerQueued: 'في انتظار نقطة التحقق التالية',+ stopRequested: 'تم طلب الإيقاف',+ requestRejected: 'لم يقبل الوكيل الفرعي الطلب',delegation: index => `التفويض ${index}`,workers: count => `${count} عامل`,workersActive: count => `${count} نشط`,diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex f1f239a4c3d..11b6d8e6ee3 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1593,6 +1593,14 @@ export const en: Translations = {streaming: 'Streaming',files: 'Files',moreFiles: count => `+${count} more files`,+ moreAgents: count => `+${count} more agents`,+ queued: 'Queued',+ waitingActivity: 'Waiting for activity',+ steer: 'Steer',+ steerPlaceholder: 'Instructions for this subagent',+ steerQueued: 'Queued for the next checkpoint',+ stopRequested: 'Stop requested',+ requestRejected: 'The subagent did not accept the request',delegation: index => `Delegation ${index}`,workers: count => `${count} workers`,workersActive: count => `${count} active`,diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 0f2b1284804..4da03e279f9 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -1406,6 +1406,14 @@ export const ja = defineLocale({streaming: 'ストリーミング中',files: 'ファイル',moreFiles: count => `+${count} 件のファイル`,+ moreAgents: count => `ほか ${count} 件のエージェント`,+ queued: '待機中',+ waitingActivity: 'アクティビティ待ち',+ steer: '指示',+ steerPlaceholder: 'このサブエージェントへの指示',+ steerQueued: '次のチェックポイントで処理します',+ stopRequested: '停止を要求しました',+ requestRejected: 'サブエージェントが要求を受け付けませんでした',delegation: index => `委任 ${index}`,workers: count => `${count} ワーカー`,workersActive: count => `${count} アクティブ`,diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex bbeac02270d..ae4716db123 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -1671,6 +1671,14 @@ export const ru = defineLocale({streaming: 'Стримится',files: 'Файлы',moreFiles: count => `+ещё ${count} ${RU_NOUN(count, 'файл', 'файла', 'файлов')}`,+ moreAgents: count => `Ещё ${count} агентов`,+ queued: 'В очереди',+ waitingActivity: 'Ожидание активности',+ steer: 'Направить',+ steerPlaceholder: 'Инструкции этому субагенту',+ steerQueued: 'В очереди до следующей контрольной точки',+ stopRequested: 'Запрошена остановка',+ requestRejected: 'Субагент не принял запрос',delegation: index => `Делегирование ${index}`,workers: count => `${count} ${RU_NOUN(count, 'воркер', 'воркера', 'воркеров')}`,workersActive: count => `${count} ${RU_NOUN(count, 'активен', 'активно', 'активных')}`,diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 9370ef9668d..f30043fe7a3 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -1404,6 +1404,14 @@ export interface Translations {streaming: stringfiles: stringmoreFiles: (count: number) => string+ moreAgents: (count: number) => string+ queued: string+ waitingActivity: string+ steer: string+ steerPlaceholder: string+ steerQueued: string+ stopRequested: string+ requestRejected: stringdelegation: (index: number) => stringworkers: (count: number) => stringworkersActive: (count: number) => stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 9581fbfb142..10d4eb9f28b 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -1353,6 +1353,14 @@ export const zhHant = defineLocale({streaming: '串流傳輸中',files: '檔案',moreFiles: count => `還有 ${count} 個檔案`,+ moreAgents: count => `還有 ${count} 個子代理`,+ queued: '排隊中',+ waitingActivity: '等待活動',+ steer: '引導',+ steerPlaceholder: '此子代理的指令',+ steerQueued: '已排隊,等待下一個檢查點',+ stopRequested: '已請求停止',+ requestRejected: '子代理未接受請求',delegation: index => `派發 ${index}`,workers: count => `${count} 個工作單元`,workersActive: count => `${count} 個活躍`,diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 6cb00e724b3..2d04fba130e 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1765,6 +1765,14 @@ export const zh: Translations = {streaming: '流式传输',files: '文件',moreFiles: count => `还有 ${count} 个文件`,+ moreAgents: count => `还有 ${count} 个子代理`,+ queued: '排队中',+ waitingActivity: '等待活动',+ steer: '引导',+ steerPlaceholder: '此子代理的指令',+ steerQueued: '已排队,等待下一个检查点',+ stopRequested: '已请求停止',+ requestRejected: '子代理未接受请求',delegation: index => `派发 ${index}`,workers: count => `${count} 个工作单元`,workersActive: count => `${count} 个活跃`,