Skip to content

The agent that grows with you

test(desktop): cover legacy deep-confirm fallback

Kevin Rajan77e41501008e
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.test.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.test.ts
index 5ab4882d7d5..38e6fbad9b9 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.test.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.test.ts
@@ -1,4 +1,5 @@
-import { describe, expect, it } from 'vitest'
+import { JsonRpcGatewayError } from '@hermes/shared'
+import { describe, expect, it, vi } from 'vitest'
import { type ChatMessage, finalizeInterruptedMessages, textPart } from '@/lib/chat-messages'
import { createClientSessionState } from '@/lib/chat-runtime'
@@ -669,6 +670,69 @@ describe('runRewindSubmit durable-address discipline (#87059)', () => {
expect(submit?.params?.truncate_before_row_id).toBe(13)
expect(submit?.params?.truncate_before_user_ordinal).toBeUndefined()
})
+
+ it('retries once without confirm_deep_truncate when an older backend rejects only that field', async () => {
+ const request = vi
+ .fn()
+ .mockRejectedValueOnce(
+ new JsonRpcGatewayError(
+ 'invalid params for prompt.submit: confirm_deep_truncate: Extra inputs are not permitted',
+ { code: 4000 }
+ )
+ )
+ .mockResolvedValueOnce({ status: 'streaming' })
+
+ await runRewindSubmit(
+ request as never,
+ 'sid',
+ 'fixed prompt',
+ 1,
+ undefined,
+ false,
+ undefined,
+ 13,
+ 'typo prompt',
+ undefined,
+ true
+ )
+
+ expect(request).toHaveBeenCalledTimes(2)
+ expect(request.mock.calls[0][1]).toMatchObject({
+ confirm_deep_truncate: true,
+ confirm_truncate: true,
+ truncate_before_row_id: 13
+ })
+ expect(request.mock.calls[1][1]).toMatchObject({
+ confirm_truncate: true,
+ truncate_before_row_id: 13
+ })
+ expect(request.mock.calls[1][1]).not.toHaveProperty('confirm_deep_truncate')
+ })
+
+ it('does not retry a different 4000 admission failure', async () => {
+ const failure = new JsonRpcGatewayError(
+ 'invalid params for prompt.submit: some_other_field: Extra inputs are not permitted',
+ { code: 4000 }
+ )
+ const request = vi.fn().mockRejectedValue(failure)
+
+ await expect(
+ runRewindSubmit(
+ request as never,
+ 'sid',
+ 'fixed prompt',
+ 1,
+ undefined,
+ false,
+ undefined,
+ 13,
+ 'typo prompt',
+ undefined,
+ true
+ )
+ ).rejects.toBe(failure)
+ expect(request).toHaveBeenCalledTimes(1)
+ })
})
describe('optimistic rewind/reload turn-clock seeding (#86795)', () => {