Skip to content

feat(chat-core): mount the shared composer root and atoms in ChatEmbed - #20102

Merged
chenmingwei23 merged 1 commit into
mainfrom
feat/chat-core-pb-embed-composer
Oct 14, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
feat/chat-core-pb-embed-composer

Conversation

@buluoray

@buluoray buluoray commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: ChatEmbed's composer is the shared chat-core composer (the Composer root with Editor and Send atoms), so composer fixes reach the app embed, and a message typed while the agent works is shown as one that will wait in the queue.

website/src/app-sdk/ChatEmbed.tsx drew its own <textarea> and Send button. The main chat and the panes build their composer on chat-core/composer/ (Composer.tsx), so a composer change made there never reached the embed, and the embed was patched separately (#19994 lists the open PRs doing that). The embed's button also looked the same whether the message would run now or wait behind a running turn; the main chat shows Queue message for the second case.

Why it matters

ChatEmbed is the chat every app (Spec Builder, Ops Mission Control, third-party apps) mounts. While it keeps a private composer, each composer behaviour has to be re-implemented and re-reviewed for it, and the next phases of #19994 (Stop in the Send atom, attachments as a shared Attach atom) have no shared home to land in. It also has to stay store-free and keep every request inside the host app's allowedApiPaths, which is why it could not simply mount ChatInput.

Not a goal

What changed (motivation → approach → change)

  • Atoms, store-free — website/src/chat-core/composer/atoms.tsx (new): ComposerEditor (the textarea; text and writer come from the root) and ComposerSend with two states decided by composerSendState: idle, and queue (a turn runs and there is something to send). The queue state carries a visible Queue label beside its icon, in the warn colour, with the Queue message accessible name and the "Run after the current work finishes" tooltip — the existing catalog keys the main chat's busy-send menu uses, so no new strings. It uses SendBtn and imports nothing from store/. Send's stop state and its attachment inputs are not shipped ahead of their writers (feat(app-sdk): give ChatEmbed a stop button for a running turn #19898, P-c); each lands as one prop when that PR rebases.
  • Root — Composer.tsx: useComposerEditor() gives an atom the editor text (subscribing to a draft store when the host passed one) and onChange. The root gains its first capabilities writer, as the RFC planned: { voice: false } keeps the Voice atom unmounted. The embed must turn it off: the Voice atom reads STT config through the dashboard api client (outside the app's scoped api, so outside allowedApiPaths) and its setup modal calls useNavigate, which throws in an app with no router.
  • ChatEmbed — mounts <Composer slotKey value={draft} onChange={setDraft} capabilities={{ voice: false }}> around ComposerEditor + ComposerSend. The draft still lives in useComposerDraft (auto-grow, IME-safe Enter, follow-up picks), so the send path, the receipt handling, draft restore on a failed send and the error/notice rows from feat(chat-core): route ChatEmbed, SideChat and app sends through the transport wire #20018 are unchanged. The send still goes sendTurn → appApiSendWire(useAppApi()).
  • Docs: docs/app-kit/api-reference.md (Queue message label; no voice input in the embed), RFC progress row + the capabilities note.

How the other open embed PRs land on this

PR Effect
#19881 optimistic row Rebases cleanly: it edits the message list and send(), not the composer markup.
#19898 Stop button One conflict in the composer row. Its showStop ? <StopControls/> : <button> branch wraps ComposerSend instead (or adds a stop prop to it, the atom's third state); its placeholder edit moves onto ComposerEditor. useEmbedStop, StopControls and the backend stop_state stay as they are.
#19917 attachments One conflict in the composer row. Its onPaste/onDragOver/onDrop pass through ComposerEditor (it forwards every textarea prop) and its enable rule (uploading, staged files count as content) becomes two ComposerSend props it adds. P-c then turns it into the Attach atom.
#19899 stalled poll Rebases cleanly: it edits the query and a notice above the composer.
#19901 queue stack (merged) Unaffected; the stack still mounts above the composer.

Backwards compatibility

Compatible: ChatEmbed's props and its "Chat message" / "Send message" accessible names are unchanged; Composer only gains an optional prop, and every existing host passes none, so its Voice atom still mounts.

Removes nothing: the embed never had voice; the textarea and button are replaced by atoms that render the same element types with the same names, and the only new state is the Queue label while a turn runs.

Tests

  • website/src/test/ChatEmbed.composerStoreFree.test.tsx (new)
    • static: walks the runtime import graph of chat-core/composer/Composer.tsx and atoms.tsx and asserts no file under src/store/ and no Redux package is reachable (a failure prints the chain); asserts ChatEmbed mounts the root and both atoms and has no <textarea> of its own.
    • runtime: renders the embed with only a QueryClientProvider (no Redux Provider, no router), checks the atoms render with no mic, a send goes through the app's scoped post('/api/chat…'), and a running turn turns Send into Queue.
  • website/src/chat-core/composer/Composer.test.tsx: voice: false unmounts the Voice atom (ChatInput gets no mic) and the root then mounts without a router; Editor/Send idle → queue, with the visible Queue word and tooltip asserted; atoms read a draft store; an atom outside a root throws; composerSendState table.
  • website/src/test/ChatEmbed.queue.test.tsx: the busy send is pressed as Queue message.

Mutations (each run alone, restored with git checkout HEAD -- <file>, clean tree between):

Mutation Red
ChatEmbed.tsx reverted to main the embed mounts the chat-core composer root and its atoms, draws the Editor and Send atoms…, both …turns Send into Queue…, shows a send made while busy…
embed passes {} (voice on) draws the Editor and Send atoms and offers no microphone, sends through the app scoped api (useNavigate() may be used only in the context of a <Router>)
drop the capabilities.voice === false gate in VoiceAtom voice: false keeps the Voice atom unmounted…, voice: false needs no router… and the atom tests
atoms.tsx imports components/chat-input/busySend nothing chat-core/composer/atoms.tsx imports reaches the Redux store (prints atoms.tsx -> busySend.tsx -> store/chatSlice.ts)
composerSendState returns idle for running+content the three queue tests and the queue table row
drop the visible Queue span a running turn turns Send into Queue once there is text, with the word shown

Gate: npx tsc --noEmit -p tsconfig.app.json clean; eslint clean on touched files; jscpd 0 clones; vitest 168 related files / 2054 tests pass. scripts/local-gate.py backend: 80 failures, 79 of which also fail on a clean origin/main worktree in this sandbox (subprocess timeouts, git init blocked); this diff has no backend code.

Manual verification

Real ChatEmbed under the real AppApiProvider, no Redux Provider, no router, fake slot data (website/capture/chat-embed-composer.html, website/scripts/capture-chat-embed-composer.mjs), base vs this branch, dark and light. The script asserts the button's accessible name per scene and that a refused send hands the text back; it fails on base for the queue scene (no Queue state there) and passes here, with no page errors.

Layout of the Queue state measured in the page after transitions settle (both themes): 81×36 px, one line, no overflow, warn background with black text, inside the 526 px composer row.

Not exercised: a real gateway, or an app hosted in an iframe.

Screenshots / video

Idle — unchanged (base, then this branch):

idle before
idle after

A turn is running and a message is typed — base keeps the plain send; this branch shows a Queue button:

queue before
queue after

Light theme, and a refused send (error row + draft restored, unchanged)

queue light after
refused before
refused after

Related Issues

Refs #19994 (phase P-b). Builds on #20018 (P-a).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f77a5683ef35bc160ef6275eceebac208c08a90d — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (8 items) — 8 justified

Intent: let app embeds use the same chat composer as the dashboard, so composer fixes reach apps too, and show when a message typed during a running turn will wait in the queue. This is an ADDITION.

  1. The app embed's text box and Send button are now the shared chat-core Composer root with its Editor and Send atoms — justified
  2. While a turn runs and text is typed, Send turns into a warn-coloured "Queue" button with the "Queue message" name and tooltip — justified
  3. The idle Send button now draws through the shared SendBtn styling — justified
  4. Composer has a new optional capabilities prop, and { voice: false } from ChatEmbed is its one writer — justified
  5. A new useComposerEditor hook gives an atom the editor text, used by both new atoms — justified
  6. The app-kit docs mention the Queue button and the missing voice input, and the RFC gets a P3-f row — justified
  7. A static import-graph test checks that the composer modules never reach the Redux store — justified
  8. A capture page and a Playwright script screenshot the embed composer — justified

[FIRST-PRINCIPLES-REVIEWED] f77a568

Description read

[DESCRIPTION-READ] ed01a6701b93258b4224383d4b3ac2d8618997ed29f36d9322f7e467fea4ebf1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f77a5683ef35bc160ef6275eceebac208c08a90d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that a send pressed during a running turn really waits in the server queue, so the new "Queue message" label matches what happens to the message.

[DESIGN-REVIEWED] f77a568

Description read

[DESCRIPTION-READ] cf84798febe3a6dba17f0cc14bb8d3be4d94d69ce564fad187e43ccd884b75a7

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

UX-level review of f77a5683ef35bc160ef6275eceebac208c08a90d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The blind reader only guessed what the new Queue button does. They read its arrow-into-a-line icon as "upload", and the yellow fill as a warning.

Watch

  • The Queue button was only guessed at. In ComposerSend, queue ? <ArrowUpFromLine/> plus bg-warn draws a yellow button with an arrow pointing into a line. The blind reader worked out the right meaning but rated it "a guess", and said "the icon looks more like 'upload' than 'send'" and "the yellow colour feels a bit like a warning" (shot-04). In this chat about upload limits, the main button now looks like an upload action. Users see this state on every send typed while the agent works, so it costs a moment's hesitation each time. Smallest fix: keep the ArrowUp glyph (or use a clock or list icon) next to the "Queue" word.
  • The light-theme Queue button is hard to read. The blind reader said "the mustard button is hard to read in light mode" (shot-05). The cause is bg-warn text-warn-fg on the light theme. Users on the light theme hit this every time they queue a message. Check that warn/warn-fg meets 4.5:1 contrast on light, or use a quieter outlined style for the queue state.

Suggestions

  • In ComposerSend's queue state, change the visible word from components.chatInput.queue ("Queue") to "Send after" or "Queue message". The button would then name the outcome, so it doesn't hinge on the tooltip.

[UX-REVIEWED] f77a568

Description read

[DESCRIPTION-READ] cb8a91ee260fbd61c7db2fa0dd5715d4a3e2caa928c9ada4c2305c9aa06cf6ba

That sha256 names everything this verdict read: the PR description, plus the 10 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed f77a5683ef35bc160ef6275eceebac208c08a90d — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f77a568

Verdict parsed from the review's SHA-scoped output markers for commit f77a5683ef35bc160ef6275eceebac208c08a90d.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f77a5683ef35bc160ef6275eceebac208c08a90d: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f77a5683ef35bc160ef6275eceebac208c08a90d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f77a568

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f77a5683ef35bc160ef6275eceebac208c08a90d: <one-sentence reason>

ChatEmbed drew its own textarea and Send button, so composer fixes made
in chat-core never reached it. It now mounts the chat-core Composer
root with the first store-free Editor and Send atoms
(chat-core/composer/atoms.tsx). Send draws three states: idle, queue
(a turn is running and there is text, matching the main chat's Queue
message control) and a host-supplied stop control.

The root gains its first capabilities writer: the embed passes
{ voice: false }, because the Voice atom reads STT config through the
dashboard api client, which would bypass the host app's
allowedApiPaths, and its setup modal needs the dashboard router.

A static import-graph test pins the composer modules as store-free,
and a runtime test renders, queues and sends from the embed with no
Redux Provider and no router, through the app's scoped api.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 14, 2026
@buluoray
buluoray force-pushed the feat/chat-core-pb-embed-composer branch from f438e13 to f77a568 Compare October 14, 2026 04:49
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19994]:

Dispositions for the findings on f438e13, fixed in f77a568:

  • First Principles (CONCERNS) — stop, disabled, hasExtraContent had no writer. Fixed. All three props and the stop state are removed from ComposerSend; composerSendState now has two states, idle and queue. feat(app-sdk): give ChatEmbed a stop button for a running turn #19898 (stop) and P-c / feat(app-sdk): attach files in the chat embed composer #19917 (attachments) add them as props when they rebase, with their own writer in the same diff. The PR body's rebase table says so.
  • UX (BLOCK) — the Queue state was an icon and colour only. Fixed. In the queue state the button now shows the word Queue beside its icon, keeps the Queue message accessible name, and its tooltip is "Run after the current work finishes". Both strings are existing catalog keys (the main chat's busy-send menu uses them), so all 12 locales already carry them. Test: a running turn turns Send into Queue once there is text, with the word shown (goes red when the visible label is removed). After-screenshots in the description are re-shot from f77a568.
  • UX watch — an empty editor during a turn gives no cue. Not changed: with nothing typed there is nothing to queue, and the button is disabled; the header already says "streaming" and the placeholder says the agent is working.
  • Design (PASS) — confirm a POST during a running turn really queues. It does: the existing ChatEmbed.queue.test.tsx case shows a send made while busy once the follow-up read returns it posts during running: true, gets {queued: true}, and the queue card renders from the next read; the server side is the unchanged POST /api/chat busy path.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 14, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19994]:

Dispositions for the UX CONCERNS on f77a568 (advisory, no push: a push restarts every lane, and none of the three is a defect in code this PR adds):

  • Queue icon reads as "upload". Rebutted. ArrowUpFromLine is the glyph the dashboard composer already draws for its queue send (components/chat-input/busySend.tsx, components/BusySendButton.tsx). A different glyph here would make the same action look different in the embed than in the main chat, which is the divergence this phase exists to remove. The word "Queue" now sits beside it, which is what the previous round asked for.
  • Light-theme Queue button hard to read. Measured, does not hold. Computed styles in the capture page after transitions settle: light bg-warn rgb(163, 138, 0) with text-warn-fg rgb(0, 0, 0) is 6.19:1; dark rgb(224, 185, 77) on black is 11.22:1. Both are above 4.5:1. The colours are the theme tokens the main chat's queue button uses.
  • Suggestion: say "Queue message" or "Send after" instead of "Queue". Not taken. The visible word reuses the existing components.chatInput.queue key, the accessible name is already "Queue message", and the tooltip carries "Run after the current work finishes". The previous round's block was the absence of any word; a longer label would widen the button in a 560 px embed for a point the tooltip and name already make.

CI on this head after the one allowed re-run of the three infrastructure reds (Publish readiness signal and Sensitive Change Review: "API rate limit exceeded for installation"; Dependency License Gate: "Dependency review is not supported"): 88 success, 10 skipped, 0 failure. PR Readiness is pending only on "pull request is a draft".

@buluoray
buluoray marked this pull request as ready for review October 14, 2026 06:31
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners October 14, 2026 06:31
@buluoray
buluoray requested a review from mbriones98 October 14, 2026 06:31
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 14, 2026
@chenmingwei23
chenmingwei23 merged commit 74318a1 into main Oct 14, 2026
103 of 106 checks passed
@chenmingwei23
chenmingwei23 deleted the feat/chat-core-pb-embed-composer branch October 14, 2026 07:58
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 14, 2026
buluoray added a commit that referenced this pull request Oct 14, 2026
Route ChatInput and ChatEmbed file selection through one store-free
Attach atom. Keep real host staging writers and leave dashboard draft
persistence, mentions, cancellation and chrome in their current hosts.

Move embed staging, file gestures and upload lifecycle into chat-core;
retain only permission checks and scoped upload transport at the SDK
edge. Keep existing send recovery and host onSend metadata contracts.

Refs #19994 (P-c)

Dependency review draft only: based on temporary integration commit
1994c94, which preserves pinned #20102
and #19917. This commit does not claim their implementation. Rebuild on
then-current main after those prerequisites merge; no auto-merge.

Validation: 94 targeted tests pass with shuffled seed 19994; tsc passes.
Five real-component fake-data captures rechecked at desktop and 390px.
buluoray added a commit that referenced this pull request Oct 15, 2026
Route ChatInput and ChatEmbed file selection through one store-free
Attach atom. Keep real host staging writers and leave dashboard draft
persistence, mentions, cancellation and chrome in their current hosts.

Move embed staging, file gestures and upload lifecycle into chat-core;
retain only permission checks and scoped upload transport at the SDK
edge. Keep existing send recovery and host onSend metadata contracts.

Refs #19994 (P-c)

Dependency review draft only: based on temporary integration commit
1994c94, which preserves pinned #20102
and #19917. This commit does not claim their implementation. Rebuild on
then-current main after those prerequisites merge; no auto-merge.

Validation: 94 targeted tests pass with shuffled seed 19994; tsc passes.
Five real-component fake-data captures rechecked at desktop and 390px.
buluoray added a commit that referenced this pull request Oct 15, 2026
* refactor(chat-core): share attachment picker and staging behavior

Route ChatInput and ChatEmbed file selection through one store-free
Attach atom. Keep real host staging writers and leave dashboard draft
persistence, mentions, cancellation and chrome in their current hosts.

Move embed staging, file gestures and upload lifecycle into chat-core;
retain only permission checks and scoped upload transport at the SDK
edge. Keep existing send recovery and host onSend metadata contracts.

Refs #19994 (P-c)

Dependency review draft only: based on temporary integration commit
1994c94, which preserves pinned #20102
and #19917. This commit does not claim their implementation. Rebuild on
then-current main after those prerequisites merge; no auto-merge.

Validation: 94 targeted tests pass with shuffled seed 19994; tsc passes.
Five real-component fake-data captures rechecked at desktop and 390px.

* refactor(chat-core): share only the Attach picker; keep embed upload state in the SDK

Per the owner's scope choice on #20178, the embed's staging, upload holds,
cancellation and failed-send recovery return to useEmbedAttachments
unchanged from #19917. Sharing that lifecycle stays open under #19994.

Refs #19994 (P-c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants