Skip to content

feat(terminal): render inline images (SIXEL, iTerm2, Kitty) in terminal panes - #21430

Closed
MikhailGA wants to merge 2 commits into
stablyai:mainfrom
MikhailGA:feat/terminal-inline-images
Closed

MikhailGA wants to merge 2 commits into
stablyai:mainfrom
MikhailGA:feat/terminal-inline-images

Conversation

@MikhailGA

@MikhailGA MikhailGA commented Sep 18, 2026 •

Copy link
Copy Markdown

ELI5

Coding agents like pi / oh-my-pi / Kimi Code can show screenshots and generated images right inside the terminal, the way Ghostty, iTerm2, and Windows Terminal do. Orca's terminal silently threw those images away. Now it draws them.

What Changed

Before: an agent (or img2sixel, imgcat) prints an image escape sequence and Orca shows nothing — the sequence is parsed and dropped, so users have to open every screenshot externally.

After: terminal panes load @xterm/addon-image, xterm.js's inline-image addon. SIXEL, iTerm2 OSC 1337 File= and Kitty graphics images render in the grid, scroll with their surrounding text, survive pane resize, and are cleared when overwritten.

Mechanism:

  • terminal-image-addon.ts builds the addon with enableSizeReports: false — Orca already answers CSI 14t / 16t through its own replay- and mobile-gated responder (terminal-capability-replies.ts); a second ungated reply would leak into the shell as stray input. Per-terminal image cache is capped at 32 MB (addon default 128 MB) because many panes share one renderer process.
  • The addon is created in createPaneDOM, loaded in openTerminal next to the other pane addons, and disposed in disposePane.
  • Pinned to 0.10.0-beta.300, whose peer range matches Orca's @xterm/[email protected]. beta.301 requires xterm beta.304 (new BufferLine.getExtended) and renders nothing on beta.303; bumping xterm is out of scope for this PR.
  • Docs: new "Inline images" section in docs/site/content/docs/terminal.mdx.

Not changed: DA1 (CSI c) still reports ?1;2c on macOS/Linux, so tools that pick a protocol from DA1 won't self-select SIXEL yet; on Windows the ConPTY reply (?61;4c) already advertises SIXEL. Agents that need a hint can set PI_FORCE_IMAGE_PROTOCOL=iterm2 (pi / oh-my-pi). Advertising SIXEL in DA1 touches the main-process query responders and their pinned tests, so it's a natural follow-up.

Why

#11668 has multiple reports (pi, Kimi Code, oh-my-pi on Windows + macOS). Windows reporter confirmed OMP emitted SIXEL that Orca dropped — matching the code path: raw PTY bytes reach terminal.write() unmodified, nothing consumes the DCS/OSC/APC image payloads.

Alternatives considered: writing a Kitty/IIP parser + canvas overlay by hand (large, duplicates the upstream addon); bumping xterm to beta.304 to use the newest addon (unrelated renderer changes, riskier for golden tests). The pinned addon is the smallest change with upstream-maintained decoders.

Linked Issue

Fixes #11668

Visual Proof

BEFORE — image sequences reserve blank rows, pixels never appear:
before

AFTER — SIXEL bands + iTerm2 PNG rendered in the same pane (WebGL renderer):
after: sixel + iip

AFTER — oh-my-pi inside Orca reading a PNG with PI_FORCE_IMAGE_PROTOCOL=iterm2:
after: oh-my-pi

Testing

Manual, macOS 15 (arm64), pnpm dev, WebGL renderer on:

  1. printf '\ePq"1;1;60;24#0;2;100;0;0…\e\\' (SIXEL) and printf '\e]1337;File=inline=1;width=40:<base64 png>\a' (IIP) in a pane → both render.
  2. PI_FORCE_IMAGE_PROTOCOL=iterm2 omp, ask it to read a PNG → image shown inline in the agent transcript.
  3. Collapse right sidebar (pane widens) and scroll back through three images + seq 1 30 → images stay anchored to their rows.
  4. Reload window → restored scrollback shows the surrounding text without the image (expected: images are not part of serialized scrollback; documented).

Not tested: Linux, Windows, SSH worktrees. Rendering is renderer-side only, so the data path is identical over SSH; the Windows DA1 already advertises SIXEL, so tools that gate on it should start showing images there.

  • I manually tested these changes locally
  • Automated tests added/updated: terminal-image-addon.test.ts guards that the addon never answers window-size reports (the one setting whose regression would inject stray input into the shell). Existing ManagedPaneInternal fixtures gained the imageAddon field. Pixel rendering itself needs a canvas and is covered by manual verification.

AI Disclosure

Implemented with Claude (Anthropic) via the oh-my-pi coding agent; reviewed and verified manually by the author.

Review

Cross-platform: renderer-only, no OS-specific code. SSH/remote: no transport change. Agents/integrations: provider-neutral (no agent-specific env injection). Performance: addon hooks onRender and walks visible rows for image tiles only when images exist in storage; storageLimit caps memory per pane. Security: addon size limits (pixelLimit, *SizeLimit) stay at defaults; no new terminal reports are enabled.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered
  • pnpm lint, pnpm typecheck pass locally; pane-manager vitest suite passes; pnpm test / pnpm build — CI

Author: @MikhailGA

…al panes

Load @xterm/addon-image into every pane terminal so image escape sequences
emitted by agents (pi, oh-my-pi, Kimi Code) and tools (img2sixel, imgcat)
render in the grid instead of being parsed and dropped.

- enableSizeReports stays off: Orca answers CSI 14t/16t through its own
  replay- and mobile-gated responder; a second reply would reach the shell.
- Per-pane image cache capped at 32 MB; many panes share one renderer.
- Pinned to 0.10.0-beta.300, whose peer range matches @xterm/xterm
  6.1.0-beta.303; beta.301 needs BufferLine.getExtended from beta.304 and
  renders nothing on the current xterm.

Fixes stablyai#11668
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The terminal pane manager now supports inline images through @xterm/addon-image. Each pane creates, stores, loads, and disposes an image addon configured for SIXEL, iTerm2, and Kitty protocols. Size reports are disabled, and storage is limited to 32 MB. Tests update pane fixtures and verify size-report behavior and capability-reply precedence. Documentation describes protocol selection and image scrollback behavior.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 6a2fb

Inline-image capability replies currently retain Orca’s DA1 response, but the regression test should cover the production setup path to prevent a future ordering change from silently altering terminal capability negotiation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 22 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: adding inline image rendering for SIXEL, iTerm2, and Kitty protocols in terminal panes.
Description check ✅ Passed The description is complete and directly addresses the template. It includes the user impact, implementation details, rationale, linked issue, visual proof, testing, AI disclosure, review consideratio…
Linked Issues check ✅ Passed The PR satisfies issue #11668. Each managed pane creates and loads an @xterm/addon-image instance. The addon enables SIXEL, iTerm2 OSC 1337 File=, and Kitty graphics support. The pane lifecycle di…
Out of Scope Changes check ✅ Passed The changes stay within issue #11668. The dependency, pane lifecycle updates, test fixture updates, protocol configuration, capability-response test, and terminal documentation support inline image re…
  • 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.

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

ℹ️ No critical issues — one optional regression-test suggestion inline.

Reviewed changes

  • Inline-image addon wired into every pane: createPaneDOM builds an ImageAddon (SIXEL, iTerm2 IIP, Kitty) through a new createTerminalImageAddon() factory, openTerminal loads it beside the other pane addons, and disposePane disposes it. ManagedPaneInternal gains the field and all pane fixtures were updated.
  • enableSizeReports: false: the addon is configured not to touch windowOptions, so xterm core adds no second reply to CSI 14t/16t/18t next to Orca's own responder; storageLimit is lowered to 32 MB per pane.
  • Dependency pin: @xterm/[email protected] (peer-compatible with the pinned @xterm/[email protected]), with a terminal-image-addon.test.ts guard that loading the addon leaves the size queries unanswered.
  • Docs: new "Inline images" section in docs/site/content/docs/terminal.mdx.

I verified the guard is meaningful rather than tautological: with enableSizeReports: true the same headless terminal replies \x1b[8;24;80t to CSI 18t, so the assertion would fail if the option regressed. I also ran the full pane-manager suite (80 files / 867 passed) and pnpm run typecheck:web; both are green.

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

…sement

addon-image registers its own CSI c handler; Orca's reply wins only because
handlers dispatch last-registered-first and the PTY connection installs Orca's
after openTerminal loaded the addon. Record the constraint and guard it.

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Exercise the production registration path in the DA1/SIXEL regression… · pane-lifecycle.ts:42-58

src/renderer/src/lib/pane-manager/pane-lifecycle.ts:42-58
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exercise the production registration path in the DA1/SIXEL regression test. Production registers the image addon's handler in openTerminal, then registers Orca's handler through connectPanePty → installPtyInputRecovery. The runtime order is correct. However, the test creates a standalone Terminal, loads the image addon, and calls installTerminalCapabilityReplyHandlers directly. It does not exercise openTerminal or connectPanePty. A future production reorder can therefore leave the test passing while the addon answers DA1 with its SIXEL advertisement instead of Orca's configured response. Add this assertion through the production pane/PTY setup.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a622730a-07d5-4af0-be1e-1c818213fcb7

📥 Commits

Reviewing files that changed from the base of the PR and between ce1c178 and 6a2fb6c.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-capability-replies.test.ts
  • src/renderer/src/lib/pane-manager/terminal-image-addon.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/lib/pane-manager/terminal-image-addon.ts

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

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

✅ No new issues found.

Reviewed changes

  • Pinned the DA1 load-order invariant: terminal-capability-replies.test.ts now loads the image addon before installTerminalCapabilityReplyHandlers, writes CSI c, and asserts Orca's ?1;2c reply wins while onData stays silent.
  • Documented the constraint: a comment next to sixelSupport in terminal-image-addon.ts records why Orca's DA1 handler must be registered after the addon.

I independently confirmed the new test is meaningful rather than tautological: with the two registrations reversed, sendInput receives zero calls, so the assertion fails if the ordering invariant breaks. terminal-capability-replies.test.ts (17 tests) passes.

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

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.

[Feature]: Inline image display

1 participant