Skip to content

feat(chat): a Continue button for a stopped ask turn — spec resume field and data-turn-end part, plugin-chatbot UI - #38698

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/project-thread-5o6334
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/project-thread-5o6334

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Part of #38609

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — the added keys are the AI chat route's wire (resume) and its stream part and stored message field (turnEnd), written by the AI service and read by the console chat; no metadata author writes them and no published skill teaches the chat wire

维护者速读

  • 用户能看到什么变化:在控制台的问答里,回答因时间、额度或轮数触顶而停下、且服务端表示可以续跑时,最后一条回答下出现「继续查」按钮并显示还能继续几次;点了不新增提问气泡,答案接着写进同一轮,刷新页面后按钮仍在。
  • 为什么做:这是「继续查」的协议与界面一半,服务端续跑那一半在云端卡(AI 服务按同一轮重建并续跑)上;协议先落,云端那一半才能接。
  • 出错会怎样:服务端没发「回合结束」信息之前界面什么都不画,现有对话不受影响;全是新增的可选字段,撤回即删。
  • 要你做什么:无(契约审核由席位安排)。

What changes

Spec (@objectstack/spec) — three additions, all closed shapes:

  • TurnEndSchema + TURN_END_PART_TYPE = 'data-turn-end' in a new packages/spec/src/ai/turn-end.zod.ts (modelled on draft-review.zod.ts): { reason, wrapUp, resumable, resumesLeft, turnId }. reason is a non-empty string, not an enum: the producer's vocabulary includes every turn-refusal kind and grows with it, and the chat decides nothing from it. resumable is the server's verdict alone.
  • AiChatRequestSchema.resume: optional { turnId } (closed, turnId non-empty). Its text says a resume names its turn itself (the top-level turnId is not read on a resume, and turnId's own description says so) and that the resume stream's start chunk carries the request's messageId or none.
  • AiConversationMessageSchema.turnEnd: optional, nullable TurnEndSchema, on the turn's last message, so a reload knows the turn end too.
  • Regenerated: api-surface, export-origins, declaration-map, references docs, strictness ledger counts, authorable-surface and json-schema manifest projections (check:generated --fix, only the five it proved stale).

UI (@object-ui/plugin-chatbot, @object-ui/app-shell, @object-ui/i18n):

  • mapMessages.extractTurnEnd reads the newest data-turn-end part through TurnEndSchema onto ChatbotEnhancedMessage.turnEnd; a refused part is no turn end.
  • New chat/ContinueTurnButton.tsx (the control) and chat/resumableTurn.ts (resumableTurnOf, where it is drawn). ChatbotEnhanced takes onResumeTurn(turnId) and draws Continue under the conversation's last answer only when its turn end is resumable with resumesLeft > 0, nothing streams, and the view is not read-only. A message sent afterwards makes the answer no longer last, so the control goes.
  • New resumeTurn.ts; useObjectChat returns resumeTurn(turnId) in API mode: the chat runtime's sendMessage(undefined, { body: { resume: { turnId } } }) sends the conversation as it stands (no user message, no bubble) and streams into the last assistant message, sending the answer's id as messageId. withTurnId stamps the turn id on every request except a resume. The runtime's no-message send addresses the newest answer holding an approval-responded tool part rather than the last answer, and offers no public way to name the target, so the hook offers resumeTurn only while that send addresses the last answer (resumeAddressesLastAnswer); otherwise no Continue is drawn.
  • The turn end is a kept data part (STORED_ANSWER_DATA_PARTS.turnEnd; write in storedAnswerParts, read in storedAnswerData), so it survives API mode's store rebuild and the message cache; toUIMessages writes a stored turnEnd field back as that part, so server history and cache are read by one reader.
  • Console wiring: ChatPane passes resumeTurn; the schema renderer passes it in both chat surfaces.
  • chatbot.continueTurn.* strings in all eleven locales (zh-Hant regenerated from zh-Hans by its generator); README and the frontend docs page document the control.

Where the stream comes from. The console's ask chat is served by the cloud AI service (agent route + stream encoder), not by this repository. Until it sends data-turn-end and accepts resume, nothing is drawn and no resume is sent. That half — persist turnEnd, emit the part, accept and execute resume, and the ADR-0013 D3 amendment — is objectstack-ai/cloud#5239. This PR is therefore Part of: the card's done-when also needs the spec released into the pin cloud consumes and a check against cloud#5239's endpoint.

Why

Maintainer-directed (filing gate ③ on the card): a turn that stops on a limit today can only be continued by typing, which starts a new turn that cannot see the tool results the stopped one already read. A server-side resume of the same turn needs the request field, an end-of-turn signal the UI can read live and after a reload, and a button.

Tests

  • packages/spec/src/ai/turn-end.test.ts — the part name; admits a resumable wrap-up and a finished answer; refuses an unknown key (unrecognized_keys), each missing key by path, a negative or fractional count, an empty reason or turn id; resume admitted and kept, refused when empty, missing turnId or carrying an unknown key; turnEnd admitted, null or absent, and refused through the same closed shape.
  • ui/packages/plugin-chatbot/src/__tests__/continueTurn-38609.test.tsx — the kept-part entry equals TURN_END_PART_TYPE; lift / refuse / newest wins / stored-part round trip; where Continue is drawn and every hide case (not resumable, none left, streaming, a later user or assistant message, loading, read-only, no handler); the request body (resume and messageId, no top-level turnId; CONTROL: without resume it is stamped); and three tests through the real chat runtime with a stubbed stream: a restored thread draws Continue, the click sends resume: { turnId } with exactly the two existing messages, messageId: 'a1' and no turnId, the rest of the answer lands in the same bubble with no new user bubble, and the new turn end hides the control; a start naming the request's messageId keeps one answer bubble; CONTROL: a start naming another id draws a second answer; the resume-target rule (last answer; an earlier answered approval wins; the last answer holding one is still last); a restored thread with an earlier approval-responded part draws no Continue and sends nothing (CONTROL: with that approval already run, Continue resumes a1).
  • ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.turnEndReload-38609.test.tsx — server history (stored turnEnd field) and cache fallback both restore Continue; CONTROL: a refused, null or absent stored turn end offers nothing.
  • Ablation (each reverted after): dropping the resume body turns the request pin and the runtime test red (2 failed); not writing the stored turnEnd back in toUIMessages turns the server-history pin red (1 failed); stamping turnId on a resume again turns the request pin and the runtime test red (2 failed); offering resumeTurn whatever the target turns the earlier-approval pin red (1 failed).

Local gates: the derived family run (dispatch-gates.mjs --commands, 119 commands) ran beside the first CI run; its readings, with the head they were taken on, are in the os-dev report comment on #38609. Spec package: pnpm --filter @objectstack/spec test 914 files / 28919 tests passed, typecheck exit 0. Spec check:generated: all 14 artifacts up to date. UI type-check (plugin-chatbot, i18n, app-shell): exit 0. UI tests (plugin-chatbot, i18n, app-shell console/ai + hooks): 337 files, 1 failure (zh-Hant not regenerated) fixed by running its generator, then green.

Acceptance notes

  • Surface beyond the claim's list: the chatbot.continueTurn.* keys in every ui/packages/i18n locale (key-parity test), one prop line in ChatPane.tsx and ui/packages/plugin-chatbot/README.md are admitted by claim amendment 7269233060; the content/docs/frontend/plugins/plugin-chatbot.mdx section (ui/AGENTS.md commandment 2) is admitted by the seat's further amendment after the contract review.
  • Clause-②: is written yes (widening) (the claim's yes, with the arm its own text states: additive, optional).
  • Metadata-protocol: is added, not the claim's none: measured from the diff, the change moves the authorable-surface shards (ai/TurnEnd:*, api/AiChatRequest:resume, api/AiConversationMessage:turnEnd), and check-changeset-no-major reads that as a key entered. @objectstack/spec is graded minor accordingly; the UI packages stay patch.
  • packages/spec/llms.txt counts the new schema module (ai 18, 233 in all) with a Turn End row, as check:llms-txt requires.
  • No browser E2E against a live stack: the console's chat is served by the cloud AI service, which neither emits data-turn-end nor accepts resume before cloud#5239. The runtime-level test above drives the real AI SDK chat with a stubbed stream instead; the card's "verified against cloud#5239's resume endpoint" stays open.
  • extractTurnEnd is not re-exported from the package root (only the chat itself reads the part).

For cloud#5239

Not fixed here: they belong to the server half, which picks them up from this list (contract review comment 7271059472 on this PR).

  • AIConversationMessage in packages/spec/src/contracts/ai-service.ts names AiConversationMessageSchema as its wire shape but carries turnId only, and addMessage has no way to write a turn end. How the turn end is stored is the server half's; widen the contract there, so the spec is not released twice for one feature.
  • A turn replayed by its turnId (ADR-0013 D1, nothing ran) sends no turn end, so a Retry of a wrapped-up answer loses Continue until a reload restores it from the stored field. Declared behaviour and a producer choice.
  • A retried resume has no idempotency key: nothing in resume: { turnId } tells a network retry of one press from the next press, so one press can spend two resumes. The shape is closed, so any such key is a later widening.

Verification

Two minutes: pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/continueTurn-38609.test.tsx — 19 passed, including the runtime tests that click Continue, read the sent body and count the answer bubbles.

Read first (by risk):

  1. ui/packages/plugin-chatbot/src/useObjectChat.ts resumeTurn + resumeTurn.ts — relies on the AI SDK sending the current messages and streaming into the last assistant message when sendMessage gets no message (ai 7.0.118, AbstractChat.sendMessage / makeRequest).
  2. packages/spec/src/api/protocol.zod.ts — the two new keys on published wire schemas.
  3. ui/packages/plugin-chatbot/src/chat/resumableTurn.ts resumableTurnOf — the show/hide rule.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (CI).
  • 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.
  • 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 with Claude Code

https://claude.ai/code/session_01JQwxbYmVBS2cvoZWKGbx92


Generated by Claude Code

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:ai tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/spec, touching 7 documentable anchor(s). ⚠️ 10 changed file(s) yielded no anchor (packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, packages/spec/authorable-surface/api.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/frontend/plugins/plugin-chatbot.mdx (via AiChatRequestSchema (symbol, a top-level const), AiConversationMessageSchema (symbol, a top-level const), TURN_END_PART_TYPE (symbol, a top-level const object), TurnEndSchema (symbol, a top-level const), resumesLeft (literal, a string literal in TurnEndSchema))
What this run could not see
  • 10 changed file(s) yielded no anchor (packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, packages/spec/authorable-surface/api.json, …) — pages documenting those are invisible to this run
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 182 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 751e83941b805879e98a210539d242511021a505 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 600e81e662d8a50d0a70561be9a0caea226700f4 — the merge of head a5a90f9ab02678f69e2544354db9fb5ea92c048e into base 751e83941b805879e98a210539d242511021a505, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 600e81e662d8a50d0a70561be9a0caea226700f4 && git checkout 600e81e662d8a50d0a70561be9a0caea226700f4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 751e83941b805879e98a210539d242511021a505 a5a90f9ab02678f69e2544354db9fb5ea92c048e && git checkout -B drift-repro 751e83941b805879e98a210539d242511021a505 && git merge --no-ff a5a90f9ab02678f69e2544354db9fb5ea92c048e

node scripts/docs-audit/affected-docs.mjs --json 751e83941b805879e98a210539d242511021a505

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 751e83941b805879e98a210539d242511021a505 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

… the reload test off the chat pane

Claude-Session: https://claude.ai/code/session_01JQwxbYmVBS2cvoZWKGbx92
Co-authored-by: Claude <noreply@anthropic.com>
…ges in the Continue snippet

The snippet handed useObjectChat().messages straight to ChatbotEnhanced,
which the doc-snippet gate refuses (ObjectChatMessage's role includes
'tool'). The console and the runtime test already convert with
toRuntimeMessages; the README and the frontend docs page now do the same.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYmVBS2cvoZWKGbx92
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract-review-claim: session_01JQwxbXyLoBzNYY1U8SNPFu · head f4fbc45 · 2026-11-30T06:42Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f4fbc45edcd6583d864d71f7d0b6f7a47cdae9b0
Local-runs: probe — read the published ai@7.0.118 package (npm pack, extracted and grepped; nothing built or executed) for the stream-continuation rule S2 rests on, which the PR body cites and the checkout has no copy of
Scope: packages/spec/src/ai/index.ts, packages/spec/src/ai/turn-end.zod.ts, packages/spec/src/api/protocol.zod.ts + ui/packages/plugin-chatbot/src/mapMessages.ts, ui/packages/plugin-chatbot/src/chat/resumableTurn.ts, ui/packages/plugin-chatbot/src/chat/ContinueTurnButton.tsx, ui/packages/plugin-chatbot/src/chat/types.ts, ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx, ui/packages/plugin-chatbot/src/resumeTurn.ts, ui/packages/plugin-chatbot/src/useObjectChat.ts, ui/packages/plugin-chatbot/src/toolResultParsers.ts, ui/packages/plugin-chatbot/src/chatMessageAdapter.ts, ui/packages/plugin-chatbot/src/renderer.tsx, ui/packages/app-shell/src/hooks/useChatConversation.ts, ui/packages/app-shell/src/console/ai/aiChatHydration.ts, ui/packages/app-shell/src/console/ai/ChatPane.tsx
Security-touching: no
Rule-change-verified: none

Inputs read: card #38609 (body and its five comments: triage 7258167601, claim 7268992318, dispatch order 7269037719, claim amendment 7269233060, dev report 7270906289), PR #38698 (body, 48-file list, net diff from merge base 5ac1ee0bc8 to the head), and the 72 check-runs on the head: 63 success, 9 skipped, 0 failed, none in progress. Every required context that ran is success (Lint & Repo Gates, TypeScript Type Check, Test Core, Build Core, Governed Surface Queue Guard, Lint UI, Type Check UI, Test UI, Build & E2E UI, Live E2E UI, Dogfood Regression Gate); Temporal Conformance (live PG + MySQL) is skipped on a PR run. The PR is a draft and Part of #38609.

① Derived judgments

  • TurnEndSchema is a new closed object, { reason, wrapUp, resumable, resumesLeft, turnId }, every key required. It is the card's shape key for key. Right. Closed from its first day follows ai/draft-review.zod.ts, the model the card names; canResume and remainingResumes are suggestions for a refused key, not accepted spellings (turn-end.test.ts pins unrecognized_keys on canResume). Right.
  • reason is string().min(1), not an enum. Right: the producer is in another repository and its vocabulary grows with its refusal kinds, and no reader in this diff branches on it (resumableTurnOf reads resumable and resumesLeft only).
  • resumesLeft is int().min(0), and resumable: true with resumesLeft: 0 is admitted. Right as a wire shape: the describe line says the chat needs both, and resumableTurnOf requires both.
  • TURN_END_PART_TYPE = 'data-turn-end': the card's name, the same custom data-part convention as DRAFT_REVIEW_PART_TYPE. Right.
  • AiChatRequestSchema.resume: optional, closed { turnId: string().min(1) }. Additive on a non-strict request object, so a server on the older spec strips it and a client on the older spec never sends it. Right. messages.min(1) still holds on a resume: the first consumer sends the conversation as it stands.
  • AiConversationMessageSchema.turnEnd: optional and nullable, the same convention as turnId beside it; additive on a response the older client strips. Right.
  • New public exports from @objectstack/spec/ai: TURN_END_PART_TYPE, TurnEndSchema, TurnEnd, TurnEndParsed; the input and parsed alias pair matches draft-review.zod.ts. api/protocol.zod.ts now imports ai/turn-end.zod.ts, which imports shared/ only, so no import cycle with ai/draft-review.zod.ts (which imports api/protocol.zod.ts). Right; TypeScript Type Check (api-surface, export-origins, declaration-map, docs) is green.
  • No route in this repository parses AiChatRequestSchema (grep at the head: spec tests and the two UI comments only; the block's own header says these schemas describe the wire cloud serves). So the new keys add no declared-but-unenforced surface here. Right.

② Semver level

.changeset/38609-chat-continue-turn.md grades @objectstack/spec minor and @object-ui/plugin-chatbot, @object-ui/app-shell, @object-ui/i18n patch. The spec gains exports and three keys the authorable-surface shards record, so minor is the floor the gate asks for, and Check Changeset is success on the head. The UI packages gain a prop, a hook member and strings, none a protocol kind: patch. Right.

Clause-②: yes (widening) — on the PR body and the changeset, identical. Verified against the diff: every schema change is an added optional key or a new export, nothing is removed, renamed, required or re-typed. Metadata-protocol: added is on both as well; it is the gate's reading of the moved shards rather than a key a metadata author writes, and the dev's report says so. Accepted as the gate reads it.

③ Boundary flags

  • open_questions: empty in report 7270906289. Nothing to answer.
  • Dev flag, Metadata-protocol: added in place of the claim's none: answered in ②, right.
  • Dev flag, Clause-②: yes (widening) for the claim's bare yes: right, the arm is what the diff is.
  • Dev flag, surface beyond the claim: the locales, the ChatPane.tsx prop line and the plugin README are admitted by amendment 7269233060; packages/spec/llms.txt is a generated index a gate holds. content/docs/frontend/plugins/plugin-chatbot.mdx is NOT among the amendment's three additions, though the PR body lists it as admitted. It is prose outside this review; the lane seat's ACCEPT answers it.
  • Dev flag, no browser E2E against a live stack: right for this PR. The producer is not in this repository, the PR is Part of, and the card's two done-when lines (released into cloud's pin; verified against cloud#5239's endpoint) stay open on the card.
  • SQL push-down: no query, id materialisation or join in the diff. Nothing to flag.
  • For cloud#5239, not graded here: a resume request carries no key that tells a retried resume from the next one, so a network retry of one press can spend two resumes. The closed { turnId } shape means any such key is a later widening.

④ Design judgment

packages/spec/src/ai/turn-end.zod.ts, against the card and its reader. The shape is the card's. Each sentence of the "Reader" and "What the chat does with it" sections holds in this diff: extractTurnEnd reads the part through TurnEndSchema and a refused part is no turn end (mapMessages.ts); the stored field is written back as the same part (toUIMessages) so one reader parses both; Continue is drawn only under the conversation's last message, when it is an answer that is not streaming, with resumable and resumesLeft >= 1 (resumableTurnOf), and not while loading, read-only or without a handler (ChatbotEnhanced.tsx); the press sends resume: { turnId } with no user message (useObjectChat.ts:1101, resumeTurn.ts). Attempts to break it: a later message hides the control (not last); a failed resume leaves the old turn end, so the control returns and the server is the one that refuses; a second turn end in the same message is read last (.pop()), and a part re-sent under the same id is replaced in place by the chat runtime, so either producer choice reads the newest verdict; a stale cache can only offer a resume the server refuses.

packages/spec/src/api/protocol.zod.ts, against the card and its first consumer. Two things the first consumer depends on are not in the published text:

S1 (should-fix) — the request now has two turn ids and the contract does not say which one a resume reads. turnId (line 4599) is the ADR-0013 D1 idempotency key: the server dedups on it and answers a completed turn from store. withTurnId stamps it on every request from the last user message's id (useObjectChat.ts:162), resume included, and continueTurn-38609.test.tsx pins turnId: 'u1' beside resume: { turnId: 'u1' }. Live, that is the id of the very turn being resumed, which D1 as written replays instead of running. After a reload it is a different value: restored messages take the store row's id (useChatConversation.ts:666; useObjectChat.ts notes a restored id is the store row's, not the turn's), so the request carries turnId = a row id and resume.turnId = the stored turn. A producer built from the spec alone cannot tell that resume must be read before the D1 dedup and that the top-level turnId means nothing on a resume. Fix on this face: one sentence on resume (and the regenerated reference docs) stating that a resume names its turn itself and the request's own turnId is not read as an idempotency key, or stop stamping turnId when the body carries resume and say that instead.

S2 (should-fix) — "streams the rest of its answer into that turn" holds in the chat only under a stream condition the contract does not state. Read in ai@7.0.118 (dist/index.js, the start case of the stream processor and the write path of the request): a start chunk with a messageId renames the response message, and a response whose id differs from the last message's is pushed as a new message. So a resume stream whose start names any id but the answer's own draws a second answer bubble holding the old parts plus the new ones, which is the card's "流追加到同一轮" failing. The request already carries the answer's id as messageId (useObjectChat.ts:160). The only test of the path stubs { type: 'start' } with no id, so nothing pins the requirement. Fix on this face: state on resume (or in the turn-end producer section) that the resume stream's start carries the request's messageId or none; a UI pin with a foreign messageId would show which the chat tolerates.

packages/spec/src/ai/index.ts: one header line and one export *, both accurate. No finding.

Implementing files, sentence by sentence against the contract: mapMessages.ts, chat/resumableTurn.ts, chat/ContinueTurnButton.tsx, chat/types.ts, ChatbotEnhanced.tsx, resumeTurn.ts, toolResultParsers.ts (the part name is spelled, and pinned to TURN_END_PART_TYPE by the new test), chatMessageAdapter.ts, renderer.tsx, useChatConversation.ts, aiChatHydration.ts, ChatPane.tsx agree with the schema text; resumeTurn is returned in API mode only, so the two schema-rendered chats pass undefined in local mode and draw nothing. useObjectChat.ts agrees with the request shape and is where S1 and S2 surface.

N1 (nit) — AIConversationMessage in packages/spec/src/contracts/ai-service.ts (not in the diff) names AiConversationMessageSchema as its wire shape and still carries turnId only, and addMessage has no way to write a turn end. The wire schema is consistent on its own and the first consumer does not read the type; how the turn end is stored is cloud#5239's. Follow-up there or on a card, so the spec is not released twice for one feature.

N2 (nit) — the producer section says a turn replayed by its turnId sends no turn end. A Retry of a wrapped-up answer therefore loses Continue until a reload restores it from the stored field. Declared behaviour, a producer choice; noted for cloud#5239.

No must-fix. S1 and S2 are open on this head.

Implemented-by: claude/project-thread-5o6334
Reviewed-by: session_01JQwxbXyLoBzNYY1U8SNPFu

VERDICT: PASS

…e answer one message

Contract review of the Continue control (S1, S2):

- A resume request no longer carries the top-level turnId. withTurnId
  stamps it on every other request; on a resume it was either the id of
  the turn being resumed (which the D1 dedup answers from store) or,
  after a reload, a store row id. AiChatRequestSchema.resume and turnId
  now say the top-level key is not read on a resume.
- The resume contract (and the turn-end docblock) states that the resume
  stream's start chunk carries the request's messageId or none: with
  ai 7.0.118 a start naming another id pushes a second answer.
- Pins: the request the client builds carries resume and messageId and
  no turnId (CONTROL: without resume it is stamped); through the real
  chat runtime, a start naming the answer's id keeps one bubble, and a
  start naming another id draws two (CONTROL).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYmVBS2cvoZWKGbx92
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract-review-claim: session_01JQwxbXyLoBzNYY1U8SNPFu · head 1c98384 · 2026-11-30T07:33Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 1c98384067c54fe893f946905d30153ec126029d
Local-runs: probe — read the published ai@7.0.118 package again (npm pack, extracted and read; nothing built or executed) for which message a send with no message addresses, the rule S3 rests on
Scope: packages/spec/src/ai/index.ts, packages/spec/src/ai/turn-end.zod.ts, packages/spec/src/api/protocol.zod.ts + ui/packages/plugin-chatbot/src/useObjectChat.ts, ui/packages/plugin-chatbot/src/resumeTurn.ts
Security-touching: no
Rule-change-verified: none

Delta review of record 7271059472 (head f4fbc45edc). Read this round: the delta f4fbc45edc..1c98384067 (one commit, 8 files), card comments 7271073171 (claim amendment) and 7271854180 (dev report), the PR body as it stands, and the 76 check-runs on the head: 65 success, 11 skipped, 0 failed, none in progress. Every required context that ran is success. The files of the first record's scope that the delta does not touch stand as judged there.

① Derived judgments

  • No accept-set change in the delta: the two schema hunks edit describe text and one docblock only. turnId stays an optional string, resume stays the closed { turnId }. Right.
  • The console no longer sends a top-level turnId on a request that carries resume. The key was and is optional, so the request still parses. Right.
  • Generated reference docs (content/docs/references/ai/turn-end.mdx, packages/spec/docs/references/api/protocol.md) carry the new text; TypeScript Type Check is green on the head.

② Semver level

Unchanged: @objectstack/spec minor, the three UI packages patch; Check Changeset is success on the head. The changeset text now states both contract sentences and nothing else moved.

Clause-②: yes (widening) — still on the PR body and the changeset, and still what the diff is.

③ Boundary flags

  • open_questions: empty in report 7271854180.
  • N1, N2 and the retry note: the PR body carries all three under "For cloud#5239", worded as recorded. Accepted as follow-up for the server half; none is fixed here, as agreed.
  • content/docs/frontend/plugins/plugin-chatbot.mdx: admitted by claim amendment 7271073171, and the PR body now credits that amendment. Answered.
  • SQL push-down: nothing in the delta queries anything.

④ Design judgment

S1: closed. withTurnId omits turnId whenever the body carries a resume object (useObjectChat.ts), on both paths that produced the two conflicting values, live and reloaded. resume and turnId both say the top-level key is not read on a resume. The request pin asserts no turnId with a control that a plain request is still stamped, and the runtime test reads the sent body. Tried to break it: the per-send body is not kept between sends, so a later ordinary message is stamped as before; a Retry after a resume carries no resume and is stamped with the turn's id, the pre-existing replay path.

S2: closed. resume and the turn-end docblock state that the resume stream's start carries the request's messageId or none, and the reason. The runtime test with start naming a1 pins one bubble, and the control with another id pins the double draw the sentence rules out.

S3 (should-fix) — new on this head, in the sentence the S2 fix added. resume now says "the chat sends the id of the answer being carried on as the request's messageId", and turn-end.zod.ts says "its messageId is the answer's id". resumeTurn does not hold that. It calls the runtime's send with no message (useObjectChat.ts, aiSendMessage(undefined, ...)), and in ai@7.0.118 that path does not simply take the last message: it scans the store from the end for an assistant message holding a tool part in state approval-responded, takes that message's id as messageId, and writes the response into that message. This chat keeps such parts: restored history preserves a server-snapshotted approval-responded state on purpose (useChatConversation.test.ts, "A later tool row must not overwrite it"; toSdkToolPart writes it into the store with its envelope). So in a thread where an earlier answer holds an answered approval and the last answer is the stopped one, Continue sends the earlier answer's id and the rest of the answer streams into the earlier answer, not the one the control sat under. Read, not run. No test covers a store with such a part. Fix on this face: make the resume address the last answer whatever else the store holds (or refuse to offer Continue in that state), pin it with an earlier approval-responded part in the store, and keep the two spec sentences only once the code holds them.

packages/spec/src/ai/index.ts: untouched in the delta. resumeTurn.ts: comment only, agrees with the code except where S3 applies.

No must-fix. S3 is open on this head.

Implemented-by: claude/project-thread-5o6334
Reviewed-by: session_01JQwxbXyLoBzNYY1U8SNPFu

VERDICT: PASS

…o an earlier answer

Contract review S3. The chat runtime's send with no message (ai 7.0.118)
addresses the newest assistant message holding an approval-responded
tool part, not the last message, and restored history keeps that state
on purpose. In such a thread a resume would send the earlier answer's
id as messageId and stream the rest into it. The runtime offers no
public way to name the target, so the hook now offers resumeTurn only
while that send addresses the last answer (resumeAddressesLastAnswer in
resumeTurn.ts mirrors the runtime's rule); otherwise no Continue is
drawn.

Pins: the target rule (last answer; an earlier answered approval wins;
the last answer holding one is still the last answer), and through the
real runtime a restored thread with an earlier approval-responded part
draws no Continue and sends nothing (CONTROL: the same thread with the
approval already run offers Continue and the resume addresses a1).
README and the frontend docs page say so.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYmVBS2cvoZWKGbx92
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a5a90f9ab02678f69e2544354db9fb5ea92c048e
Local-runs: none
Scope: packages/spec/src/ai/index.ts, packages/spec/src/ai/turn-end.zod.ts, packages/spec/src/api/protocol.zod.ts + ui/packages/plugin-chatbot/src/resumeTurn.ts, ui/packages/plugin-chatbot/src/useObjectChat.ts
Security-touching: no
Rule-change-verified: none

Delta review of record 7271982421 (head 1c98384067), which left S3 open. Read this round: the delta 1c98384067..a5a90f9ab0 (one commit, 5 files, none under packages/spec), the PR body as it stands, and the check-runs on the head: 64 success, 11 skipped, 1 cancelled, none in progress. The cancelled run is the first PR-body guards run, superseded 18 seconds later by a second run of the same check that is success. Every required context that ran is success. The runtime rule was read in the installed ai 7.0.118 package (dist/index.js, in a sibling worktree's node_modules); nothing was downloaded, built or run. The three spec files and the rest of the first record's scope are untouched by the delta and stand as judged.

① Derived judgments

  • No schema, export or accept-set change in the delta. Right.
  • useObjectChat().resumeTurn was already optional (absent in local mode); it is now also absent while a resume would not address the last answer. A narrowing of when the member is present, inside the type it already had. Right.
  • resumeTurn.ts gains two exported helpers, noMessageSendTarget and resumeAddressesLastAnswer; neither is re-exported from the package root in this delta. Right.

② Semver level

Unchanged: @objectstack/spec minor, the three UI packages patch, and Check Changeset is success on the head. The delta is a UI behaviour fix inside a feature this same changeset introduces, so patch still covers it.

Clause-②: yes (widening) — unchanged on the PR body and the changeset, and still what the diff is.

Note, not graded: the changeset's plugin-chatbot line says the hook "returns resumeTurn(turnId) in API mode" and does not mention the new withheld case; the README and the docs page do.

③ Boundary flags

④ Design judgment

S3: closed, by the second arm. The hook hands out resumeTurn only while resumeAddressesLastAnswer(aiMessages) holds, and all three hosts that draw Continue (ChatPane.tsx, and the two registrations in renderer.tsx) take it from the hook, so with it undefined ChatbotEnhanced draws nothing. No other path in ui/ passes onResumeTurn.

The mirror is the runtime's rule. AbstractChat.sendMessage with no message takes pendingApprovalMessageId if set, else scans from the end for an assistant message with a tool part in state approval-responded and falls back to the last message; makeRequest then writes into the message that id names. noMessageSendTarget is the scan and the fallback, with the runtime's own isToolUIPart. The one branch it does not mirror, pendingApprovalMessageId, is set only by addToolApprovalResponse, which nothing under ui/ calls outside tests (nor sendAutomaticallyWhen), so that field is never set in this chat.

Tried to break it:

  • An earlier answer with a restored approval-responded part: no Continue, nothing sent (runtime pin, with its ablation in the PR body).
  • The last answer itself holding the part: the target is the last answer, Continue is offered, and the resume lands there. Correct.
  • The earlier approval already run (output-available): Continue is offered and the request names a1 (the control).
  • A guard computed at render and a store that changes before the click: the control only renders from the same store snapshot, and a send in flight hides it.

The cost is stated, not hidden: a conversation whose history keeps an answered approval offers no Continue at all, and the person continues by typing. The README and the frontend docs page say so in the same words, and the spec sentence "the chat sends the id of the answer being carried on as the request's messageId" now holds for every resume the chat sends. The PR body's account (the target rule, the 19 tests, the fourth ablation) matches the tree.

N3 (nit) — the turn-end docblock's "What the chat does with it" still gives the offer rule as resumable with resumes left under the last answer, without the earlier-approval exception. It was never the full rule (read-only and no handler are also unstated), the package README and docs page carry the exception, and a spec edit would move the head. Accepted deviation.

No must-fix, no should-fix.

Implemented-by: claude/project-thread-5o6334
Reviewed-by: session_01JQwxbXyLoBzNYY1U8SNPFu

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

维护者速读

  • 用户能看到什么变化:控制台问答里,回答因时间、额度或轮数触顶停下、且服务端表示可以续跑时,最后一条回答下出现「继续查」按钮,并显示还能续几次;点了不新增提问气泡,答案接着写进同一轮,刷新后按钮仍在。如果这段对话里更早的一条回答还留着已答复的审批,就不显示按钮,用户直接打字继续。
  • 为什么做:chat:「继续查」按钮 — spec 加 resume 请求字段与 data-turn-end 部件,plugin-chatbot 在可续的最后一条回答下显示按钮 #38609「继续查」的协议和界面一半;云端续跑那一半要接在这个协议上。
  • 风险:全是新增的可选字段;服务端没发「回合结束」信息之前界面什么都不画,现有对话不受影响,撤回即删。
  • 要你做什么:无。不属于受管路径,1,255 行,席位直接入队。

席位核对

ACCEPT · L1 · area o2-A · Head-sha a5a90f9ab02678f69e2544354db9fb5ea92c048e · 2026-11-30T08:23Z

  • Contract review at CONTRACT_REVIEW_TIER, same-head delta PASS 7272843866: no must-fix, no should-fix. S1 and S2 closed in 7271982421; S3 closed here by its second arm: the hook offers resumeTurn only while resumeAddressesLastAnswer holds, and every host that draws Continue takes it from the hook. The reviewer read ai 7.0.118 and confirmed the check mirrors the runtime's own target rule.
  • Clause-②: yes (widening) · Metadata-protocol: added: the chat route's resume and the turnEnd stream part and stored field, all optional.
  • Pins: the target rule in three cases, a real-runtime pin with an earlier approval-responded part (no Continue, nothing sent), its CONTROL, and an ablation that turns the pin red.
  • Carried, not blocking: N3 (the spec's turn-end docblock does not repeat the exception; README and docs page do) and the plugin-chatbot changeset line, which does not name the withheld case. Both are text; the follow-up is the cloud half's PR, which touches the same sentences.
  • Checks at this head: every required context green; one superseded PR-body guards run cancelled, its rerun green. Mergeable, clean.
  • Landing: Tier S (not governed, 1,255 lines). Part of #38609; the cloud half continues on its own card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

2026-11-30T08:24Z · Landing · seat ACCEPT 7272862815 at a5a90f9ab0 (same head as delta contract PASS 7272843866). All required checks green, mergeable_state clean against main.

  • The release freeze does not apply: Warren (os-warren) answered in os-warren's fleet project timeline at 2026-11-30T07:08Z 「目前已经开发中的不用冻结」, which exempts work already in development.
  • Tier S (not governed, 1,255 lines): ready for review and auto-merge in this stroke. The queue re-runs every check on the merged tree.
  • Part of #38609: the card stays open for the cloud half.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 08:24
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 0d68ce2 Nov 30, 2026
76 of 77 checks passed
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 protocol:ai size/xl tests 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.

2 participants