Skip to content

The agent that grows with you

fix(desktop): a voice_stopped reply on the legacy submit fallback settles the send

Teknium554162543a0a
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit-voice-stopped.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit-voice-stopped.test.tsx
index a0357628a9d..b760c1b4577 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit-voice-stopped.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit-voice-stopped.test.tsx
@@ -71,3 +71,51 @@ it('a voice_stopped receipt settles the send with no turn, no error and no retai
expect(state.awaitingResponse).toBe(false)
expect(window.localStorage.getItem('hermes.desktop.preparedSubmissions.v1') ?? '').not.toContain('stop-1')
})
+
+// Greptile on TUI-26: the sidecar refuses `submission_id` (4000, version skew), Desktop retries the
+// send identityless, and `_submit_to_ledger_owner` answers that legacy write with the same
+// `{voice_stopped: true}`. The send settles there too: no turn will ever complete it.
+it('a voice_stopped receipt on the identityless legacy fallback settles the send too', async () => {
+ let state: ClientSessionState = createClientSessionState()
+
+ const requestGateway = vi.fn(async (method: string, params?: Record<string, unknown>) => {
+ if (method === 'prompt.submit' && params && 'submission_id' in params) {
+ throw Object.assign(new Error('unknown params: submission_id'), { code: 4000 })
+ }
+
+ return { voice_stopped: true } as never
+ })
+
+ const deps = {
+ activeSessionIdRef: { current: 'runtime-a' as string | null },
+ selectedStoredSessionIdRef: { current: 'stored-a' as string | null },
+ busyRef: { current: false },
+ copy: en.desktop,
+ createBackendSessionForSend: vi.fn(async () => null),
+ getRoutedStoredSessionId: () => null,
+ getRuntimeIdForStoredSession: () => 'runtime-a',
+ getRouteToken: () => 'same-route',
+ requestGateway: requestGateway as GatewayRequest,
+ runtimeIdByStoredSessionIdRef: { current: new Map([['stored-a', 'runtime-a']]) },
+ resumeStoredSession: vi.fn(),
+ syncAttachmentsForSubmit: vi.fn(async (sessionId: string) => ({ sessionId, attachments: [] })),
+ updateSessionState: vi.fn((_sid: string, updater: (s: ClientSessionState) => ClientSessionState) => {
+ state = updater(state)
+
+ return state
+ })
+ }
+
+ const { result } = renderHook(() => useSubmitPrompt(deps as never))
+ await act(async () => {
+ expect(await result.current('stop', { submission_id: 'stop-2' })).toBe(true)
+ })
+
+ const submits = requestGateway.mock.calls.filter(([method]) => method === 'prompt.submit')
+ expect(submits).toHaveLength(2)
+ expect(submits[1][1]).not.toHaveProperty('submission_id')
+ expect(state.messages.filter(message => message.role === 'user')).toHaveLength(0)
+ expect(state.messages.some(message => message.error)).toBe(false)
+ expect(state.busy).toBe(false)
+ expect(state.awaitingResponse).toBe(false)
+})
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
index 33398ff314b..df0fc7b7c36 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
@@ -1213,7 +1213,7 @@ export function useSubmitPrompt(deps: SubmitPromptDeps) {
// Validate the admission receipt and bind it to the optimistic bubble.
// Returns false when the receipt is not this send's admission.
const applySubmitReceipt = (result: SubmitReceipt, receiptSessionId: string): boolean => {
- if (isVoiceStoppedReceipt(legacyAccepted, result)) {
+ if (isVoiceStoppedReceipt(result)) {
// Settled with no turn: the stop phrase ended the voice chat another viewer runs. No
// turn holds the bubble, so it goes, and nothing is tracked as pending.
dropOptimistic(receiptSessionId)
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts
index 9b94d90e2ec..d640468e4cf 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts
@@ -355,9 +355,11 @@ export function isForwardedReceipt(
return legacyAccepted && result?.forwarded === true && result.status === 'queued'
}
-/** TUI-26: the owner ended the session's voice chat on a typed stop phrase and admitted nothing. */
-export function isVoiceStoppedReceipt(legacyAccepted: boolean, result: { voice_stopped?: boolean } | undefined): boolean {
- return !legacyAccepted && result?.voice_stopped === true
+/** TUI-26: the owner ended the session's voice chat on a typed stop phrase and admitted nothing. The
+ * identityless legacy retry gets the same reply (the sidecar forwards it to the ledger owner), and no
+ * turn will complete that send either. */
+export function isVoiceStoppedReceipt(result: { voice_stopped?: boolean } | undefined): boolean {
+ return result?.voice_stopped === true
}
const sleep = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms))