Skip to content

fix(host): preserve query-time cursor replies - #25

Merged
kitlangton merged 1 commit into
mainfrom
fix/opentui-cursor-replies-maintenance
Sep 2, 2026
Merged

fix(host): preserve query-time cursor replies#25
kitlangton merged 1 commit into
mainfrom
fix/opentui-cursor-replies-maintenance

Conversation

@kitlangton

Copy link
Copy Markdown
Collaborator

Why
An application requesting CSI 6 n under --host opentui receives no standalone cursor-position response, even though Ghostty has already generated the correct reply. The OpenTUI startup bundle instead injects three hardcoded home-position reports, including when no cursor query was sent.

What Changes
Forward actual query-time cursor reports while retaining the OpenTUI host's other overrides.

Output / Current State Before After
CSI 6 n at row 3, column 7 No reply ESC[3;7R
Split CSI 6 n at row 9, column 11 No reply One ESC[9;11R on completion
Queries at three successive positions in one chunk No replies Three ordered query-time reports
Startup foreground/background queries only Three unsolicited ESC[1;1R reports No cursor reports

Ghostty remains responsible for VT parsing and cursor state, including hidden cursors and origin-relative coordinates. Preserve its callback boundaries, select complete ASCII-digit CPR records for OpenTUI, and seed the existing host response before appending its overrides. The combined response is sent once and returned unchanged for recording. Default hosting still concatenates all Ghostty replies in their original order.

Includes a patch Changeset for the existing fixed six-package release group; no versions are bumped.

Scope
This addresses cursor replies in the shared terminal response path. Related #16; this does not implement that PR's Windows session transport or ConPTY teardown work.

Verification

PATH="/opt/homebrew/opt/zig@0.15/bin:$PATH" cargo test --locked --lib cursor_replies -- --nocapture
cargo +1.93.0 fmt --all -- --check
PATH="/opt/homebrew/opt/zig@0.15/bin:$PATH" cargo +1.93.0 test --locked --all-targets
PATH="/opt/homebrew/opt/zig@0.15/bin:$PATH" cargo +1.93.0 test --locked --doc
PATH="/opt/homebrew/opt/zig@0.15/bin:$PATH" cargo +1.93.0 clippy --locked --all-targets --all-features -- -D warnings
PATH="/opt/homebrew/opt/zig@0.15/bin:$PATH" cargo +1.93.0 build --locked --release
bun install --frozen-lockfile
TERMCTRL_TEST_BINARY="$PWD/target/release/termctrl" bun run test:npm
bun run build:npm
bun run validate:npm "$PWD/target/release/termctrl"
cargo +1.93.0 package --locked --list --allow-dirty
PATH="/opt/homebrew/opt/zig@0.15/bin:$PATH" cargo +1.93.0 package --locked
bun run changeset status
  • Three regression tests at the real respond_to_output seam fail before the fix and pass after it on the same Rust 1.95 toolchain.
  • Rust 1.93: 118 all-target tests and one doctest pass; one existing manual benchmark remains ignored. Formatting, Clippy, release build, and crate packaging pass.
  • Table-driven tests cover whole queries, every two-way split, bytewise feeds, repeated and hidden-cursor queries, origin mode, multiple query-time positions, real width probes, exact mixed startup replies, default reply ordering, written/returned byte equality, and closed versus denied writers.
  • Npm typechecks, 21 tests, builds, and packed clean Bun/Node consumers pass using the source release executable.
  • Owned disposable PTY fixtures on macOS reproduce missing/canned reports before the fix and verify correct reports afterward for initial, moved, split, repeated/hidden, multiple-position, origin-relative, mixed-startup, and post-startup queries in both host profiles.
  • Real OpenTUI 0.4.5 renders readiness and exits normally on q before and after. Three received CPRs match three emitted queries and the recorded host CPRs. Non-CPR host bytes are identical between recordings; width, scaling, and pixel-mode capability values remain unchanged. No owned fixture processes remain.

Additional bun run --cwd packages/opentui release:check packs successfully but fails at npm publish --dry-run --access public because unchanged version 1.1.0 is already published: You cannot publish over the previously published versions: 1.1.0. No publish or version change was performed.

@kitlangton
kitlangton merged commit 4de9fec into main Sep 2, 2026
2 checks passed
@kitlangton
kitlangton deleted the fix/opentui-cursor-replies-maintenance branch September 2, 2026 03:18
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