test(chat): regression test for multi-select auto-submit + stale closure fix#13
Open
hackxixi wants to merge 1 commit into
Open
test(chat): regression test for multi-select auto-submit + stale closure fix#13hackxixi wants to merge 1 commit into
hackxixi wants to merge 1 commit into
Conversation
… stale closure Adds a vitest-browser regression test for the "AskUserQuestion multi-select auto-submit" bug: after a single-select question auto-advances to a multi-select question, clicking a multi-select option should NOT auto-submit — the user must be able to keep selecting before manually submitting. The production fix (if (multiSelect) return inside handleOptionSelection) was already present in the codebase, but the browser test revealed it was silently broken: the React Compiler memoises the callback passed to useEffectEvent before React's commit phase can refresh ref.impl, leaving activeQuestion stale as q1 (multiSelect=false) when the q2 button is first clicked. The guard never fired. Fix: look up the question directly from prompt.questions using the questionId argument (which is always correct because it comes from the button's key/onClick created during the q2 render) rather than relying on the useEffectEvent closure to deliver a fresh activeQuestion. Also fixes three pre-existing TypeScript strict-mode errors (exactOptionalPropertyTypes in _chat.settings.tsx, union-type property access in anthropicAdapter.ts, ReadonlyArray narrowing in http.ts, flatMap return-type inference in gateway.ts) so that bun typecheck passes on this branch. Claude-Session: https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC
Collaborator
❌ Changes RequestedThis PR has merge conflicts with the base branch and cannot be merged as-is. Issues:
Action Required:
Please update and re-request review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vitest-browserregression test (ComposerPendingUserInputPanel.browser.tsx) that documents and locks the fix for the multi-select auto-submit bug: after a single-select question auto-advances to a multi-select question, clicking a multi-select option must not trigger auto-submit — the user should be able to keep selecting before manually submitting.if (multiSelect) return) silently inoperative when the React Compiler is active. The compiler memoises the callback before React's commit phase can updateuseEffectEvent'sref.impl, soactiveQuestionwas still q1 (multiSelect=false) at the moment the first q2 button was clicked. Fix: derivemultiSelectfromprompt.questions.find(q => q.id === questionId)instead of the closure.exactOptionalPropertyTypesin_chat.settings.tsx, union-type property access inanthropicAdapter.ts,ReadonlyArraynarrowing inhttp.ts,flatMapreturn-type inference ingateway.ts) so thatbun typecheckpasses on this branch.Test plan
bun fmt && bun lint && bun typecheckall pass (zero bun.lock delta)bun run test apps/web/src/components/chat/ComposerPendingUserInputPanel.browser.tsx— both tests green (regression case + single-select still auto-submits)https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC