Skip to content

ui-react: combine sent image previews and original-file details into one attachment #3988

Open

Description

@schlessera

Out of scope

No new conversion or image-restoration policy, original retention changes, provider-history changes or broad transcript/composer redesign. Do not merge by filename or remove authorized original access. SVG/BMP conversion and restored held-message frames have separate follow-ups.

Context

Part of #3150. The maintainer selected #3155 I3 B (2026-11-11): combine a sent image's visual preview and file row into one attachment display, retaining file details and authorized original access. The current two displays were not accepted as the final layout.

At inspected main 3c44ac6fc56d27675dadaf38a16254db53c39f69, MessageBubble (packages/ui-react/src/components/chat/message-bubble.tsx) renders image attachments separately from SentFiles (same file:75), which maps original files to kit rows at :82; the original files are rendered at :172 and UserAttachments renders previews at :204. AttachmentRow (packages/ui-kit/src/conversation/AttachmentRow.tsx:86) and its existing conversation stories supply the shared visual boundary. Image-frame previews currently map to presentation data in framesFor (packages/ui-react/src/lib/image-frames.ts:174); correlate the exact original identity rather than positional/name guesses.

Scope

First design the combined display using existing kit patterns, with a concrete state/action/data mapping. Then implement the necessary kit component/stories before app integration, preserving every original-file detail/action and existing read-evidence semantics. One original with a corresponding frame has one accessible attachment display in a sent message. Legacy inline images without an original reference remain usable; unknown/missing associations never cause another file's access to be merged.

Approved design and implementation split (maintainer, 2026-11-15)

Blocked by #4015

The November 15 combined-attachment proposal is approved as the implementation direction with the following rulings. These override conflicting proposal details:

  1. One primary row action: a verified image/original pair renders once as an image AttachmentRow. Activating it opens the existing image viewer; authorized Open original and Download original actions live inside the viewer. No nested controls or second inline original action. Where no preview is possible, the row can open an authorized original instead.
  2. Responsive thumbnail: 64px on phones, 96px on desktop. This supersedes the proposal's 64px-everywhere value. Retain original filename/size, known dimensions and honest content/read details beside it. Use existing responsive conventions; check 320px, desktop and 200% text without clipping actions or losing metadata.
  3. Unmatched identity: keep both displays when a frame cannot be associated by exact fileId. Never merge by filename, position or size, and never hide an unmatched preview to make the message look cleaner. Keep original ordering; legacy frame-only messages remain usable. Original-only restored history retains its existing truthful presentation without implying a preview failure.
  4. Kit first: ui-kit: add combined image-attachment preview and original-action presentation #4015 owns additive preview-row and original-action presentation/stories before this integration. AttachmentRow is in ui-kit; ImageViewer and ZoomableImage currently live in ui-react, so their actual viewer wiring remains here. Preserve this package boundary rather than treating the proposal's viewer API as already exported by the kit.
  5. Review: approve direction now; bring the built stories back for the reserved ui-react: offer a generic file picker with honest attachment lifecycle states #3155 visual review. The review remains an acceptance step, not an immediate coding prerequisite. Direction approval is not completed visual acceptance.

Use the proposal's loading/ready/missing/failed and unavailable/forbidden original states, honest partial/unknown read evidence, focus/return rules, safe original access and reduced-motion behavior. A preview never proves model reading. No original URL/action may be exposed without authorization. Display interaction does not send, read content for the model or change retention/history.

At inspected main, ChatImageAttachment already carries fileId (ensureFrame, packages/ui-react/src/lib/image-frames.ts:113), but framesFor (:174) drops that identity from presentation previews. Carry exact identity through app-local presentation data; do not infer it by position. Restored messages may have originals/count only: this change does not silently introduce frame persistence or rewrite history. Any necessary public-contract addition follows the contract rules below. Record the approved display policy in the existing attachment decision guidance as part of the implementation, coordinating with #3989.

Acceptance criteria

  • Implement the approved November 15 direction and the five rulings above, consuming ui-kit: add combined image-attachment preview and original-action presentation #4015 first. Provide 320px/desktop stories in both themes with enlarged text and exact state/action mapping. Record the later ui-react: offer a generic file picker with honest attachment lifecycle states #3155 maintainer visual review of built stories separately; if it remains after independent implementation, hand off with needs: human and concrete story/evidence links.
  • Kit stories cover preview plus original details/access, long/duplicate filenames, mixed attachments, pending/unavailable/failed preview, partial/unknown read evidence and legacy frame-only messages. Kit components/stories precede integration; app reuses them.
  • A sent image with a verified original/frame identity appears once, keeps name/size, original access and existing honest content/read details. Mixed ordering and same-name/different-ID cases are correct across send, session switch, reconnect and reload.
  • A missing association or unauthorized original gets a truthful safe fallback, not a guessed merge, broken duplicate or leaked URL. Merely displaying/expanding it neither reads contents for the model nor changes send/retention state.
  • Real offline browser checks verify 320px/desktop, light/dark, 200% text, keyboard/touch focus and accessible naming. Guard against duplicate attachment displays and loss of original access using named failing-first/restored mutations.

Verification

Extend the approved kit stories plus packages/ui-react/tests/browser/sent-attachments.layout.tsx and composer-image-originals.offline.tsx, with relevant session/reload runtime proof. Use exact original IDs and authorized fixture routes, no live accounts or providers. Record design review and meaningful mutation/browser receipts; run affected required checks.

Contract impact

Prefer additive kit props/internal presentation associations and preserve current wire schemas. Any exported API or identity field change updates its API report and relevant integration-contract component in the same CONTRACT commit. No format, history or ownership change is selected here.

2026-11-15: folded in A1–A5 maintainer answers and approved the design direction with 64px phone / 96px desktop thumbnails. Split kit work into #4015. The decision prerequisite is resolved; this integration is agent-ready and blocked on #4015. Built-story visual acceptance remains outstanding and does not block coding now.

Activity

  1. schlessera commented on Nov 11, 2026

    @schlessera
    OwnerAuthor

    #3155 I3 B settles the behavior: one sent-image attachment combines the preview, file details and authorized original access. The remaining work is the visual/state/action hierarchy and its accessible layout. Source alone does not choose those details, and the existing reserved #3155 visual review is still outstanding.

    Design the combined sent-image attachment for this issue under brain-kit#3150.
    
    Read first:
    - This issue and brain-kit#3155, the maintainer's 2026-11-11 I1 B / I2 B / I3 B ruling, and the existing rev 5/G1/G2 attachment decisions. I3 is settled; do not propose keeping the duplicate thumbnail/file row as the final design.
    - docs/decisions/chat-attachments.md; docs/plans/chat-attachments.md, especially image/frame and sent-file evidence; docs/decisions/design-kit/components-and-interactions.md; docs/decisions/design-kit/sessions-and-drafts.md (D52); docs/decisions/provider-history.md.
    - At main 3c44ac6fc56d27675dadaf38a16254db53c39f69: SentFiles and UserAttachments in packages/ui-react/src/components/chat/message-bubble.tsx:75 and :204; framesFor in packages/ui-react/src/lib/image-frames.ts:174.
    - AttachmentRow in packages/ui-kit/src/conversation/AttachmentRow.tsx:86 and packages/ui-kit/stories/conversation/AttachmentRow.stories.tsx; existing sent-attachments.layout.tsx and composer-image-originals.offline.tsx browser cases.
    
    Problem:
    A sent image currently appears as a thumbnail plus an original-file row. The user wants one compact attachment display that preserves file details and original access, without losing the distinction between an original, a derived preview and observed content-read evidence.
    
    Design:
    1. Draw the preview, filename/size, original-access action and existing read/limitation details as one coherent unit. Decide hierarchy, truncation/expansion and safe accessible action placement. Preserve fileId identity; never merge same-name files by name or index.
    2. Specify loading, ready, missing/failed preview, original unavailable/forbidden, known content limitation and partial/unknown read evidence. A preview is not proof the model read content. Define the no-preview fallback and legacy inline-image-only display.
    3. Show mixed files/images and multiple same-name originals, live send and restored messages. Do not reorder attachments or duplicate keyboard stops/details when one preview belongs to one original.
    4. Cover 320px and desktop, both themes, long names, 200% text, touch, keyboard/focus and announcements. Preserve existing kit typography, tokens and interaction language; include an effective 44px touch target for actions and reduced motion.
    5. List additive kit props and app associations needed, including the absent/missing-identity case. State how kit stories are completed before integration.
    
    Requirements:
    - Retain original details and authorized access; external/local uploaded content is never executed.
    - No implicit sends, model reads, storage/retention changes or provider-history rewrites from display interaction.
    - Preserve existing source/read honesty, original ownership and no cross-account URL exposure.
    - Use fictional Odysseus examples and the pinned 2026-07-12 date. No private account screenshots.
    
    Deliverable:
    - ASCII mocks at 320px and desktop with exact copy, state/action/focus mapping, identity rules and component/API proposal.
    - Recommended layout with concise alternatives/trade-offs for the remaining visual choices, plus a Storybook/browser state matrix.
    - A smaller implementation using existing kit pieces is acceptable if it satisfies the single-display policy and preserves all required access/details. Dropping file details/access or retaining duplication is not an acceptable substitute for I3 B.
    - Bring the concrete design back for the existing review. A prompt/proposal alone does not clear needs: design; this issue has no approved final layout yet.
    
  2. added
    type: feat
    area: ui-react
    area: ui-kit
    priority: p2
    needs: design
    on Nov 11, 2026
  3. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Design: one combined sent-image attachment

    Summary. A sent image with a verified original↔frame identity renders as one AttachmentRow in its image kind:

    • the real preview replaces the hatched thumb;
    • the original's name, size and read details stay as the row's text and meta;
    • one primary action opens the image viewer, and the original's access sits inside that viewer, with a fallback (see 1).

    No second thumbnail, no second row and no extra tab stop for the same file. Where identity is missing, nothing is merged.

    Examples: Odysseus, 2026-07-12, raft-at-ithaca.jpg (2.4 MB, 3024 × 4032).


    1. Hierarchy and actions

    The AttachmentRow layout stays as it is:

    [ preview 64×64 ]  raft-at-ithaca.jpg                      [⤢]
                       JPEG · 2.4 MB · 3024 × 4032
                       read by agent: image, 1 time        ← existing read evidence
    
    • Preview thumb: 64 px, rather than the kit's 44 px default, so the image is recognisable. It is object-fit: cover on the hatched background, so a loading or transparent image never shows a blank.
    • Text: the name is the label (wraps, overflowWrap: anywhere). The meta lines are unchanged from attachmentRowProps (type · size · dimensions, then the read evidence).
    • Single action: the whole row is one role="button" (the existing .bk-row pattern), which opens the ZoomableImage viewer at the full frame. The trailing icon is expand.
      • Accessible name: "raft-at-ithaca.jpg, image, 2.4 MB. Open preview."
    • Original access: the viewer's toolbar gains "Open original" and "Download original", shown only when the original is authorized. This replaces the separate file row's action, with the same route and authorization; no URL is ever rendered when the original is unauthorized.
      • Why not a second button in the row: two actions on one card means a nested interactive inside a role=button, which is invalid, or a split card with two stops. The viewer already exists and is where a user goes to see the full image.
    • No preview possible (see 2): the row's action becomes open original, if authorized, with the existing next icon. Accessible name: "…Open original."

    Alternative considered: the preview on top with the row below, in one bordered card. It's more visual, but it doubles the height at 320 px and still needs two actions.

    2. States

    State Thumb Meta / note Action
    Preview loading Hatch plus a quiet 1 px progress ring (static under reduced motion) unchanged Opens the viewer, which loads there
    Ready Image unchanged Opens the viewer
    Preview failed or missing Hatch plus the image glyph adds preview not available Opens the original, or none
    Original unavailable (deleted or expired) Image, if a preview exists adds original no longer available Viewer only, without the original actions
    Original forbidden (not this account) Image, if a preview exists adds original not shared with you Viewer only; no URL
    Known content limitation unchanged the existing limitation line (e.g. sent as a preview · 1568 px max) unchanged
    Read evidence partial or unknown unchanged the existing honest line (no read record yet / read: unknown on this host). A preview never implies a read. unchanged
    Legacy, frame only (no original reference) Image image · no original attached Viewer only
    Restored, count only (attachmentCount, no frames) — the existing AttachmentCount chip, unchanged —

    None of these interactions sends anything, reads contents for the model, or changes retention.

    3. Identity and ordering

    • When to merge: a frame merges with an original only when the frame's presentation data carries the original's exact fileId. That means an additive originalFileId on the frame mapping from framesFor, set at compose time where both are known.
    • Never merge by filename, index or size.
    • If there's no originalFileId, or it names a file not in attachmentFiles: render both separately, as today. Duplication beats a wrong merge.
    • Order: the original's order in attachmentFiles. Unmatched frames come first, then the rows, as today; nothing is reordered.
    • Same-name originals: two raft-at-ithaca.jpg files with different fileIds give two rows, each with its own preview. The meta adds a disambiguator only when names collide in one message: 1 of 2, 2 of 2.
    • Session switch, reconnect, reload: identity comes from fileId, so the merge result is stable. A restored message without frames shows the row with the hatched thumb, i.e. the "preview not available" path is not used for history. The thumb is simply the kit default, with no note.

    4. Layout, themes, text size

    • 320 px:
      • the row is full width, with the 64 px thumb on the left;
      • the name wraps to 2 lines, then a middle ellipsis plus the full name in the viewer title;
      • the meta wraps freely.
    • Desktop: the same row, capped at 420 px wide in the user bubble.
    • Mixed attachments: images, docs and audio stack in one grid gap-2 list in original order. The thumbnail strip (UserAttachments) disappears whenever every frame merged.
    • Themes: the thumb's border is color.edge in both themes; the image is never filtered.
    • 200 % text: the thumb stays 64 px and the text column grows. The row's minimum height is 44 px, and the whole row is the target.
    • Focus: the .bk-row ring at −2 offset (unchanged). The viewer opens with focus on its close button and returns focus to the row on close.
    • Announcements: only when the viewer opens or closes (existing). State changes in a sent message are not announced.

    Mocks

    320 px, one merged image plus a doc

    You · 09:14
    ┌──────────────────────────────┐
    │ ┌──────┐ raft-at-ithaca.jpg  │
    │ │ img  │ JPEG · 2.4 MB ·     │
    │ │64×64 │ 3024 × 4032      ⤢  │
    │ └──────┘ read by agent: image│
    │          · 1 time            │
    ├──────────────────────────────┤
    │ ▤ ithaca-harbour-notes.pdf   │
    │   PDF · 6 pages · 380 KB  ›  │
    └──────────────────────────────┘
    Where should the raft be moored?
    

    Desktop, same-name pair plus a failed preview

    ┌─────────────────────────────────────────────────┐
    │ [img] raft-at-ithaca.jpg                     ⤢  │
    │       JPEG · 2.4 MB · 3024 × 4032 · 1 of 2      │
    │       no read record yet                        │
    ├─────────────────────────────────────────────────┤
    │ [img] raft-at-ithaca.jpg                     ⤢  │
    │       JPEG · 1.1 MB · 2048 × 1536 · 2 of 2      │
    ├─────────────────────────────────────────────────┤
    │ [▨ ] sail-sketch.heic                        ›  │
    │       HEIC · 3.0 MB · preview not available     │
    └─────────────────────────────────────────────────┘
    

    Viewer toolbar (opened from the row)

    ┌ raft-at-ithaca.jpg ───────────── [Open original] [Download original] [✕] ┐
    │                          (full frame)                                     │
    └───────────────────────────────────────────────────────────────────────────┘
    original forbidden → the toolbar shows only [✕]; the subtitle reads "original not shared with you"
    

    Legacy frame only

    │ [img] Image                                  ⤢  │
    │       image · no original attached              │
    

    Kit and app inventory (additive)

    • AttachmentRow, two additive props:
      • preview?: { src: string; alt: string; state?: "loading" | "ready" | "failed" } draws an image in the thumb when state is ready; the hatch otherwise.
      • thumbSize already exists; 64 is used for merged images.
      • Absent preview renders exactly as today, so existing baselines hold.
    • ImageViewer / ZoomableImage: an additive originalActions?: { open?: () => void; download?: () => void; note?: string }.
    • App:
      • framesFor adds originalFileId?;
      • MessageBubble builds a fileId → frame map and passes preview to the matching SentFiles row;
      • frames that matched are dropped from UserAttachments.
    • No wire, history or retention change.

    Story and browser matrix

    • Stories (320 px and desktop, light and dark, 200 % text, reduced motion):
      • each AttachmentRow preview state: loading, ready, failed;
      • original unavailable, forbidden and limitation;
      • partial and unknown reads;
      • legacy, frame only;
      • same-name pair, mixed list and long name;
      • the viewer with and without original actions.
    • Browser tests (sent-attachments.layout.tsx, composer-image-originals.offline.tsx):
      • one display per verified pair;
      • two for a missing originalFileId;
      • same-name, different-id ordering across send, switch and reload;
      • no original URL in the DOM when forbidden;
      • opening the viewer issues no read or send request.
    • Mutations to fail first: merge by name; drop original actions; render both displays for a verified pair.

    Open questions for the maintainer

    • A1. Original access inside the viewer (recommended), or a second inline action that splits the card?
    • A2. Is the 64 px thumb in the row acceptable, or should merged images be larger (e.g. 96 px at desktop)?
    • A3. For an unmatched pair, keep both displays as today (recommended), or show the row only and drop the stray frame?
    • A4. Split into a ui-kit issue (AttachmentRow.preview, viewer originalActions and the stories) that blocks the integration here?
    • A5. Design sign-off (the reserved ui-react: offer a generic file picker with honest attachment lifecycle states #3155 visual review) on the stories once built.
  4. added
    needs: decision
    and removed
    needs: design
    on Nov 15, 2026
  5. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-15):

    These are the user's explicit interactive choices. The body is updated to the selected branch and correct source/package ownership. Remove needs: decision; add agent-ready and blocked on #4015. The later visual review is an acceptance step and does not block independent coding now. The implementation must record the resulting display policy in the existing attachment guidance, coordinating with #3989. No provider, retention or history change is authorized by this layout decision.

  6. added
    agent-ready
    blocked
    and removed
    needs: decision
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-kitarea: ui-reactblockedpriority: p2type: feat

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions