Skip to content

fix(terminal): enable Codex CLI image previews - #44920

Merged
nwparker merged 5 commits into
mainfrom
nwparker/codex-cli-img-preview
Nov 20, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/codex-cli-img-preview

Conversation

@nwparker

@nwparker nwparker commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Pasting an image into Codex in an Orca terminal now shows the thumbnail above the prompt so you can see which image you attached.

Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​341 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​330
Prod 47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​407 $\color{#cf222e}{\Huge{\mathbf{−}}}$​275 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​132

What Changed

Orca enables Codex's existing Kitty image path when a terminal starts with inline images enabled and its viewer supports them. For codex typed in an Orca shell, the shell function supplies a synthetic KITTY_WINDOW_ID=0 for the Codex invocation. Managed launches use the same compatibility hint through the shell function or a wrapper around a recognized literal Codex command. An explicitly supplied window ID takes precedence.

Orca now stamps ORCA_IMAGE_PROTOCOL=kitty centrally and clears it when the launch settings or viewer disable graphics. Pi can consume the same hint through its upstream support. Orca’s shell wrapper also enables Claude’s image flag for a typed Claude invocation. Paired splits and plain-shell worktree and folder creation use the viewer's negotiated image capability. The terminal reference documents the graphics and hyperlink signals and their behavior under tmux.

Why

Codex accepts the pasted attachment in Orca but suppresses the thumbnail when terminal detection reports Orca. The existing renderer already handles the raster graphics Codex emits. The compatibility value enables that path while preserving the terminal identity and terminfo Orca advertises. Codex can eventually select Kitty through terminal capability detection directly. The upstream reports are Codex image detection and Codex OSC 8 detection.

Linked Issue

Related to #6880 (terminal capability detection) and #25913 (previews for pasted or dropped images). This covers the Codex CLI case.

Visual Proof

Same clipboard image and Codex CLI 0.170.0 on macOS.

Before After
Codex composer with the image label Codex composer with the thumbnail above the image label

Testing

  • In a hidden Orca dev instance on macOS, started Codex CLI 0.170.0 by typing codex in a fresh terminal. Pasted a PNG with Cmd+V and inspected the rendered thumbnail. Backspace removed both the attachment and the thumbnail.

  • Repeated the paste through Orca's Codex quick launch. With inline images disabled, a fresh terminal displayed the attachment label.

  • The shell regression test verifies scoped environment injection, a preexisting value, and the disabled case. Ran the shell tests with Bash, Zsh, Fish, and PowerShell 7 on macOS.

  • pnpm check:changed passed its static checks against origin/main. Its related-test selection expanded to 1,564 files. I ran the focused Codex launch, shell, remote viewer, spawn-environment, and daemon compatibility tests locally.

  • Verified a newly opened Orca terminal advertises Kitty and returns a successful graphics query with Inline Images enabled. Disabling the setting removes the hint and the Kitty reply.

  • The review follow-up passed scoped suites and executable checks with fish 3.3.1 and PowerShell 7.4.7. WSL checks exercised generated launch plans.

  • Verified paired split and plain-workspace launch routing in RPC, runtime, and renderer integration tests. Live paired desktop and mobile rendering remain unverified.

Risk

Low. The synthetic window ID is scoped to the Codex process and its children. Command Prompt, custom launchers, and some legacy SSH startup commands use Codex's existing detection. Viewer support and the inline-images setting are evaluated when the terminal is created.

Review

The change uses Orca's existing viewer capability and shell launch paths. WSL forwards the preview hint to the guest. Paired callers without image support and headless launches without a supported viewer do not get the compatibility hint. macOS was verified end to end. Windows, native Linux, SSH, and mobile were reviewed at the launch boundary.

Agent skill upstream boundary

  • Not applicable.

paste-before

paste-after

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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
Walkthrough

PTY launch assembly now configures terminal image environment values based on viewer support, inline-image settings, and host type. Codex and Claude shell wrappers respond to the image protocol, and Codex startup commands can receive scoped Kitty window ID setup. WSL launch paths forward the Kitty window ID when it is present in both relevant environments. Workspace creation and terminal split flows pass viewer support and split environment values to new terminals. The daemon protocol and local-build compatibility contract advance to version 61. Tests and documentation cover the updated behavior.

Merge Risk: Moderate · up to 730aa

Splits started through the terminal.split RPC or by agent teams can lose the environment variables the caller supplied when viewer support is unknown, which is the default path in shipped builds. Fix the env forwarding in terminal-split.ts before merging. The workspace-trust settings-snapshot concern remains open with low impact.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(terminal): enable Codex CLI image previews" matches the main change. The PR makes Codex's existing Kitty image path active in Orca terminals when inline images are enabled, so pasted im…
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.
Description check Passed The description follows the template well. It has a clear ELI5, a detailed What Changed section, a Why section with upstream references, a linked issue (related issues #6880 and #25913 are cited, thou…
Full details: Title check

Explanation

The title "fix(terminal): enable Codex CLI image previews" matches the main change. The PR makes Codex's existing Kitty image path active in Orca terminals when inline images are enabled, so pasted images show thumbnails. The title is specific and concise, and it follows a conventional commit style.

Full details: Description check

Explanation

The description follows the template well. It has a clear ELI5, a detailed What Changed section, a Why section with upstream references, a linked issue (related issues #6880 and #25913 are cited, though the template says 'Fixes #' and the author uses 'Related to'), visual proof with before/after images, a Testing section with concrete steps on macOS plus shell tests across Bash, Zsh, Fish, and PowerShell, a Risk section with a Low level and scope explanation, and a Review section. The AI Disclosure section is empty, and the Agent skill upstream boundary box is checked. The Risk section does not say how to back the change out (a plain revert or otherwise), which the template asks for. The Linked Issue section does not use a 'Fixes #' closing reference, and the 'Related to' wording is a weaker link than the template's 'Fixes #' expectation for outside contributors. The description is mostly complete, so it passes despite these gaps.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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 · Read workspace trust from the settings in effect at the trust… · spawn-options-assembly.ts:223

src/main/ipc/pty/spawn/spawn-options-assembly.ts:223
Minor · Security & Privacy · Quick win

Read workspace trust from the settings in effect at the trust call.

settings is captured at line 154, before the await at line 193. The trust decision at line 223 uses that earlier object. If the user disables automatic workspace trust while the Codex no-daemon launch plan is pending, this launch can still write a workspace trust entry. Read the settings again for the trust call. Keep the earlier read for history isolation and image environment.

Suggested fix

-    settings,
+    settings: input.getSettings?.(),
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c1893d9-3399-4693-a433-f48edce8ef25
Commits

Reviewing files that changed from the base of the PR and between 99237f9 and 3c1ab1b.

Files selected for processing: 17

  • docs/site/content/docs/terminal.mdx
  • src/main/daemon/pty-subprocess/spawn-environment.ts
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/host-env/spawn-host-env.ts
  • src/main/ipc/pty/host-env/types.ts
  • src/main/ipc/pty/provider/local-configure.ts
  • src/main/ipc/pty/spawn/spawn-options-assembly.ts
  • src/main/ipc/pty/spawn/terminal-image-environment.test.ts
  • src/main/ipc/pty/spawn/terminal-image-environment.ts
  • src/main/providers/local-pty/local-pty-spawn-environment.ts
  • src/main/pty/shell-startup/codex-shell-no-daemon.test.ts
  • src/main/pty/shell-startup/wsl-orca-env.ts
  • src/main/runtime/terminal/launch/remote-viewer-launch-env.ts
  • src/main/runtime/terminal/launch/terminal-image-viewer-env.ts
  • src/shared/shell/launch/agents/claude-shell-function.ts
  • src/shared/shell/launch/agents/codex-shell-function.ts
  • src/shared/terminal/images/terminal-image-protocol.ts
Files with no reviewable changes: 6

  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/host-env/spawn-host-env.ts
  • src/main/ipc/pty/host-env/types.ts
  • src/main/ipc/pty/provider/local-configure.ts
  • src/main/pty/shell-startup/wsl-orca-env.ts
  • src/main/runtime/terminal/launch/terminal-image-viewer-env.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3537d57-56dd-49ac-b1b3-e688162176a4
Commits

Reviewing files that changed from the base of the PR and between f09fe12 and 730aa83.

Files selected for processing: 26

  • src/main/ipc/pty/spawn/terminal-image-environment.test.ts
  • src/main/runtime/client/events/runtime-notifier-contract.ts
  • src/main/runtime/repositories/runtime-project-group-controller.ts
  • src/main/runtime/rpc/methods/terminal/terminal-lifecycle-methods.ts
  • src/main/runtime/rpc/methods/workspaces/folder-workspace.ts
  • src/main/runtime/terminal/launch/paired-terminal-creator.test.ts
  • src/main/runtime/terminal/launch/runtime-agent-terminal-startup.ts
  • src/main/runtime/terminal/launch/terminal-split-in-main.ts
  • src/main/runtime/terminal/launch/terminal-split-surface.ts
  • src/main/runtime/terminal/launch/terminal-split.ts
  • src/main/runtime/workspaces/creation/orca-runtime-worktree-provisioning-availability.test.ts
  • src/main/runtime/workspaces/creation/runtime-folder-worktree-create.ts
  • src/main/runtime/workspaces/creation/runtime-group-folder-setup-host.ts
  • src/main/runtime/workspaces/creation/runtime-group-folder-setup.ts
  • src/main/runtime/workspaces/startup/runtime-local-worktree-terminal-startup.ts
  • src/main/runtime/workspaces/startup/runtime-worktree-terminal-provisioning.ts
  • src/main/runtime/workspaces/startup/workspace-activation.ts
  • src/main/window/runtime-window-lifecycle.ts
  • src/preload/api/window-ui/ui-bridge-terminal-and-session-tabs.ts
  • src/preload/api/window-ui/ui-command-event-api.ts
  • src/renderer/src/components/terminal-pane/layout/split/pane-split-startup.ts
  • src/renderer/src/components/terminal-pane/mounting/terminal-pane-mount-events.ts
  • src/renderer/src/constants/terminal.ts
  • src/renderer/src/hooks/ipc-events/terminal/terminal-ui-routing-ipc-bridge-split.test.ts
  • src/renderer/src/hooks/ipc-events/terminal/terminal-ui-routing-ipc-bridge.ts
  • src/shared/workspace-layout/terminal-topology/renderer-terminal-split-request.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

this.notifier?.splitTerminal(leaf.tabId, leaf.paneRuntimeId, {
direction,
command: opts.command,
...(opts.terminalImageViewerSupported !== undefined ? { env: opts.env } : {}),

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.

Major · Data Integrity & Integration · Quick win

Forward caller env on the renderer-owned split path regardless of viewer support.

The renderer-owned branch drops opts.env whenever terminalImageViewerSupported is undefined. The viewer flag controls only the image hint. It does not control the caller's own environment. The RPC terminal.split handler sends env without the flag when viewer support is unknown (terminal-lifecycle-methods.ts:150-173). The agent-teams split also sends paneEnv without the flag (claude-agent-teams-pane-layout.ts:78-85). In shipped builds this branch is the default, so those splits start without the requested variables. The main-owned and live-PTY branches already forward env unconditionally, so the renderer branch should match them.

Suggested fix

--- "a/src/main/runtime/terminal/launch/terminal-split.ts"
+++ "b/src/main/runtime/terminal/launch/terminal-split.ts"
@@ -89,7 +89,7 @@
     this.notifier?.splitTerminal(leaf.tabId, leaf.paneRuntimeId, {
       direction,
       command: opts.command,
-      ...(opts.terminalImageViewerSupported !== undefined ? { env: opts.env } : {}),
+      ...(opts.env ? { env: opts.env } : {}),
       worktreeId: leaf.worktreeId,
       sourceLeafId: leaf.leafId,
       telemetrySource: opts.telemetrySource,
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
...(opts.terminalImageViewerSupported !== undefined ? { env: opts.env } : {}),
...(opts.env ? { env: opts.env } : {}),

@nwparker
nwparker merged commit 8c28ea1 into main Nov 20, 2026
70 checks passed
@nwparker
nwparker deleted the nwparker/codex-cli-img-preview branch November 20, 2026 01:51
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.

1 participant