The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): pin first-send delivery across a late React Router route commit (#62990)
Roger Haneb2f648628a5
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsxindex 7c4f1c04d73..3b946a19f58 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx@@ -2834,6 +2834,65 @@ describe('usePromptActions new-chat first-send delivery (#63078)', () => {])})+ it('delivers the first prompt when React Router commits the created-session route late (#62990)', async () => {+ // The creator requests the navigation, but React Router can still expose+ // the OLD new-chat route to the submit continuation for a beat, committing+ // the created session's URL only before the next await settles. Neither+ // route snapshot (stale '/', then the late-committed session route) is a+ // user switch — both are the pipeline's own transition and the first+ // prompt must still reach the gateway.+ const activeSessionIdRef: MutableRefObject<string | null> = { current: null }+ const selectedStoredSessionIdRef: MutableRefObject<string | null> = { current: null }+ let sessionCreated = false+ let routeReadsAfterCreate = 0++ const createBackendSessionForSend = vi.fn(async () => {+ activeSessionIdRef.current = NEW_RUNTIME_ID+ selectedStoredSessionIdRef.current = NEW_STORED_ID+ sessionCreated = true++ return NEW_RUNTIME_ID+ })++ const requestGateway = vi.fn(async () => ({}) as never)++ let handle: HarnessHandle | null = null+ render(+ <Harness+ activeSessionId={null}+ activeSessionIdRef={activeSessionIdRef}+ createBackendSessionForSend={createBackendSessionForSend}+ getRouteToken={() => {+ if (!sessionCreated) {+ return '/::'+ }++ routeReadsAfterCreate += 1++ // React Router can still expose / to the outer submit continuation,+ // then commit the created-session route before the next await settles.+ return routeReadsAfterCreate === 1 ? '/::' : `/${NEW_STORED_ID}::`+ }}+ onReady={h => (handle = h)}+ refreshSessions={async () => undefined}+ requestGateway={requestGateway}+ selectedStoredSessionIdRef={selectedStoredSessionIdRef}+ storedSessionId={null}+ />+ )+ await waitFor(() => expect(handle).not.toBeNull())++ expect(await handle!.submitText('hello')).toBe(true)+ expect(requestGateway).toHaveBeenCalledWith(+ 'prompt.submit',+ {+ session_id: NEW_RUNTIME_ID,+ text: 'hello'+ },+ 1_800_000+ )+ })+it('aborts a new-session submit when sidebar navigation changes the route before its selected ref (#62562)', async () => {const activeSessionIdRef: MutableRefObject<string | null> = { current: null }const selectedStoredSessionIdRef: MutableRefObject<string | null> = { current: null }diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..2fd7ab83dd2--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1,2 @@+Roger--Han+# PR #62990 salvage (issue #63078)