Skip to content

fix(tui): detect Orca image support - #2454

Open
XRX193 wants to merge 1 commit into
MoonshotAI:mainfrom
XRX193:fix/orca-inline-images
Open

XRX193 wants to merge 1 commit into
MoonshotAI:mainfrom
XRX193:fix/orca-inline-images

Conversation

@XRX193

@XRX193 XRX193 commented Jul 31, 2026

Copy link
Copy Markdown

Related Issue

No Kimi issue. This completes client-side compatibility for stablyai/orca#11668 and stablyai/orca#11706.

Problem

Orca exports TERM_PROGRAM=Orca and is adding Kitty graphics support, but Kimi Code treats it as an unknown terminal and falls back to text instead of displaying inline images.

What changed

  • Recognize Orca as supporting Kitty inline images, true color, and OSC 8 hyperlinks.
  • Preserve the existing tmux and screen precedence.
  • Add a regression test and package/CLI changesets.

Tested with pnpm --filter @moonshot-ai/pi-tui test (716 passing) and pnpm --filter @moonshot-ai/pi-tui typecheck.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6b47eee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/pi-tui Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78e23ae82b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/pi-tui/src/terminal-image.ts Outdated
@XRX193

XRX193 commented Sep 29, 2026

Copy link
Copy Markdown
Author

Refreshing this with the upstream dependency now resolved: the Orca-side capability advertisement has landed.

stablyai/orca#19512 merged on 2026-09-18 (09073086a8) and exports ORCA_IMAGE_PROTOCOL=kitty on all three PTY spawn paths — daemon subprocess, local provider, and relay handler — with the variable forwarded across the WSL boundary. That's the signal this PR gates on, and the contract is unchanged: images stay off unless both TERM_PROGRAM=Orca and ORCA_IMAGE_PROTOCOL=kitty are present, so Orca releases predating #19512 keep the text fallback rather than reserving blank image rows.

That closes the loop on the concern raised in the earlier review — the gating is on a capability Orca now actually advertises, not on an open upstream PR.

Branch state: still mergeable against current main, no conflicts. Happy to rebase or narrow the scope if the maintainers would prefer this routed differently. The equivalent change is also proposed for the sibling TUI in earendil-works/pi#9329.

Orca sets TERM_PROGRAM=Orca, which no branch recognises, so inline images
fell back to the text placeholder. Orca supports the Kitty graphics protocol
but only advertises it out-of-band via ORCA_IMAGE_PROTOCOL; require both
signals so releases predating that advertisement keep the text fallback
instead of reserving image rows nothing renders.

The check sits with the other outer-terminal detectors, ahead of the
KITTY_WINDOW_ID branch, because that variable leaks into Orca panes.
@XRX193
XRX193 force-pushed the fix/orca-inline-images branch from d92fbd7 to 6b47eee Compare October 29, 2026 07:02
@XRX193

XRX193 commented Oct 29, 2026

Copy link
Copy Markdown
Author

Rebased onto current main (89e07b81). Head is now 6b47eee9, one commit, mergeable again.

The conflict was structural, not semantic. packages/pi-tui/src/terminal-image.ts gained two outer-terminal detectors at exactly the slot this branch inserts its Orca check:

  • #10573 — herdr
  • #11131 — rex

The Orca check now sits after rex and still ahead of the KITTY_WINDOW_ID branch, for the same reason as the others: that variable can leak into Orca panes, so first-match wins has to reach the explicit-capability block before the ambient one. detectCapabilities keeps its exported name — only the internal helper was renamed to detectCapabilitiesFromEnvironment, so the test file needed the new env key and nothing else.

Diff is a pure addition, +32/-0 across 4 files: one source block (+6), two tests plus the env key (+16), and two changesets (+5 each).

Verification — full packages/pi-tui suite at this head, Windows 11 / Node 22.22.2:

node --test test/*.test.ts
# tests 1145   # pass 1139   # fail 5   # skipped 1

All 5 failures reproduce identically on unmodified 89e07b81 (1143 / 1137 / 5), so none are introduced here:

  • Linux ARM64 prebuild supports 64 KB system pages
  • uses the native platform helper directly as the clipboard API
  • Linux loads X11 lazily and rechecks DISPLAY
  • imageFallback → 2 cases, hardcoded POSIX path separators on Windows

The two new Orca cases pass: TERM_PROGRAM=Orca alone stays images: null; with ORCA_IMAGE_PROTOCOL=kitty it resolves to kitty plus hyperlinks.

Still zero required check runs on this fork head, so GitHub reports blocked — the only remaining gate is a maintainer triggering CI.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b47eee96f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


// Orca advertises Kitty graphics support through ORCA_IMAGE_PROTOCOL. Check it before
// outer-terminal detection because variables like KITTY_WINDOW_ID can leak into its panes.
if (termProgram === "orca" && process.env['ORCA_IMAGE_PROTOCOL'] === "kitty") {

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 Badge Add an upstream intent card for Orca detection

This adds a new local capability-detection behavior to the vendored fork, but the commit leaves packages/pi-tui/UPSTREAM.md unchanged and none of its existing intent cards covers Orca image detection. The next upstream reconstruction therefore has no decision/why-not-in-app record telling maintainers to preserve this branch; add the mandatory intent card alongside the test before landing.

AGENTS.md reference: packages/pi-tui/AGENTS.md:L11-L17

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T07:08:16.417400Z 6b47eee New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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