Repository navigation
fix(ui): the AI build chat says what really happened — plan card states, queued sends, preview empty state, customer wording, labels - #33333
Conversation
The plan card follows the build (confirmed, building, built, not built), a message typed during a reply waits above the composer instead of being lost, the draft preview of an unpublished object draws an empty list, build issues lead with a customer sentence, and the change card names objects and fields by label. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pAEP2nn4Qk4wi1V3u
…adge wording Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pAEP2nn4Qk4wi1V3u
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD Contract reviewServed-tier: Read: card #32984 body and all four comments (triage 6847536755, claim 6879542746, amendment 6879628332, os-dev-report 6881099882); PR #33333 body and its 24-file list; the net diff ① Derived judgmentsPublished surface, measured on the diff:
Code findings (not contract, non-blocking at this face):
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
A doubled first send with files is held once; the preview wrapper's texts say what it does; the published draft badge's failed-item count goes through the pack; the chat pane's label resolvers read objects by name. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pAEP2nn4Qk4wi1V3u
…names it Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pAEP2nn4Qk4wi1V3u
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD Contract reviewServed-tier: Read: card #32984 body and all five comments (triage 6847536755, claim 6879542746, amendments 6879628332 and 6881185212, os-dev-report 6881099882); PR #33333 body as rewritten for this round, its 26-file list, the net diff ① Derived judgmentsPublished surface, measured on the net diff at this head:
Code findings (none is contract-blocking at this face):
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD 席位核对Verdict: ACCEPT · head
|
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD Regen-provenance: 6881840690 · |
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD Landing · head
State: ready + auto-merge. The PR says |
…, and give its text back when the create fails (objectstack-ai#33561) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XGSudkpvjYSMB3ZosFUW2qM)_ Fixes objectstack-ai#33420 Clause-②: no Metadata-protocol: none Seat `domain:ui#2` · os-project-manager · card thread `session_01FEkQ5oYya4wGgRN7g6MEWJ` · claim 6885536750 (and its two amendments: the conversation hook, then the dock and Studio hosts) ## 维护者速读 - 改了什么:AI 对话新建会话时,用户发出的第一条消息立刻以用户气泡出现在对话里(下面是助手的「思考中」小点),等 `POST /conversations` 返回、会话打开后正常发出,且只显示一次;等待期间再发的第二条会并进第一条一起显示。创建会话失败时,气泡撤掉,文字放回输入框,并显示「消息未发送」提示(与现有发送失败的处理一致),不再把消息悄悄藏着等下一次一起发。全页 AI 对话、控制台侧边对话和 Studio 助手三处都生效。 - 为什么改:objectstack-ai#32984 报告新会话第一条消息要等约 5 秒才出现;原因是第一条消息在会话 id 生成前被暂存在页面里、不进对话,创建失败时也没有任何回滚信号。 - 风险与回滚:只改 app-shell(私有包,随 console 发布)的前端显示和会话 hook 的失败上报,不改服务端、不改 spec、不改已有会话的发送路径。回滚即还原本 PR。 - 先看:ui/packages/app-shell/src/console/ai/AiChatPage.tsx(`useDeferredFirstSend` 新增 `onHeldChange` / `createError`,`ChatPane` 的 `shownMessages`)、ui/packages/app-shell/src/hooks/useChatConversation.ts(`createError` 的设置与清除)、ui/packages/app-shell/src/layout/ChatDockConversation.tsx(一行传参)。 - 两分钟验证:pnpm dev,打开 `/ai/build`,在浏览器开发者工具里把 `POST /conversations` 节流到很慢,发一条消息:气泡立刻出现;放开后只出现一条且收到回复。再把该请求设为失败:气泡消失,文字回到输入框,出现未发送提示。 - 需要你做的:无,席位落地。 ## What changes On a new conversation the first send is what creates the conversation (`useChatConversation().ensureConversation`, objectstack#32031), and `ChatPane` is keyed on the conversation id, so `useDeferredFirstSend` holds the message in the host-owned stash until the id lands and the pane remounts. Measured on `origin/main` f068cde with the rendered pins below: while the create is held open the thread draws nothing, and when the create fails the composer stays empty, nothing is shown, and the text sits in the stash to be sent with whatever the user sends next. - **The held message is drawn.** `useDeferredFirstSend` gains `onHeldChange`: it reports the user's held message (never a stash targeted at another agent surface, i.e. the handoff seed) when it is stashed or joined, `null` when it is replayed or rolled back, and, on mount, the stash a replaced pane left behind, from a layout effect so the id-keyed remount never paints an empty thread. Only a committed pane is told (see Acceptance notes for why). `ChatPane` keeps it in state and draws `shownMessages`: the runtime messages plus the user's bubble and an empty streaming assistant turn, which `ChatbotEnhanced` draws as its existing thinking dots. No new visual language and no new string. When the replay sends, the stash and the drawn bubble clear in the same task, and `useObjectChat`'s own optimistic bubble takes over, so it is drawn once. - **A second message typed during the wait** joins the held one as since objectstack-ai#33333, and the drawn bubble shows the joined text, first part first. - **The create failure has a signal.** `useChatConversation` returns `createError`: set when a create fails, tagged the way `useObjectChat` tags a send that never left the client (`notSent: true`, plus `status` when the server answered), cleared when the next create starts, when the surface settles empty, and whenever a conversation is held. This covers both the create a send starts and a request recorded during a still-running resolve that `settlePending` → `createFor` makes later, which used to fail with nobody told. `ensureConversation`'s contract is unchanged (it still resolves `undefined` on failure). - **The rollback is the existing one.** `ChatPane` hands `createError` to `ChatbotEnhanced` as its `error` (ahead of the chat's own), so its not-sent restore puts the typed text back in the box and `SendErrorNotice` shows the generic "Couldn't send your message" line, both unchanged. A new `createError` also clears the user's held message from the stash, so a retry sends it once. - **Hosts.** The `/ai` page, the console dock (`ChatDockConversation`) and the Studio copilot (`StudioAiCopilot`) each pass `conversationCreateError={createError}`; the drawing needs no host change. - **Changeset** `.changeset/33420-ai-chat-first-message-drawn.md`: `@object-ui/app-shell` and `@object-ui/console` patch (app-shell is private; console's `dist` ships it). ## Tests - New `AiChatPage.firstMessageDrawnAtOnce-33420.test.tsx`, through the REAL `AiChatPage` / `ChatDockConversation`, `ChatPane`, `useChatConversation`, `useObjectChat` transport and `ChatbotEnhanced`, driven through the composer (type, submit the form), with `POST /conversations` held open until the test answers it: - on the full-page chat and on the console dock: create held → the bubble is in the thread before it answers; answered → the chat request carries the message and it is drawn exactly once after the remount; - on both hosts: create fails (503) → the bubble is gone, the text is back in the composer, the send-error notice shows, nothing was sent; sending again retries the create, sends once and the notice goes; - a second message typed during the wait is drawn too, after the first, and both go out as the joined first turn; - a send recorded while the resolve of a cached (gone) conversation is still running rolls back the same way when the create it then makes fails; - CONTROL: a send in an existing conversation (`/ai/build/conv-7`) creates nothing and draws and sends as before. - `useChatConversation.test.tsx`: the failed-create test now also asserts `createError` is `{ notSent: true, status: 500 }` and cleared after the retry; new: a create recorded during the resolve that then fails (network) is reported. - Red first, on `origin/main` f068cde (the pin file alone, before any source change): 5/5 failed (the drawn pins `expected +0 to be 1`; the CONTROL failed on a harness timing, fixed by letting the deep-linked conversation open before typing, see Acceptance notes). - Ablations, one-off through `scripts/ablation-replace.mjs` (app-shell tests read `src`, no rebuild), each restored with the blob equal to HEAD and `git diff HEAD` empty: - the drawing removed (`messages={shownMessages}` → `messages={runtimeMessages}`): 6 failed / 1 passed (only the CONTROL stays green); - the failure signal removed (the hook returns `createError: undefined`): 3 failed / 4 passed (the three failure pins, at "bubble gone"). ## Acceptance notes - **A send that reaches an uncommitted pane.** The first cut reported the held message from the send itself, and `ChatDock.requestContext-30043.test.tsx` ("on a record page…", which sends through the first `ChatbotEnhanced` props it sees) went red: React warned "Can't perform a React state update on a component that hasn't mounted yet" and the stash was lost. Bisected to the state update in the send (removing it alone turns the file green). The report now goes only to a committed pane (`committedRef`), and the mount report covers the pane once it commits; the file is 7/7 green. - **Two sends, then a failed create (measured, a narrow-path change).** The existing restore puts back the text the composer itself last submitted (`ChatbotEnhanced`'s own last-submitted text). A one-off probe through the same rendered harness (two sends during a held create, the create answers 503, then resend what the box holds) read `box = "second part"` and the retried chat request `["second part"]`: the first message is dropped with the stash. Before this change both stayed hidden in the stash and went out with whatever the user sent next. Giving the joined text back needs `ChatbotEnhanced` (`@object-ui/plugin-chatbot`) to take the text to restore from the host, outside this card's surface; reported for the seat to file. - **A handoff seed is not drawn** and is kept in the stash on a failed create, as before: the user did not type it here, and there is nothing of theirs to restore. - **The latency of `POST /conversations` is unchanged** (the card's ⛔). - Observed while building the CONTROL, not chased: on a deep link to an existing conversation (`/ai/build/conv-7`), a message submitted before the conversation's GET answered was not sent within 4 s in this harness (no chat POST, composer cleared, not queued). Mechanism not read; the CONTROL types once the conversation is open. ## Verification <details><summary>Local gates, type-check, lint and suites (head 3f97718)</summary> - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derives 37 families for this diff. All 37 exit 0 on 3f97718; `--ran` reconciliation: 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN. Two read on their own reruns: `pnpm check:type-check-debt` (the first run answered exit 3 while a locked suite held the closure build; rerun alone: 0 entries above their measurement, exit 0) and `pnpm --dir ui exec vitest run scripts/` (the first run was SIGKILLed by the box's memory limit while a suite ran beside it; rerun alone under the lock with `--maxWorkers=2`: 171 files passed, 2 skipped, 5062 tests passed, exit 0). - `pnpm --filter @object-ui/app-shell run type-check`: exit 0. ESLint (`--no-inline-config`) on the six changed source and test files: exit 0. `pnpm check:new-line-citations` (ui/AGENTS.md objectstack-ai#11): 0 new citations, exit 0. - Suites under the lock, `pnpm exec vitest run --maxWorkers=2` from `ui/` over `packages/app-shell/src/hooks/__tests__/useChatConversation.test.tsx`, `packages/app-shell/src/console/ai/`, `packages/app-shell/src/layout/`, `packages/app-shell/src/views/studio-design/`: 527 files, 3854 tests passed (head 3f97718). On the first cut (1650db1) the same run had 1 failure, `ChatDock.requestContext-30043.test.tsx` "on a record page…", green on base f068cde (7/7) and fixed by baaaeda..3f97718 (see Acceptance notes). - The full app-shell suite and the rest of the farm are CI's. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5oYya4wGgRN7g6MEWJ --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oYya4wGgRN7g6MEWJ)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Requested by Leehom · project thread
Refs #32984 (items 1, 2 and 3 in full; the ui halves of items 4 and 5). Items 4 and 5 each keep a producer half in the cloud build agent, named under Acceptance notes, so this PR does not close the card.
Clause-②: yes (widening) — measured on this diff:
ChatbotEnhancedProps(exported by the published@object-ui/plugin-chatbot) gains three optional props,resolveObjectLabel,resolveFieldLabelandresolveFieldTypeLabel; the published@object-ui/i18npacks gain ten keys and one count family,chatbot.build.needsAttention(its base key plus each locale's plural slots), in all eleven shipped locales, and change or remove none.Metadata-protocol: none
维护者速读
ChatbotEnhanced.tsx的resolvePlanBuildStates与applyBlueprintOutcome(徽标判定);同文件handleSubmit的排队分支和发送 effect;preview/unpublishedObjectReads.ts(只吞那一种答复)。pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.buildChat-32984.test.tsx packages/app-shell/src/views/ObjectView.unpublishedPreview-32984.test.tsx,预期Tests 15 passed (15)。What changes
ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx).builtPlanIdscounted anyapply_blueprintafter a plan as built, running or refused. It is replaced byresolvePlanBuildStates, which gives every plan card one ofpending · confirmed · building · built · failed. An attempt is built only when its result envelope saysdraftedorpublished; a call with no result isbuildingwhile the turn is live andfailedonce it has ended; a refusal (blueprint_not_confirmedand the like) or an errored call isfailed. Any built attempt after the plan outranks earlier failures. A click on Build it readsconfirmeduntil the next attempt speaks: the approval is keyed to the tool-invocation count at the click, so an attempt that already failed before the click does not overwrite it.failedshows "Not built — nothing was created" beside Build it and Adjust, so the user can approve again. Anawaiting_confirmationanswer still leaves the card pending (objectui#8343), and a running or built plan is still never offered a second Build it ([WIP] Update action run status for job #432).resolveProposalCardStatelearnsbuildingandbuildFailedfor the header.isLoadinggoes into a queue drawn above the box ("Sends when the current reply finishes"), and the oldest queued message is sent on the next task after the turn ends. Each queued item has Cancel, which puts its text back in the box. The not-sent rollback (sendErrortests) is unchanged.ui/packages/app-shell/src/console/ai/AiChatPage.tsx,useDeferredFirstSend). While the first send is creating the conversation, a second submit was dropped without a word (it kept the first message and discarded the second). It now joins the held first message, which has not left the browser yet, so both reach the agent as the first turn. A repeat (the same text and the same files, a file being the same object or the same name, size, type and lastModified) is held once; a different message joins, and a file both carry is not doubled.ui/packages/app-shell/src/preview/unpublishedObjectReads.ts:withUnpublishedObjectReads(ds, onUnpublished)wraps the data source so afindthe engine refuses withOBJECT_NOT_FOUND(read throughansweredLoadFailure) answers an empty page and reports the object. That holds for any object the engine has not registered, read through this source (a lookup into another drafted object included), not only the listed one.objectViewListRenderer.tsxinstalls it only whenusePreviewDrafts()says the page is in the draft preview, and only the listed object's own empty state changes, to "Records appear here once you publish" with a sentence on why. Any other failure (a 403, a 500, a refusedfindOne), and every read outside the preview, reaches the list unchanged.chatbot.build.issuesSummary, orwarningsSummarywhen there are only warnings); the verification messages, written for the agent, move into a closed details element, "Technical details". Folded in (seat ruling, same defect class): the published draft badge's failed-item suffix ("· N need attention", English with anspicked on=== 1) now reads the count familychatbot.build.needsAttention.resolveObjectLabel(name),resolveFieldLabel(objectName, fieldName)andresolveFieldTypeLabel(type). The card's target readsCustomer · Phonewith the machine name on the tooltip, and the params lead with the field type's localized name.AiChatPagepasses resolvers built fromreadObjectsByName(each object by name, when a change card asks: the chat dock mounts this pane on an app's object-list open, where reading the wholeobjectsregistry at render would undo objectui#12811),useObjectLabelandfieldTypeName(type, locale).openPathObjectReaders-12811.test.tsgains AiChatPage's row, kindbyName. A name the metadata does not hold yet (a field the change is about to add) shows as given.ui/packages/i18n: ten keys and theneedsAttentioncount family in all eleven locales (chatbot.plan.confirmed,chatbot.plan.buildFailed,chatbot.build.issuesCount,issuesSummary,warningsSummary,issuesDetails,chatbot.composer.queued,queuedCancel,preview.unpublishedList.title,message). zh-Hant is the generator's output (gen:zh-hant).chatbot.build.issuesCountjoinsCOUNT_NEUTRAL.invariantincount-families-11445.test.ts: in every pack the number stands before an infinitive, after a label, or with a counter, so no word agrees with it..changeset/32984-build-chat-honest-states.md: patch for@object-ui/plugin-chatbot,@object-ui/i18nand@object-ui/app-shell, with both declaration lines.Tests
New pins, each driving the real component (and, for the chat, the real
uiMessagesToChatMessagesmapper over wire-shaped parts):plugin-chatbot/src/__tests__/ChatbotEnhanced.buildChat-32984.test.tsx, 12 cases. Item 1: six refused applies read failed with Build it offered again; an errored apply reads failed; a running apply reads building with no Build it; an apply the ended turn never answered reads failed; refused then built reads built; a click after a refusal reads confirmed. Item 2: Enter during a turn queues the text in sight and sends it when the turn ends; Cancel restores the text; control, Enter with no turn sends at once. Item 4: the summary sentence carries no agent text, the details element is closed and holds it, the chip reads1 to fix. Item 5: object, field and type by label with the machine names intitle; control, an unknown name shows as given.app-shell/src/views/ObjectView.unpublishedPreview-32984.test.tsx, 3 cases through a realObjectViewandListViewunder a forcedPreviewModeProvider: the empty state with the publish sentence and noOBJECT_NOT_FOUND; control, the same answer outside the preview is still an error; control, a 500 inside the preview is still an error.app-shell/src/console/ai/__tests__/useDeferredFirstSend.test.tsx: a second message during the create joins the first; the double-submit case submits the same text twice and expects it once; a doubled submit with one file is held once (text once, file once); control, a second submit with a different file joins, and the file both carry is not doubled.plugin-chatbot/src/__tests__/ChatbotEnhanced.needsAttention-32984.test.tsx, 3 cases under a realI18nProvider(its own file, so the provider's module-level global cannot leak into the provider-less pins): zh-Hans reads 「2 项需要处理」 and no English; en reads1 needs attentionand2 need attention; control, no failed item, no suffix.ChatbotEnhanced.test.tsxfixtures give theirapply_blueprintadraftedresult (one with no result now reads failed once the turn has ended), and the optimistic-click tests inChatbotEnhanced.test.tsx,sendErrorandplanApprovalPending-11666expectproposed-plan-confirmed.awaitingConfirmBuild-8343's running case renders withisLoadingand expects building.Ablations (
scripts/ablation-replace.mjs, each anchor hit once, each restored withgit diff HEADempty; ui vitest resolves@object-ui/*from source, so no rebuild leg):apply_blueprintresult counts as builtA2's first attempt was refused by the tool (its multi-line anchor was passed through a shell string and never matched; nothing was written) and re-run with the anchor passed as an argument.
Acceptance notes
apply_blueprint's verificationissues[].messageis written to the agent ("Do NOT publish…"). The ui now folds it away behind a generic sentence; a per-issue customer sentence needs the producer to send one.changes_proposedrows could carry the label the agent chose.main: the composer textarea was disabled whileisLoading, so the two paths that could lose a message in the ui were Enter during a turn (now queued) and the second submit during the first send's create (now joined).PublishHealthLineprints the publish-health issue messages the server sends, verbatim. The words are the producer's; not changed here.suggested: truedraws a dashed chip ending 「· 补充」 (chatbot.plan.suggestedField), with no legend and a tooltip that shows only the machine name, so nothing says what it means. The roughly 5 s blank thread before the first bubble reproduces as a mechanism, read on the tree, not timed: on a new conversation the first message waits inuseDeferredFirstSend's stash, outside the transcript, untilPOST /conversationsanswers and the pane remounts on the new id, so nothing is drawn for that long; the 5 s itself is the server's latency and was not measured here.Verification
All readings at head
7888f40d(based4fbb4db,origin/mainwhen the branch was cut) unless a line says otherwise.Tests
Round 1 (head
09f30cfb): plugin-chatbot + i18nTest Files 199 passed (199); app-shell, the 95 files that import the changed modules,Tests 744 passed (744); the two new pin filesTests 15 passed (15). Type-check of i18n, plugin-chatbot and app-shell exit 0.Patch round 1 (head
7888f40d):pnpm --dir ui exec vitest run packages/plugin-chatbot/ packages/i18n/ packages/app-shell/src/console/ packages/app-shell/src/preview/ packages/app-shell/src/views/ObjectView.unpublishedPreview-32984.test.tsxatb258a44f's content:Test Files 517 passed, with 1 failed (518):all-locales-key-parityasked the new family for its base key in every pack. The base key landed in7888f40d, andpackages/i18n/plus the needsAttention pin then readTest Files 103 passed (103),Tests 1897 passed | 13 skipped (1910), VERDICT command-exit 0. The 517 green files includeopenPathObjectReaders-12811.test.ts(the CI red on09f30cfb) anduseDeferredFirstSend.test.tsx.@object-ui/app-shell^...closure rebuilt, thenpnpm run type-checkin i18n, plugin-chatbot and app-shell chained with&&: VERDICT command-exit 0.Gates
dispatch-gates --commands --repo objectstack-ai/objectstackat7888f40dderives the same 40 commands as round 1; all 40 pluspnpm check:changeset-fixedexit 0, each code captured before any pipe.--ranwith exit codes: "40 derived famil(ies) accounted for — 40 run, 0 NOT-MEASURED (a DERIVED zero)". Round 1's one red,check:test-source-aliasat6d7affa4, was fixed in09f30cfb. The CI type-check lanes the derivation names as not runnable locally are left to CI.Generated by Claude Code