fix(tui): replace alternate scroll heuristic with MouseCapture#89
Merged
yishuiliunian merged 2 commits intomainfrom Apr 6, 2026
Merged
fix(tui): replace alternate scroll heuristic with MouseCapture#89yishuiliunian merged 2 commits intomainfrom
yishuiliunian merged 2 commits intomainfrom
Conversation
…terministic scroll detection (#88) The previous approach used xterm alternate scroll mode (\x1b[?1007h) to convert mouse wheel events into Up/Down arrow key sequences, then relied on batch-counting heuristics (≥2 arrows per batch = scroll) to distinguish scroll from keyboard input. This was fundamentally unreliable across different terminal emulators and system load conditions. Switch to crossterm's EnableMouseCapture which provides actual MouseEvent::ScrollUp/ScrollDown events, making the distinction deterministic. Up/Down arrow keys now always route to history navigation.
yishuiliunian
added a commit
that referenced
this pull request
Apr 6, 2026
…ror misclassification (#89) When thinking mode is active, Anthropic's API rejects assistant-message prefill ("conversation must end with a user message"). The auto-continuation flow in turn_exec records an assistant message then loops back, violating this constraint. The error was also misclassified as ContextOverflow because `invalid_request_error` matched too broadly. - Narrow ContextOverflow detection to exclude generic `invalid_request_error` - Add `ThinkingCapability::forbids_prefill()` (true only for Anthropic) - Add `needs_continuation_injection()` gating on capability + thinking state - Inject synthetic user message at all 3 continue points when needed - Fix stop-hook feedback path: create proper User message instead of appending to (wrong-role) last message via `append_warnings_to_last_user` - Preserve assistant-prefill for non-Anthropic providers (OpenAI, Google)
yishuiliunian
added a commit
that referenced
this pull request
Apr 6, 2026
…ror misclassification (#89) (#90) When thinking mode is active, Anthropic's API rejects assistant-message prefill ("conversation must end with a user message"). The auto-continuation flow in turn_exec records an assistant message then loops back, violating this constraint. The error was also misclassified as ContextOverflow because `invalid_request_error` matched too broadly. - Narrow ContextOverflow detection to exclude generic `invalid_request_error` - Add `ThinkingCapability::forbids_prefill()` (true only for Anthropic) - Add `needs_continuation_injection()` gating on capability + thinking state - Inject synthetic user message at all 3 continue points when needed - Fix stop-hook feedback path: create proper User message instead of appending to (wrong-role) last message via `append_warnings_to_last_user` - Preserve assistant-prefill for non-Anthropic providers (OpenAI, Google)
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.
Summary
\x1b[?1007h+arrow_count >= 2) with crossterm'sEnableMouseCapturefor deterministicMouseEvent::ScrollUp/DownChanges
terminal.rs: Remove customEnableAlternateScroll/DisableAlternateScroll, useEnableMouseCapture/DisableMouseCaptureevent.rs: AddAppEvent::ScrollUp/ScrollDownvariants, handleCrosstermEvent::Mouse, drain-buffer optimizationtui_loop.rs: Remove batch detection logic (arrow_count/is_scroll_burst), handleScrollUp/ScrollDowndirectlyscroll_burst_test.rs→scroll_test.rs: Rewrite without batch simulatione2e_scroll_test.rs: Rewrite withAppEvent::ScrollUp/DowninjectionTest plan
bazel test //crates/loopal-tui:loopal-tui_test— 50/50 passbazel build //... --config=clippy— zero warnings