Skip to content

fix(omp): attach desktop and mobile images through file mentions - #20608

Closed
nwparker wants to merge 3 commits into
mainfrom
nwparker/omp-image-attachments-review
Closed

nwparker wants to merge 3 commits into
mainfrom
nwparker/omp-image-attachments-review

Conversation

@nwparker

@nwparker nwparker commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​338 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​321
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​76 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57

OMP treats pasted image paths as ordinary text unless they are file mentions. Desktop and mobile attachments now send separated @ mentions to OMP, so multiple images and the following prompt reach its image loader. Verified native attachment agents keep their existing paste behavior. Clipboard images can now be attached to OMP chats.

Absolute paths containing both quote characters use file URLs, which OMP decodes. The existing URI formatter also preserves literal POSIX backslashes.

Closes #20389

Validation

  • Independent review approved implementation a7e70c1ac9ae855cacded778f925a4114b751225: 151 desktop/shared and 59 mobile tests passed, including paste ownership, structured sends, separators, and file URI consumers.
  • Node, renderer and mobile typechecks, changed-file lint and formatting passed.
  • Actual read-only OMP file-mention processors loaded four PNGs with spaces, both quotes, @, #, %, backslashes and nested directories; every decoded image matched the original bytes. Repeated against current OMP source and installed source package 18.1.2. These are file-loader runtime checks with no model turns; terminal paste-frame removal was simulated.
  • Separate installed WSL OMP 18.1.21 runtime proof loaded five PNG paths with ordinary names, spaces, @, and each quote character.
  • Hidden Electron rendered clipboard regression passed (4.4s): a synthetic image paste event in the OMP composer renders the attachment thumbnail. Only clipboard persistence is substituted in the test app; the system clipboard is untouched. This checks attachment UI, not a model turn or full image submission.
  • Windows/UNC edge paths have decoder coverage; native Windows image loading is not claimed.

OMP composer accepts the image

Credit @mmarabel for the related #20390/#20391 attachment direction; co-author attribution is included in the commit.

nwparker and others added 3 commits September 14, 2026 04:17
Format desktop and mobile image uploads for the target agent, separating
each OMP file mention from adjacent attachments and following text. Allow
OMP clipboard chips, preserve native attachment paths for verified agents,
and encode otherwise unquotable absolute paths as file URLs.

Closes #20389

Co-authored-by: mmarabel <[email protected]>
@nwparker
nwparker marked this pull request as ready for review September 14, 2026 11:49
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 89d0f3da-395c-46b7-bfdc-b19e93a37d53

📥 Commits

Reviewing files that changed from the base of the PR and between b87a6c0 and 62e58ff.

📒 Files selected for processing (28)
  • mobile/src/session/mobile-clipboard-image.test.ts
  • mobile/src/session/mobile-clipboard-image.ts
  • mobile/src/session/mobile-image-attachment.test.ts
  • mobile/src/session/mobile-image-attachment.ts
  • mobile/src/session/mobile-native-chat-image-send.test.ts
  • mobile/src/session/mobile-native-chat-image-send.ts
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/session/use-mobile-image-attachment.ts
  • mobile/src/session/use-mobile-native-chat-image-attachments.test.ts
  • mobile/src/session/use-mobile-native-chat-image-attachments.ts
  • mobile/src/session/use-mobile-session-attachments.ts
  • mobile/src/session/use-mobile-session-image-attachments.ts
  • mobile/src/session/use-mobile-terminal-paste.test.ts
  • mobile/src/session/use-mobile-terminal-paste.ts
  • src/renderer/src/components/native-chat/NativeChatComposer.test.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-target.ts
  • src/renderer/src/components/native-chat/native-chat-image-paste.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-image-send.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send-launch-draft.test.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-paste.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-paste.ts
  • src/renderer/src/components/native-chat/use-native-chat-pty-composer-send.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/shared/agent-image-paste.test.ts
  • src/shared/agent-image-paste.ts
  • src/shared/file-uri-path.ts
  • tests/e2e/omp-image-clipboard.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change adds shared agent-aware image path formatting and paste sequencing. Desktop Native Chat now passes the selected agent through image attachment sends and accepts clipboard images without an agent capability gate. Mobile session, terminal, picker, and native chat attachment flows now propagate the resolved agent. OMP uses portable @ references, while attachment-capable agents retain raw paths. Tests cover desktop, mobile, shared formatting, runtime parity, and an OMP end-to-end clipboard paste.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 62e58

Image attachments are formatted and separated for OMP while native attachment agents retain their existing behavior. The reviewed paths do not show a current merge-blocking risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Issue #20389 scopes this fix to the desktop composer send path and the mobile Native Chat send path. It explicitly leaves mobile terminal-drop and clipboard-accessory surfaces for follow-up. This PR c… Remove the mobile terminal-drop and clipboard-accessory changes from this PR, or move them to a separate follow-up issue and pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 27 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: routing desktop and mobile OMP image attachments through file mentions.
Description check ✅ Passed The description explains the change and rationale, links issue #20389, provides visual proof, and includes detailed validation results. It does not reproduce all template headings or checklist confirm…
Linked Issues check ✅ Passed Issue #20389 requires raw bracketed paths for verified attachment agents, framed portable @path references for unverified agents, and unchanged shell-escaped paths for plain terminals. `src/shared/a…
Full details: Out of Scope Changes check

Explanation

Issue #20389 scopes this fix to the desktop composer send path and the mobile Native Chat send path. It explicitly leaves mobile terminal-drop and clipboard-accessory surfaces for follow-up. This PR changes those excluded surfaces in mobile/src/session/mobile-image-attachment.ts, mobile/src/session/use-mobile-terminal-paste.ts, and their related hooks and tests. These changes implement the same behavior, but they are outside the stated issue scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 27 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

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

Important

One behavioral regression to address before merging, detailed inline: mobile's terminal clipboard paste derives its agent from nativeChatController.nativeChatAgent — which is null unless the active tab is in chat view — and never consults launchAgent. A terminal running Claude that has launched but not yet reported agentStatus (and a plain shell) therefore emits an @ file mention instead of the raw bracketed path the attachment agents require.

Reviewed changes

  • New src/shared/agent-image-paste.ts — getAgentImageHandling, formatAgentImagePath, agentImagePasteWrites, and the relocated formatNativeChatFileReference (now also quotes paths containing @ and prefers single quotes). OMP paths with both quote characters and an absolute location become @"file:///…"; every other non-attachment agent gets a framed @ reference.
  • Desktop native chat — sendNativeChatMessageWithImageAttachments takes agent first and use-native-chat-pty-composer-send threads it; the composer's acceptsImages gate and imageUnsupported notice are removed, so unverified/custom agents now fall back to mentions instead of a refusal.
  • Mobile — clipboard, native-chat and terminal attachment paths thread an agent; the terminal paste path now also separates a pasted image from following text.
  • src/shared/file-uri-path.ts — POSIX absolute paths keep literal backslashes instead of folding them to / (Windows/UNC branches unchanged).
  • Tests — per-agent byte assertions for desktop/mobile, a route-parity hash bump for the new 'agentStatus' literal, and a hidden Electron clipboard spec.

I ran the changed desktop/shared (95) and mobile (62) suites, tc:web, and the markdown link consumers of filesystemPathToFileUri; all pass (mobile tsc shows only pre-existing generated-module errors).

ℹ️ Nitpicks

  • use-native-chat-composer-paste.ts still declares agent: AgentType in UseNativeChatComposerPasteArgs, and NativeChatComposer.tsx still passes it, but the hook no longer reads it after the gate removal — drop both.
  • native-chat-send.ts:43 still says "A plain typed path (or @file mention) is treated as text/file-read". That is now exactly the intended OMP behavior, so the comment is stale.
  • Labelling OMP as 'unsupported' in getAgentImageHandling while deliberately routing it to a file reference invites the old "refuse this agent" reading; a 'raw-path' | 'file-reference' shape would carry the new meaning.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +42 to +45
const agent =
activeSessionTab && 'agentStatus' in activeSessionTab
? (activeSessionTab.agentStatus?.agentType ?? nativeChatController.nativeChatAgent)
: nativeChatController.nativeChatAgent

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.

This resolves the agent from nativeChatController.nativeChatAgent, which is null unless the active tab is in chat view (use-mobile-native-chat-active-resolution.ts:41), and never consults launchAgent. A terminal whose Claude has launched but not yet reported agentStatus therefore resolves to agent === null, and use-mobile-terminal-paste.ts:138 then emits an @ mention instead of the raw bracketed path Claude needs for an attachment. resolveMobileTerminalTabOwnedAgentId already does agentStatus.agentType ?? launchAgent and could drive this.

Technical details
# Mobile terminal image paste resolves to the wrong form before agentStatus arrives

## Affected sites
- `mobile/src/session/use-mobile-session-attachments.ts:42` — `agent` derived from `nativeChatController.nativeChatAgent`, ignoring `activeSessionTab.launchAgent`
- `mobile/src/session/use-mobile-terminal-paste.ts:138` — passes that `agent` into `formatAgentImagePath`
- `src/shared/agent-image-paste.ts:54` — null/unknown agent falls back to `formatNativeChatFileReference` (`@…`)

## Required outcome
- A terminal tab running a verified attachment agent (`claude`, `codex`, …) emits the raw bracketed path even before its live `agentStatus` lands, and a plain shell keeps a shell-usable path rather than an `@` mention.

## Suggested approach
- Resolve the active tab's owned agent with the existing `resolveMobileTerminalTabOwnedAgentId(activeSessionTab)` (`mobile/src/session/mobile-terminal-tab-agent.ts:25`) — `agentStatus?.agentType?.trim() ?? launchAgent` — instead of `nativeChatController.nativeChatAgent`, which is chat-view gated (`use-mobile-native-chat-active-resolution.ts:41`).

## Open questions for the human
- Should a plain shell (no agent at all) paste a raw path, a shell-escaped path, or an `@` mention? Issue #20389 says plain terminals keep a shell-usable path; the current fallback gives `@…`.

@nwparker

Copy link
Copy Markdown
Contributor Author

Superseded by the clean rebase in #21651: #21651

The replacement preserves the image-attachment implementation and rendered E2E proof, rebases onto current main, refreshes the mobile route parity contract, and passes desktop/mobile focused tests, typechecks, changed-code quality, and hidden Electron E2E. Closing this stale head to keep review focused on the low-risk replacement.

@nwparker

Copy link
Copy Markdown
Contributor Author

Superseded by #21651.

@nwparker nwparker closed this Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native Chat: agents without a verified image-paste gesture receive a naked image path

1 participant