feat(terminal): support inline images - #11706
Conversation
Greptile SummaryThis PR adds inline image support to Orca's terminal panes by integrating the official
Confidence Score: 5/5Safe to merge. Changes are renderer-only and additive: a new xterm addon is instantiated per pane with explicit memory bounds and disposed on pane close, and an environment variable is injected into all three PTY spawn paths to advertise capability to TUIs. All three PTY spawn paths are consistently updated. The ImageAddon follows the same creation/load/dispose lifecycle pattern as every other addon in the codebase. Memory is bounded at multiple layers (per-image payload cap, pixel limit, per-pane FIFO storage cap). SIXEL is explicitly disabled. Test coverage verifies the constructor options, load order, and disposal. No IPC, authentication, filesystem, or network code was touched. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/lib/pane-manager/pane-dom-creation.ts | Adds ImageAddon instantiation with bounded options (8 MB payload cap, 4 MP pixels, 16 MB storage, FIFO eviction). SIXEL is explicitly disabled. The addon is always created and assigned to the pane object. |
| src/renderer/src/lib/pane-manager/pane-lifecycle.ts | Loads imageAddon after terminal.open() and before WebGL attachment (consistent with other addon ordering). Disposes it in disposePane() using the same try/catch pattern as all other addons. |
| src/renderer/src/lib/pane-manager/pane-manager-types.ts | Adds optional imageAddon?: ImageAddon to ManagedPaneInternal. Not surfaced on the public ManagedPane type, consistent with webglAddon and ligaturesAddon. |
| src/main/providers/local-pty-provider.ts | Adds ORCA_IMAGE_PROTOCOL: 'kitty' to the PTY spawn environment. Consistent with the other two spawn paths. |
| src/main/daemon/pty-subprocess.ts | Adds ORCA_IMAGE_PROTOCOL: 'kitty' to the daemon subprocess environment, advertising Kitty graphics capability to TUIs running under the daemon path. |
| src/relay/pty-handler.ts | Adds ORCA_IMAGE_PROTOCOL: 'kitty' to the relay PTY spawn environment, completing the three-path coverage for the environment variable advertisement. |
| src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts | New test verifies loadAddon:image is called during openTerminal and that imageAddon.dispose() is called exactly once on pane disposal. |
| src/renderer/src/lib/pane-manager/pane-dom-creation.test.ts | New test verifies that all ImageAddon constructor options match the intended bounds (pixelLimit, storageLimit, size caps, sixelSupport: false, iipSupport: true, kittySupport: true). |
Sequence Diagram
sequenceDiagram
participant Shell as Shell / TUI
participant PTY as PTY Provider
participant Renderer as Renderer createPaneDOM
participant xterm as xterm.js Terminal
participant ImageAddon as ImageAddon
PTY->>Shell: "spawn(env: {ORCA_IMAGE_PROTOCOL: 'kitty', ...})"
Note over Shell: TUI detects Kitty graphics support
Renderer->>ImageAddon: "new ImageAddon({pixelLimit, storageLimit, kittySizeLimit, iipSizeLimit, ...})"
Renderer->>xterm: new Terminal(opts)
Renderer->>xterm: terminal.open(xtermContainer)
Renderer->>xterm: loadAddon(fitAddon)
Renderer->>xterm: loadAddon(imageAddon)
Renderer->>xterm: loadAddon(searchAddon, ...)
Renderer->>xterm: attachWebgl(pane)
Shell-->>xterm: Kitty / iTerm2 image escape sequences
xterm->>ImageAddon: decode and render (RGBA canvas overlay)
Note over ImageAddon: Bounded: 8MB payload, 4MP pixels, 16MB/pane FIFO
Note over Renderer: On pane close
Renderer->>ImageAddon: imageAddon.dispose()
Renderer->>xterm: terminal.dispose()
Reviews (2): Last reviewed commit: "fix(terminal): advertise inline image ca..." | Re-trigger Greptile
📝 WalkthroughWalkthroughAdds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
thanks for the PR. will review it. since it touches terminal, it will have a longer review time as we ensure it doesn't cause any functionality or performance regression for the terminal |
|
@coderabbitai review The linked-issue compatibility warning now has verified client follow-ups: MoonshotAI/kimi-code#2454 is open with 716/716 |
|
✅ Action performedReview finished.
|
Summary
Fixes #11668.
Screenshots
Not included. This change renders protocol output inside the existing terminal surface; the Electron renderer bundle and addon lifecycle are covered below, but the current Pi/Kimi releases do not emit image sequences for
TERM_PROGRAM=Orcayet (see Notes).Testing
pnpm lint- code-quality, type-aware, reliability, and max-lines gates passed; the command stopped on pre-existing stale generated skill manifests.pnpm typecheckpnpm test- 36/36 focused tests passed. The full suite hit the 15-minute limit with unrelated environment failures (restricted Electron download/network access, unavailable WSL, and denied system-directory writes).pnpm build-pnpm build:electron-vitepassed; native/release targets were not run.AI Review Report
Reviewed addon ownership, activation order, pane disposal, memory pressure, protocol scope, renderer bundling, and the capability negotiation used by Pi Code and Kimi Code. The review rejected globally spoofing Kitty/Ghostty environment variables because they could enable unrelated terminal-specific behavior. Instead, Orca keeps its existing
TERM_PROGRAM=Orcaidentity and the client allowlists need a small compatibility follow-up.Cross-platform review covered macOS, Linux, and Windows. This PR is renderer-only and adds no shortcut, label, path, shell, PTY-provider, or Electron platform branch. Local, SSH, WSL, and relay terminals all feed the same pane renderer, so protocol parsing is shared across execution hosts.
Security Audit
Terminal output is untrusted input. The addon is the official xterm implementation rather than a custom decoder, SIXEL is disabled because it is outside this issue, sequence payloads are capped at 8 MB, decoded images at roughly 4 million pixels, and retained storage at 16 MB per pane with FIFO eviction. Image storage is explicitly disposed when a pane closes.
No command execution, filesystem path handling, IPC, authentication, credentials, secrets, or network requests were added.
Notes
Orca keeps its existing
TERM_PROGRAM=Orcaidentity and does not setKITTY_WINDOW_IDor impersonate another terminal. Client-side compatibility is tracked by verified follow-ups:pi-tuisuite passes 716/716 tests and type-checks.pi-tuibuild pass. A PR will be opened after the required maintainerlgtm.