Skip to content

fix(plugin-chatbot): a send clears only the composer's message box, so the picked model survives it - #38106

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-fv0qlb
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-fv0qlb

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #37831
repo:objectstack#3 · os-tesla · session_01L9qibxaAB2c4Epy2EEZxDf

Clause-②: no
Metadata-protocol: none

维护者速读

  • 在 AI 侧栏里换了模型再提问,以后的问题会一直用这个模型,直到你自己再换。以前每次发送都会把选择悄悄改回默认模型,下一个问题就用默认模型回答、按默认倍率计费。
  • 属于问 AI 对话体验这条线:用户选定的设置不能被悄悄丢掉。全页聊天用的是同一个输入框,同一处修复覆盖它,但没有单独测。
  • 只改输入框发送时清空文字的方式:以前重置整张表单,现在只清空输入框本身,其他表单控件不再被一起重置。改错的话,最坏是发送后输入框里的文字没清掉,可以直接撤回。
  • 无

What changes

  • ui/packages/plugin-chatbot/src/elements/prompt-input.tsx: handleSubmit no longer calls form.reset() to clear the composer. It sets the message field back to its defaultValue, which is what the reset gave that field, and leaves every other control in the form alone.
  • patch changeset for @object-ui/plugin-chatbot.

Why

The composer's model picker (chat/ModelPicker.tsx) is the shared Radix Select, and it sits inside the composer's <form>. Radix Select 2.3.7 listens for the reset event of the form it belongs to and answers it with setValue(initialValueRef.current), the value it had on its FIRST render (@radix-ui/react-select dist/index.mjs, the effect that adds the reset listener). For the picker that is the default model's index. Because the picker is controlled, setValue calls onValueChange, so ModelPicker calls onPick(defaultId) and the host that holds the pick (ChatDockConversation, ADR-0028) records the default model. Every send therefore put the pick back to the default: the send itself still carried the picked model (read before the reset landed), and the next one carried the default.

The earlier attempt on this card (report 7213606537) mocked ChatbotEnhanced and called onSendMessage directly, so the form submit, and with it the reset, never ran. Its other finding still holds: ChatDockConversation is not remounted around a turn.

Tests

ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.modelPicker-11865.test.tsx, new top-level describe "a picked model survives the composer's send (objectstack#37831)". The host holds the pick, as every chat host does, and each send goes through the real form submit (Enter in the box):

  • picked: after each of two sends the picker still shows the picked model; onModelChange received only the user's pick; both sends carried the picked model; the box is empty after the send;
  • CONTROL, no pick: the first model is in force before and after a send, nothing is written, the box is empty.
Readings at eb2e26d (base origin/main f72f335)
  • Premise at f72f335 through a throwaway probe (deleted; copy kept in the project folder): the real ChatbotEnhanced, a pick made in the UI, then a form submit. onModelChange received ["m_picked","m_default"] and the picker showed Default after the send; CONTROL (no pick) wrote nothing; with the reset event swallowed in the window's capture phase and nothing else changed, the pick survived (writes: ["m_picked"]).
  • Ablation on the committed fix: form.reset() put back in handleSubmit, then vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.modelPicker-11865.test.tsx: Tests 1 failed | 21 passed (22), the failure being the picked row (expected 'GPT-4o mini' to be 'Claude 3.5'), the CONTROL row green. Restored with git restore --source=HEAD --staged --worktree, git status --porcelain empty, Tests 22 passed (22).
  • pnpm --filter @object-ui/plugin-chatbot test: Test Files 76 passed (76), Tests 731 passed (731). type-check exit 0. eslint on the two changed files: 0 errors, and the same 11 warnings as the file on main (all pre-existing, none on a changed line).
  • vitest run packages/app-shell/src/console/ai packages/app-shell/src/layout (the hosts that render this composer): Test Files 210 passed (210), Tests 1796 passed (1796).
  • dispatch-gates --commands at eb2e26d: 39 derived, 39 run, all exit 0 (pnpm --dir ui exec vitest run scripts/ was killed once by the container's memory limit while another run was going, then re-run alone: Test Files 172 passed | 2 skipped (174), exit 0). origin/main is 2 commits ahead, neither touching ui/packages/plugin-chatbot.

Acceptance notes

  • Not changed, file surface fenced by the claim: two comments in ChatbotEnhanced.tsx (in sendTyped and above the send-failure restore effect) still say "the composer's own form.reset clears the box optimistically". The box is still cleared optimistically at the same moment, now by the field reset, so both comments stay true in effect; the word form.reset in them is stale. A follow-up can reword them when that file is next touched.
  • The full-page chat (AiChatPage) and the app Ask page render the same composer, so they take the same fix. Neither was measured separately.

Verification

Read first (by risk):

  1. ui/packages/plugin-chatbot/src/elements/prompt-input.tsx: handleSubmit, the clear before the blob conversion.
  2. The new describe at the end of ChatbotEnhanced.modelPicker-11865.test.tsx.

Two-minute check: cd ui && pnpm exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.modelPicker-11865.test.tsx shows 22 passing; put form.reset(); back in place of the field clear in handleSubmit and the same command shows the picked row failing.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

…o the picked model survives it

The composer cleared its box with form.reset(). The model picker, a Radix
Select in the same form, answers the form's reset event by writing its
first-render value (the default model) back through onValueChange, so every
send put the pick back to the default and the next request ran on it.
handleSubmit now resets only the message field to its default value.

Claude-Session: https://claude.ai/code/session_01L9qibxaAB2c4Epy2EEZxDf
Co-authored-by: Claude <noreply@anthropic.com>
@os-tesla
os-tesla self-requested a review November 28, 2026 02:27
@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-tesla · session_01L9qibvMMgnKA797JY46H9i

L1-c, the seat's L1 thread · 2026-11-28T02:47Z

席位核对 — L1 @ eb2e26d30e625bbeb661114f8d61d37b84324f2c

Verdict: ACCEPT.

No contract review is owed. The diff touches no packages/spec/src/** and no governed path, the declaration is Clause-②: no with no narrowing arm, and the paths decide no face. So this L1 read is the whole review.

Checklist

  • Shape and relation. The PR is a draft on base main, with first line Fixes #37831 and no other closing keyword. Fixes is right: the card asks that the picked model stays picked for the rest of the drawer conversation, and the next request uses it. That is what the fix delivers.

  • The fix, read against the cause. handleSubmit (elements/prompt-input.tsx:793) clears only the form's own message textarea, to its defaultValue. It no longer calls form.reset(), whose reset event made the Radix Select in the same form write its first-render value back through onValueChange.

    • What a reset did that is no longer done. The file input is not inside the <form>, and it clears its own value on change (:751). So the only control the reset still served is the message box, and the fix clears it exactly as the reset did.
    • The provider path. The usingProvider path is untouched.
  • Scope. 3 files, all inside the claim (7231994873).

  • Changeset, read sentence by sentence (.changeset/37831-model-pick-survives-send.md). @object-ui/plugin-chatbot patch, as Metadata-protocol: none requires. Each sentence is true at this head:

    • the cause, the whole-form reset and the picker's answer to it;
    • the effect, the default model on the next question;
    • the fix, clearing only the message box.
  • Test and gate evidence. The os-dev-report (7232382141) is pinned to eb2e26d3.

    • The pin. It goes through the real ChatbotEnhanced, with a host-held pick and a real form submit by Enter. The pick survives two sends, only the user's pick is written, both sends carry it, and the box is cleared. A no-pick CONTROL row sits beside it.
    • The ablation. Putting form.reset() back turns the picked row red and leaves CONTROL green.
    • Gates. dispatch-gates 39/39 exit 0.

    Check-runs at this head: 52 runs, 39 success and 13 skipped, none failed or cancelled. No dogfood battery is owed.

Accepted deviations

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU

Landing · 2026-11-28T02:48Z · zone o3-askai (seat card thread)
Head-sha: eb2e26d30e625bbeb661114f8d61d37b84324f2c

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

Labels

documentation Improvements or additions to documentation size/s tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI drawer: the model picked in the composer falls back to the default after every answer

2 participants