Repository navigation
feat(site): display file attachments in chat UI - #24281
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c536eee to
aa5f35c
Compare
b181308 to
09619fc
Compare
aa5f35c to
785e4a0
Compare
09619fc to
f2f766d
Compare
be57d92 to
f6dea5a
Compare
2429f26 to
0c202b2
Compare
f6dea5a to
a12df00
Compare
0c202b2 to
b865dc9
Compare
d3e53a0 to
c18090d
Compare
11095b3 to
6c530e8
Compare
5c8027c to
1363433
Compare
deeba77 to
0e4bde5
Compare
ce10201 to
16e23a6
Compare
87b1c7e to
83d9c9b
Compare
16e23a6 to
8d433df
Compare
83d9c9b to
cf835bc
Compare
8d433df to
260443f
Compare
Agents can already see workspace files and take screenshots, but users could not download those artifacts from chat. This PR adds durable chat attachments to chatd. `attach_file`, explicit `computer` screenshot actions (not the automatic post-action screenshots), and `propose_plan` now fetch bytes over the agent connection, store them in `chat_files`, link them to the chat, and carry attachment metadata in tool responses so `buildAssistantPartsForPersist` can materialize ordinary `type:"file"` assistant parts that the chat file APIs serve. The same storage helpers are reused for other artifact-producing paths. `wait_agent` recordings and thumbnails are stored as chat files and linked back to the parent chat, with best-effort relinking so parent chats retain those artifacts without leaving orphaned rows when chat-file caps reject links. `storeChatAttachment` wraps insert + link in one transaction, files are capped at 10 MB each and 20 per chat, and serving defaults to `Content-Disposition: attachment` with an explicit inline-safe allowlist. This PR also consolidates chat-file media policy in `coderd/chatfiles`. Uploads and tool-generated attachments share byte-based MIME detection, SVG blocking, inline-safety rules, and compatible `text/plain` refinement for JSON, CSV, and Markdown. Prompt construction still only inlines synthetic pasted text for model consumption; assistant-created attachments are persisted for the user and intentionally not replayed into later LLM turns. UI follow-up lives in #24281. Relates to CODAGT-91
cf835bc to
ef6969d
Compare
260443f to
74b83a7
Compare
27d5ddb to
d457cdb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d457cdbb13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d457cdb to
e094490
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
c2e45b7 to
bf2e784
Compare
ethanndickson
left a comment
There was a problem hiding this comment.
Clean consolidation — collapsing the two near-duplicate FileBlock/TextAttachmentButton implementations into a shared AttachmentBlock is the right structural move, and FetchTextAttachmentError + getTextAttachmentErrorMessage replacing string-matching across two files is a clear win. The new story coverage for user-side attachments, JSON previews, and the fetch-failure retry message is well targeted.
The findings cluster around the new attachment-identity handoff (backend persistedMediaResult ↔ ComputerRenderer) and a couple of a11y/touch gaps in the shared frame. 4 P2, 9 P3, 3 Nits, 2 Obs across 18 inline comments. The P2s are worth addressing before merge; most of the P3s are one-line fixes while the code is fresh.
bf2e784 to
24a2a69
Compare
24a2a69 to
f0f9a65
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

Renders the durable file attachments introduced in #24280 in the chat interface. Without this, attachments were stored and served correctly but the UI showed raw file parts with no previews or download UX.
Every attachment gets a download affordance, split into three rendering tiers:
onFocusCapture/onBlurCapturewithcontains(relatedTarget)keeps the overlay open while tabbing between the image and its download link.text/*,application/json) — expandable preview button with loading + error-with-retry states and the same download overlay. Preview fetches throw a typedFetchTextAttachmentErrorwith a.statusfield instead of a stringly-typed error.FileCardwith extension badge, filename, and download link.User-side and assistant-side rendering now share
AttachmentBlocks.tsx(AttachmentPreviewFrame,TextAttachmentButton,ImageAttachmentButton,FileCard, plusgetAttachmentHref/getAttachmentName) instead of two near-duplicate implementations. The text-attachment overlay anchors to the preview surface so the download button stays pinned even when a loading/error status line widens the row below.ComputerRendererdetects when a screenshot was stored as a durable attachment (attachment_file_id) and suppresses the stale base64 rendering — the screenshot appears as a proper file part instead.ToolLabelshows the attached filename forattach_filetool calls.Storybook coverage in
ConversationTimeline.stories.tsxwas expanded to cover every tier (single/multiple images, inline + file-id text, JSON, download-only files, fetch-failure retry, mixed attachments + file references) with play-function assertions.Cleanup
Per Mathias' post-merge suggestion on #24280, this PR also relocates
coderd/chatfiles→coderd/x/chatfilesso the durable-attachment helpers live beside the rest of thechatdexperimental surface.Closes CODAGT-91