Skip to content

fix(terminal): clear the Kitty input mirror when a shell is confirmed - #23483

Merged
Jinwoo-H merged 3 commits into
mainfrom
fix/confirmed-shell-reset-clears-kitty-tracker
Sep 28, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
fix/confirmed-shell-reset-clears-kitty-tracker

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

When Orca confirms that an agent died and the shell is back, it resets the terminal so the shell stops receiving the agent's special key codes. But Orca keeps a second record of which key format the program asked for, and that record wasn't reset. So after the crash, keys like Shift+Enter were still sent to the shell as agent-style codes. Now both records reset together.

What Changed

The renderer keeps two records of a pane's Kitty keyboard protocol state:

  • xterm's own flags, which decide the bytes a key sends;
  • TerminalKittyKeyboardModeTracker, which shortcut policy reads. For example, it decides whether Shift+Enter becomes \x1b[13;2u.

When the foreground tracker confirms a return to the shell after a real process read (#9608), onConfirmedShellForeground wrote POST_REPLAY_REATTACH_RESET into xterm only.

  • Before: after an agent died with the Kitty protocol on, on a host that doesn't reset input modes in the output stream, the tracker still held the dead agent's flags. Shift+Enter kept sending \x1b[13;2u to the shell. Those hosts are SSH, sessions on a pre-update daemon, the local fallback, and paired runtimes.
  • After: queued output is flushed first, as the replay path already does. The tracker then scans the exact same reset bytes xterm receives, so both records apply the same bytes in stream order and end in the same state. That includes output still queued for a hidden pane, a live sequence split across chunks (the reset's ESC cancels it in both), and the alternate screen (only the active screen resets, in both).
  • The tracker's doc comment now states accurately what feeds it.

Why

  • Why the same bytes: a dedicated tracker method would be a second description of the reset that could drift from what xterm actually applies.
  • Why not route the reset through the normal output path: that path scans automatically, but it would drop the replay guard and viewport options.
  • Why scan() rather than reset(): reset() would move the tracker back to the main screen while xterm stays on a dead full-screen app's alternate screen.

Linked Issue

N/A (follow-up to #9608)

Visual Proof

N/A: input-encoding state, covered by unit tests; nothing visible changes except which bytes Shift+Enter sends after a confirmed agent death.

Testing

  • I manually tested these changes locally

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

  • Connection test: an agent arms Kitty flags, sent as a split sequence. After the confirmed shell, the tracker reads 0. On current main this fails with "expected 5 to be +0". When the process read still shows the agent after a leaked 133;D, the flags stay armed.

  • Queued output: a hidden pane has a Kitty push still queued when the shell is confirmed, and xterm and the tracker end equal. Without the flush this fails, because xterm gets the reset before the queued push.

  • Tracker test against a real headless xterm: the reset arrives in the middle of a split live Kitty push on the alternate screen, and xterm and the tracker agree on 0.

  • Suites: terminal-pane, dashboard-popout, and the shared Kitty and reset-profile suites all pass.

  • Gates: pnpm run typecheck, oxfmt, check:code-quality:changed and the anti-slop lint pass.

Review

Known limitation: on Windows, synchronized-output frames can be held briefly. Draining queued output skips a held frame, so if the shell is confirmed while one is held, the input mirror scans the reset before that frame reaches xterm. This only matters if the held frame itself changes Kitty flags. Main never clears the mirror at all. The planned host-side redesign moves this reset into the output stream and removes the gap.

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

  • Platforms: the change applies on every platform and transport that uses the fix(terminal): disarm stale TUI modes when a pane confirms return to shell #9608 confirmation.
  • Other resets: the Ctrl+C and reattach resets are unchanged. They are separate, planned follow-ups.
  • Residual: on hosts that don't reset input modes themselves (SSH, pre-update daemons, paired runtimes), revealing a hidden pane can restore the dead agent's flags from the host's snapshot. The host never saw this renderer-side reset. Host-side cleanup is the planned fix.
  • Security, SSH wire, mobile, performance: no impact.

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)

@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 critical issues — one documentation nitpick.

Reviewed changes

  • Confirmed-shell reset now feeds the Kitty mirror — onConfirmedShellForeground scans POST_REPLAY_REATTACH_RESET through TerminalKittyKeyboardModeTracker immediately before replaying the same bytes into xterm, so shortcut policy stops encoding for the dead app whenever the reset itself is applied.
  • Tracker class doc corrected — the comment now names the reset paths that actually reach the mirror (Windows ConPTY agent-idle reset and confirmed-shell reset) instead of claiming it is fed only by application output.
  • Integration test — asserts the mirror reads 5 after a chunk-split \x1b[>5u and 0 after the confirmed-shell disarm; this is the assertion that fails without the fix.
  • Headless-xterm agreement test — a real @xterm/headless terminal and the tracker both land on 0 when the reset interrupts a split live Kitty push on the alternate screen.
  • Test deps type tightened — paneKittyKeyboardModesRef now matches the production Map<number, TerminalKittyKeyboardModeTracker> (pty-connection-types.ts:80).

ℹ️ Nitpicks

  • src/renderer/src/components/terminal-pane/pty-connection/connect-pane-pty.ts:165 still says the mirror is "fed only from application output ... never from renderer-generated resets". The tracker's updated class comment and this change now contradict that; worth updating it in the same pass.

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

@coderabbitai

coderabbitai Bot commented Sep 27, 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: ab66baff-d723-47a1-8412-b1d962f9dde8

📥 Commits

Reviewing files that changed from the base of the PR and between 63ed223 and d5847df.

📒 Files selected for processing (1)
  • src/shared/terminal-kitty-keyboard-mode-tracker.test.ts

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


📝 Walkthrough

Walkthrough

Confirmed-shell handling now flushes queued terminal output before it scans post-replay reset bytes with the Kitty keyboard mode tracker and replays them to the terminal. Tests cover split Kitty keyboard sequences and verify that confirmed-shell cleanup clears tracked flags while a still-live agent retains them. The connection test dependency type now uses TerminalKittyKeyboardModeTracker.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to d5847

A narrow synchronized foreground-output case can still deliver Kitty mode-setting bytes after shell cleanup, potentially affecting terminal keyboard behavior. Fix or explicitly accept this before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d5847

The change fixes a shell input-mode mismatch in the normal path. A narrower case may remain when terminal output is deliberately held during shell confirmation: older output could arrive after the reset and leave the two mode records out of sync. This appears limited to an affected pane and has not been demonstrated end to end.

Retained concerns

  • Low · security · inferred: A held foreground frame can remain queued across the confirmed-shell reset. If it contains a Kitty mode change, its later xterm write could leave xterm and the already-reset input mirror out of sync.
Security review details

Security Blast Radius

  • inferred — The changed reset is renderer-local and pane-scoped. Its replay targets xterm, not a new PTY or remote-service write path.

Security Findings and Attack Paths

  • inferred — Under the conditional held-frame sequence, application-controlled Kitty mode bytes could reach xterm after the shell reset while the input mirror retains its reset state. The available evidence does not establish an exploitable shell-input outcome.

Trust Boundaries and Controls

  • observed — Foreground-process confirmation and PTY identity checks gate the reset; guarded replay writes the reset to the local terminal rather than forwarding it to shell stdin.

Resilience and Maintainability Implications

  • observed — Held and coalesced foreground output has a timed release path, but the reset callback does not wait for that release before updating the tracker and xterm.

Hardening Proposals

  • proposed — Establish an ordering barrier for held foreground frames before applying a confirmed-shell reset, and verify tracker/xterm agreement when a held frame carrying Kitty mode bytes is released.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: clearing the Kitty input mirror when the shell is confirmed.
Description check ✅ Passed The description is comprehensive and follows the template. It explains the user impact, mechanism, rationale, testing, limitations, platform considerations, and checklist status. The linked issue is i…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files.
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.
✨ Finishing Touches
📝 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.

@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: Advanced

Run ID: 8e88f081-6563-43b7-a8ba-3fd8c496254a

📥 Commits

Reviewing files that changed from the base of the PR and between f72079b and 6056428c924b91e406e434001cc3ddd18adf69d6.

📒 Files selected for processing (5)
  • src/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-deps.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/shared/terminal-kitty-keyboard-mode-tracker.test.ts
  • src/shared/terminal-kitty-keyboard-mode-tracker.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.

@Jinwoo-H
Jinwoo-H force-pushed the fix/confirmed-shell-reset-clears-kitty-tracker branch from 6056428 to 30e6233 Compare September 27, 2026 22:39

@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

  • Flush before the confirmed-shell reset — onConfirmedShellForeground now drains the pane's queued scheduler output (flushTerminalOutput) before scanning POST_REPLAY_REATTACH_RESET into the mirror and replaying it into xterm, so a hidden pane's stale agent bytes reach xterm ahead of the disarm instead of re-arming Kitty modes after it.
  • Queued-output ordering test — a hidden pane with a live Kitty push still in the background queue asserts that replaying the captured xterm writes in order leaves both the mirror and xterm at 0; I confirmed it fails with the flush removed (xtermView.flags becomes 5).
  • Split-sequence headless test — the tracker agrees with a real @xterm/headless terminal when the reset interrupts a chunk-split live Kitty push on the alternate screen.
  • Existing disarm tests tightened — the confirmed-death and live-agent cases now assert the mirror reads 5 while armed and 0 after the confirmed-shell disarm.
  • Tracker class doc — now names the feeds actually routed through the mirror (application output, snapshot restores, the ConPTY agent-idle and confirmed-shell resets).

One pre-existing documentation nit remains open and unaddressed (non-blocking): connect-pane-pty.ts:165-168 still describes the mirror as "fed only from application output ... never from renderer-generated resets", which the tracker's updated class comment now contradicts — the confirmed-shell reset is renderer-generated and does feed the mirror. Carrying it forward rather than re-flagging.

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

@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: Advanced

Run ID: fe68f575-e2fe-4189-9b46-fedc0004fb53

📥 Commits

Reviewing files that changed from the base of the PR and between 6056428c924b91e406e434001cc3ddd18adf69d6 and 30e6233e6b14410168e921fa7e78db80eb6d2fb0.

📒 Files selected for processing (3)
  • src/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/shared/terminal-kitty-keyboard-mode-tracker.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/shared/terminal-kitty-keyboard-mode-tracker.ts

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

@@ -181,6 +182,10 @@ export function installPaneAgentIdentity(session: ConnectPanePtySession): void {
// Why: a hard-killed agent leaves mouse/focus/kitty modes armed, and the
// surviving shell then receives pointer moves as typed SGR reports; the
// replay guard keeps xterm's auto-replies from leaking to the shell.
// The input mirror scans the same bytes so shortcuts stop encoding for the dead app;
// draining queued output first keeps both in stream order.
flushTerminalOutput(session.pane.terminal)

@coderabbitai coderabbitai Bot Sep 27, 2026 •

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

sed -n '145,210p' src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
sed -n '1,220p' src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.ts
rg -n 'flushTerminalOutput|foregroundHold|holdTerminal|coalesc|release.*[Hh]old' src/renderer/src/components/terminal-pane src/renderer/src/lib/pane-manager

Repository: stablyai/orca

Length of output: 43611


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- flusher ---'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-flusher.ts
printf '%s\n' '--- writer ---'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-writer.ts
printf '%s\n' '--- foreground queue state ---'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-foreground-queue-state.ts
printf '%s\n' '--- queue registry relevant definitions ---'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-queue-registry.ts | sed -n '1,230p'
printf '%s\n' '--- queue backlog relevant release ---'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.ts | sed -n '1,180p'
printf '%s\n' '--- drain ---'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-drain.ts | sed -n '1,260p'
printf '%s\n' '--- foreground output scan ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/foreground-output-scan.ts
printf '%s\n' '--- write path ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm.ts | sed -n '1,180p'
printf '%s\n' '--- identity tests and foreground setup references ---'
rg -n -C 8 'onConfirmedShellForeground|confirmed shell|foregroundHold|coalesceForeground|POST_REPLAY_REATTACH_RESET|kittyKeyboardModes' src/renderer/src/components/terminal-pane/pty-connection* src/renderer/src/lib/pane-manager/*foreground*test.ts

Repository: stablyai/orca

Length of output: 43260


🏁 Script executed:

#!/bin/bash
set -e
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-flusher.ts
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-writer.ts
cat -n src/renderer/src/lib/pane-manager/pane-terminal-foreground-queue-state.ts
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-queue-registry.ts | sed -n '1,230p'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.ts | sed -n '1,180p'
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-drain.ts | sed -n '1,260p'
cat -n src/renderer/src/components/terminal-pane/pty-connection/foreground-output-scan.ts
cat -n src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm.ts | sed -n '1,180p'
rg -n -C 8 'onConfirmedShellForeground|confirmed shell|foregroundHold|coalesceForeground|POST_REPLAY_REATTACH_RESET|kittyKeyboardModes' src/renderer/src/components/terminal-pane/pty-connection* src/renderer/src/lib/pane-manager/*foreground*test.ts

Repository: stablyai/orca

Length of output: 41995


🏁 Script executed:

cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-flusher.ts; cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-writer.ts; cat -n src/renderer/src/lib/pane-manager/pane-terminal-foreground-queue-state.ts; cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.ts; cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-drain.ts; cat -n src/renderer/src/components/terminal-pane/pty-connection/foreground-output-scan.ts; cat -n src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm.ts | sed -n '1,180p'; rg -n -C 8 'onConfirmedShellForeground|confirmed shell|foregroundHold|coalesceForeground|POST_REPLAY_REATTACH_RESET|kittyKeyboardModes' src/renderer/src/components/terminal-pane/pty-connection* src/renderer/src/lib/pane-manager/*foreground*test.ts

Repository: stablyai/orca

Length of output: 42859


🏁 Script executed:

cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-flusher.ts
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-writer.ts
cat -n src/renderer/src/lib/pane-manager/pane-terminal-foreground-queue-state.ts
cat -n src/renderer/src/lib/pane-manager/pane-terminal-output-drain.ts

Repository: stablyai/orca

Length of output: 30106


🏁 Script executed:

set -e
printf '%s\n' '--- replay guard ---'
cat -n src/renderer/src/components/terminal-pane/replay-guard.ts
printf '%s\n' '--- replay call sites and terminal write bindings ---'
rg -n -C 12 'function replayIntoTerminal|export .*replayIntoTerminal|replayIntoTerminal|writeReplayData|writePtyOutputToXterm' src/renderer/src/components/terminal-pane src/renderer/src/lib/pane-manager
printf '%s\n' '--- confirmed-shell lifecycle and tests ---'
rg -n -C 18 'onConfirmedShellForeground|confirmForegroundProcess|confirmedShell|POST_REPLAY_REATTACH_RESET|kitty.*enable|kittyKeyboard' src/renderer/src/components/terminal-pane/pty-connection src/renderer/src/components/terminal-pane/*test.ts

Repository: stablyai/orca

Length of output: 45653


🏁 Script executed:

set -e
cat -n src/renderer/src/components/terminal-pane/replay-guard.ts
rg -n -C 12 'function replayIntoTerminal|export .*replayIntoTerminal|replayIntoTerminal|writeReplayData|writePtyOutputToXterm' src/renderer/src/components/terminal-pane src/renderer/src/lib/pane-manager
rg -n -C 18 'onConfirmedShellForeground|confirmForegroundProcess|confirmedShell|POST_REPLAY_REATTACH_RESET|kitty.*enable|kittyKeyboard' src/renderer/src/components/terminal-pane/pty-connection src/renderer/src/components/terminal-pane/*test.ts

Repository: stablyai/orca

Length of output: 45655


🏁 Script executed:

set -e
cat -n src/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.ts
rg -n -C 12 'POST_REPLAY_REATTACH_RESET|kitty.*(enable|flag|mode)|\?1u|\?2004h|\?1004h|\?2026h|foregroundHold' src/renderer/src/components/terminal-pane/pty-connection/*test.ts src/renderer/src/lib/pane-manager/*test.ts

Repository: stablyai/orca

Length of output: 42188


Drain held foreground output before applying the confirmed-shell reset.

When flushTerminalOutput sees a held or coalesced entry, it returns without writing the queued bytes. replayIntoTerminal then writes the reset directly to xterm, so the scheduler can drain the queued bytes after the reset. A Kitty enable in that held chunk can re-enable stale Kitty flags in xterm after the reset. The Kitty tracker was scanned before the chunk was queued, so this can leave xterm and the tracker out of sync.

Make the reset wait for the queued output, or add an ordered flush that preserves this sequence. Add a regression test with a held foreground chunk containing a Kitty enable sequence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed: flushTerminalOutput skips entries that are held or coalesced by synchronized-output framing, so on that path the reset can be scanned before a held frame reaches xterm. The mis-order only matters if the held frame itself changes Kitty flags, inside the window between the shell being confirmed and the frame releasing. Main is strictly worse here: it never clears the tracker at all. Draining held frames from this call site would mean breaking the synchronized-frame contract. The follow-up redesign moves this reset into the host's output stream, where ordering is exact by construction and this call site goes away. I'm noting it as a known limitation in the PR description.

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.

@Jinwoo-H, thanks for the clarification. I agree that forcing flushTerminalOutput to drain a held frame would break the synchronized-output contract. The Kitty ordering issue remains possible until the reset enters the host output stream, so I’ll leave this finding open as a known limitation. Would you like a follow-up issue for that redesign?


✏️ Learnings added
Learnt from: Jinwoo-H
Repo: stablyai/orca PR: 23483
File: src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts:187-187
Timestamp: 2026-09-28T05:00:17.683Z
Learning: In `src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts`, `flushTerminalOutput` does not drain output held or coalesced by synchronized-output framing. Forcing a drain at the confirmed-shell reset call site would break that framing contract. A held frame that changes Kitty flags can reach xterm after the renderer scans the reset with `TerminalKittyKeyboardModeTracker`, leaving their states out of sync. Moving the reset into the host output stream is the planned ordering fix.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

A confirmed return to the shell (a host foreground read proving the agent is
gone) wrote the Kitty keyboard reset into xterm but not into the renderer's
Kitty mode tracker. Shortcut policy reads the tracker, so after an agent died
with Kitty flags armed on a host that does not ground the stream itself,
Shift+Enter and other chords stayed CSI-u encoded for the plain shell.

Scan the same reset bytes through the tracker before xterm parses them, so
both records apply identical input. The tracker doc now states its rule: fed by
application output and host-proven process boundaries, never renderer guesses.
The Ctrl+C and reattach resets are unchanged.
@Jinwoo-H
Jinwoo-H force-pushed the fix/confirmed-shell-reset-clears-kitty-tracker branch from 30e6233 to 63ed223 Compare September 27, 2026 22:57

@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

  • Tracker per-screen reset assertion — terminal-kitty-keyboard-mode-tracker.test.ts now feeds \x1b[?1049l after the confirmed-shell reset and asserts both the tracker and a real headless xterm report the parked main screen's flags (5), pinning that scan() clears only the active alternate screen rather than resetting both records.
  • Mirror doc reword — connect-pane-pty.ts now defers to TerminalKittyKeyboardModeTracker for its feed list instead of claiming the mirror is fed only by application output; this resolves the prior review's open doc nit.

The merge commit d5847df contributed no net textual change to the PR's files. The tracker suite passes (29 tests).

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

@Jinwoo-H
Jinwoo-H merged commit 0e871a9 into main Sep 28, 2026
49 checks passed
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