feat(web): insert path mentions for non-image file drops and pastes
What
Dropping or pasting a non-image file into the composer currently fails with "Unsupported file type ... Please attach image files only." This PR turns those files into file mention chips instead, so the agent can read them where they already live:
- Drop: non-image files (and folders) become mentions - workspace-relative when inside the repo, absolute otherwise. Images keep the exact existing attachment flow; mixed drops attach the images and mention the rest.
- Paste: non-image clipboard files become mention chips at the cursor.
- Desktop bridge: exposes
webUtils.getPathForFileas an optionalDesktopBridgemethod (Electron >= 32 removedFile.path). Browser tabs have no OS path access; they keep the image-only flow with a clearer error. - Path mentions are only offered when the selected environment is the primary same-host backend; SSH/relay/remote/WSL environments have different filesystems and get the same image-only error.
- Bonus: thread title seeds now render file links as their basename instead of raw
[name](path)markup (also fixes titles for existing file-tree drag mentions).
Why this shape
Mentions are plain prompt text, so there are zero contract or server protocol changes. I'm aware of the orchestration V2 rework (#2829) that closed #4058 - this deliberately stays out of that layer entirely, and follows @juliusmarminge's suggestion there to just provide the path where the agent can find the file. Complementary to the attachment work in #3927.
Fixes #2126
Before Screenshots ⛔
After Screenshots ✅
Verification
- New pure-logic tests for the drop partition, path relativization, and title basenames; typecheck clean across web, desktop, contracts, and shared.
- Manually tested in the desktop app - screenshots and video coming shortly.
[!NOTE]
Insert path mentions for non-image file drops and pastes in the chat composer
- Dropping or pasting non-image files into the chat composer now inserts workspace-relative or absolute path mention tokens instead of being ignored; images continue to be attached as before.
- A new composerFileDrop.ts utility module handles partitioning dropped files into images and path mentions, resolving OS paths via
window.desktopBridge.getPathForFile(Electron), and computing workspace-relative paths with platform-aware (Windows/POSIX) semantics.registerComposerInlineTokenPastein composerInlineTokenPaste.ts is extended to accept aresolvePastedFilePathcallback and insert mention nodes for pasted non-image files.- New thread titles strip file-link mentions down to basenames via
replaceComposerFileLinksWithBasenamesin composerInlineTokens.ts.- Behavioral Change: unresolvable non-image file drops or pastes now surface a thread-level error message rather than silently doing nothing.
Macroscope summarized d544e80.
[!NOTE] Medium Risk User-facing composer and prompt text change with cross-platform path rules; mistakes could point the agent at wrong or unreadable paths, though scope is limited to primary same-host desktop and covered by new unit tests.
Overview Non-image OS files in the composer now become file path mentions (workspace-relative when under
gitCwd, otherwise absolute) instead of failing as unsupported attachments. Images still use the existing attachment flow; mixed drops attach images and mention the rest.Desktop exposes optional
getPathForFileonDesktopBridge(ElectronwebUtils) so the renderer can resolve dropped/pasted file paths afterFile.pathwas removed. Web has no path API and keeps image-only behavior with a clearer thread error when non-images are pasted without a resolvable path.Mentions are only built when the active environment is
PrimaryConnectionTargetand the resolved path style matches the environment OS (avoids unusable Windows paths against a Linux/WSL agent). NewcomposerFileDrophelpers partition drops, relativize paths, and wire through Lexical paste handling viaresolvePastedFilePath.Thread title seeds now run prompts through
replaceComposerFileLinksWithBasenamesso[name](path)markup does not show raw in the thread list.Reviewed by Cursor Bugbot for commit d544e80f02fae4d51247d962747a35f4158928ec. Bugbot is set up for automated code reviews on this repo. Configure here.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
e8ddd24d-8b9b-4807-b4ad-241c8ce581a7You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- [ ] 🔍 Trigger review
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.
Comment @coderabbitai help to get the list of available commands.
Approvability
Verdict: Needs human review
This PR adds a new feature (non-image file drop/paste to path mentions) with substantial new logic for cross-platform path resolution and desktop bridge integration. There is also an unresolved comment identifying a potential bug in error handling for mixed image/file drops.
You can customize Macroscope's approvability policy. Learn more.
[!NOTE] 🤖 GPT-5.6 Sol responding on behalf of Theo
We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.
#6203 keeps the useful drop and paste behavior in a much smaller patch. This branch also changes inline-token paste rules and thread-title seeds, and its extra folder support does not justify that added scope.
If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.