Skip to content

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

Merged
nwparker merged 5 commits into
mainfrom
nwparker/omp-image-attachments-current
Sep 19, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/omp-image-attachments-current

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 804 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1247 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1185 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62

ELI5

When you paste an image into OMP chat, Orca now sends it as an image attachment that OMP understands. Ordinary text paste stays unchanged, and agents without native attachment support receive a safe file mention.

What changed

  • Centralized image paste handling for desktop and mobile.
  • Preserved native attachment flow for supported agents.
  • Added explicit fallback formatting for unsupported agents.
  • Added hidden Electron coverage for the OMP composer and mobile route parity coverage.

Proof

The repository-wide mobile test typecheck currently reports pre-existing errors across unrelated test files under the current TypeScript/React Native dependency set; the changed production/mobile typecheck passes, and focused runtime tests pass.

Readiness

  • OMP source remained read-only.
  • No wire or persisted-state changes.
  • Desktop and mobile paths are covered.
  • No negative user-facing trade-off found.

Closes #20389.
Supersedes stale #21651, whose branch was based on an older main.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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: 6620d581-e561-4352-9689-5338196b2899

📥 Commits

Reviewing files that changed from the base of the PR and between 4c7c91d and 17b379a.

📒 Files selected for processing (1)
  • mobile/rpc-foundation/pilot-scenarios.json
💤 Files with no reviewable changes (1)
  • mobile/rpc-foundation/pilot-scenarios.json

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


📝 Walkthrough

Walkthrough

The change adds shared agent-aware image path formatting and paste-write handling. Desktop native chat and mobile session flows now pass the selected agent through image attachment and terminal-send paths. OMP uses portable @ references, including file-URI encoding for paths that require quoting. Desktop clipboard image handling no longer blocks agents based on the previous attachment classification. Tests cover formatting, desktop and mobile sends, asynchronous mobile attachment state, parity data, recorded scenarios, and an OMP end-to-end paste event.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Issue #20389 excludes mobile terminal-drop and clipboard-accessory surfaces. This pull request changes mobile/src/session/use-mobile-terminal-paste.ts, `mobile/src/session/mobile-image-attachment.ts… Remove the agent-specific formatting and related tests and golden updates from the mobile terminal-drop and clipboard-accessory paths. Keep this pull request limited to the scoped desktop composer send path and mobile Native Chat send path,…
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 identifies the main change: OMP image handling for desktop and mobile through file mentions.
Description check ✅ Passed The description is substantive and covers the user impact, implementation scope, linked issue, testing results, visual proof, limitations, and readiness. It omits several template headings and checkli…
Linked Issues check ✅ Passed Issue #20389 requires agent-specific image delivery for the desktop composer send path and the mobile Native Chat send path. The desktop runtime send path now passes the agent to `agentImagePasteWrite…
Full details: Out of Scope Changes check

Explanation

Issue #20389 excludes mobile terminal-drop and clipboard-accessory surfaces. This pull request changes mobile/src/session/use-mobile-terminal-paste.ts, mobile/src/session/mobile-image-attachment.ts, and mobile/src/session/mobile-clipboard-image.ts to apply agent-specific image formatting. It also changes the related mobile attachment hooks, tests, and RPC goldens. These changes extend the implementation beyond the scoped desktop composer send path and mobile Native Chat send path.

Resolution

Remove the agent-specific formatting and related tests and golden updates from the mobile terminal-drop and clipboard-accessory paths. Keep this pull request limited to the scoped desktop composer send path and mobile Native Chat send path, or move the excluded mobile surface changes to a follow-up.

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


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

@nwparker

Copy link
Copy Markdown
Contributor Author

CI static analysis failed on two pre-existing base files, unrelated to this PR:

  • src/main/agent-hooks/server/server-status-update.ts: 304 lines
  • src/main/agent-hooks/server/server-ingest-remote.ts: 305 lines

The same full-repo lint gate is outside this PR's changed files; local changed-code quality remains 0 findings across 27 files. I am leaving the PR unmerged until the repository gate is either repaired or an authoritative baseline waiver is applied.

@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

The mobile agent derivation can fall through to a null/'unknown' agent, turning terminal image paste into a file mention where the previous behavior was a native attachment. One inline comment.

Reviewed changes

  • Shared image-paste module. New src/shared/agent-image-paste.ts centralizes getAgentImageHandling, formatAgentImagePath, agentImagePasteWrites, and the moved formatNativeChatFileReference; desktop native chat and mobile terminal/native-chat paste now route through it.
  • OMP file mentions. omp paths with whitespace/@ and both quote kinds become @"file://…" mentions; otherwise attachment agents get the raw path and unsupported agents get @path / @"path" / @'path', with a separator after each mention.
  • Composer gate removed. useNativeChatComposerPaste no longer rejects image paste for unsupported agents; every clipboard image becomes a chip and is formatted at send time.
  • Path and catalog plumbing. filesystemPathToFileUri no longer rewrites \ in POSIX absolute paths; the runtime-required English catalog gains the now-unreferenced imageUnsupported key; route-parity hashes refresh.
  • Tests. New shared, mobile-terminal-paste, and e2e OMP specs, plus signature updates across the desktop/mobile suites.

ℹ️ Nitpicks

  • UseNativeChatComposerPasteArgs.agent is still a required prop but the hook no longer reads it (the destructuring dropped it), while NativeChatComposer.tsx and the probe test still pass it. Drop it from the type and callers, or document why it is retained.
  • components.native-chat.composer.imageUnsupported now has no code reference. Because the catalog generator keeps unreferenced keys, this PR ships the orphaned string in en-runtime-required.json (boot bundle). Remove the key from the locale catalogs instead.
  • native-chat-image-paste.ts re-exports getAgentImageHandling and AgentImageHandling, but no production code consumes either — only the test imports getAgentImageHandling.
  • formatAgentImagePath's OMP branch only file-URL-encodes paths that also match /[\s@]/, so an absolute path containing both quote kinds but no whitespace or @ (e.g. /tmp/a"b'c.png) falls through to a bare @path that still contains quotes.

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.

For a terminal tab that is not in chat view, nativeChatController.nativeChatAgent is null (activeChatResolution requires tabWantsChat, which is false off-chat), and agentStatus.agentType can be absent or the 'unknown' sentinel. Both resolve to 'unsupported', so buildMobileImagePastePayload now emits @path instead of the raw bracketed path — a file mention where the previous behavior was a native attachment (and an unusable path in a plain shell). The existing resolveMobileTerminalTabOwnedAgentId already covers exactly these states.

Technical details
# Mobile terminal image paste resolves a null/unknown agent

## Affected sites
- `mobile/src/session/use-mobile-session-attachments.ts:42-45` — `agentStatus.agentType ?? nativeChatController.nativeChatAgent` has no `launchAgent`/`'unknown'` handling.
- `mobile/src/session/use-mobile-native-chat-active-resolution.ts:38-47` — `nativeChatAgent` is `null` whenever `tabWantsChat` is false (terminal view).
- `mobile/src/session/mobile-clipboard-image.ts:182-187` and `mobile/src/session/mobile-image-attachment.ts:56-59` — consume `agent` for the payload.

## Required outcome
- A terminal running an attachment agent must send the raw bracketed path even when `agentStatus.agentType` is absent or `'unknown'`; only genuinely non-attachment agents should get a file mention.

## Suggested approach
- Derive `agent` with the existing resolver, e.g. `resolveMobileTerminalTabOwnedAgentId(activeSessionTab) ?? nativeChatController.nativeChatAgent` (`mobile/src/session/mobile-terminal-tab-agent.ts:25`), which filters `'unknown'` and falls back to `launchAgent`.
- Add a focused test for the terminal-paste path with a null/`'unknown'` `agentStatus` so this stays pinned.

@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

The re-recorded goldens are still pinned to a baseline that predates this PR's product change, so the RPC recording pin check fails. Details in the section below.

Reviewed changes

Re-reviewed the re-record commit de4e392 on top of 1006ad6, the behavior change it refreshes.

  • Refreshed image-paste recordings. The nine nativeChat.image-paste and clipboard.image-terminal-attachment goldens now record @path (for example \x1b[200~@/tmp/a.png\x1b[201~ ) instead of the raw bracketed path, with matching pilot-scenarios.json expectations and scenarioSha256 values.
  • Bumped provenance on a subset. lockfileSha256 moves to the current mobile/pnpm-lock.yaml digest on those nine files only; the other 778 goldens keep the previous digest. baseline is unchanged everywhere.

⚠️ Re-recorded goldens are pinned to a baseline that cannot produce them

The refreshed goldens and scenario expectations are still pinned to baseline: 889c2b56, the main commit this branch forked from, which does not contain the @-prefix behavior change. The RPC recording pin job replays the candidate corpus against that pin and fails with Request params mismatch: terminal.send#N on all nine image-paste goldens.

Technical details
# Repin `baseline` before re-recording

## Affected sites
- `mobile/rpc-foundation/pilot-scenarios.json:3` — `baseline` is still `889c2b562f15b9c98604b28267d8a0aaf1aa361a`; it must name the commit that carries the product change (`1006ad670aa347d0bcaecddb6c41b8caa245b358`, or the branch tip after merging main).
- `mobile/rpc-foundation/goldens/*.json` — every golden's `baseline` header. The repin rewrites all 787, so the re-record must cover the whole corpus, not the nine image-paste files.

## Evidence
- `RPC recording pin` (Mobile Checks) failed at `de4e392e`: ancestry passes (`Recording pin 889c2b56… is an ancestor of HEAD`), then `reproduce --if-changed-since b0ec11f5b0` throws `Request params mismatch: terminal.send#1/#2` for `clipboard-image-attachment-anonymous`, `clipboard-image-attachment-pasted`, `native-chat-image-paste-single`, `-two-images`, `-stops-on-rejection`, `-trailing-image`, and both `matrix-nativechat.image-paste-terminal.send-*` goldens.
- Only nine goldens carry the new lockfile digest (`afafc16f…`); the other 778 still carry `45686333…`, confirming a subset refresh rather than a corpus re-record.

## Required outcome
- The pinned tree's `mobile/src`, `src/shared` and `mobile/pnpm-lock.yaml` must be the tree that produces the committed goldens, so `reproduce` replays clean.
- After the repin, re-record the whole corpus so no golden is pinned to a different tree.

## Suggested approach
- Set `baseline` in `pilot-scenarios.json` to `1006ad67`, then run `ORCA_BACKGROUND_LAUNCH=1 RPC_FOUNDATION_RECORD=1 pnpm --dir mobile exec tsx scripts/rpc-recording.mts --record`. The nine image-paste goldens keep their bodies; every other golden moves only its `baseline` header (and lockfile digest). See "Recording a behaviour change" in `mobile/src/test-support/rpc-recording/README.md`.

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

@nwparker

Copy link
Copy Markdown
Contributor Author

Hosted verification update: the main workflow is green (including all 8 test shards, package/package-windows, static analysis, typecheck, E2E, and verify). The separate RPC recording pin gate failed with 8 request-parameter mismatches in the image-paste family/pilot recordings because the refreshed goldens were generated from the changed source while the scenario baseline still pointed at the old pinned tree. I am correcting the provenance and will rerun the pin gate before merge.

@nwparker
nwparker merged commit e7da72c into main Sep 19, 2026
37 checks passed
@nwparker
nwparker deleted the nwparker/omp-image-attachments-current branch September 19, 2026 14:05
Jinwoo-H added a commit that referenced this pull request Sep 19, 2026
…21690)

#21674 re-recorded the corpus with `baseline` set to its own branch commit
`1006ad670a`, which the squash merge left unreachable from main. The pin
guard on the push to main fails, and so does the pin job on every open
pull request, since the merge ref cannot reach that commit either.

Repin to main's tip `e8a7be4ce2` and re-record from that tree. Every
golden's body is byte-identical to the one #21674 recorded; only the two
header lines move: `baseline` (788 files) and `lockfileSha256` (778
files), the latter because #21652 changed `mobile/pnpm-lock.yaml` after
that branch recorded.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…ng pin

The recording pin guard found the pull request that keeps a squash-dropped
pin by walking main's first-parent history for the commit that wrote the pin
into the manifest and reading "(#n)" off its subject. A merger who edits the
squash title loses the number, and the push to main turns red anyway. That
already happened on main: of the 22 squashes that left a pin outside main's
history, #21674's title had no "(#n)".

The guard now asks GitHub for the pull requests associated with the pinned
commit (GET /repos/{owner}/{repo}/commits/{sha}/pulls) and, for each in turn,
fetches refs/pull/<n>/head and accepts only when git proves the pin is an
ancestor of that head. GitHub only nominates candidates, so a wrong answer can
fail the guard but never pass it. The endpoint named the right pull request
for all 22 historical cases, #21674 included, and names none for commits a
force-push orphaned.

This removes the pickaxe walk, its 600 s budget and its lazy blob fetches in
a blobless clone, the first-parent subtlety, and the subject regex. A revert
that restores an older pull-request-only pin now resolves too, because the
lookup is by the pin itself rather than by the commit that last wrote it.

CI passes the job token to both guard steps and grants the job
pull-requests: read. Local runs work without a token on this public repo and
send GITHUB_TOKEN or GH_TOKEN when set. A failed lookup throws with the HTTP
status, and names the rate limit when an unauthenticated call is refused.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
… pull request (#23720)

* fix(ci): keep a squash-merged RPC recording pin reachable through its pull request

Main's "RPC recording pin" check has been red since #22762: that branch pinned
the recording corpus to its own commit 03995ae, and the squash-merge left that
commit out of main's history. Every behaviour-change squash did the same, and
each needed a hand-made repin PR to clear it (#23565, #23535, #23046 and more).

The guard now accepts a pin that is either in this history or in the head of the
pull request whose squash wrote it into the manifest. It finds that pull request
from the `(#n)` subject of the commit that added the pin and fetches
`refs/pull/<n>/head`, which GitHub keeps after the branch is deleted. The
reproduce step uses the same lookup, so it can still check the pinned tree out.

* fix(ci): give the recording pin lookup room to walk a blobless clone

In CI's blobless clone, `git log -S` fetches the manifest's blobs one commit at a
time, a few seconds each. Under the 30 s process default the walk was killed after
a handful of manifest commits, which main's history already exceeds (up to 7
manifest commits between a pin landing and the next pin change), and the guard
then failed with an empty "Could not find the commit that pinned" error. The
lookup and the pull request fetch now carry explicit budgets and say when they
timed out.

The not-an-ancestor instruction now names the pull request whose head was
checked, or says the commit that pinned it names none.

Adds the two merge-preview shapes the guard runs on: a branch opened after a
squash resolves main's pin through the squash's pull request, and a branch whose
rebase dropped its own pinned commit fails on its pull request instead of on main.

* fix(mobile): tell a missing recording pin apart from product drift

After a squash the pinned commit can live only in its pull request's head, so a
clone that never fetched it makes `git diff --quiet <baseline>` exit 128. The
recorder reported that as "Product sources or lockfile differ from the pinned
main baseline", which sends the developer to repin a tree that may match. It now
prints git's error and the command that fetches the pin.

* fix(ci): ask GitHub which pull request holds a squash-dropped recording pin

The recording pin guard found the pull request that keeps a squash-dropped
pin by walking main's first-parent history for the commit that wrote the pin
into the manifest and reading "(#n)" off its subject. A merger who edits the
squash title loses the number, and the push to main turns red anyway. That
already happened on main: of the 22 squashes that left a pin outside main's
history, #21674's title had no "(#n)".

The guard now asks GitHub for the pull requests associated with the pinned
commit (GET /repos/{owner}/{repo}/commits/{sha}/pulls) and, for each in turn,
fetches refs/pull/<n>/head and accepts only when git proves the pin is an
ancestor of that head. GitHub only nominates candidates, so a wrong answer can
fail the guard but never pass it. The endpoint named the right pull request
for all 22 historical cases, #21674 included, and names none for commits a
force-push orphaned.

This removes the pickaxe walk, its 600 s budget and its lazy blob fetches in
a blobless clone, the first-parent subtlety, and the subject regex. A revert
that restores an older pull-request-only pin now resolves too, because the
lookup is by the pin itself rather than by the commit that last wrote it.

CI passes the job token to both guard steps and grants the job
pull-requests: read. Local runs work without a token on this public repo and
send GITHUB_TOKEN or GH_TOKEN when set. A failed lookup throws with the HTTP
status, and names the rate limit when an unauthenticated call is refused.
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