diff --git a/apps/desktop/src/app/chat/composer/status-stack/subagent-controls.test.tsx b/apps/desktop/src/app/chat/composer/status-stack/subagent-controls.test.tsx
new file mode 100644
index 0000000000..8836b4d3d9
--- /dev/null
+++ b/apps/desktop/src/app/chat/composer/status-stack/subagent-controls.test.tsx
@@ -0,0 +1,62 @@
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { afterEach, expect, it, vi } from 'vitest'
+
+import * as gateway from '@/store/gateway'
+import { _resetSessionOwnerHintsForTests, setSessionOwnerHint } from '@/store/session'
+import { $subagentsBySession, upsertSubagent } from '@/store/subagents'
+
+import { SubagentSection } from './subagent-section'
+
+vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ disconnect() {}
+ observe() {}
+ unobserve() {}
+ }
+)
+Element.prototype.animate = vi.fn(() => ({ cancel() {} }) as Animation)
+afterEach(() => {
+ cleanup()
+ $subagentsBySession.set({})
+ _resetSessionOwnerHintsForTests()
+ vi.restoreAllMocks()
+})
+
+it('sends steer and stop to the child parent owner, never the active gateway or child transcript', async () => {
+ const request = vi.spyOn(gateway, 'requestGatewayForAgent').mockResolvedValue({ status: 'queued', found: true })
+ setSessionOwnerHint('parent', { connectionId: 'remote-owner', profile: 'research' })
+ upsertSubagent('parent', { subagent_id: 'worker', child_session_id: 'child-transcript', goal: 'Owned work' })
+ render()
+ fireEvent.click(screen.getByRole('button', { name: /Owned work/ }))
+ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Check the negative control' } })
+ fireEvent.click(screen.getByRole('button', { name: 'Steer' }))
+ await waitFor(() =>
+ expect(request).toHaveBeenCalledWith('remote-owner', 'research', 'subagent.steer', {
+ session_id: 'parent',
+ subagent_id: 'worker',
+ text: 'Check the negative control'
+ })
+ )
+ expect(screen.getByText('Queued for the next checkpoint')).toBeTruthy()
+ fireEvent.click(screen.getByRole('button', { name: 'Stop' }))
+ await waitFor(() =>
+ expect(request).toHaveBeenCalledWith('remote-owner', 'research', 'subagent.interrupt', {
+ session_id: 'parent',
+ subagent_id: 'worker'
+ })
+ )
+ expect($subagentsBySession.get().parent?.[0]?.status).toBe('running')
+})
+
+it('keeps rejected steer text and does not retarget when the owner is unknown', async () => {
+ const request = vi.spyOn(gateway, 'requestGatewayForAgent').mockResolvedValue({ status: 'rejected' })
+ upsertSubagent('unknown', { subagent_id: 'worker', goal: 'Unbound work' })
+ render()
+ fireEvent.click(screen.getByRole('button', { name: /Unbound work/ }))
+ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Keep this instruction' } })
+ fireEvent.click(screen.getByRole('button', { name: 'Steer' }))
+ await waitFor(() => expect(screen.getByRole('alert')).toBeTruthy())
+ expect(request).not.toHaveBeenCalled()
+ expect((screen.getByRole('textbox') as HTMLInputElement).value).toBe('Keep this instruction')
+})
diff --git a/apps/desktop/src/app/chat/composer/status-stack/subagent-controls.tsx b/apps/desktop/src/app/chat/composer/status-stack/subagent-controls.tsx
new file mode 100644
index 0000000000..5f20481c04
--- /dev/null
+++ b/apps/desktop/src/app/chat/composer/status-stack/subagent-controls.tsx
@@ -0,0 +1,89 @@
+import { useState } from 'react'
+
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { useI18n } from '@/i18n'
+import { requestForOwnedSession } from '@/store/session-states'
+
+interface SubagentControlsProps {
+ sessionId: string
+ subagentId: string
+}
+
+export function SubagentControls({ sessionId, subagentId }: SubagentControlsProps) {
+ const { t } = useI18n()
+ const [text, setText] = useState('')
+ const [pending, setPending] = useState(false)
+ const [feedback, setFeedback] = useState('')
+ const [failed, setFailed] = useState(false)
+
+ const send = async (action: 'steer' | 'interrupt') => {
+ setPending(true)
+ setFeedback('')
+ setFailed(false)
+
+ try {
+ // Unlike global chrome, a child control must NEVER fall back to whichever
+ // gateway happens to be active, even on a legacy unbound session.
+ const result = await requestForOwnedSession<{ found?: boolean; status?: string }>(
+ sessionId,
+ async () => {
+ throw new Error(t.agents.requestRejected)
+ },
+ `subagent.${action}`,
+ { session_id: sessionId, subagent_id: subagentId, ...(action === 'steer' ? { text: text.trim() } : {}) }
+ )
+
+ if (action === 'steer' ? result.status !== 'queued' : !result.found) {
+ throw new Error(t.agents.requestRejected)
+ }
+
+ setFeedback(action === 'steer' ? t.agents.steerQueued : t.agents.stopRequested)
+
+ if (action === 'steer') {
+ setText('')
+ }
+ } catch {
+ setFailed(true)
+ setFeedback(t.agents.requestRejected)
+ } finally {
+ setPending(false)
+ }
+ }
+
+ return (
+
+ )
+}
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.tsx
index 98f120e121..acdd0aea10 100644
--- 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.tsx
@@ -6,9 +6,18 @@ import { $subagentsBySession, upsertSubagent } from '@/store/subagents'
import { ComposerStatusStack } from './index'
-vi.stubGlobal('ResizeObserver', class { disconnect() {} observe() {} })
+vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ disconnect() {}
+ observe() {}
+ }
+)
-afterEach(() => { cleanup(); $subagentsBySession.set({}) })
+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++) {
@@ -17,7 +26,13 @@ it('automatically previews bounded live work only from the composer session, inc
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()
+
+ const view = render(
+
+
+
+ )
+
expect(screen.getByText('Task 0')).toBeTruthy()
expect(screen.getByText('Reading actual source')).toBeTruthy()
expect(screen.queryByText('Task 4')).toBeNull()
@@ -25,13 +40,21 @@ it('automatically previews bounded live work only from the composer session, inc
expect(screen.getByRole('button', { name: /5 Subagents/ })).toBeTruthy()
fireEvent.click(screen.getByRole('button', { name: /5 Subagents/ }))
expect(screen.getByText('Task 4')).toBeTruthy()
- view.rerender()
+ view.rerender(
+
+
+
+ )
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()
+ render(
+
+
+
+ )
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.tsx
index fda6f4c4ef..a1a2a19768 100644
--- a/apps/desktop/src/app/chat/composer/status-stack/subagent-section.tsx
+++ b/apps/desktop/src/app/chat/composer/status-stack/subagent-section.tsx
@@ -9,6 +9,8 @@ import { useI18n } from '@/i18n'
import { useSessionSlice } from '@/lib/use-session-slice'
import { $subagentsBySession, type SubagentProgress } from '@/store/subagents'
+import { SubagentControls } from './subagent-controls'
+
interface SubagentSectionProps {
sessionId: string
}
@@ -23,36 +25,67 @@ export function SubagentSection({ sessionId }: SubagentSectionProps) {
const hasLive = live.length > 0
useEffect(() => {
- if (!hasLive) { return }
+ if (!hasLive) {
+ return
+ }
+
const timer = setInterval(() => setNowMs(Date.now()), 1000)
return () => clearInterval(timer)
}, [hasLive])
- if (!hasLive) { return null }
+ if (!hasLive) {
+ return null
+ }
const row = (item: SubagentProgress) => (
-