Skip to content

fix(terminal): the terminal's owner answers colour queries for the terminal's whole life - #23925

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/codex-osc-colour-replies
Sep 30, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/codex-osc-colour-replies

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1161 $\color{#cf222e}{\Huge{\mathbf{−}}}$​188 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​973
Prod 55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​860 $\color{#cf222e}{\Huge{\mathbf{−}}}$​211 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​649

ELI5

Programs like Codex and Claude Code ask the terminal "what are your colours?" when they start, and pick their own colours from the answer. Orca only answered in some situations (a few seconds after a tab opened, or once a window was showing the tab), so late or background launches got no answer and drew their messages and prompt without the right background. Now whatever owns the terminal always answers, for the terminal's whole life, with the colours the pane is really painted with.

What Changed

What this fixes:

Scope: colour replies (OSC 10/11) in every terminal on macOS, Linux and Windows: local, terminal daemon, SSH relay, and headless hosts with paired desktop clients. Nothing about how panes are painted changes; only what programs are told when they ask.

Before: the host answered colour queries during a 5-second startup window, then handed them to whichever window was showing the tab. On Windows (ConPTY), late queries were swallowed with no reply. A tab nobody was showing got no reply at all.

After: the process that owns the terminal (the local provider, the terminal daemon, or the SSH relay) answers every colour query for the terminal's whole life, and removes it from the output so no window answers it a second time. It answers with, in order:

  1. colours the program itself set in that terminal (OSC 10/11, cleared by OSC 110/111);
  2. the theme of the Orca window on the host;
  3. on a headless host with no window, the theme a paired desktop client last reported (on connecting, on a theme change, and when its window gains focus);
  4. the host's saved theme settings;
  5. Orca's default dark theme.

The theme also reaches the host when you change theme or the OS switches light/dark with no terminal pane open. The terminal theme catalog moved into shared code, so the app, main process, daemon and relay resolve themes from one source.

Mechanism notes:

  • Terminal daemon protocol goes to v38. New tabs start on a fresh daemon that has this behaviour. Tabs already open on the old daemon keep the old behaviour until you open new ones.
  • SSH relays get an optional new notification carrying the theme. Older relays ignore it.
  • Paired clients report their colours through a new optional RPC method, terminal.setViewerColors. An older host answers "unknown method" and the client stops asking that connection. An older client never calls it; the colours it already sends when creating a terminal are used instead.
  • Window answerers stay as a fallback for a new app talking to an old host, which still hands queries to windows. A new owner never passes a query on, so there is still exactly one answer.
  • Echo handling: the owner's own late replies get a short echo watch (512 bytes). Replies relayed from the app keep the existing long watch.
  • Split queries: a query cut across two reads is released after 500 ms if the rest never arrives.

Why

  • One answerer, in the process that owns the terminal, is the only way every query gets exactly one reply. Answers were split between the host (early) and whichever window was showing the tab (later). That left gaps: a background tab, a late launch on Windows, a headless host before anyone attaches.
  • Why the host's own window wins over a paired client: the owner holds one colour pair per host. Letting the last client to report win meant a laptop reconnecting after sleep could change the colours Codex gets on the desktop you are sitting at. A headless host has no window of its own, so there the paired client's colours are the ones you see.
  • Alternatives considered:
  • This supersedes fix: provide terminal colors before headless agent startup #22501.

Known limits:

  • A desktop host you also use from a paired client with a different theme answers with the host's own theme, so a Codex started from the client gets the host's colours.
  • A headless host used from two paired clients with different themes answers with whichever client last reported.
  • A Codex that is already running keeps the colours it read at launch (Codex asks once).
  • A headless host used only from the phone app answers with the host's saved theme; the phone does not report its colours yet.
  • An older paired client on a new headless host: an agent started from its UI gets the host's saved theme until the client updates.
  • A reply that lands in bash's line editor at a cooked prompt can still be hidden there. The app's own replies already behaved the same way.

Linked Issue

Fixes #22332
Fixes #22500

Visual Proof

Tested live on the PR head against its base, each as a background dev build with its own profile.

Windows (#22332), Codex started in a terminal open more than 15 seconds. Before: your own message row has no shading. After: it has the grey band.

Before (base) After (this PR)
Windows before: Codex user message row unshaded Windows after: Codex user message row shaded grey

The same late terminal asked directly for its colours. Before: no reply at all. After: one reply per query, matching the painted theme.

Before (base) After (this PR)
Windows before: colour probe gets 0 replies Windows after: colour probe gets 2 replies with the dark theme colours

Headless host + light-theme desktop client (#22500), Codex started from the Orca UI in a background tab. Before: the composer has no background. After: it has the light shaded band.

Before (base) After (this PR)
Headless before: Codex composer has no background Headless after: Codex composer has a light shaded band

A late colour query on the headless host answers with the light client's colours. A desktop host keeps answering with its own dark theme after a light client connects.

Headless host, light client Desktop host's own window
Headless host answers the light client colours Desktop host answers its own dark theme

Testing

  • I manually tested these changes locally

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

  • 26 test files covering this change pass (1,604 tests), including real fish, bash and zsh PTY tests and the full runtime suite, on the branch merged with current main.

  • New tests cover: late queries, a headless host before any window attaches, one reply per query, app-set colour overrides and resets, the host window winning over a paired client, a headless host taking a paired client's colours, the paired-client push (connect, change, focus, older host), the echo watch for relayed replies, split fragments, the daemon protocol gate, and the relay push including a resend on reconnect.

  • A differential fuzz (500,000 randomized chunk splits) shows the faster query scan emits byte-identical output to the previous scan.

  • Typecheck clean (node, web, cli); oxlint, oxfmt and the changed-code quality gate clean.

  • Live: Windows 11 (terminal daemon + ConPTY, real Codex 0.159.0) and macOS (headless orca serve host paired to a light-theme desktop client, real Codex 0.158.0), each PR head vs its base. Not run live: SSH relay, WSL, the phone app, and a non-daemon ConPTY terminal (every normal pane on that build was daemon-backed).

AI Disclosure

Review

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

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Performance: the whole-life scan only looks at ESC ] starts once the first few seconds are over. Measured per 240 KB chunk of coloured output: about 0.5 ms (plain text about 0.01 ms).
  • Mixed versions: an old daemon or relay keeps its old behaviour. The theme push is sent only to v38 daemons, relays ignore the unknown notification, and an older host refuses the new RPC method without side effects.
  • Merge order: open PR fix(daemon): bump main to v38 so it doesn't reuse the 1.4.217 patch daemon #23908 also bumps the daemon protocol to v38. Whichever lands second must move to v39.
  • Security: reported colours are validated as colour values before use, so a paired client cannot inject escape sequences into replies. The new method is not available to mobile tokens.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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)

…le life

Codex and Claude's `theme: auto` ask the terminal for its foreground and
background colours (OSC 10/11) and pick their colours from the reply. Orca
answered in the process that owns the PTY only for agent launches and only
for 5 s; after that the query was handed to whichever viewer was attached.
On Windows ConPTY the owner kept swallowing the query but stopped answering
it, so a Codex started from an older shell tab lost its message shading
(#22332). On a headless `orca serve` host no viewer existed yet, so a Codex
started before anyone attached got no reply at all (#22500).

The owner (in-process provider, terminal daemon, SSH relay) now answers
every OSC 10/11 query for the PTY's whole life and strips it, so no
downstream view ever sees one to answer twice. It answers from, in order:
the host-wide viewer theme pushed to that process, the creating viewer's
colours sent at spawn (now for every PTY, not only agents), and Orca's
default dark theme. The desktop pushes its renderer theme to every owner
on change and on (re)connect: a daemon request gated on protocol v38, and
an SSH relay notification that older relays ignore. The answer-once rule,
the 5 s colour window and the colour-authority handoff are removed; Kitty
keyboard queries keep their startup window.

Viewer-side answerers (renderer xterm, main's hidden-pane model responder,
the mobile webview) stay as the fallback for older owners, which still hand
queries off; they are never reached for a new owner.
…ainted with

Review follow-ups to the lifetime PTY-owner colour answerer.

- The theme catalog moves to src/shared so the renderer and the PTY owners
  read one source; the owner's last-resort default is derived from it
  rather than copied.
- Main seeds every owner from the host's saved theme settings (light or
  dark, custom themes, colour overrides) at startup, so a headless host
  and a desktop pane that queries before the renderer's first push are
  not told dark to a light-theme user. The renderer's push replaces it.
- Colours an app sets with OSC 10/11, and clears with OSC 110/111, are
  tracked per terminal and reported back, as a viewer paints them; a theme
  change drops them, as a viewer's theme apply does.
- A terminal a paired client created with its own colours answers with
  those, not the host's theme (`colorSource: 'remote-viewer'` on the
  spawn intent), so a light client on a dark host is told light.
- After the 5 s startup window a reply's echo is watched for 512 bytes
  instead of 256 KB, and a torn query candidate is released after 500 ms
  rather than held indefinitely.
…e lookup

The 512-byte post-startup echo watch now applies only to replies the PTY
owner produced itself. A viewer's reply relayed through
answerLiveQueryReply keeps the 256 KB watch, because a cooked-mode app can
keep printing after it queries and the echo then trails that output.

The renderer's getTerminalTheme now calls the shared lookupTerminalTheme,
so the custom-vs-built-in theme lookup exists once.
Two indexOf searches per OSC went quadratic on long runs of ST-terminated
hyperlinks, and the tracker now sees every chunk of every terminal.
…acted last

A paired client's colours reached the host only as frozen spawn colours on
terminal.create, tagged remote-viewer. UI-started agent sessions on a headless
host answered OSC 10/11 with the host's saved theme, and a client's theme flip
never reached panes it had created.

The host now holds one viewer colour value that every PTY owner answers with.
The desktop renderer's push, a window focus on the host, the new
terminal.setViewerColors RPC, and terminal.create colours from older clients
all set it; equal values do not re-notify daemons or relays. The remote-viewer
tag (colorSource / terminalColorQuerySource / spawnFromRemoteViewer) is gone;
it never shipped in a release.
… change and focus

The renderer publisher now hands each published fg/bg to subscribers. A new
remote-runtime-terminal-color-push module calls terminal.setViewerColors on
every host this client is connected to when it connects (or the host restarts),
when the colours change, and when the window gains focus. A host that answers
method_not_found or forbidden is not asked again until it reconnects.

The app shell also republishes terminal view attributes on settings and system
theme changes, so a theme change reaches main and paired hosts with no
terminal pane open.
…own theme

Round 1 kept one host-wide viewer colour value set by whichever viewer acted
last, so a paired client's push (reconnect after sleep, a dusk theme flip)
took over the host desktop's own panes until its window regained focus.

The value is now derived: this host's renderer colours when a local window
has pushed, otherwise the last paired client's push (terminal.setViewerColors
or terminal.create colours), otherwise the saved theme. Only a headless host
takes a client's theme. The window-focus reassert and the identical-re-push
takeover are gone; owners are notified only when the derived value changes.
…y window closes

The PTY owner answers OSC 10/11 for the terminal's whole life, and it tried
every ESC as a query start: a 240 KB SGR-heavy read cost about 2 ms and 256 KB
of bare ESC about 15 ms, long after startup.

Once the Kitty query window closes only an OSC colour query can match, so the
scan jumps between ESC ] starts, plus a trailing lone ESC so a query torn right
after its ESC still resolves on the next read. Output and replies are
unchanged.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready (head 71bcf3b)

The problem: Codex and Claude Code ask the terminal for its colours when they start and shade their messages and prompt from the answer. Orca answered only during a 5-second startup window or from a window showing the tab. So on Windows a Codex started in a shell open more than 5 seconds lost the grey band on your own messages (#22332), and on a headless orca serve host a Codex started from a paired desktop's UI got no prompt background (#22500).

What changes for you: every terminal now answers colour queries for its whole life, with the colours it is painted in. On Windows, late Codex launches keep their message shading. On a headless host, Codex started from a paired desktop gets that desktop's theme. A desktop host always answers with its own window's theme, so a paired laptop can't change the colours on the machine you're sitting at.

Fixed during review (pushed):

  • The first version sent a paired client's colours only when it created a plain terminal, so [Bug]: New Codex sessions on headless runtimes can miss prompt background #22500's own case (an agent started from the UI) still got the host's saved theme, which is dark by default on a headless box. A headless host that used to pass late queries to the client's window also started answering dark. Fix: paired clients now report their terminal colours to the host through a new optional terminal.setViewerColors method (on connect, on a theme change, and on window focus), and a headless host answers with them.
  • A follow-up regression from that fix: a paired laptop reconnecting after sleep could change the colours Codex got on the host desktop's own panes. Fix: a host with its own Orca window always answers with its own theme; only a headless host uses a paired client's colours.
  • A theme or OS light/dark change made with no terminal pane open never reached the host, so later background launches got stale colours. It is now published.
  • Performance: the colour scanner went quadratic on output full of hyperlinks (33 ms per 256 KB chunk). It is now one linear pass (0.1 ms per 64 KB). The whole-life query scan now looks only at ESC ] once the first seconds are over (240 KB of coloured output: about 2 ms down to about 0.5 ms per chunk). A 500,000-case differential fuzz shows byte-identical output.
  • Merged current main. The daemon protocol is still v37 on main, so v38 here is correct.

Deferred (not blocking):

  • A desktop host you also use from a paired client with a different theme answers with the host's theme (intended; listed under Known limits).
  • A headless host used from two clients with different themes: last reporter wins, and switching clients drops colours a full-screen app set itself.
  • A headless host used only from the phone answers with the host's saved theme; the phone doesn't report its colours yet (follow-up: the phone app calls terminal.setViewerColors).
  • An older client on a new headless host gets the host's saved theme for UI-started agents until it updates.
  • A terminal.create retried after a theme change can reinstate the older colours on a headless host (narrow).
  • Minor: small edge cases where the colour tracker differs from xterm's parser; the headless seed isn't refreshed when the host's own settings change.

Before merging: open PR #23908 also bumps the daemon protocol to v38. Whichever lands second must move to v39.

Verified:

  • Live on Windows 11 (terminal daemon + ConPTY, real Codex 0.159.0) and macOS (headless host paired to a light-theme desktop client, real Codex 0.158.0), PR head against its base. On base: 0 replies to a late colour query and no shading. On this PR: exactly one reply per query with the painted colours, and correct shading in dark and light. On a desktop host, its own window still answered dark after a light client connected. Screenshots are in the description.
  • 26 test files (1,604 tests) on the branch merged with main; typecheck clean for node, web and cli; all CI green.

Not verified: SSH relay and WSL live runs; the phone app; a non-daemon Windows terminal (every normal pane was daemon-backed on that build). With the "system" theme under automation on Windows, one run showed a light pane answering dark. The code reads both from the same source, so this is most likely the test harness emulating light on one page, but it wasn't reproduced on a real OS switch.

@brennanb2025
brennanb2025 marked this pull request as ready for review September 30, 2026 00:11
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 2/5

[High risk] Rewires terminal color query handling across daemon and renderer.

The PR is not ready to merge because ordinary daemon reconnections can retain stale answer colours, theme reapplication can desynchronize app-set colours, and a partially failed combined reply is lost.

Findings

  1. P1 Theme update lost on reconnect ▶
  2. P1 Stale app-set colour survives theme ▶
  3. P1 Second colour reply can disappear ▶

Summary

The PR moves OSC 10/11 replies to PTY owners for the lifetime of each terminal, shares terminal-theme resolution across processes, and publishes viewer colours to daemons, SSH relays, and paired hosts.

  • Late and background queries now receive owner-generated replies instead of depending on a visible window.
  • Reconnection, theme reapplication, and partially failed combined replies need correction before merge.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  V[Desktop viewer or saved theme] --> R[Host colour store]
  C[Paired client] --> R
  R --> L[Local PTY owner]
  R --> D[Daemon owner]
  R --> S[SSH relay owner]
  L --> Q[OSC 10/11 reply]
  D --> Q
  S --> Q
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment on lines 45 to +49
if (isFreshConnection) {
this.resyncBackgroundedSessions()
// Why: a replacement daemon starts with no colours, and a disconnected push was dropped.
this.syncColorQueryReplyColors()
}

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 Theme update lost on reconnect

If the daemon socket drops while the theme changes, notify drops the colour update. Reconnecting to the same daemon keeps the existing event listener, so this isFreshConnection check skips the resend. Existing panes then answer later OSC 10/11 queries with the old theme until another colour change is published.

Comment on lines +61 to +66
resolve(base: TerminalOscColorQueryReplyColors): TerminalOscColorQueryReplyColors {
if (this.overridesBase !== null && this.overridesBase !== baseKey(base)) {
this.overrides = {}
this.overridesBase = null
}
return { ...base, ...this.overrides }

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 Stale app-set colour survives theme

If a theme apply changes another property, such as cursor appearance, but leaves foreground and background unchanged, xterm rebuilds its palette and clears colours set by the program. This tracker compares only the two base colours, so it retains the old override. Later OSC queries report a colour the pane no longer paints.

Comment on lines +307 to +312
private answerColorQuery(slots: readonly TerminalOscColorQuerySlot[]): boolean {
const replies = this.colorQueries.replies(slots)
return (
replies.length > 0 &&
replies.findIndex((reply) => !this.delivery.answer(reply, 'owner')) !== 0
)

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 Second colour reply can disappear

For a combined OSC 10/11 query, if the first reply is written but the second write fails, findIndex returns 1 and this method treats the query as answered. The ingress strips it from downstream output, leaving the program without a background-colour reply.

@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

  • One owner answers OSC 10/11 for the terminal's whole life — PtyStartupIngress now scans only ESC ] starts once the Kitty window closes, answers every colour query from a shared PtyOwnerColorQueryReplies (app-set overrides → host theme), and strips it so no downstream view answers twice. The old answeredSlots/queryOpen handoff is removed; a torn candidate is held 500 ms then released.
  • Shared theme source — the terminal theme catalog and selection rules move to src/shared/terminal-themes* + terminal-theme-selection.ts, so app, main, daemon and relay resolve colours from one place; ORCA_DEFAULT_COLOR_QUERY_REPLY_COLORS is the last-resort pair.
  • Viewer-colour precedence — terminal-view-attribute-store resolves own-window attrs ?? paired client ?? seeded settings; a paired push only overrides on a host with no window.
  • Push plumbing — main publishColorQueryReplyColors fans out to local/daemon/relay owners with dedupe, and the renderer (remote-runtime-terminal-color-push + use-terminal-viewer-color-publication) pushes to paired hosts on connect, theme change and focus.
  • Protocol — daemon PROTOCOL_VERSION 38, new gated setColorQueryReplyColors request, new pty.setColorQueryReplyColors relay notification, new terminal.setViewerColors RPC appended to the manifest, compatibility contracts bumped.

Scope of review: full diff plus three focused passes (ingress exactly-once, viewer-colour plumbing, mixed-version wire compatibility).

ℹ️ Rollout sequencing for the two v38 bumps

This PR and open PR #23908 both raise PROTOCOL_VERSION to 38. Whichever lands second must move to v39, otherwise a daemon built with the other capability set is labelled v38, passes supportsColorQueryReplyColors(38), and silently ignores the new notification — losing host-colour answering without any error. The PR body already flags this; calling it out so it is handled at merge time rather than after.

Technical details
# Daemon protocol version collision on merge

## Affected sites
- `src/main/daemon/daemon-protocol-version.ts` — `PROTOCOL_VERSION = 38`, `COLOR_QUERY_REPLY_COLORS_DAEMON_PROTOCOL_VERSION = 38`.
- `src/shared/local-build-compatibility-contract.{ts,json}` — `daemonProtocolVersion: 38`.

## Required outcome
- The two capabilities must carry distinct daemon protocol versions so `supportsColorQueryReplyColors` cannot return true for a daemon that lacks the `setColorQueryReplyColors` handler.

## Open questions for the human
- Which of #23908 / #23925 lands second, and is the version bump in the message or a follow-up commit?

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

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 66bbdf22-291a-4ac4-b08b-576641b84ac7

📥 Commits

Reviewing files that changed from the base of the PR and between a57863b and 71bcf3b.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (80)
  • src/main/daemon/daemon-color-query-reply-colors.test.ts
  • src/main/daemon/daemon-foreground-confirmation-protocol.test.ts
  • src/main/daemon/daemon-protocol-version.test.ts
  • src/main/daemon/daemon-protocol-version.ts
  • src/main/daemon/daemon-pty-connection-lifecycle.ts
  • src/main/daemon/daemon-pty-owner-query-protocol.ts
  • src/main/daemon/daemon-pty-router.ts
  • src/main/daemon/daemon-request-router.ts
  • src/main/daemon/degraded-daemon-pty-provider.ts
  • src/main/daemon/session.test.ts
  • src/main/daemon/terminal-host-pty-owner-backend.test.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty-dispatcher-handshake-osc-answers.test.ts
  • src/main/ipc/pty/ipc/resize-visibility.ts
  • src/main/ipc/pty/ipc/terminal-view-attributes-ipc.test.ts
  • src/main/ipc/pty/ipc/terminal-view-attributes-ipc.ts
  • src/main/ipc/pty/provider/registry-color-query-reply-colors.test.ts
  • src/main/ipc/pty/provider/registry.ts
  • src/main/ipc/pty/session.ts
  • src/main/ipc/terminal-startup-color-query-replies.test.ts
  • src/main/ipc/terminal-startup-color-query-replies.ts
  • src/main/providers/local-pty-provider-io-events.test.ts
  • src/main/providers/local-pty-provider.ts
  • src/main/providers/pty-provider-contract.ts
  • src/main/providers/ssh-pty-provider-rpc-operations.ts
  • src/main/providers/ssh-pty-provider.test.ts
  • src/main/providers/ssh-pty-provider.ts
  • src/main/runtime/orca-runtime-create-terminal-dependencies.ts
  • src/main/runtime/orca-runtime-create-terminal.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-02.spec.ts
  • src/main/runtime/rpc/methods/terminal-manifest-characterization.test.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/methods/terminal/terminal-viewer-colors-method.test.ts
  • src/main/runtime/rpc/methods/terminal/terminal-viewer-colors-method.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/main/runtime/terminal-view-attribute-store.ts
  • src/main/window/attach-main-window-services.ts
  • src/relay/pty-handler-output-streaming.test.ts
  • src/relay/pty-handler.ts
  • src/renderer/src/app-shell/use-app-shell-services.ts
  • src/renderer/src/app-shell/use-app-startup-hydration.ts
  • src/renderer/src/app-shell/use-terminal-viewer-color-publication.test.tsx
  • src/renderer/src/app-shell/use-terminal-viewer-color-publication.ts
  • src/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.test.ts
  • src/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/lib/terminal-contrast-correction.test.ts
  • src/renderer/src/lib/terminal-theme.ts
  • src/renderer/src/lib/terminal-themes-data.ts
  • src/renderer/src/runtime/remote-runtime-terminal-color-push.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-color-push.ts
  • src/shared/fish-query-reply-child-stdin.node-pty.test.ts
  • src/shared/local-build-compatibility-contract.json
  • src/shared/local-build-compatibility-contract.ts
  • src/shared/pty-owner-color-query-colors.test.ts
  • src/shared/pty-owner-color-query-colors.ts
  • src/shared/pty-owner-color-query-replies.ts
  • src/shared/pty-startup-color-query-answer.ts
  • src/shared/pty-startup-ingress-contract.ts
  • src/shared/pty-startup-ingress-lifetime-colors.test.ts
  • src/shared/pty-startup-ingress-live-query-reply.test.ts
  • src/shared/pty-startup-ingress.test.ts
  • src/shared/pty-startup-ingress.ts
  • src/shared/pty-startup-query.ts
  • src/shared/pty-startup-reply-delivery.ts
  • src/shared/rpc-contract/terminal-unary-params.ts
  • src/shared/terminal-osc-color-override-tracker.test.ts
  • src/shared/terminal-osc-color-override-tracker.ts
  • src/shared/terminal-theme-selection.test.ts
  • src/shared/terminal-theme-selection.ts
  • src/shared/terminal-themes/classic.ts
  • src/shared/terminal-themes/defaults.ts
  • src/shared/terminal-themes/index.ts
  • src/shared/terminal-themes/popular-dark-core.ts
  • src/shared/terminal-themes/popular-dark-extended.ts
  • src/shared/terminal-themes/popular-dark.ts
  • src/shared/terminal-themes/popular-light.ts
  • src/shared/terminal-themes/shared.ts
  • src/shared/terminal-themes/types.ts
  • src/shared/terminal-view-attributes.ts
💤 Files with no reviewable changes (1)
  • src/shared/pty-startup-color-query-answer.ts

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


📝 Walkthrough

Walkthrough

PTY owners now answer OSC 10/11 color queries throughout a PTY’s lifetime. Replies use validated host colors, startup colors, or dark-theme defaults, with application-set overrides tracked across output. Viewer colors are selected and published through IPC, daemon and relay providers, and paired-runtime RPC. The daemon protocol advances to version 38. Startup-window handling remains for Kitty queries.

Fixed issue severity: <fixed_issue_severity>Medium</fixed_issue_severity>

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 71bcf

The change supports lifetime color replies and headless theme updates without an established merge-blocking issue. It is mergeable subject to normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 71bcf

The inspected changes restrict replies to validated colors and retain existing remote-access checks. No introduced security regression was established. Risk remains low rather than minimal because complete remote-path isolation and mixed-version behavior were not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A valid color publication can affect all PTYs in each receiving owner process and propagate to every registered provider, not merely one terminal. The inspected mutation is limited to foreground/background reply state; per-PTY application overrides remain owned by their ingress instances.

Security Findings and Attack Paths

  • inferred — The inspected paired-client color path does not establish arbitrary PTY-input injection: schema limits and normalization precede publication, and the reply encoder emits numeric color sequences. This bounds the reviewed path but does not prove complete authorization coverage for every transport.

Trust Boundaries and Controls

  • observed — Paired WebSocket dispatch validates device tokens, rejects disagreement with the authenticated channel token, and applies a mobile-scope allowlist that does not include terminal.setViewerColors. Relay-backed paired channels also require the authenticated device to match the relay device identity.
  • observed — The daemon checks its hello token before installing the control-request parser. The new color request updates daemon-wide normalized color state rather than selecting a session; a complete control/stream pair is not required by that request branch.

Resilience and Maintainability Implications

  • observed — Lifetime ingress queues reentrant operations, bounds incomplete query and override parsing, registers expected echoes before writes, and closes delivery and timers during teardown. These controls contain parser state and prevent nested callbacks from reordering the current query transition.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 36.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 50 files. (20 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 and specifically describes the main change: terminal owners answer color queries for the terminal's entire lifetime.
Description check ✅ Passed The description is complete and closely follows the required template. It explains the user impact, implementation, rationale, linked issues, visual proof, testing, compatibility, and known limits.
Linked Issues check ✅ Passed The PR addresses both active coding objectives. For #22332, PtyStartupIngress answers OSC 10/11 queries for the PTY lifetime, resolves current host colors with spawn/default fallbacks, consumes the …
Out of Scope Changes check ✅ Passed The changes remain connected to #22332 and #22500. Daemon and relay protocol changes carry owner color updates. Shared color normalization, theme selection, PTY tracking, echo handling, and performanc…
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 50 files. (20 skipped: 1 unsupported, 19 over the file limit.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant