Skip to content

feat(site): route non-attachment chat files to workspace uploads - #27080

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/chat-workspace-upload/ui
Sep 27, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/chat-workspace-upload/ui

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

Frontend for chat workspace uploads:

  • Files whose declared MIME type is outside the attachment allowlist are automatically routed to the workspace upload endpoint (picker, drag-drop, and paste). Empty/application/octet-stream types stay on the attachment path so the server can sniff bytes.
  • useWorkspaceFileUploads: react-query mutation with eager upload on select, bounded to 3 concurrent streams, per-entry abort (removing a chip cancels its in-flight request), and generation-scoped workers so switching chats mid-upload cannot leak a stale upload into the new chat.
  • Composer chips (WorkspaceUploadPreview) show queued ("Waiting to upload..." beyond the 3 in flight), uploading, uploaded, and error states; removal copy makes explicit that already-uploaded bytes stay in the workspace.
  • Timeline chips (WorkspaceFileChip) render workspace-file-reference parts with name/size and the absolute path in a tooltip.
  • References survive message edits and queued-message edits.
  • Upload error text is the server message plus its detail when present, without a doubled period or the generic developer-console hint. The shared formatAgentAttachmentUploadError helper had the same defect for inline attachments and is fixed there.
  • The affordance is gated on a bound workspace with a connected agent; otherwise the input falls back to attachments only. A disabled (read-only) composer refuses workspace routing entirely. The target agent is the one the server resolves for the chat binding (main now enriches the binding server-side), so the frontend no longer mirrors agentselect.FindChatAgent.
  • Message edits only rehydrate workspace-file-reference parts whose workspace_file_workspace_id matches the currently bound workspace; references from a previous binding are dropped from the edit draft (the server also rejects them).

Why

Completes CODAGT-211: dropping a .zip/.tar.gz/dataset whose MIME type is outside the attachment allowlist into chat lands it at ~/.coder/chats/<chat-id>/files/ where the agent can act on it, without pushing bytes through the LLM context.

How tested

  • pnpm vitest for the upload hook (including a chat-switch race regression test), routing predicate, message parsing/helpers; Storybook interaction tests for the chip states; tsc, biome, React Compiler check, and knip all clean.

Follow-ups

  • Persist workspace-upload metadata per chat so composer chips survive a failed workspace rebind and navigating away from and back to a chat. Today the hook resets when the chat or bound workspace changes (the server rejects references from a previous binding) and the upload list is client state only, so the chips are dropped even though the bytes stay in the workspace. (CODAGT-1172)

  • Expose workspace-upload availability from the backend (the agent agentselect.FindChatAgent would pick) instead of the client gating on the bound agent or, when the chat has none yet, on any connected root agent; a multi-root-agent workspace whose selected agent is disconnected currently gets the server's 409 on upload. (CODAGT-1174)

  • Reset or re-validate composer chips when repairChatAgentIDs replaces the bound agent after a workspace rebuild (the hooks scope on chat and workspace ID only); belongs with the upload-metadata persistence above.

  • Render timeline chips whose workspace_file_workspace_id differs from the chat's current binding in a stale/unavailable state (the prompt already renders such references as unavailable); needs the current binding threaded into the timeline and a chip variant. (CODAGT-1173)

  • Files with an unknown MIME type (empty or application/octet-stream, for example a random .bin) stay on the attachment path by design, where the server classifies the bytes and rejects them with "Unsupported file type"; routing that rejection to the workspace upload instead is a follow-up (CODAGT-1170). text/csv is an allowlisted attachment type and stays inline (UAT finding).

  • Route large files of allowlisted types to workspace upload by size (CODAGT-1169).

Part of CODAGT-211. Stack: agent API -> coderd endpoint -> UI (this PR).

This PR was authored by Mux (AI) working on Mike's behalf.

ibetitsmike commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@linear-code

ghost commented Jul 7, 2026

Copy link
Copy Markdown

CODAGT-211

@ibetitsmike

ghost commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@coderagents

ghost commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/ai-coder/agents/index.md (open) - The "File attachments" section documents only the attachment pipeline (allowlisted types, the 10 MiB cap, 50 most recent). It does not document that any other file type (e.g., .zip, archives, datasets) dropped, pasted, or selected in the chat composer is instead streamed to the workspace's filesystem at ~/.coder/chats/<chat-id>/files/, where the agent operates on it without the bytes entering the model context. The section should say which types take which path, that this requires the chat's bound workspace to be running with a connected agent, and that removing the chip from the composer detaches the reference only, not the already-uploaded bytes.

Note: The previous finding pointed at the "Image attachments" heading; that section is now "File attachments" on main (renamed by an earlier PR), so the gap is the same but the target heading changed.


Automated review via Coder Agents

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e27fef423

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 6e27fef to 1491b74 Compare July 7, 2026 22:57
@ibetitsmike

ghost commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 1491b74 to 4d92aca Compare July 7, 2026 23:02

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1491b74669

ℹ️ 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".

@ibetitsmike

ghost commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d92acabaf

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 4d92aca to dd220f8 Compare July 7, 2026 23:18
@ibetitsmike

ghost commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd220f8a6c

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from dd220f8 to f192a13 Compare July 7, 2026 23:31
@ibetitsmike

ghost commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f192a13b89

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from f192a13 to b1ae8ac Compare July 8, 2026 16:16
@ibetitsmike

ghost commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1ae8acf27

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from b1ae8ac to 45d3fb2 Compare July 8, 2026 16:30
@ibetitsmike

ghost commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45d3fb28e5

ℹ️ 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".

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28f8e4f5dd

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 28f8e4f to 11e2bb5 Compare September 21, 2026 22:40
@ibetitsmike

ghost commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11e2bb5e5b

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 11e2bb5 to e9a28bd Compare September 21, 2026 23:04
@ibetitsmike

ghost commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9a28bd704

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from e9a28bd to efc33e5 Compare September 21, 2026 23:24
@ibetitsmike

ghost commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

Stopping the automated Codex loop on this PR and handing it to a human reviewer.

Reason: the loop is not converging. Findings per round on this PR: 1, 4, 3, 3, 4. Every round surfaced new areas rather than shrinking the previous set, and the last two rounds re-raised design points that were already declined with rationale and tracked as follow-ups in the description (client-side mirror of agentselect.FindChatAgent, unknown-MIME routing, stale timeline chips, agent-scoped reset). All threads are answered and resolved; the two remaining fixes from the last round (test-only) are in efc33e585d9, and CI is green on the previous head with only that test change since.

State for review: the four other PRs in the stack are Codex-approved on their current heads. UAT round 2 on the previous tip (977657d3) passed all re-tested items (slow and large uploads, dev-bundle new-chat flow, navigate-away cleanup, reasoning effort on the deferred first message); the changes since then are the frontend gating and test adjustments listed above.

@github-actions github-actions Bot removed the stale This issue is like stale bread. label Sep 22, 2026

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. See the summary comment on #27078 and the non-blocking inline follow-ups across the stack.

Approval posted by Coder Agents on Scott's behalf.

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from efc33e5 to 7904dbc Compare September 23, 2026 19:01
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 7904dbc to 1c45f25 Compare September 23, 2026 19:46

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approved after the fix commits. Verified the addressed threads against the code (agent atomic publish, workspace status, normalized references, logging/metric, first-message fallback title, reasoning-effort override, Vitest coverage, archive-409 navigation) and ran the affected Go and Vitest suites; the remaining notes are acceptable as is. The three open follow-up threads are resolved as agreed follow-ups.

Approval posted by Coder Agents on Scott's behalf.

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 1c45f25 to 19fb01d Compare September 24, 2026 00:16
@ibetitsmike
ibetitsmike requested a review from a team as a code owner September 25, 2026 07:06
Base automatically changed from mike/chat-workspace-upload/backend to main September 26, 2026 19:41
Michael Suchacz added 3 commits September 26, 2026 19:54
Auto-route files whose MIME type is outside the attachment allowlist
to the new chat workspace upload endpoint. Uploads start eagerly on
select, are concurrency-limited and abortable, and render as chips in
the composer and timeline. workspace-file-reference parts survive
message edits and queued-message edits.
…rkspace filter

Editing a message rehydrates workspace file references only when they belong to the chat's bound workspace. Assert references from another workspace or with no workspace id are dropped from the send payload.
… queued uploads

Upload errors now show the server message followed by its detail only when present, without doubled punctuation or the developer console hint that getErrorDetail adds for any Error. This also applies to inline chat attachments, which shared the same formatter and defect.

Workspace uploads waiting for one of the three concurrent slots now carry a queued status and read "Waiting to upload..." instead of claiming to upload. Send gating treats queued and uploading alike.
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/ui branch from 19fb01d to 96d884d Compare September 26, 2026 20:09
@ibetitsmike
ibetitsmike merged commit 87303d6 into main Sep 27, 2026
@ibetitsmike
ibetitsmike deleted the mike/chat-workspace-upload/ui branch September 27, 2026 10:25
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants