Repository navigation
fix(plugin-chatbot): a send clears only the composer's message box, so the picked model survives it - #38106
Conversation
…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>
|
repo:objectstack#3 · os-tesla · session_01L9qibvMMgnKA797JY46H9i L1-c, the seat's L1 thread · 2026-11-28T02:47Z 席位核对 — L1 @
|
|
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU Landing · 2026-11-28T02:48Z · zone
|
Requested by Tesla · project thread
Fixes #37831
repo:objectstack#3 · os-tesla · session_01L9qibxaAB2c4Epy2EEZxDf
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
ui/packages/plugin-chatbot/src/elements/prompt-input.tsx:handleSubmitno longer callsform.reset()to clear the composer. It sets themessagefield back to itsdefaultValue, which is what the reset gave that field, and leaves every other control in the form alone.patchchangeset for@object-ui/plugin-chatbot.Why
The composer's model picker (
chat/ModelPicker.tsx) is the shared RadixSelect, and it sits inside the composer's<form>. Radix Select 2.3.7 listens for theresetevent of the form it belongs to and answers it withsetValue(initialValueRef.current), the value it had on its FIRST render (@radix-ui/react-selectdist/index.mjs, the effect that adds theresetlistener). For the picker that is the default model's index. Because the picker is controlled,setValuecallsonValueChange, soModelPickercallsonPick(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
ChatbotEnhancedand calledonSendMessagedirectly, so the form submit, and with it the reset, never ran. Its other finding still holds:ChatDockConversationis not remounted around a turn.Tests
ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.modelPicker-11865.test.tsx, new top-leveldescribe"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):onModelChangereceived only the user's pick; both sends carried the picked model; the box is empty after the send;Readings at eb2e26d (base origin/main f72f335)
ChatbotEnhanced, a pick made in the UI, then a form submit.onModelChangereceived["m_picked","m_default"]and the picker showed Default after the send; CONTROL (no pick) wrote nothing; with theresetevent swallowed in the window's capture phase and nothing else changed, the pick survived (writes: ["m_picked"]).form.reset()put back inhandleSubmit, thenvitest 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 withgit restore --source=HEAD --staged --worktree,git status --porcelainempty,Tests 22 passed (22).pnpm --filter @object-ui/plugin-chatbot test:Test Files 76 passed (76),Tests 731 passed (731).type-checkexit 0.eslinton the two changed files: 0 errors, and the same 11 warnings as the file onmain(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 --commandsat 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/mainis 2 commits ahead, neither touchingui/packages/plugin-chatbot.Acceptance notes
ChatbotEnhanced.tsx(insendTypedand 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 wordform.resetin them is stale. A follow-up can reword them when that file is next touched.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):
ui/packages/plugin-chatbot/src/elements/prompt-input.tsx:handleSubmit, the clear before the blob conversion.describeat the end ofChatbotEnhanced.modelPicker-11865.test.tsx.Two-minute check:
cd ui && pnpm exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.modelPicker-11865.test.tsxshows 22 passing; putform.reset();back in place of the field clear inhandleSubmitand the same command shows the picked row failing.Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code