fix(chat): sync currentChatRef when prefill creates a new chat session #153
Reference in New Issue
Block a user
Delete Branch "fix/tasklane-prefill-ref"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The dashboard prefill flow in
AssistantChatPagesetactiveChatIdafter creating a new session but never updatedcurrentChatRef.current. Every laterhandleSend/handleTaskSubmitthen tripped thecurrentChatRef.current !== sentForChatIdguard that was meant to discard responses for stale chats — and silently dropped the AI's follow-up. The user saw their submitted message but no assistant reply, no toast, no task-lane update.Reported symptom: in a troubleshooting session, after answering 3 of the 7 questions in the task lane and submitting, there was no response from the AI.
Fix
Add
currentChatRef.current = session.session_idimmediately aftersetActiveChatId(session.session_id)in the prefill effect, mirroring whathandleNewChatandhandleResumeNewalready do.Verification
frontend/e2e/assistant-chat-prefill.spec.ts. Drives the real dashboard prefill flow against the real backend and stubs/ai-sessions/*/chatso turn 1 returns deterministic questions and turn 2 returns a deterministic follow-up. Asserts the second AI message renders and the task lane clears.Got it — based on your answer…never appears) and passes once the fix is restored.tsc -bclean. No new lint errors.Test plan
Follow-up tracked separately
The
currentChatRef.current !== sentForChatIdguard is a silent return — same pattern can mask other bugs. Tracked in.ai/TODO.md.1a8cb0604fto1559feb759