Skip to content

feat(terminal): support inline images via SIXEL, iTerm2 IIP, and Kitty graphics protocol - #7775

Closed
s546126 wants to merge 7 commits into
stablyai:mainfrom
s546126:s546126/kitty-graphics-protocol
Closed

s546126 wants to merge 7 commits into
stablyai:mainfrom
s546126:s546126/kitty-graphics-protocol

Conversation

@s546126

@s546126 s546126 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add @xterm/addon-image (devDependency, matching other renderer-only xterm addons) to live terminal panes, enabling inline image rendering for SIXEL, iTerm2 IIP, and Kitty Graphics Protocol (Kitty support is alpha upstream).
  • Advertise the sixel-capable DA1 identity (ESC[?62;4;9;22c) from Orca's capability responder — it pre-empts the addon's own DA1 handler (xterm dispatches CSI handlers newest-first), so without this, probing tools like lsix never detect graphics support. Windows ConPTY identity already carried the sixel bit and is unchanged.
  • enableSizeReports stays off: Orca's existing pixel-size responder already answers CSI 14t/16t; enabling xterm's built-in responder would send duplicate replies (the [Bug] Remote server + terminal work #7329 stray-input class).
  • Addon image storage capped at 64MB per pane (half upstream default) since Orca can have many panes open concurrently.
  • No new settings toggle — enabled by default, same as other xterm addons in this codebase.

Known limitation

Inline images are rendered client-side only. The daemon snapshot/restore path serializes text cells via SerializeAddon, which carries no image data — so images displayed before an SSH reconnect, window reload, or cold restore do not reappear in the restored pane. Live output after reconnect renders normally. Persisting images across restores would require teaching the daemon-side emulator/history replay to retain image sequences and is left for a follow-up.

Review

Multi-agent review (8 finder angles + adversarial verification) ran on the initial commit; confirmed findings fixed in 71c36a05:

  • DA1 pre-emption made sixel detection fail for DA1-probing clients → fixed by advertising sixel in DEFAULT_DA1_RESPONSE.
  • enableSizeReports: true double-answered CSI 14t/16t alongside Orca's responder → set to false.
  • Settings preview loaded the addon although PREVIEW_BUFFER contains no image sequences and stdin is disabled → removed.
  • Addon options trimmed to the two that differ in intent from upstream defaults.
    Refuted candidates (verified safe): addon double-dispose (xterm AddonManager guards it), openTerminal re-entry leak (each pane opens exactly once), image loss on WebGL renderer recreation (addon re-blits on the forced refresh).

Test plan

  • pnpm typecheck passes with zero errors
  • Node 24 (Docker): pty-connection.test.ts (338), terminal-capability-replies.test.ts, pane-lifecycle.test.ts, TerminalSettingsPreview.lifecycle.test.tsx — 382 passed
  • Node 24 (Docker): full pane-manager/ + settings/ + terminal-query-reply — 128 files, 906 tests passed
  • Manual smoke test: lsix, wezterm imgcat, kitty icat against a live pane

🤖 Generated with Claude Code

ELI5

Terminals can show inline images (SIXEL, iTerm2, and Kitty graphics). Tools that draw charts or previews in the terminal finally render inside Orca panes.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8162bd6c-9080-4fdc-a9e4-3fe45425caa0

📥 Commits

Reviewing files that changed from the base of the PR and between fbe94ce and 678da10298e2bc4fa5608ff8bd9cf315d54c671f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (21)
  • package.json
  • src/renderer/src/components/terminal-pane/terminal-capability-replies.ts
  • src/renderer/src/lib/pane-manager/pane-container-listener-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-dom-creation.ts
  • src/renderer/src/lib/pane-manager/pane-drag-reorder.test.ts
  • src/renderer/src/lib/pane-manager/pane-drop-no-op.test.ts
  • src/renderer/src/lib/pane-manager/pane-fit-resize-observer.test.ts
  • src/renderer/src/lib/pane-manager/pane-image-addon-attach.test.ts
  • src/renderer/src/lib/pane-manager/pane-initial-fit-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.test.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-reveal-repaint.test.ts
  • src/renderer/src/lib/pane-manager/pane-split-close.test.ts
  • src/renderer/src/lib/pane-manager/pane-split-scroll.test.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-gpu-acceleration.test.ts
  • src/renderer/src/lib/pane-manager/pane-tree-ops.test.ts
  • src/renderer/src/lib/pane-manager/pane-tree-reparent-frame.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-context-recovery.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.test.ts
🚧 Files skipped from review as they are similar to previous changes (19)
  • src/renderer/src/lib/pane-manager/pane-drop-no-op.test.ts
  • src/renderer/src/lib/pane-manager/pane-tree-ops.test.ts
  • src/renderer/src/lib/pane-manager/pane-fit-resize-observer.test.ts
  • src/renderer/src/lib/pane-manager/pane-drag-reorder.test.ts
  • src/renderer/src/lib/pane-manager/pane-split-close.test.ts
  • src/renderer/src/lib/pane-manager/pane-initial-fit-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-gpu-acceleration.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.test.ts
  • src/renderer/src/components/terminal-pane/terminal-capability-replies.ts
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-context-recovery.test.ts
  • src/renderer/src/lib/pane-manager/pane-split-scroll.test.ts
  • src/renderer/src/lib/pane-manager/pane-container-listener-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-dom-creation.ts
  • src/renderer/src/lib/pane-manager/pane-reveal-repaint.test.ts
  • src/renderer/src/lib/pane-manager/pane-tree-reparent-frame.test.ts
  • package.json

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


📝 Walkthrough

Walkthrough

This pull request adds @xterm/addon-image and integrates ImageAddon into pane lifecycle management. ManagedPaneInternal stores nullable image addon state. Pane creation initializes this state. openTerminal configures and loads the addon, and disposePane disposes it. The default DA1 response advertises graphics support. Pane manager test fixtures include the new field, and new tests cover attachment and failure handling.

Merge Risk: 🔵 Low · up to 678da

Inline image support is enabled by default in live terminal panes, allowing terminal output to invoke additional image parsing, including alpha Kitty support. The change is mergeable with owner awareness because malformed or unusually heavy image streams could increase renderer resource or stability risk, although no specific exploitable defect is identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the feature, rationale, implementation details, limitation, review status, and automated testing. However, it omits the required linked issue and visual proof section, and man… Add a valid issue reference under a Linked Issue section, such as Fixes #123``. Add before-and-after screenshots or videos for the UI behavior, or state N/A with a brief reason if visual proof is not applicable. Complete the required test…
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 20 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 and concisely describes the primary change: adding inline image support through SIXEL, iTerm2 IIP, and Kitty graphics protocols.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the feature, rationale, implementation details, limitation, review status, and automated testing. However, it omits the required linked issue and visual proof section, and manual smoke testing remains pending.

Resolution

Add a valid issue reference under a Linked Issue section, such as Fixes #123``. Add before-and-after screenshots or videos for the UI behavior, or state N/A with a brief reason if visual proof is not applicable. Complete the required testing checklist after running the manual smoke tests, or explain why they are not required.

Full details: Docstring Coverage

Explanation

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


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: Pro

Run ID: 01cbf973-c1c9-422d-bcbb-728bf6bd844e

📥 Commits

Reviewing files that changed from the base of the PR and between a09a00f and f23eadfa52264c70eeb11d800c0c0eabacc748ec.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • package.json
  • src/renderer/src/components/settings/TerminalSettingsPreview.tsx
  • src/renderer/src/lib/pane-manager/pane-container-listener-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-dom-creation.ts
  • src/renderer/src/lib/pane-manager/pane-drag-reorder.test.ts
  • src/renderer/src/lib/pane-manager/pane-drop-no-op.test.ts
  • src/renderer/src/lib/pane-manager/pane-fit-resize-observer.test.ts
  • src/renderer/src/lib/pane-manager/pane-initial-fit-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.test.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-reveal-repaint.test.ts
  • src/renderer/src/lib/pane-manager/pane-split-close.test.ts
  • src/renderer/src/lib/pane-manager/pane-split-scroll.test.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-gpu-acceleration.test.ts
  • src/renderer/src/lib/pane-manager/pane-tree-ops.test.ts
  • src/renderer/src/lib/pane-manager/pane-tree-reparent-frame.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-context-recovery.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.test.ts

Comment on lines +178 to +193
// Why: image addon for protocol parity with live panes.
try {
const imgAddon = new ImageAddon({
enableSizeReports: false,
sixelSupport: true,
sixelScrolling: true,
iipSupport: true,
kittySupport: true,
storageLimit: 16,
showPlaceholder: true
})
terminal.loadAddon(imgAddon)
imageAddonRef.current = imgAddon
} catch (err) {
console.warn('[settings preview] image addon failed to attach', err)
}

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Dispose imgAddon on loadAddon failure for consistency with the ligatures pattern.

If new ImageAddon(...) succeeds but terminal.loadAddon(imgAddon) throws, the addon instance is not disposed — the ligatures addon handler at lines 286–289 calls addon.dispose() in its catch block. Follow the same pattern here to avoid a potential resource leak and keep the two addon attachment paths consistent.

🛡️ Proposed fix
       try {
         const imgAddon = new ImageAddon({
           enableSizeReports: false,
           sixelSupport: true,
           sixelScrolling: true,
           iipSupport: true,
           kittySupport: true,
           storageLimit: 16,
           showPlaceholder: true
         })
-        terminal.loadAddon(imgAddon)
-        imageAddonRef.current = imgAddon
+        try {
+          terminal.loadAddon(imgAddon)
+          imageAddonRef.current = imgAddon
+        } catch (loadErr) {
+          imgAddon.dispose()
+          throw loadErr
+        }
       } catch (err) {
         console.warn('[settings preview] image addon failed to attach', err)
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Why: image addon for protocol parity with live panes.
try {
const imgAddon = new ImageAddon({
enableSizeReports: false,
sixelSupport: true,
sixelScrolling: true,
iipSupport: true,
kittySupport: true,
storageLimit: 16,
showPlaceholder: true
})
terminal.loadAddon(imgAddon)
imageAddonRef.current = imgAddon
} catch (err) {
console.warn('[settings preview] image addon failed to attach', err)
}
// Why: image addon for protocol parity with live panes.
try {
const imgAddon = new ImageAddon({
enableSizeReports: false,
sixelSupport: true,
sixelScrolling: true,
iipSupport: true,
kittySupport: true,
storageLimit: 16,
showPlaceholder: true
})
try {
terminal.loadAddon(imgAddon)
imageAddonRef.current = imgAddon
} catch (loadErr) {
imgAddon.dispose()
throw loadErr
}
} catch (err) {
console.warn('[settings preview] image addon failed to attach', err)
}

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

♻️ Duplicate comments (1)
src/renderer/src/lib/pane-manager/pane-lifecycle.ts (1)

56-62: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Missing try/catch around ImageAddon construction and loading — still unaddressed.

This concern was raised in a previous review: new ImageAddon(...) or terminal.loadAddon(...) can throw since this is a beta addon (Kitty support noted as alpha upstream). If it fails, openTerminal aborts entirely and the user gets no terminal pane. The settings preview that previously served as the comparison point has been removed, but the core risk remains — image rendering is non-essential and should degrade gracefully.

🛡️ Proposed fix: wrap ImageAddon in try/catch
   // Storage capped at 64MB (half default) since Orca may have many panes.
-  const imageAddon = new ImageAddon({ enableSizeReports: false, storageLimit: 64 })
-  terminal.loadAddon(imageAddon)
-  pane.imageAddon = imageAddon
+  try {
+    const imageAddon = new ImageAddon({ enableSizeReports: false, storageLimit: 64 })
+    terminal.loadAddon(imageAddon)
+    pane.imageAddon = imageAddon
+  } catch (err) {
+    console.warn('[pane] image addon failed to attach', err)
+  }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cb358114-8eec-4d33-912a-4eef5534b42c

📥 Commits

Reviewing files that changed from the base of the PR and between f23eadfa52264c70eeb11d800c0c0eabacc748ec and 71c36a055f1bd89f7b5f4738ec671884fbbdcc7c.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-capability-replies.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts

@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 9, 2026 16:52
@s546126
s546126 force-pushed the s546126/kitty-graphics-protocol branch from 71c36a0 to 97cb660 Compare July 20, 2026 16:18
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:40
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
@naoto13

naoto13 commented Jul 28, 2026

Copy link
Copy Markdown

This is exactly the feature I’m looking for

@s546126
s546126 force-pushed the s546126/kitty-graphics-protocol branch from 97cb660 to 0851150 Compare August 9, 2026 08:00
@coderabbitai

coderabbitai Bot commented Aug 9, 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.

@s546126

s546126 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@OrcaWin This is ready for review — rebased onto latest main (post-#13312), conflicts resolved (pane-lifecycle.ts ligatures refactor + lockfile regenerated), typecheck clean and 720 pane-manager/capability-reply tests passing on Node 24.

@coderabbitai

coderabbitai Bot commented Aug 19, 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.

@cursor
cursor Bot force-pushed the s546126/kitty-graphics-protocol branch from 37cdeb4 to fd60a83 Compare August 31, 2026 15:35
@coderabbitai

coderabbitai Bot commented Aug 31, 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.

1 similar comment
@coderabbitai

coderabbitai Bot commented Aug 31, 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.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds inline terminal image rendering through the xterm image addon and updates device capability negotiation to advertise SIXEL support.

  • Loads a bounded ImageAddon instance for each live terminal pane while isolating attachment failures.
  • Advertises a SIXEL-capable default DA1 identity while preserving the native ConPTY response.
  • Adds lifecycle coverage and updates pane fixtures for image-addon ownership.

Confidence Score: 4/5

The PR should fix the capability mismatch before merging so panes that fail to initialize image support do not advertise SIXEL to terminal applications.

Image-addon initialization is intentionally allowed to fail without aborting the pane, but DA1 negotiation still claims graphics support and can cause probing applications to emit image protocols that the surviving text-only pane cannot render.

Files Needing Attention: src/renderer/src/components/terminal-pane/terminal-capability-replies.ts and src/renderer/src/lib/pane-manager/pane-lifecycle.ts

Important Files Changed

Filename Overview
src/renderer/src/lib/pane-manager/pane-lifecycle.ts Adds best-effort ImageAddon attachment and pane-level disposal; failure isolation creates a capability-state mismatch with the unconditional DA1 response.
src/renderer/src/components/terminal-pane/terminal-capability-replies.ts Changes the default DA1 identity to advertise SIXEL unconditionally, including panes where image-addon initialization failed.
src/renderer/src/lib/pane-manager/pane-manager-types.ts Adds nullable ownership of the image addon to the internal pane lifecycle state.
src/renderer/src/lib/pane-manager/pane-image-addon-attach.test.ts Covers successful attachment and graceful constructor/load failures, but not DA1 behavior after those failures.
package.json Adds the renderer-bundled image addon using the same devDependency convention as sibling xterm addons.
pnpm-lock.yaml Locks the compatible image addon package and xterm peer dependency.

Reviews (1): Last reviewed commit: "test(terminal): use T[] for image-addon ..." | Re-trigger Greptile

// registered after the addon's own DA1 handler and therefore pre-empts it
// (xterm dispatches CSI handlers newest-first). The reply must advertise the
// graphics support itself or sixel-probing tools (lsix, chafa) never emit.
export const DEFAULT_DA1_RESPONSE = '\x1b[?62;4;9;22c'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 DA1 overstates image support

When ImageAddon construction or loading fails, the pane remains open without an image handler, but this unconditional DA1 response still advertises SIXEL support. Probing applications such as lsix or chafa then emit image sequences the pane cannot render, producing missing images or unusable terminal output instead of selecting a fallback.

Knowledge Base Used: Terminal runtime and interaction

@cursor
cursor Bot force-pushed the s546126/kitty-graphics-protocol branch 3 times, most recently from 5350592 to 9576ae4 Compare September 7, 2026 15:26
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]>
@cursor
cursor Bot force-pushed the s546126/kitty-graphics-protocol branch 2 times, most recently from b9418c7 to b8fd634 Compare September 9, 2026 15:08
s546126 and others added 7 commits September 10, 2026 15:39
…l inline images

Adds @xterm/addon-image to live panes and the settings preview terminal
so inline image output renders alongside existing SIXEL/IIP/Kitty escape
sequences. No new settings toggle: enabled by default like other addons.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…gle-voiced

Review fixes for the image addon integration:

- Advertise sixel in DA1: Orca's capability responder pre-empts the image
  addon's own DA1 handler (registered later, dispatched first), so probing
  tools like lsix never saw graphics support. DEFAULT_DA1_RESPONSE now
  reports the sixel-capable identity the addon would have sent.
- Disable enableSizeReports: xterm's built-in CSI 14t/16t/18t responder
  duplicated Orca's existing pixel-size responder, sending two replies per
  query (stray-input class stablyai#7329).
- Drop ImageAddon from the settings preview: PREVIEW_BUFFER contains no
  image sequences and stdin is disabled, so it was dead weight per mount.
- Trim addon options to the two that differ in intent from upstream
  defaults.

Co-Authored-By: Claude Fable 5 <[email protected]>
A beta addon construct/load error must not abort openTerminal. Dispose a
half-attached instance and keep the text pane usable, matching WebGL/ligatures.

Co-authored-by: s546126 <[email protected]>
Rebase onto current main dropped pnpm-lock.yaml; re-add
@xterm/[email protected] against main's current xterm patch hash.

Co-authored-by: s546126 <[email protected]>
Satisfies the typescript/array-type lint on the new attach isolation tests.
ImageAddon construct/load failures leave a text-only pane, but DA1 still
claimed sixel via DEFAULT_DA1_RESPONSE. Resolve the identity from the
public pane's hasImageSupport flag so probing tools fall back instead of
emitting unrenderable sequences.

Co-authored-by: s546126 <[email protected]>
A new main fixture landed after the previous merge-base and must include the nullable image addon field.

Co-authored-by: s546126 <[email protected]>
@cursor
cursor Bot force-pushed the s546126/kitty-graphics-protocol branch from b8fd634 to 7264d47 Compare September 10, 2026 15:39
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 three-protocol image integration and adds coordinated loading, capability signaling, and resource limits.

@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

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants