The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep clarify/connection cards open for /bg side tasks
Austin Pickettbbdf0a34fcc8
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsxindex 96f8e0deafc..28cd5cd0eb5 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx@@ -501,7 +501,13 @@ describe('useComposerSubmit with a clarify parked on the session', () => {vi.restoreAllMocks()})- it.each(['/btw what is the task?', '/BTW what is the task?', '/btw'])('keeps a pending clarify answerable while dispatching %s', async text => {+ it.each([+ '/btw what is the task?',+ '/BTW what is the task?',+ '/btw',+ '/bg summarize the logs',+ '/background run the tests'+ ])('keeps a pending clarify answerable while dispatching %s', async text => {parkClarify('runtime-session')const { hook, onSubmit, onSteer } = renderSubmitHook({ busy: true, text })@@ -623,31 +629,34 @@ describe('useComposerSubmit with a connection card parked on the session', () =>$connectionRequests.set({ 'runtime-session': connection })}- it.each(['/btw what is the task?', '/BTW what is the task?', '/btw'])(- 'keeps the connection card answerable while dispatching %s',- async text => {- parkConnection()- vi.spyOn(sessionOwnerUtils, 'resolveSessionOwner').mockRejectedValue(new Error('test no owner'))- const gatewayRequest = vi.fn(async () => ({}))- $gateway.set({ request: gatewayRequest } as NonNullable<ReturnType<typeof $gateway.get>>)- const { hook, onSubmit, onSteer } = renderSubmitHook({ busy: true, text })-- act(() => {- hook.result.current.submitDraft()- })+ it.each([+ '/btw what is the task?',+ '/BTW what is the task?',+ '/btw',+ '/bg summarize the logs',+ '/background run the tests'+ ])('keeps the connection card answerable while dispatching %s', async text => {+ parkConnection()+ vi.spyOn(sessionOwnerUtils, 'resolveSessionOwner').mockRejectedValue(new Error('test no owner'))+ const gatewayRequest = vi.fn(async () => ({}))+ $gateway.set({ request: gatewayRequest } as unknown as NonNullable<ReturnType<typeof $gateway.get>>)+ const { hook, onSubmit, onSteer } = renderSubmitHook({ busy: true, text })- await waitFor(() => expect(onSubmit).toHaveBeenCalledWith(text, expect.anything()))- expect(onSteer).not.toHaveBeenCalled()- expect(gatewayRequest).not.toHaveBeenCalledWith('connection.respond', expect.anything())- expect($connectionRequests.get()['runtime-session']?.settled).toBe(false)- }- )+ act(() => {+ hook.result.current.submitDraft()+ })++ await waitFor(() => expect(onSubmit).toHaveBeenCalledWith(text, expect.anything()))+ expect(onSteer).not.toHaveBeenCalled()+ expect(gatewayRequest).not.toHaveBeenCalledWith('connection.respond', expect.anything())+ expect($connectionRequests.get()['runtime-session']?.settled).toBe(false)+ })it('still continues the connection request for an ordinary reply', async () => {parkConnection()vi.spyOn(sessionOwnerUtils, 'resolveSessionOwner').mockRejectedValue(new Error('test no owner'))const gatewayRequest = vi.fn(async () => ({}))- $gateway.set({ request: gatewayRequest } as NonNullable<ReturnType<typeof $gateway.get>>)+ $gateway.set({ request: gatewayRequest } as unknown as NonNullable<ReturnType<typeof $gateway.get>>)const { hook, onSteer } = renderSubmitHook({ busy: true, text: 'continue without connecting' })act(() => {diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.tsindex 1b5c26a5fff..e3512e7766c 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts@@ -2,6 +2,7 @@ import { SLASH_COMMAND_RE } from '@hermes/shared'import { type RefObject, useLayoutEffect, useRef } from 'react'import { usePaneVisible } from '@/components/pane-shell/pane-visibility'+import { isSideTaskSlashCommand } from '@/lib/desktop-slash-commands'import { triggerHaptic } from '@/lib/haptics'import { hasClarifyRequest, skipClarifyRequest } from '@/store/clarify'import { clearSessionDraft, type ComposerAttachment } from '@/store/composer'@@ -230,8 +231,11 @@ export function useComposerSubmit({// both RPCs ride the same socket in call order, so the gateway resolves the// clarify before it sees the follow-up. Awaiting first would leave the draft// live for a tick — long enough for a second Enter to send it twice.- // /btw takes a separate side-question path and answers neither parked card.- const isSideQuestion = /^\/btw(?:\s|$)/i.test(text.trim())+ //+ // /btw and /bg run beside the turn (snapshot / separate session) and answer+ // neither parked card. With attachments the draft isn't routed as a slash+ // command, so it falls back to the ordinary-message behavior.+ const isSideQuestion = !attachments.length && isSideTaskSlashCommand(text)if (payloadPresent && !queueEdit && !isSideQuestion && hasClarifyRequest(sessionId)) {void skipClarifyRequest(sessionId)diff --git a/apps/desktop/src/lib/desktop-slash-commands.ts b/apps/desktop/src/lib/desktop-slash-commands.tsindex a5e0409bc3f..be1b40a2f60 100644--- a/apps/desktop/src/lib/desktop-slash-commands.ts+++ b/apps/desktop/src/lib/desktop-slash-commands.ts@@ -512,6 +512,24 @@ export function resolveDesktopCommand(command: string): DesktopCommandSpec | nulreturn local ?? specFromCatalog(command)}+/** Actions that fork their own run instead of speaking into the current turn. */+const SIDE_TASK_ACTIONS: ReadonlySet<DesktopActionId> = new Set(['background', 'btw'])++/**+ * True for a slash command that runs beside the live turn (`/btw`, `/bg`,+ * `/background`): it answers from a snapshot or a separate session, so it must+ * not resolve a clarify/connection card parked on the current turn.+ */+export function isSideTaskSlashCommand(text: string): boolean {+ if (!text.trim().startsWith('/')) {+ return false+ }++ const surface = resolveDesktopCommand(text)?.surface++ return surface?.kind === 'action' && SIDE_TASK_ACTIONS.has(surface.action)+}+function isKnownHermesSlashCommand(command: string): boolean {const normalized = normalizeCommand(command)