fix(desktop): preserve fresh-chat file submits - #65708
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the fresh-chat attachment race. The underlying premise is still present on current main: apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:429-432 re-pins the raw route token after creation, and the post-upload check at :437-443 can abort before prompt.submit when that route commit lands during attachment synchronization.
Problems
apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:346turns off route validation for the entire created-session remainder. That accepts an unrelated route-only navigation as well as the expected delayed navigation; it does not prove the changed route belongs to the session this submit created.
Suggested changes
- Preserve a created-session or semantic route-identity check: accept the created session's delayed route commit, but keep rejecting a route to another session.
- Add the counterpart regression for unrelated route-only navigation during
file.attach, asserting thatprompt.submitis not sent.
This is an automated hermes-sweeper review.
| // session ids — not the still-settling route — guard this phase. | ||
| startingStoredSessionId = selectedStoredSessionIdRef.current | ||
| startingRouteToken = getRouteToken() | ||
| guardRouteToken = false |
There was a problem hiding this comment.
This disables route drift detection for every post-create route change, not just the created session's delayed navigation. Please retain an expected created-session/semantic route check and add a regression for a route-only change to a different session during attachment sync.
Summary
file.attachis awaiting I/ORoot cause
A fresh-chat submit creates a backend session and navigates to its stored-session route. That navigation can commit asynchronously, especially during a profile swap while file bytes are uploading. The submit pipeline compared the post-upload route with its pre-create route and aborted before
prompt.submit, leaving an empty session. Established chats do not hit this transition.The guard still aborts real user switches through the pinned stored/runtime session IDs.
Related to the session-isolation guard introduced around #54527.
Verification
npx vitest run src/app/session/hooks/use-prompt-actions/index.test.tsx— 46/46 passednpm run typecheck— passedfalsebefore the fix and passes after the fix