Skip to content

feat(terminal): render inline images (SIXEL / iTerm2 IIP) via @xterm/addon-image - #19201

Closed
lmsh7 wants to merge 3 commits into
stablyai:mainfrom
lmsh7:feat/terminal-inline-images
Closed

lmsh7 wants to merge 3 commits into
stablyai:mainfrom
lmsh7:feat/terminal-inline-images

Conversation

@lmsh7

@lmsh7 lmsh7 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Programs running inside Orca's terminal can now show pictures. When a tool like yazi, chafa, timg, or a coding agent (pi, Kimi, OpenCode) prints an image using the standard terminal image sequences, Orca draws the image in the terminal instead of leaving a blank gap.

What Changed

  • Added @xterm/addon-image (the xterm.js-org addon, 0.10.0-beta.300, whose peer range is exactly the @xterm/xterm 6.1.0-beta.303 Orca already ships). It handles SIXEL and the iTerm2 inline image protocol (OSC 1337), plus part of the kitty graphics protocol.
    • DA1 identity is unchanged. The addon registers its own primary-DA reply (\x1b[?62;4;9;22c, advertising SIXEL), but xterm dispatches CSI handlers most-recently-registered first and Orca installs its own DA1 responder (installTerminalCapabilityReplyHandlers, with the replay guard and ConPTY variant) at PTY connect, after openTerminal attached the addon — so Orca's \x1b[?1;2c keeps winning (verified against @xterm/headless). Consequence: TUIs that autodetect SIXEL purely from DA1 (yazi, chafa) still see no SIXEL flag in this PR; IIP/kitty emitters (pi, Kimi, OpenCode, OMP with a forced protocol) and explicitly configured SIXEL work. Advertising SIXEL means updating every DA1 responder and reply-echo filter (renderer, daemon startup, ConPTY) coherently, which is a follow-up.
  • New terminal-inline-image-addon.ts loads the addon with a dynamic import() so the ~80 KB chunk stays off the boot path (same reasoning as the WebGL addon loader). The constructor is memoised, so only the first pane pays the async hop; later panes attach synchronously. A failed chunk load is warned and not memoised, so one transient failure does not disable images for the session.
  • openTerminal attaches it after terminal.open(); disposePane disposes it. A pane closed while the chunk is still loading bumps a token so the late resolve is dropped instead of loading into a disposed terminal.
  • Storage cap set to 64 MB (addon default 128 MB). Images are held as unpacked RGBA canvases and agent sessions can stream many screenshots; FIFO eviction keeps the renderer bounded and leaves the addon's placeholder in scrollback.
  • ManagedPane (public view) exposes imageAddon so callers and probes can read decoded images by buffer cell via getImageAtBufferCell.

Not in this PR (follow-ups): advertising SIXEL in DA1 (see above); a settings toggle to turn images off (as #13336 suggested, mirroring the GPU/ligature precedent); image persistence across remote reattach, because @xterm/addon-serialize does not serialise images, so a paired remote terminal restored from a snapshot shows the placeholder for images received before the reattach.

Why

Fixes the most-requested terminal gap on the tracker: #11668 (pi / Kimi inline images), with #13336 (yazi / chafa detection, closed as duplicate), #18414 (broken image rendering vs Ghostty), #18481 (SSH remote images) and #6880 (capability detection) all describing the same missing feature. Every image-capable TUI already speaks SIXEL or IIP, and the xterm.js org maintains a first-party addon for exactly this, so adopting it is far cheaper and safer than a bespoke decoder.

Linked Issue

Fixes #11668
Refs #13336, #18414, #18481, #6880

Visual Proof

Same script (node print-inline-image.js, which writes an OSC 1337 sequence with a PNG) run in the embedded terminal.

Before (main): the sequence is silently consumed, nothing is drawn.

before: blank gap where the image should be

After (this branch): the image renders inline at the requested cell size and the cursor advances past it.

after: crest rendered inline

Testing

  • pnpm typecheck, pnpm exec oxlint src tests, audit:code-quality:*, check:*-ratchet, check:reliability-gates — pass (the only typecheck errors are the two pre-existing duplicate-key errors in src/main/agent-hooks/first-work-branch-rename.test.ts on main).

  • vitest run src/renderer/src/lib/pane-manager src/renderer/src/components/terminal-pane — 5075 passed.

  • New unit spec terminal-inline-image-addon.test.ts: lazy load + memoised reuse, dispose-before-load drops the late attach, dispose clears the addon, idempotent attach, failed chunk load warns and allows retry.

  • New e2e spec tests/e2e/terminal-inline-image.spec.ts (electron-headless): builds a 16×16 PNG in-test, prints it through the PTY via nodeTerminalCommand (no printf, so it runs on Windows shells too), then asserts every cell of the 8×4 image area resolves through getImageAtBufferCell and reads back the red pixel. Passes locally on macOS (Apple Silicon).

  • Platforms actually tested: macOS 26 (arm64). Linux/Windows: no platform-specific code paths, the addon is pure renderer-side JS on top of xterm.js; CI e2e should cover.

  • Remote/SSH: rendering happens in the renderer on the received byte stream, so remote shells get images too ([Feature]: Inline images in desktop terminal for SSH remote shells (Windows frontend shows [Image #1] placeholder) #18481). Reattach from a serialised snapshot loses images received earlier (placeholder), see "Not in this PR".

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with Claude Code (Claude Fable 5.1); the author reviewed, ran the checks, and captured the screenshots.

Review

Agent review summary:

  • Cross-platform: no process.platform branches, no paths; the addon is renderer-only JS on top of xterm.js and the e2e uses nodeTerminalCommand so it does not rely on printf.
  • SSH/remote/local: renderer-side decode of the incoming stream, independent of where the PTY lives. Known limitation: images are not part of @xterm/addon-serialize output, so snapshot-based reattach shows a placeholder.
  • Agents/integrations: provider-neutral; benefits any TUI or agent emitting SIXEL/IIP.
  • Performance: chunk is deferred off boot; parser hooks are inert without image sequences; memory bounded by storageLimit: 64 MB FIFO plus the addon's pixelLimit (16 M px) decode guard. enableSizeReports stays at the addon default so CSI 14/16/18 t size queries answer, which image TUIs need for layout.
  • UI: no new UI.
  • Security: the addon only decodes PNG/JPEG/GIF via the browser's Image/canvas path and SIXEL via its own decoder; no file download support (IIP inline=0 is ignored), no network.

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

  • pnpm-lock.yaml gains only the @xterm/addon-image entry.
  • 0.10.0-beta.300 was published 2026-08-24, clearing the workspace's 3-day minimumReleaseAge.

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)

Author X handle: N/A

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: be11497f-345b-4c39-8fe0-21bfaa507f54

📥 Commits

Reviewing files that changed from the base of the PR and between 7adb5b3 and 23066c0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • package.json
  • src/renderer/src/lib/pane-manager/pane-dom-creation.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts
  • src/renderer/src/lib/pane-manager/pane-public-view.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.test.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.ts
  • src/renderer/src/main.tsx
  • src/renderer/src/web/main.tsx
  • tests/e2e/terminal-inline-image.spec.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • package.json
  • src/renderer/src/main.tsx
  • src/renderer/src/web/main.tsx
  • src/renderer/src/lib/pane-manager/pane-public-view.ts
  • tests/e2e/terminal-inline-image.spec.ts
  • src/renderer/src/lib/pane-manager/pane-dom-creation.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.ts
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.test.ts

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


📝 Walkthrough

Walkthrough

The change adds @xterm/addon-image support to embedded terminals. Panes now track an optional image addon and attach it after terminal initialization. The loader supports SIXEL and iTerm2 images, limits storage to 64 MB, cancels attachment for disposed panes, and retries failed loads. Pane disposal releases the addon. Unit and end-to-end tests cover lifecycle behavior and rendered inline images.

Priority: ➖ Normal — Impact reflects medium issue severity.

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 23066

This change adds bounded, lifecycle-managed inline image rendering to terminal panes, with coverage for loading, disposal, retries, and image rendering. No current merge-readiness risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 9 files. (1 skipped: … 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 identifies the primary change: inline image rendering in terminals through @xterm/addon-image, including SIXEL and iTerm2 support.
Description check ✅ Passed The description is complete and follows the repository template. It explains the change and motivation, links issue #11668, includes visual proof, testing details, AI disclosure, scope limitations, an…
Linked Issues check ✅ Passed The changes satisfy issue #11668 by adding renderer-side support for inline images used by pi and Kimi sessions. The addon is loaded, attached to terminal panes, disposed safely, and covered by unit a…
Out of Scope Changes check ✅ Passed The changes remain focused on inline image support. Package updates, pane lifecycle integration, lazy loading, disposal handling, tests, and renderer bootstrap changes directly support the stated obje…
Full details: Docstring Coverage

Explanation

Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 9 files. (1 skipped: 1 unsupported.)

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

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 16438633-6332-43e5-b712-d5dfe9845532

📥 Commits

Reviewing files that changed from the base of the PR and between f1d8545 and cc974b6b1e422a5c46d997a2b700552f37a738a5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • package.json
  • src/renderer/src/lib/pane-manager/pane-dom-creation.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts
  • src/renderer/src/lib/pane-manager/pane-public-view.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.test.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.ts
  • tests/e2e/terminal-inline-image.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 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 — one behavior change worth flagging below.

Reviewed changes

  • @xterm/addon-image adoption — adds the xterm.js-org addon (0.10.0-beta.300) whose peer range exactly matches the @xterm/xterm Orca already ships, enabling SIXEL and iTerm2 IIP (and, by default, the kitty protocol) decoding.
  • Lazy, memoised loader — terminal-inline-image-addon.ts defers the ~80 KB chunk behind a dynamic import() with a memoised constructor, a per-pane inlineImageAttachToken that drops late resolves for disposed panes, and a failed-load path that re-arms for the next pane.
  • Pane lifecycle wiring — attaches after terminal.open(), disposes in disposePane, and exposes imageAddon? on ManagedPane for probes.
  • Tests — unit spec covers lazy/memoised/dispose-race/failure/idempotent paths; the e2e spec builds a hand-rolled PNG in-test, emits it through the PTY via nodeTerminalCommand, and asserts decoded cells through getImageAtBufferCell with a real red-pixel readback.

ℹ️ Primary DA1 now identifies the terminal as VT220+SIXEL, not just to image TUIs

@xterm/addon-image registers its own primary-DA1 (CSI c) handler during activate(), and because xterm dispatches CSI handlers most-recently-registered first, that handler replaces xterm's stock reply (\x1b[?1;2c, or \x1b[?6c under TERM=linux) with \x1b[?62;4;9;22c (VT220 + SIXEL + charsets + ANSI colors). Every program that queries DA1 now sees a different terminal identity, not only the image-capable TUIs, and the change is not opt-outable without also disabling SIXEL (sixelSupport gates the reply). Secondary DA (CSI > c) is unaffected. This is the addon's intended feature-detection mechanism, so it is informational rather than a defect — flagging it only so the identification change is a conscious decision, since the PR frames it narrowly as "answers DA1 probes."

Technical details
# DA1 identification change

## Affected sites
- `src/renderer/src/lib/pane-manager/terminal-inline-image-addon.ts:17` — `sixelSupport: true` (the addon default regardless) drives the addon's `_da1` reply `\x1b[?62;4;9;22c`.
- Verified in the installed `@xterm/[email protected]` source: `activate()` registers `{ final: 'c' }` → `_da1`; xterm's `EscapeSequenceParser` dispatches CSI handlers LIFO, so the addon's handler runs before `InputHandler.sendDeviceAttributesPrimary`.

## Required outcome
- None required for merge. Confirm no integration keys on the stock `\x1b[?1;2c` reply, and consider a changelog line noting the identification change.

## Open questions for the human
- Should this be called out in the release notes alongside the image-rendering feature, given it affects terminal identification broadly (e.g. tmux sixel passthrough detection will now activate)?

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

@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 in the delta.

Reviewed changes (since the prior review at cc974b6)

  • Boot-time prime of the image addon — main.tsx and web/main.tsx now call primeTerminalInlineImageAddon() right after first render (mirroring primeTerminalWebglAddon), so the deferred chunk resolves before the first pane opens and openTerminal attaches the parser hook synchronously. This closes the first-pane race where an OSC 1337 / SIXEL sequence parsed before the lazy attach would have been consumed and lost.
  • Live imageAddon on the public pane view — toPublicPane now exposes imageAddon as a getter (get imageAddon() { return pane.imageAddon ?? null }), so a view handed out earlier (onPaneCreated, a retained getActivePane result) observes the addon once it attaches.
  • Two new unit tests — synchronous first-pane attach after a resolved prime, and the retained-view getter observing attach/dispose.

Both changes are correct and consistent with the existing WebGL loader and entry-point patterns; the static import in main.tsx pulls in only the small loader module (the addon type is import type, the chunk itself stays behind import('@xterm/addon-image')), and the web entry keeps the dynamic-import shape it uses for WebGL.

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

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: d5e1b0fc-367d-4ade-a489-a9579ae9bb33

📥 Commits

Reviewing files that changed from the base of the PR and between cc974b6b1e422a5c46d997a2b700552f37a738a5 and f3617b5d4f355dff78240586058ee913e7fd585a.

📒 Files selected for processing (5)
  • src/renderer/src/lib/pane-manager/pane-public-view.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.test.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.ts
  • src/renderer/src/main.tsx
  • src/renderer/src/web/main.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/lib/pane-manager/pane-public-view.ts
  • src/renderer/src/lib/pane-manager/terminal-inline-image-addon.ts

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

Comment thread src/renderer/src/web/main.tsx Resolved
@lmsh7

lmsh7 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Re the Pullfrog note on DA1 identity — good catch, and it turns out the identity does not change in Orca, for a reason worth recording:

Orca installs its own primary-DA responder (installTerminalCapabilityReplyHandlers, with the replay guard and the ConPTY variant) at PTY connect, which is after openTerminal attached the image addon. xterm dispatches CSI handlers most-recently-registered first (verified against @xterm/headless: two CSI c handlers registered, only the later one runs), so Orca's \x1b[?1;2c keeps winning and the addon's \x1b[?62;4;9;22c is shadowed. Nothing that keys on the stock reply (pty-startup-reply-echo-shapes, the daemon startup responder, ConPTY's ?61;4c) sees a different string.

The flip side, now stated in the PR description and in a comment next to the addon options (efee8751): TUIs that autodetect SIXEL purely from DA1 (yazi, chafa) still see no SIXEL flag in this PR. IIP/kitty emitters and explicitly configured SIXEL work. Advertising SIXEL properly means changing the DA1 string in every responder and echo filter (renderer, daemon startup barrier, ConPTY) in one coherent change, so I left it as a follow-up rather than let it leak in from the addon by registration order.

@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 (delta against the prior review at f3617b5)

  • Documented the DA1 identity ordering — terminal-inline-image-addon.ts gained a comment explaining why the addon's SIXEL-advertising primary-DA reply (\x1b[?62;4;9;22c) does not actually change the terminal identity: Orca's own installTerminalCapabilityReplyHandlers registers its { final: 'c' } responder later (at PTY connect, after openTerminal attached the addon), and xterm dispatches CSI handlers LIFO, so Orca's \x1b[?1;2c keeps winning. I confirmed this ordering against terminal-capability-replies.ts and pty-input-recovery.ts:187; the comment is accurate and closes out the informational DA1 note from the initial review.
  • Guarded the web entry's loader-module import — web/main.tsx now attaches a rejection handler to import('../lib/pane-manager/terminal-inline-image-addon'), degrading to a console.warn instead of an unhandled rejection when the loader chunk fails to load. The renderer entry (main.tsx) needs no equivalent because it uses a static import and primeTerminalInlineImageAddon already absorbs its own failure internally.

Both changes are correct and consistent with the existing loader patterns.

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

@lmsh7

lmsh7 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

For the record, this overlaps with #11706 (opened 2026-07-31, now conflicting with main), which I only found after opening this one — apologies for not cross-referencing earlier. Same addon, same issue; the differences, in case it helps whoever reviews either:

  • No PTY-side changes. feat(terminal): support inline images #11706 injects ORCA_IMAGE_PROTOCOL=kitty into every spawn path (daemon subprocess, local provider, relay, WSLENV). This PR is renderer-only and leaves protocol advertisement to the existing terminal identity, so nothing in src/main / src/relay moves.
  • SIXEL stays on (the addon default); feat(terminal): support inline images #11706 disabled it. That is what yazi/chafa/timg/matplotlib speak.
  • Deferred load off the boot chunk, primed at renderer start like the WebGL addon, with the dispose-during-load race handled.
  • Visual proof + e2e: before/after screenshots from the real Electron build, and a Playwright spec that emits an IIP sequence through the PTY and reads the decoded pixels back through getImageAtBufferCell.

Happy to fold anything from #11706 in, or to close this one if the maintainers prefer to land that branch.

@lmsh7

lmsh7 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@AmethystLiang @nwparker @OrcaWin — would one of you be up for taking a look at this when you get a chance? Tagging you three since you triaged the related tickets (#13336 → #11668 dup, #18414 "looking into it") and #11706's review request.

Where it stands:

  • Three bot review rounds (CodeRabbit ×2, Pullfrog ×2) are all resolved: boot-time prime removes the parser-registration race, the public pane view exposes the addon live, the web entry handles a failed chunk load, and the DA1-identity question is answered above (Orca's own responder keeps winning, so nothing changes there).
  • Renderer-only, 3 commits, no conflicts with main; unit + Playwright e2e pass against the real Electron build, screenshots in the description.
  • Known gap stated up front: SIXEL is decoded but not yet advertised in DA1, so yazi/chafa autodetect needs the follow-up that touches the daemon/ConPTY responders coherently.

If you'd rather land #11706 or an internal version instead, that's fine too — just say so and I'll close this one. Thanks!

lmsh7 and others added 3 commits September 8, 2026 10:54
…addon-image

The embedded terminal parsed no image protocol, so yazi/chafa/timg fell back
to block art and agents that emit screenshots (pi, Kimi, OpenCode) left a blank
gap. Load the xterm.js-org image addon after open(), deferred off the boot
chunk like the WebGL addon, with a 64 MB FIFO storage cap; dispose it with the
pane and drop an in-flight load for a pane closed meanwhile. Expose the addon
on the public pane view so callers can read decoded images by buffer cell.

Fixes stablyai#11668
Refs stablyai#13336, stablyai#18414, stablyai#18481, stablyai#6880

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ublic pane view

Review follow-ups: the addon hooks the parser, so an image sequence parsed
before it attaches is lost. Prime the chunk right after first render in both
renderer entries (like the WebGL addon) so the first pane attaches
synchronously from the memoised constructor. Expose imageAddon on the public
pane view through a getter so a view retained before the attach observes it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…; document DA1 ordering

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

nwparker pushed a commit that referenced this pull request Sep 8, 2026
Add opt-in inline terminal images (SIXEL, iTerm2 IIP, Kitty graphics)
through @xterm/addon-image, designed to keep idle terminals unaffected.

Performance:
- The addon (base64-inlined wasm decoders + protocol handlers) loads off
  the boot critical path via a deferred loader that mirrors the WebGL
  addon: primed after first paint only when the setting is on, read back
  synchronously at attach, with a 3-attempt cap so a transient failure
  never disables images for the session and a missing chunk never
  refetches per pane. renderer-boot-graph guards against eager import.
- enableSizeReports:false so the addon never sets windowOptions and
  double-answers Orca's own CSI 14t/16t responder.
- Perf-tuned decode/storage limits (storageLimit, sixel/iip/kitty size
  caps) in one place.

Correctness:
- Orca's DA1 handler wins over the addon's (last-registered-first), and
  the default DA1 response never advertised Sixel (;4), so DA1-detecting
  tools (chafa, img2sixel, viu, timg) never emitted it. The winning
  handler now appends ;4 while the setting is on, resolved per query so a
  live toggle changes the next DA1; idempotent against the ConPTY
  response that already lists it.
- ORCA_IMAGE_PROTOCOL=kitty is exported to spawned shells (local, daemon,
  relay/SSH) and forwarded across the WSL boundary, so image-capable
  agents can pick an encoder. Unknown image sequences are swallowed by
  xterm when the addon is detached, so this never garbles output.
- Settings toggle (default on) gates rendering and DA1 advertisement.

Cross-checked against community PRs #7775, #11706, and #19201 at the end;
credited below.

Co-authored-by: s546126 <[email protected]>
Co-authored-by: XRX193 <[email protected]>
Co-authored-by: lmsh7 <[email protected]>
nwparker pushed a commit that referenced this pull request Sep 8, 2026
Add opt-in inline terminal images (SIXEL, iTerm2 IIP, Kitty graphics)
through @xterm/addon-image, designed to keep idle terminals unaffected.

Performance:
- The addon (base64-inlined wasm decoders + protocol handlers) loads off
  the boot critical path via a deferred loader that mirrors the WebGL
  addon: primed after first paint only when the setting is on, read back
  synchronously at attach, with a 3-attempt cap so a transient failure
  never disables images for the session and a missing chunk never
  refetches per pane. renderer-boot-graph guards against eager import.
- enableSizeReports:false so the addon never sets windowOptions and
  double-answers Orca's own CSI 14t/16t responder.
- Perf-tuned decode/storage limits (storageLimit, sixel/iip/kitty size
  caps) in one place.

Correctness:
- Orca's DA1 handler wins over the addon's (last-registered-first), and
  the default DA1 response never advertised Sixel (;4), so DA1-detecting
  tools (chafa, img2sixel, viu, timg) never emitted it. The winning
  handler now appends ;4 while the setting is on, resolved per query so a
  live toggle changes the next DA1; idempotent against the ConPTY
  response that already lists it.
- ORCA_IMAGE_PROTOCOL=kitty is exported to spawned shells (local, daemon,
  relay/SSH) and forwarded across the WSL boundary, so image-capable
  agents can pick an encoder. Unknown image sequences are swallowed by
  xterm when the addon is detached, so this never garbles output.
- Settings toggle (default on) gates rendering and DA1 advertisement.

Cross-checked against community PRs #7775, #11706, and #19201 at the end;
credited below.

Co-authored-by: s546126 <[email protected]>
Co-authored-by: XRX193 <[email protected]>
Co-authored-by: lmsh7 <[email protected]>
nwparker pushed a commit that referenced this pull request Sep 18, 2026
Add opt-in inline terminal images (SIXEL, iTerm2 IIP, Kitty graphics)
through @xterm/addon-image, designed to keep idle terminals unaffected.

Performance:
- The addon (base64-inlined wasm decoders + protocol handlers) loads off
  the boot critical path via a deferred loader that mirrors the WebGL
  addon: primed after first paint only when the setting is on, read back
  synchronously at attach, with a 3-attempt cap so a transient failure
  never disables images for the session and a missing chunk never
  refetches per pane. renderer-boot-graph guards against eager import.
- enableSizeReports:false so the addon never sets windowOptions and
  double-answers Orca's own CSI 14t/16t responder.
- Perf-tuned decode/storage limits (storageLimit, sixel/iip/kitty size
  caps) in one place.

Correctness:
- Orca's DA1 handler wins over the addon's (last-registered-first), and
  the default DA1 response never advertised Sixel (;4), so DA1-detecting
  tools (chafa, img2sixel, viu, timg) never emitted it. The winning
  handler now appends ;4 while the setting is on, resolved per query so a
  live toggle changes the next DA1; idempotent against the ConPTY
  response that already lists it.
- ORCA_IMAGE_PROTOCOL=kitty is exported to spawned shells (local, daemon,
  relay/SSH) and forwarded across the WSL boundary, so image-capable
  agents can pick an encoder. Unknown image sequences are swallowed by
  xterm when the addon is detached, so this never garbles output.
- Settings toggle (default on) gates rendering and DA1 advertisement.

Cross-checked against community PRs #7775, #11706, and #19201 at the end;
credited below.

Co-authored-by: s546126 <[email protected]>
Co-authored-by: XRX193 <[email protected]>
Co-authored-by: lmsh7 <[email protected]>
nwparker pushed a commit that referenced this pull request Sep 18, 2026
Add opt-in inline terminal images (SIXEL, iTerm2 IIP, Kitty graphics)
through @xterm/addon-image, designed to keep idle terminals unaffected.

Performance:
- The addon (base64-inlined wasm decoders + protocol handlers) loads off
  the boot critical path via a deferred loader that mirrors the WebGL
  addon: primed after first paint only when the setting is on, read back
  synchronously at attach, with a 3-attempt cap so a transient failure
  never disables images for the session and a missing chunk never
  refetches per pane. renderer-boot-graph guards against eager import.
- enableSizeReports:false so the addon never sets windowOptions and
  double-answers Orca's own CSI 14t/16t responder.
- Perf-tuned decode/storage limits (storageLimit, sixel/iip/kitty size
  caps) in one place.

Correctness:
- Orca's DA1 handler wins over the addon's (last-registered-first), and
  the default DA1 response never advertised Sixel (;4), so DA1-detecting
  tools (chafa, img2sixel, viu, timg) never emitted it. The winning
  handler now appends ;4 while the setting is on, resolved per query so a
  live toggle changes the next DA1; idempotent against the ConPTY
  response that already lists it.
- ORCA_IMAGE_PROTOCOL=kitty is exported to spawned shells (local, daemon,
  relay/SSH) and forwarded across the WSL boundary, so image-capable
  agents can pick an encoder. Unknown image sequences are swallowed by
  xterm when the addon is detached, so this never garbles output.
- Settings toggle (default on) gates rendering and DA1 advertisement.

Cross-checked against community PRs #7775, #11706, and #19201 at the end;
credited below.

Co-authored-by: s546126 <[email protected]>
Co-authored-by: XRX193 <[email protected]>
Co-authored-by: lmsh7 <[email protected]>
nwparker added a commit that referenced this pull request Sep 18, 2026
…9512)

* feat(terminal): inline images via @xterm/addon-image, perf-first

Add opt-in inline terminal images (SIXEL, iTerm2 IIP, Kitty graphics)
through @xterm/addon-image, designed to keep idle terminals unaffected.

Performance:
- The addon (base64-inlined wasm decoders + protocol handlers) loads off
  the boot critical path via a deferred loader that mirrors the WebGL
  addon: primed after first paint only when the setting is on, read back
  synchronously at attach, with a 3-attempt cap so a transient failure
  never disables images for the session and a missing chunk never
  refetches per pane. renderer-boot-graph guards against eager import.
- enableSizeReports:false so the addon never sets windowOptions and
  double-answers Orca's own CSI 14t/16t responder.
- Perf-tuned decode/storage limits (storageLimit, sixel/iip/kitty size
  caps) in one place.

Correctness:
- Orca's DA1 handler wins over the addon's (last-registered-first), and
  the default DA1 response never advertised Sixel (;4), so DA1-detecting
  tools (chafa, img2sixel, viu, timg) never emitted it. The winning
  handler now appends ;4 while the setting is on, resolved per query so a
  live toggle changes the next DA1; idempotent against the ConPTY
  response that already lists it.
- ORCA_IMAGE_PROTOCOL=kitty is exported to spawned shells (local, daemon,
  relay/SSH) and forwarded across the WSL boundary, so image-capable
  agents can pick an encoder. Unknown image sequences are swallowed by
  xterm when the addon is detached, so this never garbles output.
- Settings toggle (default on) gates rendering and DA1 advertisement.

Cross-checked against community PRs #7775, #11706, and #19201 at the end;
credited below.

Co-authored-by: s546126 <[email protected]>
Co-authored-by: XRX193 <[email protected]>
Co-authored-by: lmsh7 <[email protected]>

* fix(terminal): bound inline image memory and classify Kitty replies

* fix(terminal): bound image decode and release image resources on cleanup

* fix(terminal): address image addon review feedback

* test(terminal): stub setPaneInlineImagesEnabled in appearance manager fakes

* fix(terminal): evict unplaced kitty payloads before displayed images

Byte-budget eviction dropped the oldest transmitted blob regardless of
placement, so a new upload could erase a visible image while abandoned
blobs still held budget. Unplaced payloads now go first and displayed
ones only when that is not enough. The incoming image is always stored,
so an oversized one overshoots the cap by one payload instead of being
dropped after the protocol already acked OK.

* fix(terminal): gate DA1 Sixel on real addon attachment; claim SSH image spec in CI

- DA1 advertised Sixel from the setting alone, so a pane whose lazy addon
  chunk was still loading (or had failed all three attempts) told
  feature-detecting tools to emit DCS that nothing could render. Track the
  attached decoder per terminal and require it before setting the ;4 bit.
- tests/e2e/terminal-inline-images-ssh.spec.ts was Docker-gated but claimed
  by no lane runner, so pr-e2e-gate-contract failed and the spec would have
  self-skipped green forever.
- Reject non-positive PNG IHDR dimensions before decode: they are parsed with
  signed shifts, so a dimension >= 0x80000000 came back negative and slipped
  past the pixel-limit comparison.
- One resolveTerminalInlineImagesEnabled() for the default-on setting; the
  four call sites mixed '?? true' with '!== false', which disagree on null.
- One readInlineImageResources() walk of the addon internals instead of two
  copies that could drift against the patched dependency.
- Isolate the deferred-attach drain per pane; make the zoom-invariance and
  backing-storage e2e assertions fail when the feature is dead.

* refactor(terminal): one lazy xterm addon loader for webgl and image

terminal-image-addon-loader was a structural clone of the webgl one — same
memo, attempt cap, and .then(ok,err)-clears-memo recovery. Both now wrap
createLazyXtermAddonLoader; each keeps its literal import() specifier so the
bundler still splits the chunk (verified against a fresh build: addon-image
stays out of the boot graph).

* refactor(terminal): name openTerminal's addon flags; pin image addon limits

Two adjacent optional booleans could be swapped without a type error once
inline images added the second one.

* docs(terminal): state the real per-pane image ceiling; drop test ordering dependency

storageLimit:32 reads like the pane's budget but keys three pools — decoded
pixels, retained encoded Kitty blobs, and pending WASM decoders — so the worst
case is ~98 MB per pane with no cross-pane governor. Say so at the constant.

pane-inline-images.test.ts's deferred case needed to run first; it now takes a
fresh module instead, and the rest prime in beforeAll. Verified by running the
file with that test moved last.

* fix(terminal): satisfy rebased static analysis gate

* fix(terminal): complete casting gate cleanup

* fix(terminal): recover failed image addon loads

* fix(terminal): bound image decoder allocations

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: s546126 <[email protected]>
Co-authored-by: XRX193 <[email protected]>
Co-authored-by: lmsh7 <[email protected]>
Co-authored-by: Neil <[email protected]>
Co-authored-by: Neil <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by merged PR #19512, which incorporates the @xterm/addon-image approach with deferred loading, remote transport coverage, and bounded image resources.

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

[Feature]: Inline image display

2 participants