Skip to content

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

Closed
nwparker wants to merge 3 commits into
nwparker/omp-resume-test-contractsfrom
nwparker/omp-image-attachments-review-rebase
Closed

nwparker wants to merge 3 commits into
nwparker/omp-resume-test-contractsfrom
nwparker/omp-image-attachments-review-rebase

Conversation

@nwparker

@nwparker nwparker commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​337 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​320
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129 $\color{#cf222e}{\Huge{\mathbf{−}}}$​70 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59

ELI5

When you paste an image into OMP chat, Orca now sends it as an image attachment that OMP understands. It keeps ordinary text paste unchanged and uses a safe file URL when an agent cannot consume a native attachment.

What changed

  • Centralized agent image handling so desktop and mobile use the same policy.
  • OMP receives file mentions for pasted images, with each image separated from nearby text.
  • Verified agents keep their native attachment flow; unsupported agents receive a safe, explicit representation instead of a naked path.
  • Refreshed the mobile route parity pin for current main.

Proof

  • Hidden Electron E2E: tests/e2e/omp-image-clipboard.spec.ts — 1 passed. It injected a real image clipboard event into the OMP composer, asserted the rendered image chip, and captured the screenshot below.
  • Desktop focused tests: 59 passed.
  • Mobile focused tests: 24 passed.
  • pnpm tc:node — passed.
  • pnpm --dir mobile typecheck — passed.
  • pnpm --dir mobile typecheck:tests — passed.
  • pnpm run check:code-quality:changed — 0 new findings across 27 changed files.

Visual proof

omp-image-attached.png

Readiness checklist

  • No OMP source changes; /Users/nwparker/projects/oh-my-pi was read-only.
  • No wire or persisted-state changes.
  • Desktop, mobile, and hidden Electron paths exercised.
  • Cross-agent fallback remains explicit and safe.
  • No negative user-facing trade-off found.

Closes #20389.

Supersedes the stale #20608 head, which was based on an older main.

@coderabbitai

coderabbitai Bot commented Sep 19, 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: cb8c04d2-b549-4712-9451-5518cf4a6b48

📥 Commits

Reviewing files that changed from the base of the PR and between 211821d and 2b0d218b88c6d5c206df0b467a0d8df10d095e25.

📒 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; 2 remain after this review.


📝 Walkthrough

Walkthrough

The change adds shared agent-specific image formatting, including OMP @ references and URI fallbacks. Renderer and mobile image-send paths now pass the selected agent through paste generation. Native chat accepts clipboard images for all agents. Tests cover OMP formatting, mobile propagation, captured dependencies, runtime parity, and an end-to-end clipboard flow.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 2b0d2

Image pastes retain a safe portable representation when no agent is available, with no concrete merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
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 the main change: desktop and mobile OMP images now use file mentions.
Description check ✅ Passed The description covers the user impact, implementation, rationale, linked issue, visual proof, and testing results. It is mostly complete, although it does not use the template's exact headings and om…
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 💡
  • Commit to this branch
  • Create a new PR

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.

nwparker and others added 3 commits September 19, 2026 02:57
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 force-pushed the nwparker/omp-image-attachments-review-rebase branch from 2b0d218 to 01195e0 Compare September 19, 2026 09:57
@nwparker
nwparker changed the base branch from main to nwparker/omp-resume-test-contracts September 19, 2026 09:57
@nwparker

Copy link
Copy Markdown
Contributor Author

Stacking note: this PR now targets nwparker/omp-resume-test-contracts (#21648) so its CI includes the current transcript-path and async relay test contracts. Review/merge order is #21648 first, then #21651; the image implementation remains isolated from production changes in the parent test-contract PR.

@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

Mobile image paste can resolve the wrong agent: use-mobile-session-attachments.ts derives it inline and skips the 'unknown' filter and launchAgent fallback used elsewhere, so a Claude terminal can send @path (a file mention) instead of the raw path its TUI needs for an attachment.

Reviewed changes

  • Shared agent image policy — new src/shared/agent-image-paste.ts centralizes getAgentImageHandling, formatNativeChatFileReference, and the new formatAgentImagePath/agentImagePasteWrites. OMP, which is not an attachment agent, now renders as a @path mention (a file URL when the path has whitespace/@ and both quote kinds).
  • Desktop composer — the acceptsImages gate and the unsupported-agent notice were removed, so every agent accepts clipboard images; native chat delivers references through agentImagePasteWrites.
  • Mobile — clipboard, picker, and native-chat image sends thread the active tab's agent through the same formatter.
  • file-uri-path — a POSIX path beginning with / no longer has its backslashes rewritten.
  • Tests — shared formatter round-trip, mobile terminal/native-chat payloads, desktop OMP send order, and a hidden-Electron clipboard E2E.

ℹ️ Nitpicks

  • components.native-chat.composer.imageUnsupported is added to en-runtime-required.json:2666 while the only code reference to it is deleted in this PR, leaving a shipped English key that can never render. Either keep the notice or drop the catalog entry.
  • UseNativeChatComposerPasteArgs still declares agent: AgentType, but the hook no longer reads it — the type now promises per-agent behavior it does not have.
  • formatNativeChatFileReference now single-quotes paths containing a " (and quotes paths containing @), and it is shared with desktop non-image file drops for every agent, not just OMP. Worth confirming the other agents' mention parsers accept @'…' before relying on that branch.

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 derivation drops the 'unknown' filter and the launchAgent fallback that resolveMobileTerminalTabOwnedAgentId already implements. Before the first hook status (or on an unknown report) agentStatus?.agentType is empty and nativeChatAgent is null for a terminal tab in terminal view, so formatAgentImagePath falls through to formatNativeChatFileReference and the paste becomes @path — a file mention Claude's TUI reads as text (native-chat-send.ts:43), not the raw path that creates an image attachment. Mobile terminal paste always sent the raw path before this PR, so this is a regression in that window.

Technical details
# Mobile terminal image paste resolves the agent without the canonical resolver

## Affected sites
- `mobile/src/session/use-mobile-session-attachments.ts:42-45` — inline `agent` derivation.
- `mobile/src/session/use-mobile-terminal-paste.ts:139` — `buildMobileImagePastePayload(imagePath, agent)` now depends on that value.
- `mobile/src/session/mobile-terminal-tab-agent.ts:25-36` — `resolveMobileTerminalTabOwnedAgentId` already trims, drops `'unknown'`, and falls back to `launchAgent`.

## Required outcome
- A mobile terminal running an attachment agent (Claude/Codex/…) must send the raw path whenever its agent is known, including from the `launchAgent` hint before the first live status and when the live status reads `unknown`.
- Non-attachment agents (OMP and custom) keep receiving `@path` references.

## Suggested approach (optional)
- Use `resolveMobileTerminalTabOwnedAgentId(activeSessionTab)` for terminal tabs, falling back to `nativeChatController.nativeChatAgent` only when it returns null (the structured `agent-session` case, where terminal paste does not run anyway).

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

ℹ️ The head was force-pushed and the base retargeted since the last review; the diff against the new base is byte-identical, so the prior review's finding still stands. One scope note below.

Reviewed changes

  • No PR-authored code delta — the branch was rebased (all three commit SHAs changed: a229f10ad2, cd555ad136, 01195e0f1d) and the base moved from main to nwparker/omp-resume-test-contracts. diffPath against the new base is byte-identical to the previous review's, so nothing new was reviewed; the use-mobile-session-attachments.ts agent-derivation finding from the prior review is unchanged.

ℹ️ PR base now targets a feature branch

Both pullfrog_checkout_pr and the REST API report the base as nwparker/omp-resume-test-contracts rather than main. The diff against that branch is byte-identical to the diff against main, so the retarget did not change any of this PR's files — but as configured, merging lands these 28 files on nwparker/omp-resume-test-contracts, not main.

Technical details
# Base retargeted to a feature branch

## Affected sites
- PR #21651 base ref — now `nwparker/omp-resume-test-contracts` (was `main` when this run started).
- `diffPath` vs the new base is byte-identical to the `main` diff (28 files), so no code changed.

## Required outcome
- Confirm the stack target is intentional; if not, retarget the PR back to `main`.

## Open questions for the human (optional)
- Is `nwparker/omp-resume-test-contracts` intended to reach `main` before or with this PR?

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

@nwparker

Copy link
Copy Markdown
Contributor Author

The stacked image PR run 35436107770 completed with all image-specific/E2E, typecheck, static analysis, packaging, mobile bundle, and runtime checks passing. Two generic test failures remain outside this diff: the pre-existing pane-title scan-budget assertion and (, expected 0 errors but received 2). I am not treating either as evidence against the image implementation.

@nwparker

Copy link
Copy Markdown
Contributor Author

The stacked image PR run 35436107770 completed with all image-specific/E2E, typecheck, static analysis, packaging, mobile bundle, and runtime checks passing. Two generic test failures remain outside this diff: the pre-existing pane-title scan-budget assertion and browser-route-webrtc-egress.electron.test.ts (no result, expected 0 errors but received 2). I am not treating either as evidence against the image implementation.

@nwparker

Copy link
Copy Markdown
Contributor Author

Superseded by current-main replacement #21674. The replacement is the review target; #21651 remains stale and is not mergeable.

@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