handleSend can target the previous session during the navigation stale window #529

Closed
opened 2026-08-20 02:54:55 +02:00 by dries · 0 comments
Owner

Found during review of PR #520 (fix: keep session model on navigation). Pre-existing, not introduced by that PR — the PR fixed the same stale window for model seeding only.

When the URL session id flips, there is a one-commit window before useSession's atomic load dispatch replaces session/messages/parts. PR #520 guards the model-seed effect with session?.id !== id (SessionDetail.tsx:787), but handleSend still reads session.id — so a message sent inside that window is delivered to the old session.

Narrow race (requires sending within one render commit of navigating), but the failure is silent misdelivery of a user prompt.

Fix: have handleSend (and any other mutation handlers reading session.id) guard on session?.id === id from the route, or use the route id directly. A regression test can reuse the navigation harness added in frontend/src/pages/session-detail/modelSeed.test.tsx / harness.tsx from PR #520.

Found during review of PR #520 (fix: keep session model on navigation). **Pre-existing**, not introduced by that PR — the PR fixed the same stale window for model seeding only. When the URL session id flips, there is a one-commit window before `useSession`'s atomic `load` dispatch replaces `session`/`messages`/`parts`. PR #520 guards the model-seed effect with `session?.id !== id` (`SessionDetail.tsx:787`), but `handleSend` still reads `session.id` — so a message sent inside that window is delivered to the **old** session. Narrow race (requires sending within one render commit of navigating), but the failure is silent misdelivery of a user prompt. Fix: have `handleSend` (and any other mutation handlers reading `session.id`) guard on `session?.id === id` from the route, or use the route `id` directly. A regression test can reuse the navigation harness added in `frontend/src/pages/session-detail/modelSeed.test.tsx` / `harness.tsx` from PR #520.
dries closed this issue 2026-08-20 23:12:38 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#529
No description provided.