Repository navigation
feat(app-sdk): collapse long pastes in ChatEmbed like the dashboard chat - #21100
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Before merge, check that a send with files and no paste produces the same wire text as before, now that it runs as a [DESIGN-REVIEWED] ed13046 Description read[DESCRIPTION-READ] 6c2a7c0dd3b38e9d7bba2094fffbcd052e1af0330e474a00a8e8b71617646c9e 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: in every embed, Cmd/Ctrl+Z now runs the composer's own undo history instead of the browser's, even when the draft has no chip. What this change shipsInventory (10 items) — 10 justifiedIntent: an app user who pastes a long log into an embedded chat gets the main chat's collapsed chip, and the same wire shape on send, instead of a flooded composer. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] ed13046 Description read[DESCRIPTION-READ] c63f06b119e13caebbbf1d3b67f2e6bc0755d4839191e81339c1b9d8bd950172 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS In Spec Builder, the user's sent paste starts as a folded chip and then opens into the full 40 lines when the server row arrives. The blind reader found this inconsistent. Watch
[UX-REVIEWED] ed13046 Description read[DESCRIPTION-READ] 845b300bdfdacfbf08125dcd190b9184920b006375dfa9aa353967fe70b5fe98 That sha256 names everything this verdict read: the PR description, plus the 12 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsFINDING -- docs/app-kit/api-reference.md:376 -- False positive or not applicable? A repository writer can comment: |
|
UX review on b30ac35, both watch items:
|
b30ac35 to
3ee1374
Compare
|
UX review on 3ee1374:
|
3ee1374 to
0a07aea
Compare
|
UX review on 0a07aea, the three watch items:
|
0a07aea to
b041c43
Compare
b041c43 to
c8aecfe
Compare
|
Rebased onto main 9d088c8 (now includes #21152 pickers and #21066 layout-effect undo recording). New head c8aecfe. Conflicts kept both sides: picker docs and long-paste docs side by side, Review dispositions for b041c43:
|
c8aecfe to
7e43c8b
Compare
|
Conflict-free rebase onto 943a4e5 (#21792) to pick up main's fix for Lane note on c8aecfe: Opus and GPT found nothing; Design PASS. First Principles now asks whether |
|
UX lane on 7e43c8b: the hint, footer-count and expand items are all in the shared |
…ws retire on trimmed text Move useUndoHistory into chat-core/composer/undoHistory.ts and mount it in ChatEmbed as ChatInput does, so Cmd/Ctrl+Z after deleting a selected chip brings back its block and the send carries the full text, not the token. A host onSend endpoint may strip the text it stores, so retire the optimistic row on trimmed text. Reload showFullPastes on mc-config-changed/focus. Pin the flex-item guarantee on the textarea wrapper.
7e43c8b to
ed13046
Compare
|
Rebased onto main a5c1e85 (picks up #22042 host-send proof, #14761 Tab indent, #18263 mention range). New head ed13046, still 2 commits. Conflicts in Lane dispositions on ed13046:
|
Problem / Motivation
Goal: A long paste into an app's embedded chat (
ChatEmbed) collapses into the same[ Paste #N · M lines ]chip the dashboard chat uses, and is sent with the same wire shape, instead of flooding the composer.Today a 40-line log pasted into Spec Builder's or Ops Mission Control's chat lands in the small embed textarea as raw text: the box fills, the draft is hard to edit around, and the message goes out with no
meta.pastes, so the transcript shows the full text too. The dashboard chat has collapsed long pastes for a long time; the embed never got it.Why it matters
ChatEmbedis the recommended chat for apps (chat-core RFC, P4). Every app that embeds chat hits this the first time a user pastes a stack trace or a file. Fixing it once in the shared Paste atom also removes one more place where the embed and the dashboard chat behave differently, which is what the chat-core extraction exists to stop.Not a goal
@file/folder,/slash and$skill pickers in the embed composer (a separate item, in flight in parallel).ChatInputbehaviour, into chat-core.UserMessage(it already readsmeta.pastes).What changed (motivation → approach → change)
Goal: one implementation of long-paste collapse that both composers mount, store-free so an app with no Redux
Providercan use it.Approach: the dashboard's paste-token hook already took only state and refs; it imported no store. So it moves rather than being copied:
components/chat-input/paste.ts→chat-core/composer/pasteEditor.ts(usePasteTokens, unchanged logic). Itsimeparameter is narrowed to the one method it reads (isComposing), souseComposerDraft's IME guard can supply it.ChatInputimports the same hook from the new path; nothing else in the dashboard composer changes.ChatEmbedkeeps its blocks in the existing chat-core Paste atom (useComposerPastes), hands them to theComposerroot (pastes), and binds its textarea tousePasteTokens: paste, token keys (atomic delete / caret step), click-to-expand (a click selects the chip, a double-click expands it in place, a tap on touch expands directly), selection snap, copy/cut expansion, theCmd/Ctrl+Shift+Vraw chord, and the user'sshowFullPastessetting. A file paste still goes to the attach path first; only a paste it leaves alone can collapse.PasteHighlightLayermirror behind a transparent textarea, and the hover/caret preview is the sharedPasteHoverLayer.PasteHighlightLayergains an optionaltypoprop so the embed passes its own box classes (default unchanged:INPUT_TYPO).buildOutgoingTurnnow runs as a'send'turn (the main chat's shape) whenever files or pastes are staged, so each live token expands on the wire and the block ridesmeta.pastes;storeSentPasteswrites the side table. A newkeepFolderTokensinput keeps the embed's existing rule that@rel/folder tokens stay as typed (no project root, nometa.dirs) — previously that was done by using the text-only'steer'channel, which would have droppedmeta.pastes.ChatInput's snapshot history (useUndoHistory) moves fromcomponents/chat-input/draftHistory.tstochat-core/composer/undoHistory.ts(logic unchanged; itsimeparameter narrowed toisComposing, as for the paste hook), andChatEmbedmounts it before the token keys. Each snapshot carries the blocks, so Cmd/Ctrl+Z after deleting a selected chip brings back its content and the send never carries a bare token.draftHistory.tskeeps the ↑/↓ prompt recall.meta.pastes, so the user's bubble shows the chip until the server row lands. A hostonSendreceives the blocks asmeta.pastes; its optimistic row is retired by the stored user row compared on trimmed text, because a host endpoint may strip what it stores (a paste ending in whitespace otherwise showed twice). Whether the stored row keeps the chip is up to the host: Spec Builder's message endpoint stores the expanded text only, so its bubble shows the full text once the server row lands.mc-config-changed/focus, like the font size, so a changed setting applies to the next paste without a remount.restorePasteson the parked receipt), throughuseComposerPastes().carry, so a block whose number the composer already uses is renumbered, as in the panes.Backwards compatibility
Compatible:
ChatEmbedSendMetaonly gains an optionalpastesfield;onSend(message)is still called with no meta when nothing is staged, and a send with neither files nor a collapsed paste produces exactly the old wire text. The dashboard chat's paste behaviour is the same hook at a new path.Removes nothing: the moved module keeps every export (
usePasteTokens,isKeyboardRepaste,REPASTE_KEY_WINDOW_MS,LastPaste) and its two importers were updated in this diff; no behaviour, key or record is taken away.Tests
website/src/test/ChatEmbed.longPaste.test.tsx(new): a large paste becomes the token and the mirror draws its chip; the send expands it on the wire with the block onmeta.pastes; the optimistic row carries the block; a refused send hands the chip back with its block and the retry still sends the full text; Backspace deletes the whole token; "Show pasted text in full" keeps the text; a hostonSendgets the blocks and its stripped stored row retires the optimistic one (one user row); turning the setting on elsewhere applies to the next paste. Undo after deleting a selected chip restores the chip with its block, and the send carries the full text. Mutation-checked one at a time againstChatEmbed.tsx: removing thehandlePastewiring reddens 4 tests, droppingpastesfrom the turn 2, droppingrestorePastes1, removinghandleTokenKey1, forcingshowFullPastes: false1, dropping the optimisticmeta.pastes1, comparing untrimmed text 1, not reloadingshowFullPastes1, skippinghandleUndoKey1, not restoring blocks on undo 1.website/src/chat-core/composer/outgoingTurn.test.ts: a row forkeepFolderTokens(folder token stays, nometa.dirs, files and pastes keep the send shape). Reddens when the flag is ignored; the existingChatEmbed.attachmentsfolder-token tests also redden if the embed drops the flag.website/src/test/ChatEmbed.composerStoreFree.test.tsx: pins that the embed usespasteEditor+composerPastes+undoHistory, thatChatInputimports the same hook and the old file is gone, and addspasteEditor.ts,undoHistory.ts,composerPastes.ts,PasteHighlightLayer.tsxandPasteHoverLayer.tsxto the no-Redux import-graph check.ChatInput.paste,ChatInput.iosRepaste,PasteHoverLayer,ChatPane.pasteSidecar,SideChat.pasteSidecar,pasteTokenssuites and everyChatEmbed*/ChatInput*/ChatPane*/SideChat*/ chat-core composer suite pass: 160 files, 1978 tests.Manual verification
Pod from this worktree, Spec Builder app, real paste of a 40-line log via the clipboard: the draft holds
Please review this log:+ the chip +thanks, the chip background sits on its token text in light, dark and a 390px phone width, and hovering the chip opens the preview.tsc -p tsconfig.app.json, eslint on the touched files,jscpd(0 clones) and the docs/feature-map/focus-cue/comment-history gates pass.Not verified: a real touch device (tap-to-expand runs through the same hook as the dashboard, untested here) and IME composition on the embed textarea beyond the unit-level guard.
Screenshots / video
Desktop, light:
Hover preview:
Dark and phone width
Expanding a chip in the composer (Spec Builder, this head's build). Before:
One click selects the whole chip; a double-click puts the full 40 lines back in the composer as editable text:
After sending (Spec Builder, the send held 5s on the wire so the optimistic row is visible): the bubble shows the chip.
After the server row lands: one user bubble (Spec Builder stores the expanded text, so the full log shows), and the agent answered from the full 40 lines.
A refused send (409 simulated on Spec Builder's message endpoint for this one POST): the text and the chip are back in the composer, with the "Delivery not confirmed" notice. The red "slot is busy" banner is the simulated error.
Review dispositions
PasteHoverLayer, unchanged by this PR and identical in the dashboard chat. Not taken here, to keep the dashboard unchanged.Related Issues
Refs #19994
Checklist
docs/app-kit/api-reference.md"Long pastes",docs/system-specs/modules/app-kit-platform.md, the chat-core RFC P3-c row, the feature map)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.