Skip to content

fix(console): a failed AI chat create gives back every message sent while it waited - #33673

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-snu787
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-snu787

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #33562

Refs #33567

Clause-②: yes (widening)
Metadata-protocol: none

Seat domain:ui#2 · os-project-manager · card thread session_01FEkQ5mV4rtksbPPvwm9w8L · claim 6889053115

维护者速读

What changes

#33562. On a new conversation the first send creates the conversation, and useDeferredFirstSend holds the message until POST /conversations answers; a second send during that wait joins the held one (first\n\nsecond, since #32984). When the create failed (#33420's rollback), ChatbotEnhanced's not-sent restore put back the text the composer itself last submitted, so the box got only the second part, and the held message (the only copy of the first part) was dropped so a retry would not send it twice. Measured on origin/main d95ddeb through the rendered page: box "second part" (see Tests, red first).

  • ChatbotEnhanced gains one optional prop, unsentText?: string: the text a not-sent error gives back to the composer when the host, not the composer, holds what was not sent. The restore reads unsentText ?? lastSubmittedRef.current, once per not-sent error and only into an empty box, as before. One rule differs: on its own the composer restores only text the user typed (a chip or card send clears lastSubmittedRef, objectui#7253), while a host-named unsentText is restored however it was sent, a held suggestion chip included (see Acceptance notes). A host that passes nothing keeps today's restore. This is the Clause-②: yes (widening) on @object-ui/plugin-chatbot.
  • ChatPane passes unsentText={conversationCreateError ? heldFirstMessage?.content : undefined}. heldFirstMessage is the joined held message AI chat: on a new conversation the user's first message is not drawn until POST /conversations answers, so the thread sits blank for that long #33420 already keeps in state for drawing; in the render the create error arrives in it is still set (useDeferredFirstSend drops it in a passive effect of the parent, which runs after the composer's restore effect), so the composer gets the whole text. A handoff seed is never reported as held, so it still restores nothing of its own. All three hosts (the /ai page, the console dock, the Studio copilot) render ChatPane, so none needs a change.
  • Changeset .changeset/33562-ai-chat-failed-create-joined-restore.md: @object-ui/plugin-chatbot, @object-ui/app-shell, @object-ui/console patch (a widening ships patch, AGENTS.md Post-Task Checklist step 3; app-shell is private and console's dist ships it).

#33567 (measured first, does not reproduce). On a deep link to an existing conversation (/ai/build/conv-7) with its GET /conversations/conv-7 held open, a message submitted through the composer is held by useDeferredFirstSend (the pane is …:pending, so apiMode && !conversationId), drawn at once, and ensureConversation records the request without creating anything (pendingKeyRef is unset while the resolve runs); when the GET answers, the resolve drops that request (finally: a run that found a thread), the pane remounts on conv-7 and the replay sends the message once. The #33561 observation came from the harness: findByRole('textbox') resolved on the …:pending pane's textarea, and by the time the test typed and submitted, the GET (answered at once there) had remounted the pane, so the test typed into a detached textarea (isConnected === false before the change event) whose form React no longer listens to. No line drops a send. This PR adds the pin only.

Tests

Acceptance notes

  • A typed but unsent draft is lost on the pane's id remount (measured, not changed here). ChatPane is keyed on ${chatApi}:${conversationId ?? 'pending'}, and the composer's text lives in the pane. A rendered probe on origin/main d95ddeb: on /ai/build/conv-7 with the GET held, text typed (not sent) into the composer is gone when the GET answers (new box ""); on /ai/build, after a first send, a second message typed but not sent is gone when the create answers (new box "", only the first part sent). A submitted message is never lost on either path. Reported for the seat to file; it needs the draft to outlive the remount, outside this card's ruling.
  • The latency of POST /conversations and fix(console): draw a new AI chat conversation's first message at once, and give its text back when the create fails #33561's first-message drawing are unchanged (the order's ⛔).
  • unsentText is read only on a not-sent error; a streamed-response error and a clean submit are unchanged.
  • A held suggestion chip now comes back on a failed create (accepted by the seat, patch round 1). An empty-state chip clicked as the first send of a new conversation is held like a typed first message. If that create fails, ChatPane names the held text as unsentText, so the chip's text comes back into the composer; before this PR nothing came back, because a chip send clears lastSubmittedRef. It returns the message that was not sent, not a stale delivered prompt, which is the harm objectui#7253 guards against. The restore comment and the prop doc say so, and a unit pin holds it.
  • A held message on a deep link whose GET fails hangs (measured on head d32d4df, seat to file, not changed here). On /ai/build/conv-7, a message sent while GET /conversations/conv-7 is held, then the GET answering 503 or failing as a network error: after 3 s the bubble and thinking dots are still drawn, nothing is sent, no create is made, no notice shows and the box is empty; a second send joins the held one and hangs the same way (still nothing sent, no create, no notice). Mechanism: the resolve's catch in useChatConversation.ts (L1221 onward) clears the id without settling the surface (pendingKeyRef stays unset, so no create is ever allowed) and its finally (L1231) drops the recorded request, and no error reaches the host. This PR's diff does not touch that path.

Verification

Patch round 1: local gates, type-check, lint and suites (head 07caf19)
  • 07caf19 changes only ChatbotEnhanced.tsx comments (the restore effect and the unsentText doc) and adds one test to ChatbotEnhanced.sendError.test.tsx; no runtime line moved.
  • dispatch-gates --commands derives the same 37 families at 07caf19; all 37 exit 0 after the @object-ui/app-shell^... closure build; --ran: 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN.
  • @object-ui/app-shell and @object-ui/plugin-chatbot type-check: exit 0. ESLint (--no-inline-config) on the four changed source and test files: exit 0. check:new-line-citations (from ui/): exit 0.
  • Suites under the lock, from ui/: AiChatPage.firstMessageDrawnAtOnce-33420.test.tsx and all of packages/plugin-chatbot/: 100 files, 968 tests passed (VERDICT command-exit 0). Narrowed from the first round's 627-file run because no runtime line changed; CI runs the full suites.
Local gates, type-check, lint and suites (head d32d4df, first round)
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derives 37 families for this diff (tree d32d4df). All 37 exit 0 on d32d4df, after the @object-ui/app-shell^... closure build (lock VERDICT command-exit 0). --ran reconciliation: 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN. pnpm --dir ui exec vitest run scripts/ ran alone under the lock with --maxWorkers=2.
  • pnpm --filter @object-ui/app-shell run type-check: exit 0. pnpm --filter @object-ui/plugin-chatbot run type-check: exit 0. ESLint (--no-inline-config) on the four changed source and test files: exit 0. pnpm check:new-line-citations (from ui/, ui/AGENTS.md Migrate documentation site to Fumadocs with monorepo structure and shared content #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/ and packages/plugin-chatbot/: 627 files, 4821 tests passed (VERDICT command-exit 0, head d32d4df).
  • origin/main moved 36 commits since base d95ddeb while the gates ran; none touches ui/packages/app-shell/src/console/ai/, ui/packages/plugin-chatbot/ or useChatConversation.ts.
  • The full app-shell suite and the rest of the farm are CI's.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5mV4rtksbPPvwm9w8L


Generated by Claude Code

…or it

ChatbotEnhanced takes an optional unsentText from the host; ChatPane hands
it the joined held first message when the conversation create fails, so a
second send made during the wait is not the only part that comes back.
Pins the held send on a linked conversation that has not opened yet.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mV4rtksbPPvwm9w8L
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8

Contract review

Served-tier: TIER_DEFAULT
Head-sha: d32d4df04a20cc315802e1d17d6a6a0fe299daa7
Local-runs: none

Inputs: card #33562 (body + 3 comments: claim 6889053115, unblock 6889055942, os-dev-report 6889844803), card #33567 (body + triage 6886866267 + claim 6889061870), PR #33673 body and its 5-file net diff, and the head's check-runs. Code outside the diff (ChatbotEnhanced.tsx, AiChatPage.tsx, useChatConversation.ts, FloatingChatbot.tsx at the head) was read to judge the diff, not reviewed.

Check-runs at render (36): 10 success, 13 skipped, 13 in_progress, 0 failure. Green: Check Changeset, Check PR Size, PR-body guards, Governed Surface Queue Guard, Type Check · workspace, Type Check · debt ledger, Test Core, Dogfood Regression Gate, Auto Label, filter. Still running: Build UI Deps, Plan Test UI shards, Live E2E UI, Type Check · source gates / consumer gates, and the 8 Lint jobs. This verdict covers the contract. It does not replace the gates, which must finish green before the merge.

① Derived judgments

  1. ChatbotEnhancedProps.unsentText?: string (exported from @object-ui/plugin-chatbot) is a pure widening. RIGHT. It is optional, with no default, and an absent value keeps the old expression (undefined ?? lastSubmittedRef.current), so every existing caller behaves as before. The props interface extends React.HTMLAttributes (of HTMLDivElement), but HTMLAttributes has no unsentText member, so there is no name clash. The component destructures unsentText explicitly (head line 2444), before ...props reaches the root div (line 4963), so it never reaches the DOM. The one consumer that spreads these props through is FloatingChatbot (FloatingChatbotProps extends ChatbotEnhancedProps, {...chatbotProps} into ChatbotEnhanced). It carries the new prop to the component that consumes it, so nothing leaks there either. SharedRecordPage and ChatPane are the other renderers, and only ChatPane passes the prop.
  2. The restore effect unsentText ?? lastSubmittedRef.current with deps [error, unsentText]: the once-per-error guard holds. RIGHT.
    • ChatPane calls useDeferredFirstSend, so the effect that drops the held message runs in the parent. Child effects run before parent effects in the same commit, so in the commit where conversationCreateError arrives, the composer's restore runs first with the joined text. The parent's drop then sets heldFirstMessage to null, unsentText becomes undefined, and the restore effect runs again with the same error. At that point restoredErrorRef.current === error, so it returns early. That is what the guard is for.
    • The new dependency could only matter if restoredErrorRef were reset (by sendTyped) while the same create error was still on screen and unsentText then changed. A retry from the composer does go through sendTyped, then handleSend, reportHeld and ensureConversation. That reaches createFor, which calls setCreateError(undefined) synchronously in the same event, and React batches the two updates. So the next render has no error and no unsentText, and the box is not refilled with the retry. A suggestion-chip send does not reset the guard.
    • An empty-string unsentText wins over ?? and hits if (!text) return, so a host passing '' would suppress a restore. This cannot happen through ChatPane. handleSubmit trims the text and sends '' only for a file-only send, and in that case lastSubmittedRef is '' as well. The join step (filter(part.trim() !== '')) keeps every non-empty part that was submitted. Nit (no effect on correctness): the jsdoc could say that '' means "restore nothing".
  3. ChatPane passes unsentText only while conversationCreateError is set. RIGHT.
    • A not-sent error that is not from the create cannot pick up held text. While conversationCreateError is set, it is the error the composer receives (conversationCreateError ?? …). Otherwise unsentText is undefined and the old restore applies unchanged. useChatConversation also returns createError as undefined once an id exists.
    • A handoff seed is never restored. reportHeld reports a held message with targetAgentRoute as null, so heldFirstMessage?.content is undefined. The drop effect keeps the seed as before.
    • Should-fix (non-blocking, not disclosed in the PR): an empty-state suggestion chip clicked as the first send of a new conversation is held. If the create then fails, the chip's text now comes back into the composer. Before, nothing came back: handleSuggestionClick clears lastSubmittedRef, and the code comment still says "Only text the user TYPED here is restorable" (objectui#7253). The text that comes back is the message that was not sent, not a stale delivered prompt, which is the harm feat(spec,lint): declare the SDUI deep-link "navigate = run action" as a validatable nav runAction reference (#4848) #7253 guarded against. So the change is defensible, but the comment and the PR's "under the same rules as before" now overstate it. The fix is to reword the comment or exclude the chip case, in a follow-up or before the merge, at the seat's choice.
  4. The AI chat: a message sent from a conversation link before the conversation finishes loading may be dropped (seen in a test harness, unconfirmed) #33567 "does not reproduce" reading holds against the code it cites. RIGHT.
    • On /ai/build/conv-7 with the GET still open, the pane is …:pending (paneConversationId is undefined). So handleSend takes the apiMode && !conversationId path and stashes the message in the page-owned pendingFirstMessageRef, which outlives the remount. ensureConversation sees pendingKeyRef !== key and only records requestedKeyRef.
    • When the GET succeeds, the resolve's finally drops that request (no create), the pane remounts on conv-7, and the replay effect sends the message once on the next task.
    • The pin asserts exactly this: drawn once, sent once, 0 creates, box empty. The detached-textarea account of the fix(console): draw a new AI chat conversation's first message at once, and give its text back when the create fails #33561 harness fits findByRole resolving on the pending pane.
    • Open question, not the card's scenario: if that GET throws (5xx or network, not a 404, since a 404 goes through settlePending), the catch clears the id without settling, and finally drops requestedKeyRef. The held send then looks stranded: drawn, not sent, with no notice. This comes from reading the code only and was not measured. Escalated in ③.
  5. The pins are adequate. There is a unit pin in ChatbotEnhanced.sendError.test.tsx, plus rendered pins on both hosts through the AI chat: on a new conversation the user's first message is not drawn until POST /conversations answers, so the thread sits blank for that long #33420 harness: the box holds first part\n\nsecond part, nothing is sent, and the retry sends the joined text exactly once. The single-send rollback tests are the CONTROL. The PR reports red-first runs and three ablations; I did not re-run them.

② Semver level

  • Clause-②: yes (widening) appears line-initial in both the PR body and the changeset body, and matches the diff: one optional prop is added and nothing is removed or narrowed. Metadata-protocol: none is RIGHT, since the diff changes no authorable metadata.
  • Under AGENTS.md Post-Task Checklist step 3, a non-protocol widening ships patch. The changeset bumps @object-ui/plugin-chatbot (public, which publishes the new prop), @object-ui/app-shell (private, with the ChatPane change) and @object-ui/console (public, whose dist bundles app-shell), all at patch. That matches what the diff publishes. No BREAKING banner is owed. The Check Changeset run is success.

③ Boundary flags

Implemented-by: claude/project-thread-snu787
Reviewed-by: session_01FEkQ5oF8GgTHN2jBZoDwz8

VERDICT: PASS

@objectstack-fleet objectstack-fleet Bot removed the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 15, 2026
claude and others added 2 commits November 15, 2026 05:49
… it was sent

The restore comment and the prop doc now say that a held suggestion chip
comes back through unsentText too, and a unit pin holds it, with the
composer-only CONTROL that restores no chip text.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mV4rtksbPPvwm9w8L
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 07caf19ae032b71a67c6d2a5367183627ec600d7
Local-runs: none

Delta record on the round-1 record (PASS on d32d4df, comment 6889891363). Inputs: that record, the delta d32d4df..07caf19 (one commit, docs(plugin-chatbot): say a host-named unsentText is restored however it was sent, 2 files, +50/−11), the current PR body, and the check-runs on 07caf19. Code outside the delta (ChatbotEnhanced.tsx at 07caf19: handleSuggestionClick, handlePlanApprove, handleChangesConfirm, the plan-question answer chips) was read to judge it, not reviewed. At render the API head is 7725b79, a merge of main into the branch whose first parent is 07caf19. It is not reviewed here.

Check-runs on 07caf19 at render (56): 40 success, 15 skipped, 1 in progress, 0 failure. The one in progress is a second Check Changeset run that started at 06:24Z. The earlier Check Changeset run on this head is success. Green include Test UI (shards 1 to 10 and the aggregate), Live E2E UI, Build & E2E UI, Build UI Deps, Lint UI, all 8 Lint jobs, Type Check UI and all four Type Check jobs, Test Core, Dogfood Regression Gate, Governed Surface Queue Guard, and both PR-body guards runs. This verdict covers the contract. It does not replace the gates, which must be green on the head that merges.

① Derived judgments

  1. The delta moves no runtime line. RIGHT. In ChatbotEnhanced.tsx, only the unsentText jsdoc (4 lines replaced by 6) and the comment above const text = unsentText ?? lastSubmittedRef.current (8 lines replaced by 12) change. The expression, the if (!text) return, the empty-box check and the deps [error, unsentText] are byte-identical. The test file gets 2 header-comment lines and one new it. Round 1's judgments ① 1 to 5 therefore stand unchanged on this head.
  2. The reworded prop doc and restore comment now state the behaviour correctly. RIGHT, with one nit.
    • The prop doc says: read once per not-sent error, only into an empty box, restored whichever way it was sent, a held chip included, and that "the composer alone restores only typed text". Absent means "the text the composer last typed and submitted". Each part matches the effect: the restoredErrorRef guard, textarea.value.trim() === '', unsentText taking precedence with no check on how the message was sent, and lastSubmittedRef written only by handleSubmit (head L3043).
    • The comment keeps objectui#7253's reason (a stale ref refilled the box with an already-answered prompt). It now says the composer on its own knows only typed text. It says a host-named unsentText is restored too, and that a held chip's text after a failed create is the unsent message, not a stale one. That is the behaviour the seat accepted.
    • Nit (no effect on correctness; the claim is older than this PR, and the delta only adds the list): "cleared by every card-driven send (a chip, a plan or changes card)" is not quite true. handleSuggestionClick (L3116), handlePlanApprove (L3152) and handleChangesConfirm (L3188) clear the ref. The plan card's question-answer chips do not: they call onSendMessage(planAnswerMessage(q, opt)) inline (L4548) and leave lastSubmittedRef as it was. This was found by reading the code and was not measured. See ③.
  3. The new pin and its CONTROL test what they say. RIGHT.
    • The test clicks the empty-state chip, and onSendMessage is called with the chip text.
    • CONTROL: a not-sent 503 is passed with no unsentText, and the box stays ''. That pins the claim "the composer alone restores no chip text": a chip send that wrote its text into lastSubmittedRef would turn it red.
    • Then a fresh not-sent 503 is passed with unsentText={chip}, and the box becomes the chip text. The fresh error object is needed because the once-per-error guard would stop a second restore for the same error. A composer that ignored unsentText would turn this red, since the ref is ''.
    • Nit: the CONTROL does not type and send a prompt before the chip. So it pins "a chip does not write its own text", not the feat(spec,lint): declare the SDUI deep-link "navigate = run action" as a validatable nav runAction reference (#4848) #7253 guard itself, which is "a chip clears an earlier typed prompt". The test does not claim the latter. I did not re-run either half.
  4. The PR body now discloses the chip restore and no longer says "under the same rules as before". RIGHT.
    • The What-changes bullet now reads: "once per not-sent error and only into an empty box, as before. One rule differs: … a host-named unsentText is restored however it was sent, a held suggestion chip included."
    • A new Acceptance note, "A held suggestion chip now comes back on a failed create (accepted by the seat, patch round 1)", gives the mechanism and the feat(spec,lint): declare the SDUI deep-link "navigate = run action" as a validatable nav runAction reference (#4848) #7253 reasoning.
    • The Tests list adds the 07caf19 pin and its CONTROL, and the Verification section adds a patch-round-1 block that says no runtime line moved, which matches the diff.
    • The body's "a chip or card send clears lastSubmittedRef" carries the same small overclaim as the nit in item 2.

② Semver level

  • The delta adds no exported symbol and changes no type, signature or default. unsentText?: string is the same optional prop as at d32d4df. Clause-②: yes (widening) and Metadata-protocol: none are still line-initial in the PR body, and both still hold.
  • The changeset is not in the delta, so the patch bumps of @object-ui/plugin-chatbot, @object-ui/app-shell and @object-ui/console from round 1 stand, and they are right for a non-protocol widening (AGENTS.md Post-Task Checklist step 3). No BREAKING banner is owed.

③ Boundary flags

  • Round-1 should-fix S1 (chip text restored after a failed create): CLOSED. The comment, the prop doc and the PR body now match the behaviour the seat accepted, and the optional pin is in (① 2 to 4).
  • Round-1 nit on '' (a host passing an empty unsentText suppresses the restore, and the jsdoc could say so): still open, and still a nit. It cannot happen through ChatPane.
  • Round-1 open question (a deep-link GET that fails with a non-404 error strands a held send): the dev has now measured it on d32d4df, and the PR body has an Acceptance note for it. The held bubble hangs with no send, no create and no notice, and the cause is the resolve's catch and finally in useChatConversation.ts. The delta does not touch that path. It is still for the seat to file as its own card.
  • Round-1 acceptance note (a typed but unsent draft is lost on the pane's id remount): unchanged and still for the seat to file.
  • Card AI chat: a message sent from a conversation link before the conversation finishes loading may be dropped (seen in a test harness, unconfirmed) #33567: unchanged. Refs #33567 is right, and the seat should still post the reading on AI chat: a message sent from a conversation link before the conversation finishes loading may be dropped (seen in a test harness, unconfirmed) #33567 and close it.
  • New, for the seat to measure before filing (older than this PR, outside the diff): plan-question answer chips (L4548) do not clear lastSubmittedRef. So if a user types a prompt that is delivered and answered, then clicks an answer chip, and that send is refused as not-sent, the composer may refill with the earlier prompt. That is the harm objectui#7253 guarded against. This comes from reading the code only. It does not block this PR.
  • CI: one Check Changeset re-run is in progress on 07caf19, with 0 failures. The merge waits for the gates on the head that merges (7725b79 at render).

Implemented-by: claude/project-thread-snu787
Reviewed-by: session_01FEkQ5oF8GgTHN2jBZoDwz8

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8

席位核对

Verdict: ACCEPT · head 7725b791 · 2026-11-15T06:43Z

  1. Shape. Draft → main, Fixes #33562, Refs #33567. 5 files, +170/−8:

    All of it is on the claimed surface.

  2. Premise. AI chat: two messages sent while a new conversation is being created, then a failed create, give back only the second message (the first is dropped) #33562, measured on d95ddebc: two sends during one held create, then a failed create, give back only the second part. Fixed: the box gets first\n\nsecond, and a retry sends the joined text once. Red first: 3 red on base. Ablations: 2 red and 3 red.

  3. Declarations. Clause-②: yes (widening) on @object-ui/plugin-chatbot (ChatbotEnhancedProps.unsentText?), Metadata-protocol: none, patch. Right.

    • Contract record PASS 6889891363 on d32d4df0 (TIER_DEFAULT).
    • Delta record PASS 6890359236 on 07caf19a: the delta is comments plus one unit pin, with no runtime line changed.
  4. Accepted deviation (round-1 S1). A suggestion chip held for a create that then fails now comes back into the composer, because the host names it as unsentText. That text is the message that was not sent, not a stale delivered prompt (the harm objectui#7253 guarded against). The comment, the prop doc and the PR body now say so, and a unit pin with a CONTROL covers it.

  5. Out of scope, filed (finding, for triage; this seat takes P1/P2 only since the maintainer's ruling of 2026-11-15T05:05Z):

  6. Gates on head 7725b791 (after the base sync below): All 52 check runs are success (39) or skipped (13). The dev's local --ran is 37/37, with 0 NOT-MEASURED.

  7. K. 44 first-parent commits since the base, which is 15 or more, so the base was synced through the relay (07caf19a → 7725b791) and CI re-ran green on the synced head. Path face: not governed; 178 changed lines.

  8. Authority. Landing under the maintainer's standing authorisation 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 06:44
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 030ce02 Nov 15, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-snu787 branch November 15, 2026 07:19
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…known, and gives back a send held when a linked conversation fails to load (objectstack-ai#33727)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XLXYgtfyzgVxE3YRd4MNb3s)_

Fixes objectstack-ai#33674
Fixes objectstack-ai#33685

Clause-②: no
Metadata-protocol: none

Seat `domain:ui#2` · os-project-manager · card thread
`session_01FEkQ5peXUXXQ6HU4H89s6J` · claims 6890508556 and 6890872696 ·
one PR for both cards, two commits (one per card), as the seat ruled.

## 维护者速读

- 改了什么:AI 对话(`/ai` 全页、控制台聊天停靠栏、Studio copilot)两处输入丢失。①
会话还没确定时(打开会话链接正在加载,或新会话正在创建)在输入框里打了但没发送的文字,会话确定后不再被清空,光标停在末尾、焦点保留,不会自动发送;切换到另一个会话时草稿不跟过去(与今天一致)。②
打开会话链接后、会话还在加载时发出的消息,如果加载失败(5xx
或断网),不再永远转圈:消息退回输入框(连发两条时两条都退回,先后不变)并显示"未发送"提示,不发送任何内容;再发一次会重新加载该会话并只发一次。
- 为什么改:① 聊天面板以会话 id 为 key,id 确定时整块重建,输入框里的文字随旧面板一起丢弃(objectstack-ai#33673 开发者实测)。②
会话加载失败的 catch 只清空 id,既不让发送去创建会话,也不通知宿主,暂存的消息就一直挂着(objectstack-ai#33673 契约复审发现,开发者实测)。
- 风险与回滚:只改前端私有包 `@object-ui/app-shell` 的两个文件(`AiChatPage.tsx` 的
`ChatPane`、`useChatConversation.ts` 的加载失败分支),不改 `ChatbotEnhanced`
的属性、服务端、spec;面板 key 保持不变。回滚即还原本 PR(两个提交可分别还原)。
- 先看:`ui/packages/app-shell/src/hooks/useChatConversation.ts`(resolve 的
`catch` 与 `ensureConversation`
的重试分支)、`ui/packages/app-shell/src/console/ai/AiChatPage.tsx`(`useComposerDraftHandoff`
与 `ChatPane` 的
`requestedConversationId`)、`ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.firstMessageDrawnAtOnce-33420.test.tsx`(新增的钉子)。
- 两分钟验证:pnpm dev,打开
`/ai/build`,发一条消息后在会话创建期间输入第二段文字不发送:创建完成后第二段仍在输入框里。再在开发者工具把 `GET
/conversations/ID` 设为 503,打开 `/ai/build/ID`
时立刻发一条消息:消息退回输入框并出现未发送提示;取消拦截后再发,只发出一次。
- 需要你做的:无,席位落地。

## What changes

### objectstack-ai#33674: a draft typed before the pane knows its conversation
survives the id remount (commit 0d69e25)

`ChatPane` is keyed on `${chatApi}:${conversationId ?? 'pending'}` in
all three hosts, and the composer's text lives inside the pane, so the
remount from `…:pending` to the real id dropped text typed but not sent:
on a deep link whose conversation GET answers, and on a new conversation
whose create answers while a second message is being typed.

- **The key stays.** Everything else in the pane (the chat runtime, its
messages, the held first message's bookkeeping) belongs to one
conversation and must reset with it; only the composer's text is
carried.
- **New hook `useComposerDraftHandoff` (in `AiChatPage.tsx`, called by
`ChatPane`).** A pending pane (no conversation id) reads its composer
box (`textarea[name="message"]` inside the pane) as it unmounts and
leaves the text, whether the box had focus, the chat endpoint and the
conversation the host was asking for when the text was last typed. The
replacing pane reads that in its mount layout effect, in the same
commit, and puts the text into its empty box with the cursor at the end,
focusing it when the old box had focus. Nothing is sent. A microtask
drops a hand-off no pane took, so it never reaches a later, unrelated
mount. The hand-off is keyed by the host's page-owned
`pendingFirstMessageRef`, the one object a host keeps across the
remount, so two hosts never trade drafts.
- **What is carried, and what is not.** Only from a pending pane (a pane
that already had a conversation hands nothing on); only to a pane with
an id on the same endpoint; and only while the host still asks for the
conversation it asked for when the text was typed. That last guard is
the new optional `ChatPane` prop `requestedConversationId`, which the
`/ai` page passes (`urlConversationId ?? legacyConversationId`, the same
value it gives `useChatConversation` as `activeId`). The dock and the
Studio copilot pass nothing, which matches their `activeId: undefined`,
so neither host file changes. Decision for the order's third CONTROL:
opening ANOTHER conversation leaves a draft behind, both from a new chat
and from an open conversation (today's behaviour), and a pin holds it.
- `ChatPane` passes the hook's recorder to `ChatbotEnhanced`'s existing
`onInputChange`. No new `ChatbotEnhanced` prop, so
`@object-ui/plugin-chatbot` is untouched: `Clause-②: no`.

### objectstack-ai#33685: a send held while a linked conversation loads is given back
when the load fails (commit 8702038)

On a deep link (`/ai/build/conv-7`, and the dock resuming a cached
conversation the same way), a send made while `GET
/conversations/conv-7` is pending is held by `useDeferredFirstSend` and
recorded by `ensureConversation`. When that GET failed with a 5xx or a
network error, the resolve's `catch` cleared the id without settling the
surface and its `finally` dropped the recorded request, so the held
message hung with its thinking dots, nothing was sent and no notice
showed.

- **The `catch` now reports to the recorded send.** When a send was
recorded during the failed run, the hook sets `createError` to a
not-sent error (the GET's status when it had one). That is the existing
objectstack-ai#33420 / objectstack-ai#33562 path: `useDeferredFirstSend` drops the held message and
`ChatPane` hands its text (joined parts included) to `ChatbotEnhanced`
as `unsentText`, so the box gets the text back with the not-sent notice.
Nothing is sent and no create is made.
- **A retry works.** The `catch` marks the key as failed. The next
`ensureConversation` for that key, finding nothing resolving, records
the request, clears the old `createError` and runs the resolve again (a
`resolveAttempt` counter in the resolve effect's deps). If the GET
answers, the held message is sent once into `conv-7`, as objectstack-ai#33567's pin
shows for a GET that answers the first time.
- `fetchConversation`'s thrown error now carries `status` (the notice
reads it); its 404 / 403 answer (`null`) is unchanged.
- **The 404 path keeps today's behaviour**, measured and pinned: a held
send on a deep link whose GET answers 404 settles on "nothing to
resume", creates a new conversation and is sent once into it, with no
notice.
- The same-conversation guard in the `catch` (a failed re-read of the
conversation already held keeps it) is untouched.

### Changesets

`.changeset/33674-ai-chat-draft-survives-remount.md` and
`.changeset/33685-ai-chat-failed-load-gives-held-send-back.md`:
`@object-ui/app-shell` and `@object-ui/console` patch each (app-shell is
private and the console's `dist` ships it), both declaration lines
`Clause-②: no` / `Metadata-protocol: none`.

## Tests

All pins are in the objectstack-ai#33420 harness,
`AiChatPage.firstMessageDrawnAtOnce-33420.test.tsx`: the REAL
`AiChatPage` / `ChatDockConversation`, `ChatPane`,
`useChatConversation`, `useObjectChat` transport and `ChatbotEnhanced`,
driven through the composer, with `fetch` holding `GET
/conversations/:id` and `POST /conversations` open until the test
answers or fails them.

**objectstack-ai#33674** (top-level describes `… a draft typed before the pane knows
its conversation survives the remount`, `… switching to another
conversation does not carry a draft`, `useComposerDraftHandoff — which
remount carries the composer text`):

- full page and dock, path (a): text typed while the conversation GET is
held is in the NEW box (the old one is detached) when it answers: same
text, cursor at the end, focused; nothing sent, no create. (The dock's
link is the cached conversation it resumes with the same GET.)
- full page and dock, path (b): first message sent, a second typed while
the create is held; when it answers, the first is sent once and drawn
once, the second is in the new box, not sent, not drawn.
- CONTROL, full page and dock: a draft in an open conversation stays in
the same box, unsent.
- CONTROL, full page: a draft typed in a new chat, then another
conversation opened (navigate to `/ai/build/conv-9`, its GET answers):
the box is empty. Likewise from an open conversation to another.
- hook unit pins: a pending pane hands its text on; a pane that already
had a conversation hands nothing on; a pane on another chat endpoint
takes nothing; a hand-off no pane took in the same commit is dropped.
- CONTROL for submitted messages: the existing objectstack-ai#33420 / objectstack-ai#33562 / objectstack-ai#33567
pins in the same file stay green (held and sent once).

**objectstack-ai#33685** (top-level describe `… a send held while the conversation
loads, when the load fails`, on the full page and on the dock):

- GET 503 and GET network error: the bubble goes, the box holds the
message, the not-sent notice shows, nothing sent, no create.
- two sends during the held GET, then a 503: the box holds `first
part\n\nsecond part`.
- retry: after the 503, sending what the box holds draws it, clears the
notice, re-runs the GET; when it answers the message is sent once into
`conv-7`, no create.
- CONTROL: a GET that answers sends the held message once (the dock's
leg is new; the page's leg is also objectstack-ai#33567's pin).
- CONTROL: a 404 creates a new conversation and sends the held message
once into it, no notice.

The harness's held GET now also takes a network failure (`Held.fail`).

<details><summary>Red first, on origin/main 5604aeb (which carries
objectstack-ai#33673)</summary>

- objectstack-ai#33674: sources at 5604aeb, harness at commit 0d69e25: 8 failed / 14
passed. The four path pins (page + dock, paths a and b) fail `expected
'' to be 'add a due date field'` / `expected '' to be 'and add a due
date'`, the box comes back empty; the four hook unit pins fail
`useComposerDraftHandoff is not a function` (the hook does not exist on
base). Every CONTROL is green on base.
- objectstack-ai#33685: `useChatConversation.ts` at 5604aeb, everything else at
0d69e25, harness at 8702038: 8 failed / 26 passed: GET 503, GET
network, joined, retry, on the page and the dock (the box stays empty,
the bubble stays drawn). Both CONTROLs (a GET that answers; the 404
path) are green on base, on both hosts.

</details>

<details><summary>Ablations, through scripts/ablation-replace.mjs (ui
vitest resolves app-shell from src, no build), each restored with the
blob equal to HEAD and git diff HEAD empty</summary>

Run over the whole harness file (34 tests):

- A1, the restore write removed (`box.value = handoff.text;` to `void
handoff.text;`): 5 failed / 29 passed, the four path pins and the hook
pin "a pending pane hands its text to the pane that gets the id".
- A2, the requested-conversation guard made always true: 1 failed, "a
draft typed in a new conversation stays behind when the user opens
another one".
- A3, the pending-only guard (`if (conversationId) return;`) made never
true: 1 failed, "a pane that already had a conversation hands nothing
on".
- A4, the microtask expiry removed: 1 failed, "a hand-off no pane took
in the same commit is dropped".
- A5, the endpoint guard made always true: 1 failed, "a pane on another
chat endpoint takes nothing".
- B1, the `catch`'s report skipped (an early return after marking the
key failed): 8 failed / 26 passed, the eight objectstack-ai#33685 pins. A first
attempt at this leg was refused by the tool before running (its
replacement still contained the anchor, so the anchor count did not
drop) and measured nothing; it was redone with a distinct replacement.
- B2, the retry branch in `ensureConversation` made never true: 2
failed, the two retry pins (page and dock).

</details>

## Acceptance notes

- **Reachability.** Every pin drives the rendered page through the
composer's real input events (`change`, `submit`) and real request
timing (held then answered or failed `fetch`); the hand-off is read from
the DOM box the next pane renders, not from the hook.
- **The Studio copilot** renders the same `ChatPane` with no
`requestedConversationId` (its `activeId` is undefined), so it takes
both fixes unchanged; it has no rendered pin of its own here, the order
names the page and the dock.
- **A draft typed in a new chat before switching agent** (ask to build)
is not carried: the endpoint differs. Unchanged from today.
- **The dock moving between apps:** a draft typed in the dock's pending
pane of app A, then the dock moving to app B, stays in the same pane
while B resolves (same key, no remount, as today) and is now kept when
B's conversation lands. A draft typed in an open conversation of app A
is not carried. Not pinned beyond the hook unit pins.
- **Out of scope, unchanged:** the latency of `POST /conversations`,
objectstack-ai#33561's first-message drawing, server, spec and cloud.
- **Three commits, not two.** The seat asked for one commit per card. A
third commit, 8500bab, changes four lines of the test harness (the
navigate helper sets its module variable from an effect instead of
during render; `react-hooks/globals` refused the first form). The branch
is the thread's harness branch, so it is not rewritten (AGENTS.md
multi-agent §3, criterion ①).

## Verification

<details><summary>Local gates, type-check, lint and suites (head
8500bab, base origin/main 5604aeb)</summary>

- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derives 38 families for this diff (tree
8500bab; the same list as at 8702038). All 38 exit 0 on 8500bab after
the `@object-ui/app-shell^...` closure build plus a rebuild of the ui
packages the rebase moved. `pnpm --dir ui exec vitest run scripts/`
first answered exit 99 (the lock's queue budget ran out behind the chat
suites, nothing measured) and was re-run alone under the lock with
`--maxWorkers=2`: 171 files passed, 2 skipped, VERDICT command-exit 0.
`--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.
- `pnpm --filter @object-ui/app-shell run type-check`: exit 0.
- ESLint (`--no-inline-config`) on `AiChatPage.tsx`,
`useChatConversation.ts` and the harness: exit 0, 0 errors; one more
warning than on base, `react-refresh/only-export-components` for the new
exported hook (the file already exports `useDeferredFirstSend` the same
way).
- `pnpm check:new-line-citations` (from `ui/`): 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/` and
`packages/plugin-chatbot/`: 627 files, 4848 tests passed (VERDICT
command-exit 0, head 8500bab).
- `origin/main` moved to ee627c6 while the gates ran; none of those
commits touches `ui/packages/app-shell/` or
`ui/packages/plugin-chatbot/`.
- 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_01FEkQ5peXUXXQ6HU4H89s6J

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5peXUXXQ6HU4H89s6J)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
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

Development

Successfully merging this pull request may close these issues.

AI chat: two messages sent while a new conversation is being created, then a failed create, give back only the second message (the first is dropped)

1 participant