fix(tui): preserve legacy Alt navigation - #707
Closed
yxlyx wants to merge 1 commit into
Closed
Conversation
Legacy terminals encode Alt+Arrow as ESC ESC followed by CSI. Treating the first Escape as a standalone key cancelled live turns and background operations before the navigation event arrived, especially when reads split or stalled. Keep complete legacy CSI navigation framed as one event through the parser, bounded stall policy, and dropped-head recovery. Genuine double Escape still resolves after the ambiguity window, while narrow evidence preserves bracketed prose instead of guessing it is navigation. Cover idle, live-turn, compact, bash, files, overlay, and paste trajectories without duplicating the broader #537 recovery work this branch builds on. Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
Owner
|
Folded onto Leaving this PR open for you to close as superseded. |
Owner
|
Shipped in v0.0.283 via #703 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #524. This PR is intentionally stacked on #699 and contains one additional commit; once #699 merges, this PR can be retargeted to
mainwithout changing its diff.What changed
ESC ESC <CSI>Alt+Left/Right/Up as one navigation event instead of Escape followed by navigation.Why
Problem / failure mode
Some terminals encode legacy Alt+Arrow as
ESC ESCplus CSI. The parser previously emitted the first Escape immediately, so the shared TUI dispatcher could cancel a model turn or background operation, close an overlay, end paste, or arm rewind before processing the arrow. Split and delayed terminal reads made this destructive behavior timing-dependent.Reason for this approach
The incorrect event originates in the shared input framing path, so the fix keeps the complete legacy sequence ambiguous until it can be decoded once. The bounded stall/recovery state from #699 already tracks live operations and late terminal tails; building on it protects every fullscreen TUI trajectory without adding downstream guards or duplicating #537's broader recovery machinery.
Constraints and trade-offs
The terminal byte stream cannot perfectly distinguish
ESC ESC [Ax]as Alt+Up thenx]from genuine double Escape followed by literal[Ax]. The implementation uses narrow evidence: exact navigation, split input, and navigation followed by ordinary coalesced text win as navigation; recognizable bracketed prose wins as text; an incomplete sequence beyond the existing ~300 ms idle / ~1 s live window resolves as genuine Escape. This preserves cancellation responsiveness while covering the reported 50–250 ms delivery range.Rejected alternatives
mainwas rejected because the delayed runtime seam needs fix(tui): harden split input and paste recovery #699's operation-aware stall/recovery behavior; restating that work would create overlapping PRs.Verification
GRAFF_TUIGUARD_JOBS=1 scripts/eval-tier1.sh— green in 562s.1860passed + 1 platform skip (1861total).514/514.18/18.[Alice]prose, unmodified and1;3CSI forms, all background operation kinds, overlay movement, paste, full-buffer recovery, and genuine Escape behavior. Final review reported no blockers.