Repository navigation
Commit c8e9bec
feat(spec, plugin-chatbot): AI model entries carry an optional tierLabel, and the closed model picker shows it (#37519)
Fixes #35578
Clause-②: yes
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:AI 对话的模型选择器在收起时,若服务端给出了档位名,只显示「快速」这样的档位名,而不再显示被截断的「Fast ·
Claude Haiku…」;展开列表不变。今天云端尚未提供档位名,所以用户暂时看不到差别。
- 为什么做:属于 AI 对话界面体验收尾,替模型选择器收起时文字被截断的问题解决;档位名由云端 AI 服务填写,另起一张云端卡跟进。
- 出错会怎样:最坏情况是收起的选择器显示档位名不对或仍显示完整名称,不影响所选模型与发送;可直接撤回本次合并。
- 要你做什么:无。
## What changes
- **Spec** (`packages/spec/src/api/protocol.zod.ts`): the object arm of
the `AiModelsResponseSchema` model entry gains an optional `tierLabel`,
a non-empty string naming the model's tier alone, in the language the
response is served in. Nothing else in the schema moves; the bare-string
arm stays.
- Name precedent: a `NOUNLabel` display string next to a plain `label`,
as with `pluralLabel` beside `label` on object definitions
(`packages/spec/src/data`) and `confirmLabel` and `addLabel` in the UI
schemas. It is a display string, not a tier id. The tier word is
operator text inside cloud's `sys_ai_model.label` (cloud ADR-0028 D5,
D8; not the plan tiers on `available_for_plans`), so an id would make
the open-source console carry cloud's tier names and their translations.
`label` is already a server-supplied display string, so a sibling
display string keeps the producer and the consumer as they are today.
- `.min(1)`: an empty tier name is not spec-legal. This follows the
`costMultiplier` precedent, where the spec states the domain and the
console keeps the value only as the spec declares it.
- **Console** (`ui/packages/plugin-chatbot`):
- `ChatbotModelOption.tierLabel?` is added.
- `useAiModels` keeps a served `tierLabel` only when it is a non-empty
string, mirroring `costMultiplierOf`.
- `ModelPicker`'s closed trigger shows `tierLabel` when the model in
force carries one, and otherwise shows `label` (then the id) as before.
The trigger's `title` and the open list's row keep the full `label`, so
the model's name is still on hover and the choice is still made from the
full names.
- Every chat host renders this one picker: the full-page AI chat, the
chat dock and the Studio copilot.
- Docs: `content/docs/frontend/plugins/plugin-chatbot.mdx` gains one
sentence under **Model Picker** (the closed picker shows `tierLabel`
when served), per the `ui/` docs-driven rule. This page is outside the
claim's declared file surface, and the report names the addition.
- Generated: `content/docs/references/api/protocol.mdx`, regenerated by
`gen:docs`. No other artefact went stale (`check:generated`: all 14 up
to date).
- Changeset `.changeset/35578-model-tier-label.md`, `patch` on
`@objectstack/spec` and `@object-ui/plugin-chatbot` (the kind is
`none`).
- Out of scope, per the card's route: step 2, cloud `service-ai` filling
`tierLabel`. The seat files that cloud card. Until it lands, the picker
looks as it does today.
**Read first, by risk:**
1. `ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx`, the `inForce` /
`shown` pair in `ModelPicker`. The trigger's text and its `title` now
come from different values.
2. `packages/spec/src/api/protocol.zod.ts`, the `tierLabel` line in the
model entry. This is the contract addition the L2 review weighs.
3. `ui/packages/plugin-chatbot/src/useAiModels.ts`, `tierLabelOf` in
`normalize`.
## Tests
Code and tests measured at `8a2ba56c`. The head `02da5d4e` adds only the
docs sentence, after which the 28 derived doc-reading families were
re-run at `02da5d4e`, all with exit 0.
- `packages/spec/src/api/protocol.test.ts` ("validates AI operations"):
an entry with `tierLabel` parses and keeps the key. `''`, `3` and `null`
are refused.
- `ChatbotEnhanced.modelPicker-11865.test.tsx`, a new top-level describe
in the picker's shared harness:
- a model with a tier name: the trigger reads the tier name only, its
`title` is the full label, and the list rows are unchanged;
- a model without one: the trigger reads its label, as before;
- a pick from the list still writes the model id.
- `useAiModels.noAiService-12508.test.tsx`, a new top-level describe: a
served non-empty `tierLabel` is kept. It is left off an entry with none,
with `''`, or with a number.
<details><summary>Local runs (exit captured before any pipe; lock
VERDICT lines)</summary>
- `pnpm --filter @objectstack/spec test && pnpm --filter
@objectstack/spec typecheck`: VERDICT command-exit 0. Test Files 898
passed (898), Tests 28488 passed, 1 todo. `check:test-typecheck: OK`.
- `pnpm --filter @object-ui/plugin-chatbot test && pnpm --filter
@object-ui/plugin-chatbot type-check`: VERDICT command-exit 0. Test
Files 103 passed (103), Tests 1079 passed (1079). This ran after
building the package's dependency closure (`turbo run build
--filter=@object-ui/plugin-chatbot^...`, 53 tasks, exit 0). The first
run, before that build, failed 72 files on an unresolved
`@objectstack/formula`, a missing dist rather than this diff.
- `pnpm --filter @objectstack/spec check:generated`: exit 1 before
`gen:docs` (only `content/docs/references/**` was stale) and exit 0
after it ("All 14 generated artifacts are up to date").
- eslint over the six changed source files: exit 0, 0 errors. The 13
warnings are in lines this diff does not touch.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs; each leg
landed on disk and restored to the HEAD blob)</summary>
- `ModelPicker`: `shown` was replaced by `inForce`. Exactly one test
went red ("a model with a tier name: the trigger reads the tier name
only…"), with 19 passed: the fallback rows stay green. Restored: the
blob equals HEAD (`76aa66d3d4e8`).
- `useAiModels`: `tierLabel` was forced to `undefined`. The tier-name
pin went red, with 3 passed. Restored: the blob equals HEAD
(`0137560494e6`).
- Spec: `.min(1)` was dropped. Red with `tierLabel "" is refused:
expected true to be false`, 266 passed. Restored: the blob equals HEAD
(`1c68b3370e1d`).
</details>
<details><summary>Derived gate families (dispatch-gates --commands,
reconciled with --ran)</summary>
- `dispatch-gates --ran`: 117 derived families accounted for. 113 ran,
all with exit 0. 4 are NOT MEASURED (exit 3, a prerequisite this shared
box lacks):
- `check-plugin-teardown-shape.mjs --self-test`: the checkout is shallow
and cannot reach the pinned fixture commit;
- `spec check:skill-examples`: `packages/client-react/dist` is unbuilt,
and the build could not take the shared lock (queue-timeout behind
another session's dogfood run);
- `check:dual-build-cjs-loads`: many packages have no dist;
- `check:type-check-debt`: its re-measure build hit the lock
queue-timeout.
CI measures all four.
- Local-only family `check-dev-prereqs.mjs`: exit 1, because packages
across the workspace are unbuilt on this box. That is local state,
outside this diff.
- `check:skill-frame-freshness`: exit 0.
- The reconciliation printed a STALE TREE note: origin/main moved 7
commits during the run, and the 3 changed files were all `scripts/pm/*`,
none read by these paths.
</details>
## Acceptance notes
- **The key lands before its producer.** The dispatch leaves that
judgement to the L2 contract review. Until cloud `service-ai` writes
`tierLabel`, no response carries it, so the change is inert at runtime.
Both sides are pinned: tiered, and untiered as before.
- **Display string vs tier id.** The card allowed either. A display
string was chosen for the reasons under What changes: the tier
vocabulary is cloud's, and the console then needs no closed tier enum
and no translations for it. The contract review on this head kept
`tierLabel` (7190559193). Step 2, cloud fills it:
objectstack-ai/cloud#5022.
- The trigger's `title` stays the full `label`. Before this change it
equalled the trigger text, and with a tier name the two now differ on
purpose.
## Verification
Two-minute check: `pnpm --filter @object-ui/plugin-chatbot exec vitest
run --root ../..
packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.modelPicker-11865.test.tsx`.
Expect 20 passed, including "the closed picker shows the tier name alone
when the model carries one".
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; eslint over the changed files has 0 errors
(the repo-wide `pnpm lint` is CI's run).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [ ] The *Before Submitting* list in CONTRIBUTING.md is done, except
the repo-wide `pnpm lint`, which is CI's run.
Dispatched by repo:objectstack#6 (claim comment 7184739601), session
`session_01Q4EjjQkY5yXZrN9BEA3rEK`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK)_
<!-- signed: repo:objectstack#6 · hotlong ·
session_01Q4EjjQkY5yXZrN9BEA3rEK -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 276174a commit c8e9bec
9 files changed
Lines changed: 111 additions & 3 deletions
File tree
- .changeset
- content/docs
- frontend/plugins
- references/api
- packages/spec/src/api
- ui/packages/plugin-chatbot/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
393 | 403 | | |
394 | 404 | | |
395 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4588 | 4588 | | |
4589 | 4589 | | |
4590 | 4590 | | |
| 4591 | + | |
| 4592 | + | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
4591 | 4596 | | |
4592 | 4597 | | |
4593 | 4598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
1197 | 1204 | | |
1198 | 1205 | | |
1199 | 1206 | | |
| |||
1277 | 1284 | | |
1278 | 1285 | | |
1279 | 1286 | | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
1280 | 1290 | | |
1281 | 1291 | | |
1282 | 1292 | | |
| |||
1304 | 1314 | | |
1305 | 1315 | | |
1306 | 1316 | | |
| 1317 | + | |
| 1318 | + | |
1307 | 1319 | | |
| 1320 | + | |
1308 | 1321 | | |
1309 | 1322 | | |
1310 | 1323 | | |
| |||
1345 | 1358 | | |
1346 | 1359 | | |
1347 | 1360 | | |
1348 | | - | |
| 1361 | + | |
1349 | 1362 | | |
1350 | 1363 | | |
1351 | 1364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
72 | 82 | | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
| 87 | + | |
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
80 | 91 | | |
| 92 | + | |
81 | 93 | | |
82 | 94 | | |
83 | 95 | | |
| |||
0 commit comments