Skip to content

test(chat): regression test for multi-select auto-submit + stale closure fix#13

Open
hackxixi wants to merge 1 commit into
PeakCode-AI:mainfrom
hackxixi:test/pending-user-input-multiselect
Open

test(chat): regression test for multi-select auto-submit + stale closure fix#13
hackxixi wants to merge 1 commit into
PeakCode-AI:mainfrom
hackxixi:test/pending-user-input-multiselect

Conversation

@hackxixi

Copy link
Copy Markdown

Summary

  • Adds a vitest-browser regression 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.
  • Fixes a subtle stale-closure bug that made the existing guard (if (multiSelect) return) silently inoperative when the React Compiler is active. The compiler memoises the callback before React's commit phase can update useEffectEvent's ref.impl, so activeQuestion was still q1 (multiSelect=false) at the moment the first q2 button was clicked. Fix: derive multiSelect from prompt.questions.find(q => q.id === questionId) instead of the closure.
  • 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.

Test plan

  • bun fmt && bun lint && bun typecheck all 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

… 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
@github-actions github-actions Bot added size:L vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jun 19, 2026
@jwangkun

Copy link
Copy Markdown
Collaborator

❌ Changes Requested

This PR has merge conflicts with the base branch and cannot be merged as-is.

Issues:

  1. Merge status: CONFLICTING — Branch has conflicts with that must be resolved before merging.
  2. Description incomplete — Missing ## Why section per CONTRIBUTING.md conventions.
  3. Diff size: 379 lines — Exceeds the <200 line target; consider splitting if possible.

Action Required:

  • Resolve merge conflicts by rebasing onto
  • Add a ## Why section to the PR description
  • Consider splitting the PR if feasible

Please update and re-request review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants