Skip to content

The agent that grows with you

test(desktop): the regenerate-after-switch test counts its confirm

kshitijk4poor3248aa237e6f
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.deep-cut.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.deep-cut.test.tsx
index d6d5c2cc556..8eaafb0a598 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.deep-cut.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.deep-cut.test.tsx
@@ -44,8 +44,10 @@ describe('usePromptActions deep-cut confirm across a session switch (#133716)',
{ id: 'u2', parts: [textPart('new prompt')], role: 'user', rowId: 13, timestamp: 2 },
{ id: 'a2', parts: [textPart('new reply')], role: 'assistant', timestamp: 3 }
]
+
const activeSessionIdRef: MutableRefObject<string | null> = { current: RUNTIME_SESSION_ID }
const submits: Record<string, unknown>[] = []
+
const requestGateway = vi.fn(async (method: string, params?: Record<string, unknown>) => {
if (method === 'prompt.submit') {
submits.push(params ?? {})
@@ -67,8 +69,11 @@ describe('usePromptActions deep-cut confirm across a session switch (#133716)',
/>
)
+ let confirms = 0
+
const stopConfirming = $confirmRequest.listen(request => {
if (request) {
+ confirms += 1
activeSessionIdRef.current = RUNTIME_SESSION_B
settleConfirm(true)
}
@@ -77,6 +82,7 @@ describe('usePromptActions deep-cut confirm across a session switch (#133716)',
await handle!.reloadFromMessage('a1')
stopConfirming()
+ expect(confirms).toBe(1)
expect(submits).toEqual([])
})
@@ -300,6 +306,7 @@ describe('usePromptActions deep-edit consent scope (#133716)', () => {
)
let confirms = 0
+
const stopConfirming = $confirmRequest.listen(request => {
if (request) {
confirms += 1
@@ -383,6 +390,7 @@ describe('usePromptActions deep-edit consent scope (#133716)', () => {
const grown = [...fresh, { id: 'u4', parts: [textPart('newer')], role: 'user' as const, rowId: 27, timestamp: 4 }]
let confirms = 0
+
const stopConfirming = $confirmRequest.listen(request => {
if (request) {
confirms += 1
@@ -544,7 +552,10 @@ describe('usePromptActions deep-edit consent scope (#133716)', () => {
it.each([
['fails', new JsonRpcGatewayError('generation failed', { code: 5035 })],
- ['hits a stale target', new JsonRpcGatewayError('target user message is no longer in session history', { code: 4018 })]
+ [
+ 'hits a stale target',
+ new JsonRpcGatewayError('target user message is no longer in session history', { code: 4018 })
+ ]
])('an edit whose submit recovers the runtime and then %s leaves the composer idle', async (_label, failure) => {
const seed = [
{ id: 'u1', parts: [textPart('first')], role: 'user' as const, rowId: 11, timestamp: 0 },
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 4c675848037..ff5a7c008c5 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
@@ -714,6 +714,7 @@ describe('runRewindSubmit durable-address discipline (#87059)', () => {
'invalid params for prompt.submit: some_other_field: Extra inputs are not permitted',
{ code: 4000 }
)
+
const request = vi.fn().mockRejectedValue(failure)
await expect(
@@ -734,7 +735,8 @@ describe('runRewindSubmit durable-address discipline (#87059)', () => {
expect(request).toHaveBeenCalledTimes(1)
})
- const DEEP_CONFIRM_REJECTED = 'invalid params for prompt.submit: confirm_deep_truncate: Extra inputs are not permitted'
+ const DEEP_CONFIRM_REJECTED =
+ 'invalid params for prompt.submit: confirm_deep_truncate: Extra inputs are not permitted'
it.each([
['another code with the same message', DEEP_CONFIRM_REJECTED, 4018, true],