Repository navigation
Conversation
Native Chat bracket-pasted a raw image path for every agent, but only agents with a verified image-paste gesture turn that into an attachment chip. `omp` is a Native-Chat-supported agent with no such gesture (it wraps Pi's TUI), so a dropped image reached it as a naked path the model reads as prose — exactly what native-chat-image-paste.ts says must not happen. The clipboard route already refused omp; the drop and file-picker routes did not. Add `attachmentForm` to the existing per-agent profile table and branch the existing attachment byte builder on it. Agents without a verified profile get the portable `@path` reference. `@path` is plain text rather than a self-delimiting frame, so every reference is space-separated, and a path holding CR/LF goes through buildNativeChatPasteBytes so a filename cannot submit the turn early.
Mobile Native Chat bracket-pasted a raw image path for every agent, but only agents with a verified image-paste gesture turn that into an attachment chip. Desktop already branches on the `attachmentForm` profile field; mobile did not, so an agent without that gesture — omp, which wraps Pi's TUI — received a naked path the model reads as prose. The desktop byte builders were renderer-bound (`native-chat-send.ts` pulled in `native-chat-composer-target.ts`, which imports the renderer i18n and runtime, and `terminal-bracketed-paste.ts` is xterm-bound), so mobile could not import them. Extract the smallest self-contained pieces instead of duplicating the mapping: `src/shared/bracketed-paste-text.ts` holds the pure framing primitives, `src/shared/native-chat-paste-bytes.ts` the paste/attachment byte builders. Both renderer modules now re-export from them, so no desktop caller changes. Mobile's send path builds its attachment writes with the shared `buildNativeChatAttachmentWrites`, keyed by the existing `getNativeChatAttachmentForm` — no third per-agent table. The agent comes from the chat tab's existing `activeChatAgentRef`, read at send time like the other mobile send paths. `@path` references go through the same framing, so a filename holding CR/LF cannot submit the turn early, and each one is space-separated because a reference is not self-delimiting. The write count per send is unchanged, so the sequence deadline still funds the whole send.
Three findings from the review of the per-agent attachment form work. formatNativeChatFileReference escaped `"` but only quoted on whitespace, so a name holding a quote without a space emitted an unquoted `@path` carrying a stray escape. Escaping only makes sense inside a quoted token, so a quote now forces quoting too. The `@path` branch framed only on CR/LF, so a file name holding TAB or another C0 byte went out unframed and would act as a key rather than pasted text. Frame anything sanitization cannot neutralise. ESC stays unframed but sanitized, which is the existing deliberate behaviour and is asserted as such. Drop the unused formatNativeChatFileReference re-export from native-chat-send.ts: the one consumer imports it from native-chat-composer-target. src/shared/native-chat-paste-bytes.ts had no direct test file; add one covering the quoting rule, the framing boundary, and both attachment forms.
8795da3 to
32e0346
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes bracketed-paste and native chat attachment encoding in shared modules. Agent profiles select either Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The reviewed change does not leave a concrete merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
- Per-agent attachment form on mobile —
pasteMobileNativeChatImagePathsnow shapes each write fromgetNativeChatAttachmentForm(agentRef.current)via the sharedbuildNativeChatAttachmentWrites, so omp and custom agents get@pathinstead of a bracketed raw image path. The agent is read at send time and plumbed through the controller contract; the structured lane correctly ignores it. - Shared byte/framing extraction —
src/shared/bracketed-paste-text.tsandsrc/shared/native-chat-paste-bytes.tsnow hold the pure primitives, and the renderer modules re-export them, so desktop callers are unchanged while mobile can import them. Theimage-pastebytes are identical to the previous mobile/desktop builders. - Reference hardening —
formatNativeChatFileReferencequotes on"as well as whitespace, and the@pathbranch frames CR/LF/TAB/C0/DEL so an unframed reference cannot be read as keystrokes. Tests pin the exact bytes and cross-check the form table againstIMAGE_ATTACHMENT_AGENTS.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…uences The extracted framing module inlined a raw 0x1b control byte and a literal U+241B glyph, while the desktop source it was extracted from writes '\u001b' and '\u241b'. A raw control byte is invisible in review and easy to mangle in editors, and the escape form keeps the extraction faithful to its original. Behavior is unchanged — the existing byte-pinning tests still pass.
|
Superseded by merged current-main replacement #21674, which covers desktop and mobile composer, drop, picker, and clipboard-accessory image attachment paths with green hosted RPC recording verification and cross-platform test proof. |

ELI5
Desktop already picks the attachment form each agent actually accepts. Mobile's native chat still sent every agent the same thing, so an agent without an image-paste gesture got a bare path where it should have got a file reference. This makes mobile use the same rule instead of keeping its own.
What Changed
buildNativeChatAttachmentWrites, keyed by the existinggetNativeChatAttachmentForm— no third per-agent table.src/shared/bracketed-paste-text.tsandsrc/shared/native-chat-paste-bytes.ts. The desktop helpers were renderer-bound (native-chat-send.tspulled innative-chat-composer-target.ts, which imports renderer i18n/runtime, andterminal-bracketed-paste.tsis xterm-bound), so mobile could not import them. Both renderer modules now re-export from the shared modules, so no desktop caller changed.activeChatAgentRef, like mobile's other send paths.@pathreference whose name holds a quote is now quoted (escaping only makes sense inside a quoted token), and a reference holding TAB or another C0 byte is framed instead of being written as keystrokes. ESC stays unframed but sanitized, which is the pre-existing deliberate behaviour.Why
Same root cause as #20389 — the attachment form was uniform per agent. Reusing the shared rule rather than copying it is also what keeps desktop and mobile from drifting on this again.
Linked Issue
Part of #20389. Stacked on #20390, which fixes the desktop path.
Visual Proof
N/A — this changes the PTY bytes written for an attachment, not any rendered UI. There is no visual or interaction change.
Testing
mobile/:pnpm test→ 510 files, 4175 passed, 3 skipped.pnpm typecheck(tsc --noEmit) clean.pnpm lint(oxlint) exit 0.Root: native-chat + terminal-pane + shared suites pass;
pnpm tc:webandpnpm tc:nodeclean;pnpm run check:code-quality:changedreports 0 new findings.A direct test file was added for
src/shared/native-chat-paste-bytes.ts, which previously had none, covering the quoting rule, the framing boundary, and both attachment forms.Platform notes: byte construction only; no new path handling or platform branches. Worth knowing for review: mobile's tsconfig excludes test files, so mobile test files are not typechecked — a review pass caught a missing required argument in a new test that
tscdid not.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude Code (Opus 5), running as an Orca-supervised worker. Reviewed by a six-reviewer pass (correctness, project standards, testing, maintainability, frontend-races, plus an independent cross-model adversarial review), and independently verified by the coordinating agent, which re-ran the mobile and root gates against this tree.
Review
Stacking
This branch is stacked on #20390 — its first commit is that PR's commit, so review #20390 first. Both PRs target
mainrather than chaining bases, because the stacked branch lives in a fork and cannot be used as a base branch upstream; once #20390 merges, this diff collapses to the mobile commit plus the hardening commit.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)