Skip to content

fix(frontend): gate paste and drag-to-attach on the file-uploads flag - #5604

Merged
mmabrouk merged 2 commits into
release/v0.107.0from
fix/agent-attach-flag-gate
Aug 1, 2026
Merged

fix(frontend): gate paste and drag-to-attach on the file-uploads flag#5604
mmabrouk merged 2 commits into
release/v0.107.0from
fix/agent-attach-flag-gate

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Jul 31, 2026

Copy link
Copy Markdown
Member

Pasting a screenshot or dropping a file into the agent chat attaches it even though the file-uploads feature is dark: the attach button is gated on NEXT_PUBLIC_AGENT_FILE_UPLOADS, but the paste and drag-and-drop paths predate the flag and are live ungated. Because the backend delivery does not exist yet, the runner flattens the file to a [image] placeholder and the model never sees it, with no warning to the user.

Before: with the flag off, paste and drag-and-drop still attach files, which then silently fail at the runner.
After: with the flag off, no path attaches a file. A drop shows the "no drop" cursor and is swallowed (releasing it would let the browser navigate to the file and unload the app); a paste that carries a file inserts nothing, while plain-text paste is untouched. With the flag on, the guard expression is byte-for-byte the old behavior.

The change is one line: the shared attachmentsBlocked guard, already consulted by every entry point (drag-enter, drag-over, drop, paste), now includes the flag. Two stale comments documenting the old ungated behavior are corrected.

This is Stage 0 of the agent multi-modality plan (docs/design/agent-workflows/projects/agent-multi-modality/plan.md), stacked on the design PR #5439. The stage protocol, including the audit of all other entry points to the attachment state, is in this PR at docs/design/agent-workflows/projects/agent-multi-modality/protocols/stage-0.md.

Implicit decisions and their tradeoffs

Full detail in the protocol file; the two worth your eyes:

  • A paste whose clipboard carries both a file and text loses the text when the flag is off, because the rich-input layer prevents the default paste for any file-carrying clipboard (otherwise a pasted screenshot inserts junk HTML). This matches the pre-existing blocked states (recorder active, composer disabled).
  • The voice-recorder completion path is deliberately not gated by the uploads flag; it has its own flag, and both are off by default. If voice ever turns on while uploads is off, a recording would still land in the attachment tray. Stage 2 (the audio release) should decide whether the recorder respects the uploads flag; flagged in the protocol.

Forced routes to double-check

None. Nothing here was a single-option path; the guard mechanism already existed and the change extends it.

QA

pnpm lint-fix and the fast typecheck (tsgo --noEmit) pass. Live QA ran on the dev stack in both flag states, with synthetic paste and drag events dispatched at the real composer (full record in the protocol file in this PR):

  • Flag off: a pasted image attaches nothing; plain-text paste inserts normally; a file drag shows no overlay; the drop is swallowed (no browser navigation) and attaches nothing.
  • Flag on: the attach button is enabled; a pasted image renders the attachment chip (counter "1 / 5"); text paste unaffected; dragging a file shows the "Drop files here" overlay. The guard is inert when the flag is true.

https://claude.ai/code/session_01A1XQVjHPYJgVBHWSNUphtx

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview Aug 1, 2026 4:36pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • File uploads are now consistently controlled by the NEXT_PUBLIC_AGENT_FILE_UPLOADS setting across paste, drag-and-drop, and attachment controls.
  • Bug Fixes

    • Prevented dropped files from navigating away from the application when uploads are disabled.
  • Documentation

    • Added documentation covering upload behavior, implementation decisions, and validation results.

Walkthrough

The attachment guard now uses NEXT_PUBLIC_AGENT_FILE_UPLOADS for paste, drag-and-drop, attachment controls, and related paths. The Stage 0 protocol documents the implementation, flag states, validation commands, and QA results.

Changes

Agent file upload gating

Layer / File(s) Summary
Apply the upload guard and document validation
web/oss/src/components/AgentChatSlice/AgentConversation.tsx, docs/design/agent-workflows/projects/agent-multi-modality/protocols/stage-0.md
attachmentsBlocked now includes the file-upload feature flag. Attachment documentation reflects the shared guard. The Stage 0 protocol records the blocked and enabled behaviors, entry-point audit, and validation results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes gating paste and drag-to-attach behavior on the file-uploads flag.
Description check ✅ Passed The description directly explains the upload-flag gating changes, behavior in both flag states, implementation, and validation results.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-attach-flag-gate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

*/
const composerDisabled = onboardingActive ? ideHandoffActive : modelBlocked
const attachmentsBlocked = () => voiceRecorder.active || composerDisabled
const attachmentsBlocked = () => !uploadsEnabled || voiceRecorder.active || composerDisabled

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The whole functional change is this one added !uploadsEnabled. This guard was already consulted by all four entry points (drag-enter, drag-over, drop, paste), so gating here covers every path with the mechanism the feature already used for "recording in flight" and "composer disabled". The comments above this line explain why the handlers still preventDefault before the guard returns: releasing the drop would let the browser navigate to the file and unload the app.

nowhere. Tradeoff: a clipboard carrying both a file and meaningful text loses the text. This
matches the pre-existing blocked-state behavior; the common case (a screenshot) would otherwise
paste junk markup.
3. **The voice-recorder completion path is deliberately not gated by the uploads flag.** A finished

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the one finding worth remembering past this PR: the voice recorder feeds the attachment tray below this guard, gated only by its own flag. Unreachable today (both flags default off), but Stage 2 turns the voice flag on, so Stage 2 must decide whether a finished recording respects the uploads flag.

@mmabrouk
mmabrouk marked this pull request as ready for review July 31, 2026 16:11
@mmabrouk

Copy link
Copy Markdown
Member Author

@coderabbitai review

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Frontend labels Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
web/oss/src/components/AgentChatSlice/AgentConversation.tsx (1)

1778-1779: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the changed comments to one short line.

Both updated comment blocks span multiple lines. Condense each block to one short line.

Suggested rewrite
-    // Every attach path — button, preview, drive uploads, paste, drag-and-drop — is gated on
-    // `NEXT_PUBLIC_AGENT_FILE_UPLOADS` until the agent service can deliver file parts.
+    // Gate every attachment path on NEXT_PUBLIC_AGENT_FILE_UPLOADS until file parts are supported.

-                                                    {/* Attach button stays dead until the agent service is ready
-                                                for inline file parts (`NEXT_PUBLIC_AGENT_FILE_UPLOADS`). */}
+                                                    {/* Gate the attach button until inline file parts are supported. */}

As per coding guidelines, “Keep in-code comments to at most one short line; use longer comments only for genuinely surprising constraints such as bugs, races, or ordering requirements.”

Also applies to: 2548-2548

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: faa9bfcc-5004-44c7-81fd-e5c0db9cdb78

📥 Commits

Reviewing files that changed from the base of the PR and between 2b57e8e and a9bbf67.

📒 Files selected for processing (2)
  • docs/design/agent-workflows/projects/agent-multi-modality/protocols/stage-0.md
  • web/oss/src/components/AgentChatSlice/AgentConversation.tsx

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-08-01T18:12:49.954Z

@mmabrouk

mmabrouk commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

The comment-shortening nitpick was applied in aa1cb47. That change lands one branch up the stack, since wp4 owns the later edits to that file. This PR's diff therefore still shows the original text, but the merged result carries the short form.

@mmabrouk
mmabrouk force-pushed the docs/agent-multi-modality branch from 5cd13b4 to 9528c48 Compare August 1, 2026 16:34
@mmabrouk
mmabrouk force-pushed the fix/agent-attach-flag-gate branch from a652f2a to e424506 Compare August 1, 2026 16:35
@mmabrouk
mmabrouk deleted the branch release/v0.107.0 August 1, 2026 18:07
@mmabrouk mmabrouk closed this Aug 1, 2026
@mmabrouk mmabrouk reopened this Aug 1, 2026
@mmabrouk
mmabrouk changed the base branch from docs/agent-multi-modality to release/v0.107.0 August 1, 2026 18:11
@mmabrouk
mmabrouk merged commit 68e9409 into release/v0.107.0 Aug 1, 2026
61 of 62 checks passed
@mmabrouk
mmabrouk deleted the fix/agent-attach-flag-gate branch August 1, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant