Skip to content

fix(terminal): preserve Ctrl+Shift chords for direct OMP launches - #17082

Closed
CodeHourra wants to merge 1 commit into
stablyai:mainfrom
CodeHourra:fix/omp-kitty-keyboard-protocol
Closed

CodeHourra wants to merge 1 commit into
stablyai:mainfrom
CodeHourra:fix/omp-kitty-keyboard-protocol

Conversation

@CodeHourra

Copy link
Copy Markdown

ELI5

OMP asks the terminal whether it supports richer keyboard input before it can tell Ctrl+Shift apart from simpler key presses. Orca already answered that question for a normal terminal, but not early enough when OMP was opened directly from the New Tab menu. This change carries the real terminal capability into the startup path and answers OMP there too.

What Changed

  • Forward xterm's actual Kitty keyboard capability through local PTY and remote-runtime spawn requests.
  • Extend the existing startup-ingress intent with an optional, backward-compatible capability flag.
  • Recognize and answer the Kitty keyboard status query once during agent startup.
  • Preserve the following Kitty mode-set sequence so xterm still updates its live keyboard mode.
  • Keep color-query handling and Windows ConPTY suppression behavior in the existing bounded startup processor.
  • Add split-boundary tests, including a regression assertion that an exact complete query is answered without waiting for another byte.

Why

When OMP was launched from New Tab > OMP, it could send its Kitty keyboard status query before the renderer owned terminal-query responses. The startup responder only modeled color queries, so OMP did not receive the capability reply and Ctrl+Shift chords were not distinguishable. Launching OMP manually inside New Terminal did not hit that timing gap.

Linked Issue

Fixes #17081

Visual Proof

N/A — there is no static UI change; this changes the startup terminal protocol exchange.

Protocol behavior:

  • Before: CSI ? u → no startup reply → OMP leaves modified-key handling unavailable.
  • After: CSI ? u → CSI ? 0 u; OMP's subsequent mode-set remains visible to xterm → Ctrl+Shift chords work.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Manual verification:

  • macOS: verified New Tab > OMP can distinguish Ctrl+Shift after rebuilding the unsigned app.
  • macOS: verified the existing New Terminal, then manually run omp, path remains functional.

Automated verification:

  • 62/62 focused Vitest tests pass across startup ingress, local PTY forwarding, and remote-runtime forwarding.
  • Node, CLI, and Web TypeScript projects pass when run individually.
  • Both native-plugin and type-aware Oxlint code-quality configurations pass with warnings denied.
  • Oxfmt and git diff --check pass for the changed files.

The local aggregate pnpm wrappers stalled before printing their child-step output in this environment. A direct full Vitest run was also attempted; it exposed broad pre-existing/environment-dependent failures in unrelated daemon sockets, network listeners, file watchers, and long-timeout UI tests. No failure was in a changed file or the focused regression suite. PR CI should run the official aggregate gates.

AI Disclosure

OpenAI Codex (GPT-5) was used for investigation, implementation, review, testing, and PR preparation.

Review

  • Correctness: the exact-query boundary bug found during self-review is fixed; every split of CSI ? u is covered and the following mode-set is not consumed.
  • Cross-platform: the CSI protocol handling is platform-neutral. No platform shortcut keys are hard-coded, and the existing Windows ConPTY query-suppression contract is preserved.
  • Local / remote / SSH: local IPC and remote-runtime RPC forwarding are tested. The new wire field is optional, so mixed client/host versions degrade to the old behavior instead of rejecting requests. No local-path assumption was added.
  • Agents / integrations: startup replies remain limited to recognized TUI-agent launches. Terminals that do not advertise Kitty support leave the query untouched; behavior is not hard-coded to OMP.
  • Performance: processing is limited to the existing five-second startup window with a 64-character partial-query bound; no new steady-state scan or polling loop was added.
  • UI quality: no visual layout, styling, or labels changed.
  • Security: only a boolean renderer capability crosses the existing typed spawn boundary; no new command execution, persistence, credential, or authorization surface was added.
  • Mobile / git providers: no mobile UI or source-control behavior changed.

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

Author X handle: N/A — the contributor's GitHub profile does not list an X handle.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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 (official aggregate wrappers/CI pending; focused checks above pass)

@greptile-apps

greptile-apps Bot commented Aug 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR propagates xterm’s Kitty keyboard capability into bounded PTY startup-query handling so directly launched agents can negotiate modified keys.

  • Adds an optional capability field across renderer, preload, IPC, and runtime terminal-create contracts.
  • Extracts startup query parsing and answers one Kitty status query while preserving subsequent mode-setting output.
  • Adds split-boundary and local/remote forwarding coverage.
  • The remote host-authority agent-session path still drops the capability.

Confidence Score: 4/5

The remote OMP launch path needs correction before merging because host-authority creation drops the capability required for the advertised Ctrl+Shift fix.

Local and legacy terminal creation carry the new capability correctly, but current remote runtimes commonly select agent-session host authority, whose request and runtime creation chain omit the field and therefore leave OMP’s startup query unanswered.

Files Needing Attention: src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts and the agent-session RPC/runtime creation path

Important Files Changed

Filename Overview
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts Adds capability forwarding to legacy remote creates but omits it from the host-authority agent-session requests used by direct OMP launches.
src/shared/pty-startup-query-processor.ts Extracts startup query parsing and adds bounded, one-shot Kitty status handling while retaining color and ConPTY behavior.
src/shared/pty-startup-ingress-intent.ts Makes color replies optional and validates an additive Kitty capability while preserving bounded deadlines.
src/main/ipc/terminal-startup-color-query-replies.ts Builds startup ingress intent for recognized agents when either valid colors or Kitty support are available.
src/main/runtime/orca-runtime.ts Threads the capability from ordinary terminal-create options into PTY spawn, but agent-session creation does not supply it.

Sequence Diagram

sequenceDiagram
  participant X as Renderer xterm
  participant T as Remote PTY transport
  participant R as Runtime RPC
  participant S as PTY startup ingress
  X->>T: "Kitty capability + launchAgent=omp"
  alt Legacy terminal.create
    T->>R: terminal.create(capability)
    R->>S: spawn(capability)
    S-->>S: Answer CSI ? u
  else Host-authority agent session
    T->>R: terminal.createAgentSession()
    Note over T,R: Capability is dropped
    R->>S: spawn without capability
    Note over S: CSI ? u remains unanswered
  end
Loading

Reviews (1): Last reviewed commit: "fix(terminal): advertise Kitty keyboard ..." | Re-trigger Greptile

...(launchTokenToSend !== undefined ? { launchToken: launchTokenToSend } : {}),
...(launchAgentToSend !== undefined ? { launchAgent: launchAgentToSend } : {}),
...(terminalColorQueryReplies ? { terminalColorQueryReplies } : {}),
...(terminalKittyKeyboardAdvertised ? { terminalKittyKeyboardAdvertised: true } : {}),

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 Host-authority drops Kitty capability

When a direct remote OMP launch uses agent-session.host-authority.v1, this capability is included only in the legacy terminal.create parameters and is omitted from terminal.createAgentSession, so startup ingress leaves CSI ? u unanswered and Ctrl+Shift chords remain indistinguishable.

Knowledge Base Used:

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds terminalKittyKeyboardAdvertised to terminal creation and PTY spawn data paths. Startup ingress intents now support Kitty keyboard advertisement without requiring color replies. A new query parser and PtyStartupQueryProcessor handle Kitty status queries, partial input, lifecycle expiry, and reply delivery. Existing ingress processing delegates query handling to the processor. Tests cover intent validation, split queries, passthrough behavior, PTY spawn forwarding, and terminal creation handoff.

Merge Risk: 🟡 Moderate · up to fafd2

Remote OMP launches may still fail to distinguish Ctrl+Shift if agent-session creation does not forward the terminal capability, and Windows may continue answering Kitty queries after startup ownership handoff. The PR is not merge-ready until these bounded risks are resolved or explicitly accepted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 19 files. (1 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 describes the primary fix: preserving Ctrl+Shift chords for direct OMP launches.
Description check ✅ Passed The description follows the repository template and explains the change, reason, linked issue, protocol behavior, testing, review considerations, and checklist status. It also explains why aggregate c…
Linked Issues check ✅ Passed The changes satisfy issue #17081 by forwarding the Kitty keyboard capability through local and remote paths, answering the startup query once, and preserving the following mode-set sequence.
Out of Scope Changes check ✅ Passed The changes remain focused on startup Kitty keyboard negotiation for direct OMP launches, including propagation, processing, validation, and regression tests. No unrelated code changes are evident.
Full details: Description check

Explanation

The description follows the repository template and explains the change, reason, linked issue, protocol behavior, testing, review considerations, and checklist status. It also explains why aggregate checks remain unchecked.

Full details: Docstring Coverage

Explanation

Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 19 files. (1 skipped: 1 too large.)

  • Fix all pre-merge checks with AI

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ead9c9f7-fd7e-404d-ae30-cb922f360db5

📥 Commits

Reviewing files that changed from the base of the PR and between fd9125e and fafd275.

📒 Files selected for processing (20)
  • src/main/ipc/pty/ipc/spawn-options.ts
  • src/main/ipc/pty/ipc/spawn-types.ts
  • src/main/ipc/pty/runtime/spawn-options.ts
  • src/main/ipc/terminal-startup-color-query-replies.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/terminal/terminal-lifecycle-methods.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/preload/api/pty-api.ts
  • src/preload/index.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-spawn-request.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pty-input-recovery.ts
  • src/renderer/src/components/terminal-pane/pty-transport-connect-spawn.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-handoff.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/shared/pty-startup-ingress-intent.ts
  • src/shared/pty-startup-ingress.test.ts
  • src/shared/pty-startup-ingress.ts
  • src/shared/pty-startup-query-processor.ts
  • src/shared/terminal-kitty-keyboard-query.ts

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

...(launchTokenToSend !== undefined ? { launchToken: launchTokenToSend } : {}),
...(launchAgentToSend !== undefined ? { launchAgent: launchAgentToSend } : {}),
...(terminalColorQueryReplies ? { terminalColorQueryReplies } : {}),
...(terminalKittyKeyboardAdvertised ? { terminalKittyKeyboardAdvertised: true } : {}),

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 12 \
  'runRemoteAgentSessionLaunch|terminal\.ensureAgentSession|terminal\.createAgentSession|terminalKittyKeyboardAdvertised' \
  src

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- repository conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 -type f -name '*.md' -maxdepth 3 -print \
  | sort \
  | while IFS= read -r f; do
      printf '\n### %s\n' "$f"
      head -80 "$f"
    done

printf '%s\n' '--- remote transport option capture and final payload ---'
sed -n '120,170p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
sed -n '2010,2060p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts

printf '%s\n' '--- session creation branch ---'
sed -n '285,410p' src/renderer/src/runtime/web-runtime-session.ts

printf '%s\n' '--- relevant type and contract declarations ---'
rg -n -C 8 \
  'terminalKittyKeyboardAdvertised|ensureAgentSession|createAgentSession|RuntimeEnsureAgentSession|RuntimeCreateAgentSession|AgentSession.*Params|AgentSession.*Request' \
  src/renderer/src src/shared src/main

Repository: stablyai/orca

Length of output: 285


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- scoped repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print \
  | sort \
  | while IFS= read -r f; do
      printf '\n### %s\n' "$f"
      head -80 "$f"
    done

printf '%s\n' '--- remote transport option and payload ---'
sed -n '135,165p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
sed -n '2025,2055p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts

printf '%s\n' '--- host-authority request construction ---'
sed -n '300,405p' src/renderer/src/runtime/web-runtime-session.ts

printf '%s\n' '--- exact symbol declarations and consumers ---'
rg -n -C 10 \
  'terminalKittyKeyboardAdvertised|terminal\.ensureAgentSession|terminal\.createAgentSession|terminal\.create|RuntimeEnsureAgentSession|RuntimeCreateAgentSession' \
  src/renderer/src/runtime src/renderer/src/components/terminal-pane src/preload src/main

Repository: stablyai/orca

Length of output: 275


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- scoped repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print \
  | sort \
  | while IFS= read -r f; do
      printf '\n### %s\n' "$f"
      head -80 "$f"
    done

printf '%s\n' '--- remote transport option and payload ---'
sed -n '135,165p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
sed -n '2025,2055p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts

printf '%s\n' '--- host-authority request construction ---'
sed -n '300,405p' src/renderer/src/runtime/web-runtime-session.ts

printf '%s\n' '--- exact symbol declarations and consumers ---'
rg -n -C 10 \
  'terminalKittyKeyboardAdvertised|terminal\.ensureAgentSession|terminal\.createAgentSession|terminal\.create|RuntimeEnsureAgentSession|RuntimeCreateAgentSession' \
  src/renderer/src/runtime src/renderer/src/components/terminal-pane src/preload src/main

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- complete host-authority payloads ---'
sed -n '2068,2145p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts

printf '%s\n' '--- connect selection and result handling ---'
sed -n '2145,2245p' src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts

printf '%s\n' '--- startup-query propagation contracts ---'
rg -n -C 12 \
  'terminalKittyKeyboardAdvertised|kittyKeyboardAdvertised|terminalColorQueryReplies|PtyStartupIngressIntent|startup.*query|startup.*reply' \
  src/main src/renderer/src src/preload \
  -g '!*.test.ts'

printf '%s\n' '--- knowledge-tree file names ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- all non-test references to the Kitty flag ---'
rg -n 'terminalKittyKeyboardAdvertised' src \
  -g '!*.test.ts' \
  -g '!*.spec.ts'

printf '%s\n' '--- runtime spawn option construction ---'
sed -n '30,150p' src/main/ipc/pty/runtime/spawn-options.ts
sed -n '30495,30575p' src/main/runtime/orca-runtime.ts

printf '%s\n' '--- agent-session RPC handlers and create parameter types ---'
rg -n -C 8 \
  'createAgentSession|ensureAgentSession|agentSessionCreateOperationId|terminalColorQueryReplies|startupIngress' \
  src/main/runtime/rpc/methods/terminal src/main/runtime \
  -g '!*.test.ts' \
  | head -500

Repository: stablyai/orca

Length of output: 41436


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- agent-session request contracts and schemas ---'
rg -n -C 12 \
  'type RuntimeEnsureAgentSessionRequest|interface RuntimeEnsureAgentSessionRequest|RuntimeEnsureAgentSessionRequest|EnsureAgentSessionParams|CreateAgentSessionParams|RuntimeCreateAgentSessionRequest|terminalColorQueryReplies|launchPreferences' \
  src/shared src/main/runtime/rpc/methods/agent-session.ts \
  -g '!*.test.ts' \
  | head -700

printf '%s\n' '--- ensureAgentSession implementation ---'
sed -n '30025,30135p' src/main/runtime/orca-runtime.ts

printf '%s\n' '--- createAgentSession implementation and launch call ---'
sed -n '30125,30315p' src/main/runtime/orca-runtime.ts

printf '%s\n' '--- agent-session presentation adapter ---'
sed -n '1,190p' src/main/runtime/rpc/methods/agent-session.ts

Repository: stablyai/orca

Length of output: 35584


Propagate terminalKittyKeyboardAdvertised through agent-session creation.

The host-authority branch uses terminal.ensureAgentSession or terminal.createAgentSession, but neither payload carries the flag. Both RPC schemas are strict, and both implementations omit the flag when calling createTerminal. Remote OMP launches can therefore miss the Kitty status reply. Add the field to both request contracts and schemas, forward it through both implementations, and assert the resulting requests and startup ingress.

nwparker added a commit that referenced this pull request Sep 19, 2026
* fix(omp): answer startup Kitty queries before renderer handoff

Forward actual renderer capability through local and remote spawn. Preserve source ranges and following keyboard mode pushes, and retain independent ConPTY color authority.

Refs #17081. Secondary review: #17082.

Co-authored-by: stevelliu <[email protected]>

* test(omp): cover fragmented keyboard modes and ConPTY handoff

* fix: preserve keyboard startup intent without terminal colors

* fix: negotiate keyboard support for host-authoritative agent launches

* fix: keep terminal creation within line budget

* fix(omp): negotiate keyboard support for paired web launches

* test: remove obsolete message type import after main integration

* fix: validate paired launch results and retry incomplete SSH test snapshots

* fix(omp): negotiate keyboard support for background paired launches

---------

Co-authored-by: stevelliu <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Superseded by merged ea02d90 / #20620 (fix(omp): answer startup Kitty queries before renderer handoff), which landed the direct OMP startup keyboard negotiation fix. Closing the stale branch.

@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OMP launched from the agent shortcut cannot distinguish Ctrl+Shift chords

2 participants