Skip to content

fix(tui): use matchesKey for Ctrl+C in pickers to support modern keyboard protocols - #136239

Closed
aniruddhaadak80 wants to merge 1 commit into
openclaw:mainfrom
aniruddhaadak80:fix/tui-ctrl-c-modern-keyboard
Closed

aniruddhaadak80 wants to merge 1 commit into
openclaw:mainfrom
aniruddhaadak80:fix/tui-ctrl-c-modern-keyboard

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Ctrl+C does not cancel TUI model, agent, and session pickers when the terminal sends Kitty CSI-u or xterm modifyOtherKeys input instead of the legacy ETX byte.

Why This Change Was Made

The existing code used raw ETX byte comparison (\u0003) for Ctrl+C detection. Modern terminals that use Kitty keyboard protocol (CSI-u) or xterm modifyOtherKeys mode send different encodings for Ctrl+C, causing the raw comparison to silently fail.

The fix replaces the raw byte comparison with \matchesKey(keyData, Key.ctrl('c')), which is the pi-tui decoder that handles all keyboard encoding protocols transparently. This is the same pattern already used in \custom-editor.ts\ for Ctrl+C handling.

User Impact

Operators using terminals with Kitty CSI-u or xterm modifyOtherKeys input can now cancel TUI pickers with Ctrl+C. The fix is backward-compatible with legacy ETX byte input.

Evidence

  • Existing test \ ilterable-select-list.test.ts:146\ uses \\u0003\ (legacy ETX byte) and will continue to pass
  • The \matchesKey\ decoder from pi-tui recognizes all three encodings: legacy ETX, Kitty CSI-u, and xterm modifyOtherKeys
  • The pattern is already used in \custom-editor.ts:103\ for the same purpose

Closes #133128

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 12:39 PM ET / 16:39 UTC.

ClawSweeper review

What this changes

The PR changes two TUI picker input handlers to recognize Ctrl+C through the shared normalized key matcher rather than only the legacy ETX byte.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until real behavior proof is added - 5 items remain

Keep this PR open: it is a focused repair, but the prior request for normalized Ctrl+C coverage remains unmet and no after-fix terminal/PTY evidence proves the advertised modern encodings.

Priority: P2
Reviewed head: e82b36ffca6245c6adcf2bf8c595a04bbeb457eb

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is compact and locally consistent, but its claimed protocol behavior has neither focused regression coverage nor after-fix real-behavior proof.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The changed production owners are the two picker input handlers whose callbacks close TUI overlays, but the supplied PR body has no redacted after-fix terminal or PTY trace showing Kitty CSI-u or modifyOtherKeys reaches the repaired cancellation behavior. Add redacted evidence and update the PR body; if review does not refresh, ask a maintainer to comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed production owners are the two picker input handlers whose callbacks close TUI overlays, but the supplied PR body has no redacted after-fix terminal or PTY trace showing Kitty CSI-u or modifyOtherKeys reaches the repaired cancellation behavior. Add redacted evidence and update the PR body; if review does not refresh, ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed 7 items Introduced handler change: The PR's sole-parent diff replaces the raw ETX equality check with the normalized Ctrl+C matcher in the filterable picker.
Introduced handler change: The same verified PR diff changes the searchable picker cancellation predicate.
Overlay owner and callers: Both picker callbacks flow through the shared overlay closer; searchable lists serve model, agent, and context pickers, while the filterable list serves sessions.
Findings 1 actionable finding [P2] Cover normalized Ctrl+C in both picker owners
Security None None.

How this fits together

Model, agent, context, and session pickers receive decoded terminal input and use cancellation callbacks to close their overlay. The session picker also clears an active filter before cancellation.

flowchart LR
  A[Terminal keyboard input] --> B[Key decoder]
  B --> C[Picker input handler]
  C --> D{Escape or Ctrl+C}
  D --> E[Clear session filter]
  D --> F[Cancel picker]
  F --> G[Close TUI overlay]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed production owners are the two picker input handlers whose callbacks close TUI overlays, but the supplied PR body has no redacted after-fix terminal or PTY trace showing Kitty CSI-u or modifyOtherKeys reaches the repaired cancellation behavior. Add redacted evidence and update the PR body; if review does not refresh, ask a maintainer to comment @clawsweeper re-review.
  • Cover normalized Ctrl+C in both picker owners (P2) - This still leaves the prior blocker unresolved: the filterable suite covers only legacy ETX and the searchable suite has no Ctrl+C case, so neither claimed modern input nor the filter-clear-then-cancel behavior is protected. Add table-driven legacy, Kitty CSI-u, and modifyOtherKeys cases for both handlers.
  • Resolve merge risk (P1) - The claimed Kitty CSI-u and modifyOtherKeys behavior remains unverified because direct pi-tui decoder inspection was unavailable and neither picker suite exercises those inputs.
  • Resolve merge risk (P1) - This bug fix adds production code without corresponding normalized-key regression coverage, leaving silent picker non-cancellation vulnerable to future decoder changes.
  • Complete next step (P2) - Add normalized-key regression cases for both picker owners and attach a redacted after-fix terminal or PTY trace for Kitty CSI-u or modifyOtherKeys.

Findings

  • [P2] Cover normalized Ctrl+C in both picker owners — src/tui/components/filterable-select-list.ts:131
Agent review details

Security

None.

PR surface

Source +2. Total +2 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 4 2 +2
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 4 2 +2

Review metrics

Metric Value Why it matters
Production versus test LOC production +4/-2 (net +2); tests +0/-0 The two typed key imports are paired with predicate substitutions, but no regression coverage was added for the behavior being changed.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #133128
Summary: This PR explicitly targets the canonical modern-keyboard picker cancellation report, which remains open until the fix is proven and merged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Prove the normalized-key contract before merge (recommended)
    Add focused encoding cases for both picker owners and a redacted after-fix terminal or PTY trace showing cancellation for the modern inputs.

Technical review

Best possible solution:

Keep the direct normalized matcher, add table-driven legacy/Kitty/modifyOtherKeys cases for both picker semantics, and attach a redacted after-fix native terminal or PTY trace.

Do we have a high-confidence way to reproduce the issue?

No. The linked issue provides a concrete native PTY scenario, but this review did not execute it and the pi-tui decoder contract was unavailable for direct inspection.

Is this the best way to solve the issue?

Unclear. The replacement matches the repository's existing normalized Ctrl+C pattern, but the dependency contract, focused protocol coverage, and after-fix behavior proof are still missing.

Full review comments:

  • [P2] Cover normalized Ctrl+C in both picker owners — src/tui/components/filterable-select-list.ts:131
    This still leaves the prior blocker unresolved: the filterable suite covers only legacy ETX and the searchable suite has no Ctrl+C case, so neither claimed modern input nor the filter-clear-then-cancel behavior is protected. Add table-driven legacy, Kitty CSI-u, and modifyOtherKeys cases for both handlers.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1623683f478b.

Labels

Label changes:

  • add merge-risk: 🚨 other: The advertised keyboard-protocol compatibility cannot yet be verified from dependency source, regression cases, or after-fix runtime evidence.

Label justifications:

  • P2: This is a bounded TUI interaction bug affecting picker cancellation in particular terminal keyboard modes.
  • merge-risk: 🚨 other: The advertised keyboard-protocol compatibility cannot yet be verified from dependency source, regression cases, or after-fix runtime evidence.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed production owners are the two picker input handlers whose callbacks close TUI overlays, but the supplied PR body has no redacted after-fix terminal or PTY trace showing Kitty CSI-u or modifyOtherKeys reaches the repaired cancellation behavior. Add redacted evidence and update the PR body; if review does not refresh, ask a maintainer to comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/tui/components/filterable-select-list.test.ts src/tui/components/searchable-select-list.test.ts.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • CJ Winslow: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add table-driven legacy ETX, Kitty CSI-u, and modifyOtherKeys cancellation cases for both picker semantics.
  • Attach a redacted after-fix native terminal or PTY trace for the modern encodings.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-02T10:46:55.484Z sha 1b835f3603bb8c740e5412c403c76fdc94cdaa5e :: needs real behavior proof before merge. :: [P2] Cover normalized Ctrl+C in both picker owners
  • reviewed 2026-09-02T15:26:52.696Z sha b6eebdf28e5650f1a174c7e8e6d293307c910fa3 :: needs real behavior proof before merge. :: [P2] Cover normalized Ctrl+C in both picker owners

@aniruddhaadak80
aniruddhaadak80 force-pushed the fix/tui-ctrl-c-modern-keyboard branch from 1b835f3 to b6eebdf Compare September 2, 2026 15:17
…oard protocols

Replace raw ETX byte comparison (\u0003) with matchesKey(keyData, Key.ctrl('c'))
in FilterableSelectList and SearchableSelectList. This fixes Ctrl+C cancellation
not working with Kitty CSI-u and xterm modifyOtherKeys keyboard encodings while
preserving backward compatibility with legacy ETX byte input.

Closes openclaw#133128
@aniruddhaadak80
aniruddhaadak80 force-pushed the fix/tui-ctrl-c-modern-keyboard branch from b6eebdf to e82b36f Compare September 2, 2026 16:31
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Sep 2, 2026
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Thanks @aniruddhaadak80. The same Ctrl+C decoding failure from #133128 is now fixed by #133151, merged as 047edf2909eac37521cbef091f549495154faa23. Its merged repair connects both picker wrappers to the existing Input.onEscape cancellation owner, removing the duplicate key checks and search-text state. Session pickers still clear a nonempty filter before closing; model and agent pickers cancel immediately.

The recorded native TUI proof passes all eight model/session cases across Escape, legacy Ctrl+C, Kitty CSI-u, and xterm modifyOtherKeys. Each case returns to chat, sends a prompt, receives its synthetic backend reply, and exits cleanly. The existing model/session selection flow also passes. This proof exercises the real TUI in PTYs with a synthetic backend.

Your contribution is preserved in #133151's description and its Co-authored-by: Aniruddha Adak <[email protected]> credit. Closing this overlapping PR now that the canonical repair has landed.

@steipete steipete closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ctrl+C does not cancel TUI pickers with modern keyboard input

2 participants