Skip to content

test(tui): cover C-x C-x literal passthrough to the focused session#619

Merged
edwin-zvs merged 1 commit into
mainfrom
fix/cx-cx-passthrough
Jun 29, 2026
Merged

test(tui): cover C-x C-x literal passthrough to the focused session#619
edwin-zvs merged 1 commit into
mainfrom
fix/cx-cx-passthrough

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

What this is

A regression test for C-x C-x passthrough in the TUI.

Investigation finding: the behavior already works

The task was to make C-x C-x cancel the C-x prefix and forward a literal
C-x to the focused session (so harnesses like grok that bind C-x internally
can still receive it). On investigation, this already works — there is a
dedicated "escape hatch" that does exactly this, in two places:

  • The main-view PTY path (is_pty_captured() branch of on_key): when a
    C-x chord is in flight and the next key is C-x, it clears the chord and
    queues 0x18 (literal C-x) to the focused session's PTY.
  • The orchestrator/operator panel (handle_orchestrator_key): the same
    escape hatch, forwarding 0x18 to the orchestrator session.

This shipped with the orchestrator-as-session work (commit 5a2ad3c). So the
runtime behavior the request describes is not broken — the second C-x does
not get swallowed; it is forwarded.

What was actually missing was test coverage: nothing locked in this
behavior, so a future refactor of the key-dispatch flow could silently break
it (and the byte forwarding is invisible in the mock-daemon test setup unless
you intercept the input channel).

What this PR adds

Two tests, asserting the escape hatch forwards a literal C-x and clears the
prefix, for each copy of the logic:

  • ctrl_x_ctrl_x_forwards_literal_ctrl_x_to_focused_pty — captured PTY view:
    first C-x arms the prefix and forwards nothing; second C-x forwards 0x18
    and clears the chord state + indicator.
  • orchestrator_panel_ctrl_x_ctrl_x_forwards_literal_ctrl_x — same, inside the
    operator panel, asserting the byte targets the orchestrator session.

Both swap the pty_input_tx channel for one the test owns, so the forwarded
bytes are observable.

Scope

Test-only — no production code changes. cargo build and the new tests pass.

Relevant binary

This PR touches only crates/cli (test code) → the binary is construct. No
behavior change, so the binary is unchanged from main.

…trator

`C-x C-x` is the escape hatch that cancels the C-x chord prefix and
forwards a literal C-x (0x18) to the focused session, so harnesses that
bind C-x internally (grok, bash's `C-x C-e`, vim completion) still
receive it. The behavior shipped with the orchestrator-as-session work
but had no regression coverage.

Add tests for both copies of the escape hatch — the main-view PTY path
and the orchestrator/operator panel — asserting the second C-x forwards
0x18 to the focused session and clears the chord prefix, while the first
(prefix) C-x forwards nothing on its own.
@edwin-zvs
edwin-zvs merged commit d0d714d into main Jun 29, 2026
1 check 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