Skip to content

fix(app-shell): the model picked in the AI assistant composer is the model the chat request sends, from the first message on - #33024

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-a2sab2
Nov 13, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-a2sab2

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #32994

Clause-②: no (a client defect; if a published prop of @object-ui/plugin-chatbot changes shape the dev reports yes)
Metadata-protocol: none

维护者速读

  • 改了什么:AI 助手里用户选的模型改由外层页面保存,不再存在聊天窗格内部;整页 /ai/build、/ai/ask,右侧助手和 Studio 助手三处都改了。
  • 为什么改:新会话的第一条消息发出时会创建会话,聊天窗格随之重建,选中的模型被清掉,于是请求带的是默认 haiku,选择器也跳回 Fast。付费用户选了高级模型却用不上。
  • 风险与回滚:只动前端状态的存放位置,请求格式和服务端都不变;没选模型时仍发默认模型,与以前一致。回滚即还原本 PR。
  • 先看:ui/packages/app-shell/src/console/ai/AiChatPage.tsx(ChatPane 读宿主传入的选择)、ui/packages/app-shell/src/layout/ChatDockConversation.tsx、新测试 AiChatPage.modelPickSurvivesFirstSend-32994.test.tsx。
  • 两分钟验证:在 ui/ 下跑 pnpm exec vitest run packages/app-shell/src/console/ai/__tests__/AiChatPage.modelPickSurvivesFirstSend-32994.test.tsx,应见 4 passed。
  • 需要你做的:无,席位落地。

What changes

Every chat host (AiChatPage, the console dock ChatDockConversation, the Studio copilot StudioAiCopilot) keys ChatPane on the conversation id. Since #32058 the first send creates the conversation, so the pane remounts in the middle of every first send of a new conversation. The composer's model pick was useState inside ChatPane (the selectedModelId / effectiveModelId pair beside the useAiModels call), so it died with the old pane: the replayed first message went out with defaultModelId and the picker showed the default again. Turns after it sent the default too, until the user picked again.

ChatPane takes two optional props, selectedModelId and onSelectedModelChange. The three hosts own the pick in their own state (beside pendingFirstMessageRef, which survives the same remount for the same reason) and pass it down. Without the props the pane keeps the pick itself, as before. The picker and the request still read one value, effectiveModelId, so the picker cannot show a model other than the one the next request sends.

Cause: ui/packages/app-shell/src/console/ai/AiChatPage.tsx, the pane-local selectedModelId state in ChatPane, combined with the key on conversation id at each host's ChatPane mount. useObjectChat's per-send modelRef injection was correct; it was handed the default.

Responsibility: 8523ef9 (#32058, 2026-11-10) "create the AI chat conversation on the first send, not on every visit". Before it the conversation was minted on mount, so the remount happened before a user could pick. After it, every first send remounts the pane. git merge-base --is-ancestor 8523ef9ac origin/main exit 0.

Bounded in-place fix, declared: ui/packages/app-shell/src/views/studio-design/StudioAiCopilot.tsx is outside the claim's named file surface. It is the third host with the same keyed mount and the same defect, and the fix is the same two props, so it is fixed here (same defect class, mechanical, no other claim on the file, same test and gate family). The seat amends the claim's file surface.

Tests

New ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.modelPickSurvivesFirstSend-32994.test.tsx, run on both the full-page build composer (AiChatPage at /ai/build) and the console dock (ChatDockConversation), with the real ChatPane, useChatConversation and useObjectChat transport. The model is read from the JSON body of each chat POST captured off a fetch stub.

  • A pick (Sonnet) before the first message: the first request sends Sonnet, the conversation is created (pane remounts), the picker still shows Sonnet, the second request sends Sonnet and the picker still shows it.
  • CONTROL: no pick: Haiku (the default) is sent on both turns and shown.

Ablation (on the fix commit f3a19b4, before the main merge, through scripts/ablation-replace.mjs): hostHoldsModel forced false, so the pane ignores the host. Both pick cases go red with expected 'anthropic/claude-haiku-5.5' to be 'anthropic/claude-sonnet-5.5' (the defect as filed), both controls stay green. Restore proven: blob == HEAD, git diff HEAD empty.

Acceptance notes

  • The pick is held for the life of the host. Closing and reopening the dock, or reloading the page, starts again from the environment default. Persisting the pick across reloads is not in this card.
  • The staging re-check of ai_traces.model (card acceptance 2) is the seat's; this container has no cloud staging access. NOT MEASURED: a browser check. The dev stack was not booted in this container (it needs a whole-tree build first), and a model picker with more than one entry needs an AI model allowlist the local stack was not checked for. The test drives the real pane, conversation hook and transport instead.

Verification

Local, head 501732c (after one merge of main)
  • pnpm exec vitest run packages/app-shell/src/console/ai packages/app-shell/src/layout/__tests__/ChatDock packages/app-shell/src/layout/__tests__/ConsoleChatbot packages/app-shell/src/views/studio-design (from ui/, under the verify lock): Test Files 392 passed (392), Tests 2894 passed (2894), VERDICT command-exit 0.
  • pnpm --filter @object-ui/app-shell run type-check (src + tsconfig.test.json): exit 0.
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 37 families, all exit 0, including node scripts/check-sdui-manifest.mjs. --ran reconciliation: 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4czLbpetCrYUqeRsq85

…s pane remount (#32994)

The chat hosts key ChatPane on the conversation id and the first send
mints it, so the pane remounts mid-send. The composer's model pick was
pane state and died there: the replayed first message sent the default
model and the picker snapped back. The hosts (AiChatPage, the console
dock, the Studio copilot) now own the pick and pass it to the pane.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czLbpetCrYUqeRsq85
@github-actions github-actions Bot added size/m 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 13, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-elon-musk · session_016WV4cwxNJ1s5i1doop7KEv

席位核对 · ACCEPT · domain:ui#1 · 2026-11-13T05:13Z · head 501732ca66a2f561114e23694db3fad85c75e586

  • Shape: draft → main, Fixes #32994. Files: ui/packages/app-shell/src/console/ai/AiChatPage.tsx, ui/packages/app-shell/src/layout/ChatDockConversation.tsx, ui/packages/app-shell/src/views/studio-design/StudioAiCopilot.tsx, one new test, one root .changeset/ (@object-ui/app-shell patch). No server code.
  • Seat's own read of the diff: cause as reported: ChatPane held the pick in its own useState, and all three hosts key it on the conversation id, which the first send now mints (8523ef9, fix(app-shell): create the AI chat conversation on the first send, not on every visit #32058), so the remount dropped the pick and the replayed first message sent defaultModelId. Each host now owns a selectedModelId state (declared before its early return null, so hook order is stable) and passes selectedModelId + onSelectedModelChange; ChatPane uses the host's pair when onSelectedModelChange is given and its own state otherwise. effectiveModelId stays the one value the picker shows and the request sends. With no pick the default is sent as before.
  • Clause-② re-checked: ChatPane / ChatPaneProps are not exported from @object-ui/app-shell's entry (only AiChatPage, DefaultAiChatPage, hydratedMessagesToChatMessages are, src/index.ts:355–359), and AiChatPage's own props are unchanged. no holds.
  • Gates (check-runs on this head): 51 runs, 38 success, 13 skipped, 0 red. Dev's local: 37 derived gates exit 0 incl. check-sdui-manifest, 392 test files / 2,894 tests green, type-check 0; ablation red on both pick cases (report 6844468785).
  • Accepted deviations: the third host StudioAiCopilot.tsx fixed in place under the four conditions (same defect class, mechanical, unclaimed, same gate family); the claim's file surface was amended in the same round (6844500952) and the PR body names the host. Browser check not run (no dev stack); the staging ai_traces.model re-check stays owed by the seat after release.
  • Out of scope / landing: none filed. check-governed-merges --pr 33024: NOT governed, +277/−1. K = 8 behind main, no merge owed. Lands by the seat: ready + auto-merge into the merge queue.

@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 43370693670 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Dogfood Regression Gate (1/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/security-catalog-showcase.dogfood.test.ts > showcase, 'single': the security catalog read > permission: lists exactly the declared names
      ↳ 失败原因: (这条 FAIL 之后 12 行内没有可识别的原因行 —— 点进 job 看)
    @objectstack/dogfood:test:  FAIL   isolated  test/security-catalog-showcase.dogfood.test.ts > showcase, 'single with the Default Organization': the security catalog read > permission: lists exactly th
      ↳ 失败原因: (这条 FAIL 之后 12 行内没有可识别的原因行 —— 点进 job 看)
    @objectstack/dogfood:test:  FAIL   isolated  test/security-catalog-showcase.dogfood.test.ts > showcase, 'walled': the security catalog read > permission: lists exactly the declared names
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: expected [ 'admin_full_access', …(18) ] to deeply equal [ 'admin_full_access', …(17) ]
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • test/security-catalog-showcase.dogfood.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 14 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Merged via the queue into main with commit faa8c88 Nov 13, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-a2sab2 branch November 13, 2026 05:53
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/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants