Skip to content

fix(native-chat): pick the attachment form per agent - #20390

Closed
mmarabel wants to merge 1 commit into
stablyai:mainfrom
mmarabel:mmarabel/native-chat-attachments
Closed

mmarabel wants to merge 1 commit into
stablyai:mainfrom
mmarabel:mmarabel/native-chat-attachments

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Native Chat sends an image to an agent by pasting the file's path into its terminal. Some agents see that paste as an image attachment, others only see text — and for agents without a verified image-paste gesture the path arrived as a bare mention the model read as prose. This makes Orca pick the form each agent actually accepts.

What Changed

  • Adds attachmentForm ('image-paste' | 'file-reference') to the existing per-agent Native Chat profile table in src/shared/native-chat-agent-profiles.ts, rather than introducing a second mapping.
  • Branches the attachment byte builder on it: agents with a verified gesture keep the bracketed raw-path paste, agents without one get the portable @path reference. A reference is framed when the name would otherwise be interpreted as keystrokes (CR/LF would submit the turn early).
  • Threads the agent through the one existing PTY image-send path (native-chat-runtime-image-send.ts, use-native-chat-pty-composer-send.ts).
  • Table-driven tests assert the two forms differ: claude emits a bracketed frame where omp emits @path.

Why

Native Chat reaches exactly claude, openclaude, codex, grok and omp (src/shared/native-chat-agent-support.ts). omp is the one with no verified image-paste gesture — absent from IMAGE_ATTACHMENT_AGENTS, because it wraps Pi's TUI (src/shared/tui-agent-config.ts).

The clipboard route already refused omp, but the drop and file-picker routes never consulted the agent, so a dropped image reached it as a naked path. Branching on the existing profile table fixes all of them without a new pipeline.

Linked Issue

Fixes #20389

Visual Proof

N/A — this changes the PTY bytes written for an attachment, not any rendered UI. There is no visual or interaction change; what changes is which form an agent receives.

Testing

  • pnpm test on the native-chat, shared and terminal-pane suites touched here.

  • pnpm tc:web, pnpm tc:node, pnpm run check:code-quality:changed.

  • Platform notes: the change is platform-neutral byte construction — no new path handling, shortcuts, or platform branches. Not manually exercised on each OS for that reason.

  • Review: a six-reviewer pass (correctness, project standards, testing, maintainability, frontend-races, plus an independent cross-model adversarial review) found one real defect in this change — an unframed @path write let a CR/LF filename submit the turn early — which is fixed here and pinned with a regression test.

  • 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 the multi-reviewer pass described above, and independently verified by the coordinating agent, which re-ran the test and typecheck gates against this exact tree.

Review

Table-driven coverage per agent for the emitted bytes, plus a regression test for the CR/LF framing case. The @path fallback keeps the existing sanitisation so a pasted escape cannot reach the composer.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: byte construction only; no new IPC surface, no new dependency, no credential or path-ownership change.
  • Cross-platform: no path or shortcut handling added; identical construction on macOS, Linux and Windows.
  • SSH/remote: the send path is the existing one, so remote and local behaviour stay identical.
  • Mobile: parity is handled in a stacked PR (fix(mobile-native-chat): pick the attachment form per agent #20391), which reuses these builders rather than adding a third table.
  • Backwards compatibility: plain terminals keep their existing shell-escaped path behaviour.
  • Performance: one extra profile lookup per attachment; write count per send is unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@pullfrog

pullfrog Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Pullfrog stalled

The agent stopped emitting events for 123s and was killed by the activity-timeout watchdog. The model produced no output at all before the stall — the request was sent but nothing came back. This is usually transient; re-running often succeeds.

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

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

coderabbitai Bot commented Sep 12, 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: a0565097-75ed-40aa-b28b-69880b2c4e46

📥 Commits

Reviewing files that changed from the base of the PR and between 4cdf031bde4bb2a73cda6a9b92c6c791edde51c9 and e982fb4.

📒 Files selected for processing (3)
  • src/renderer/src/components/native-chat/NativeChatComposer.test.tsx
  • src/shared/native-chat-agent-profiles.test.ts
  • src/shared/native-chat-agent-profiles.ts

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


📝 Walkthrough

Walkthrough

Native chat agent profiles now define attachment forms. Attachment builders produce either bracketed raw-path pastes or framed @path references. Runtime image sends resolve the form from the agent and pass agent identifiers through composer send paths. Tests cover supported-agent mappings, fallback behavior, formatting, spacing, sanitization, and runtime forwarding.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to e982f

Agent-aware attachment formatting and fallback behavior are covered without an identified merge-blocking regression.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: selecting the Native Chat attachment form per agent.
Description check ✅ Passed The description follows the required template, explains the change and rationale, links issue #20389, documents testing and platform considerations, marks visual proof as not applicable with a reason,…
Linked Issues check ✅ Passed The PR satisfies the coding requirements in issue #20389. NativeChatAgentProfile.attachmentForm selects image-paste for verified agents and file-reference for unverified agents such as omp. Fi…
Out of Scope Changes check ✅ Passed The changed production and test code stays within issue #20389. The profile field, attachment formatter, PTY write logic, agent propagation, and related tests directly implement or verify the issue ob…
  • Fix all pre-merge checks with AI

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

Copy link
Copy Markdown
Contributor

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.

@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

2 participants