Repository navigation
refactor(chat-core): share the attachment picker - #20178
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the three [DESIGN-REVIEWED] 9ec62aa Description read[DESCRIPTION-READ] a03467457db16a3962940fc8030a13112a20322875ebb80b05a73a806e462324 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 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 9ec62aa Description read[DESCRIPTION-READ] 36a52ff10ecd063f2fbdd942ec165a6ced3d649b35254e7edc13a269a1738251 That sha256 names everything this verdict read: the PR description, plus the 8 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (6 items) — 4 justifiedIntent: one file-picker fix should reach both the dashboard composer and the app embed. This is an ADDITION (a refactor extraction under RFC P3-f,
[FIRST-PRINCIPLES-REVIEWED] 9ec62aa Description read[DESCRIPTION-READ] ddf3a9d181c155445822c55c55ce4549bc91965e4aa05664e23679526bf18c4d That sha256 names the PR description this verdict read. 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: |
|
|
|
|
9ab3962 to
c1254fa
Compare
c1254fa to
24622d6
Compare
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at 24622d6.
The code change is sound. ComposerAttach calls onFiles only for a non-empty pick and resets the input, which matches both handlers it replaces (Attach.tsx#L11-L25). Upload grants and send recovery stay in useEmbedAttachments. The lifecycle deferral is tracked in #19994 (P-c). CI is green.
One doc defect needs a fix. It was raised by both the Opus finding and the Design suggestion on this head, and neither has a reply. In the RFC, the new Attach-slice paragraph sits between **P3 — Composer.** and the phase's own definition. The bullet now opens with slice status and leaves 'ChatInput extraction with capability flags; SideChat and ChatEmbed adopt it.' hanging on its own line (rfc-chat-core-extraction.md#L83-L91). Smallest fix: put the definition sentence back right after the bold label, and move the Attach-slice note into the phase's Status: text.
After that push, please also re-post the UX disposition on the native file-picker check for the new head. The current one names 473efed.
I read the diff and the tests but did not run them.
— crew-pr-reviewer (r102)
24622d6 to
3cc83e2
Compare
|
|
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]: @iamwhatever re review 5526995321 — fixed at 3cc83e2. The P3 bullet opens with its definition again; the Attach-slice note moved into the phase's Status: text. Folded into commit 2 (still 2 commits; tree diff vs 24622d6 is that one RFC file only). Replied to the Opus finding and the Design suggestion, and re-posted the UX native-picker disposition for the new head. |
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.
3cc83e2 to
9ec62aa
Compare
Problem / Motivation
Goal: Keep attachment handling consistent across chat surfaces without changing app permissions or losing staged files when a send fails.
ChatEmbed has its own file-selection and attachment lifecycle implementation. Fixes to that implementation do not reach the main composer, while the two file inputs repeat the same selection/reset behavior.
Why it matters
One attachment fix should not require separate picker changes for the dashboard and an app embed. The extraction keeps the working upload, staged-file and send-recovery behavior while putting the shared behavior in store-free chat-core code.
Not a goal
What changed (motivation → approach → change)
Duplicated file-input handling → one small store-free Attach atom → both
ChatInputandChatEmbedsupply their real staging callbacks to it. The atom forwards each host's input ref, id, accept hint, multiple/hidden attributes and resets selection after a pick; existing triggers and focus-return logic remain in place.Only the picker is shared. The embed's staging, paste/drop policy, in-flight uploads, abort cleanup, late-result fencing and failed-send recovery stay in the SDK's
useEmbedAttachments, unchanged from #19917, beside its explicit upload grant and scopedrawtransport. No Redux Provider, router or default dashboard network client is introduced.Remaining under #19994: sharing the attachment lifecycle itself (staging, upload holds, cancellation, failed-send recovery) between
ChatEmbedand the main chat is not done here. It needs a real second writer on the main-chat side, so it stays open as follow-up work under #19994.The existing shared multipart builder, file preview strip and outgoing-turn builder are reused. The existing send-recovery and app
onSendmetadata paths remain intact.Design: chat-core RFC, layer 4 / P3-f. This is the attachment slice, P-c.
Base
Targets
mainatbcedb90c32(the #19917 merge). #20102 and #19917 are both merged. The earlier temporary basetmp/chat-core-pc-deps-20102-19917is no longer used; the P-c commits were rebased off it onto main with conflicts resolved to main's merged code, souseEmbedAttachments.tsandatoms.tsxare byte-identical to main.Files changed: 12 files, +257/-16, the same P-c content as before the rebase. The second commit also updates the mutation script anchor to main's
ComposerSenduploadingprop.Backwards compatibility
Compatible: host upload opt-in, scoped API checks,
onSend(message, meta), paste/drop handling, staged paths, failed-send recovery and cancellation remain in place, in the SDK hook #19917 ships. Dashboard staging still uses its existing persistence/mention/recovery writers.Reader:
website/src/components/ChatInput.tsx:usePasteTokens— chat — the privatehandleFileInputChangemember moves toComposerAttach; the sameonUploadFilescallback receives selected files, with focus-return and accept-hint regressions passing.Reader:
website/src/app-sdk/ChatEmbed.tsx:useEmbedAttachments— app — the hook and its return contract are unchanged from #19917; only its file input is nowComposerAttach. Attachment tests cover opt-in refusal and send recovery.Tests
Validation on the rebased tree (
24622d67c6, same tree asc1254fa38c, base mainbcedb90c32):src/chat-core/composer,src/test/ChatEmbed*,src/components/chat-input,src/test/ChatInput*): 1124 passed, 3 failed. The 3 failures are inChatInput.approval.test.tsx(approval bar) and fail identically on a clean detached checkout of mainbcedb90c32; they are not from this diff.local-gate.pyselection was inspected, not executed: 816 backend / 425 frontend files. Focused tests above were run instead; full/main-base validation remains pending.Manual verification
Mounted real
ChatEmbedwith realAppApiProviderand React Query, no Redux Provider or router. Fixed fake data/API only; no real gateway chat or upload was sent. Five scenes rerun from the tree committed as this head, opened and inspected individually: desktop dark, 390px light, refused-send recovery, denied upload and file-only queue. Browser assertions verify staged files, send enablement, restored text and no horizontal overflow. No page errors or visible overlap found.Native OS file-picker dialogs and real gateway authorization are not verified by this harness. The preview server binds loopback and closes with its browser in
finally.Screenshots / video
Permission denial and file-only queue
Related Issues
Refs #19994 (P-c)
Builds on #20102 and #19917 (both merged).
Pattern harvest
Not generalizable: this is an extraction onto the existing chat-core boundary; behavior is pinned by component regressions and deliberate mutations, not a new cross-repository rule.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.