Repository navigation
fix(render): treat delivered input as proof the surface is visible - #3025
Merged
Merged
Conversation
Switching away stops frame callbacks, so the 300 ms starvation probe closes the surface gate; returning to the workspace can deliver none of the qualifying reveal edges, and the gate then stays closed while damage accumulates and the loop parks - the window keeps an old frame until an unrelated event. A key press, pointer button or motion, scroll, or focus gain can only be delivered to a mapped, focused surface, so any of them reopens the gate and queues the from-truth redraw. Timer, PTY-readable and IPC wakes are excluded: they say nothing about visibility. The reveal also clears a confirmation bound left over from the hidden incarnation, which the new frame re-arms on commit.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Xuepoo
commented
Nov 8, 2026
Xuepoo
left a comment
Contributor
Author
There was a problem hiding this comment.
Guard review — PR #3025 (input delivery as a reveal edge, #3024)
Independent checks against the tree at 5dfad4d4.
- Gate transition is the real one.
reveal_surface_from_inputearly-returns when the
surface is already visible and otherwise callsset_surface_gate(true, "input")
(terminal_app.rs:1468), which is the same transition every native reveal edge uses: it
clears the hidden-incarnationhidden_repair_probe_atand calls
runtime.set_surface_visibility(true)(terminal_app.rs:1449-1458). No second gate path is
introduced. - Ordering is correct. The new block sits at
terminal_app.rs:4961-4973, i.e. before the
chrome intercept (:5002) and before the capture fall-through (:5025), so an input event
that is consumed downstream still reveals first. That is the case the bug report needs — keys
pressed during the freeze were applied but never presented. - The exclusion set is the defensible one.
is_input_visibility_proofmatches
KeyboardInput,MouseInput,MouseWheel,CursorMoved,Focused(true)only. Timer
(AboutToWait),PtyReadableand IPC wakes are excluded, which is exactly the property the
negative test asserts (timer_and_ipc_wakes_do_not_reveal_a_closed_surface).ModifiersChanged,
IME bookkeeping, andCursorEnteredare excluded and documented as such. - The positive test discriminates. It closes the gate through the same runtime transition
theOccluded(true)edge applies, arms both the repair probe and a #2989 confirmation bound,
then delivers one unbound key. Without the new branch nothing sets visibility true, so the
a delivered key reopens the gateassertion cannot pass — the test is not tautological, and
it is not derived from the same container as the gate value it checks. - Confirmation-bound cleanup is right.
clear_present_confirmation()on the reveal branch
(present.rs) drops a bound armed for the hidden incarnation; the reveal frame queues a
from-truth present (present_coalescing_deadlineis assertedSome), so a duplicate
corrective repaint would only be noise. The test asserts the deadline isNoneafterwards. - Residual risk, accepted.
Focused(true)andCursorMovedcan arrive on a surface a
compositor still considers occluded (stacking-order occlusion with focus retained). Worst case
is a few frames presented to an occluded surface — wasted work, no truth mutation — and it is
the same assumption the nativeFocused(true)reveal edge already makes. The PR body
correctly flags live-compositor behaviour as unverified. - Checks. 13 pass / 0 fail at review time;
Quality gates (1)andWindows check and test
still pending. Merge watcher requires the full set green.
VERDICT: APPROVE
This was referenced Nov 8, 2026
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 #3024.
Root cause
Switching away from Bitty's Hyprland workspace stops the compositor's frame callbacks.
OcclusionProbe(OCCLUSION_STARVE = 300 ms) turns the unansweredrequest_redrawinto a syntheticOccluded(true), which closes the surface gate. On return, Hyprland may deliver none of the qualifying reveal edges — nativeOccluded(false)needs the xdg-shellsuspendedstate, and the synthetic path needsRedrawRequested,Focused(true),ResizedorScaleFactorChanged— so the gate stays closed, damage accumulates,present_owed()stays false, and the loop parks on an old frame.Evidence from the live instance (0.0.36): the main thread sat in
do_epoll_waitat 0.0 % CPU for a 10 s / 32-sample window,bitty ctlanswered, the window was mapped and focused, and keys pressed during the freeze took effect once something finally repainted.Fix
A delivered input event is proof the surface is visible: keys, pointer buttons, pointer motion, scroll, and focus gain are only delivered to a mapped, focused surface.
TerminalApp::handle_event_innernow checks that before the chrome-key intercept, the capture fall-through andRuntime::handle_platform_event, and reopens the gate throughset_surface_gate(true, "input"), which already queues the from-truth repaint.Deliberately excluded:
ModifiersChanged, IME enable/disable,CursorEntered, and every non-input event — plus timer (AboutToWait),PtyReadableand IPC wakes, which say nothing about visibility.The reveal branch also clears a #2989 confirmation bound left over from the hidden incarnation; the new frame re-arms it on commit, so no duplicate corrective repaint follows.
Tests
delivered_input_reveals_a_surface_the_occlusion_probe_closed— closes the gate through the exact transition theOccluded(true)edge applies, retains damage, arms the hidden-repair probe and a confirmation bound, then delivers a key. Asserts the gate reopens, the app probe and both deadlines clear, a from-truth deadline is queued, anddrive_tick()presents exactly one frame. Fails today: with the classifier forced tofalseit stops ata delivered key reopens the gate.timer_and_ipc_wakes_do_not_reveal_a_closed_surface—AboutToWait+PtyReadableleave the gate closed and present nothing.Gates
cargo fmt --all -- --checkclean;RUSTFLAGS="-D warnings" cargo clippy -p bitty-terminal --all-targetsand-p bitty-runtime --all-targetsclean;cargo test -p bitty-terminal --features input-vm-test-support --bin bitty1510 passed;cargo test -p bitty-runtime --lib runtime::present158 passed;RUSTDOCFLAGS="-D warnings" cargo doc -p bitty-terminal --no-depsclean.Not verified
No live compositor run: whether Hyprland delivers any covered event while the surface is still marked suspended, and whether input can arrive on a surface the compositor has not yet resumed, are unverified here. The fix relies on the xdg-shell guarantee that a suspended surface receives no key or pointer input.