Skip to content

fix(render): queue a from-truth frame for a redundant reveal edge - #3031

Merged
Xuepoo merged 4 commits into
mainfrom
ctx-3030/fix-prompt-reveal
Nov 8, 2026
Merged

Xuepoo merged 4 commits into
mainfrom
ctx-3030/fix-prompt-reveal

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3030.

Root cause

A reveal proof that arrives while the surface gate is already open was dropped end to end:

  • TerminalApp::set_surface_gate filtered the duplicate edge before the runtime saw it (terminal_app.rs:1444).
  • Runtime::set_surface_visibility_at returned early on surface_visible == visible (present.rs:2564).

The #2989 confirmation repair reopens the gate speculatively while the surface is still occluded. When the compositor later serves the return's frame callback, the occlusion probe synthesizes Occluded(false); both layers see surface_visible == true, no-op, owe nothing and arm no wake. The loop parks on the last sampled frame — which predates the output written while away. With aws configure --profile root that is exactly the reported shape: earlier rows intact, the unterminated prompt lines missing.

The prompt-row rebuild itself is not the defect: six regression tests drive the real aws configure transcript shape (unterminated AWS Access Key ID [None]: ) through hide/reveal for the primary pane, a split pane and a second-workspace pane, and all of them paint the prompt row byte-identically on unmodified origin/main.

Fix

Tests

Failing before the fix (verified by reverting the single queue_reveal_repaint call — redundant_reveal_queues_a_from_truth_frame panics at present.rs:12344):

  • runtime::present::surface_visibility_tests::redundant_reveal_queues_a_from_truth_frame
  • tests::input_vm_boundary::reveal_edge_while_the_gate_is_open_still_presents

Updated contract test: repeated_hides_are_no_ops_and_repeated_reveals_repaint.

Regression pins (pass before and after): prompt_reveal_tests::{reveal_keeps_the_unterminated_prompt_primary, ..._split_pane, ..._second_workspace, reveal_shows_the_prompt_that_arrived_while_hidden, ..._split_pane..., ..._second_workspace...} — each asserts the prompt row has ink, the whole headless_rgba frame matches a reference runtime, and the switch wrote no PTY bytes and issued no grid or surface resize.

Gates

cargo fmt --all -- --check; RUSTFLAGS="-D warnings" cargo clippy -p bitty-runtime -p bitty-terminal -p bitty-ui --all-targets; cargo test -p bitty-runtime --lib runtime::present 165 passed; full bitty-runtime --lib 1511 passed; bitty-terminal --bin bitty --features input-vm-test-support 1511 passed; view_style_carry 5 passed; rustdoc clean.

Not verified live

Which edge the owner's return actually delivers (Resumed, native Occluded(false), or only input) was not observed on a live host; the fix covers the same-state reveal class, which is the only path found that leaves earlier output intact while the newest rows are missing. A build with #3025 is required to compare against 0.0.36, which predates it.

Summary by CodeRabbit

  • Bug Fixes
    • Revealing a terminal now triggers a fresh frame, even if it was already marked visible.
    • Repeated hides remain no-ops. Hiding and revealing does not add terminal input or resize the display.
    • Prompts and output that arrive while hidden are displayed correctly after the terminal is revealed.

A reveal proof that arrives while the surface gate is already open was dropped end to end: set_surface_gate filtered the duplicate edge and set_surface_visibility_at returned early, so nothing was owed and no wake was armed. The #2989 confirmation repair reopens the gate speculatively while the surface is still occluded; when the compositor later serves the return frame callback the probe synthesizes Occluded(false), both layers no-op, and the loop parks on the last sampled frame - which predates output written while away (reported with aws configure: the unterminated prompt lines vanish, earlier output stays).

A redundant hide stays a no-op. A redundant reveal now queues one full-redraw frame and the next-frame wake through queue_reveal_repaint, ends the hidden-repair probe, and clears the confirmation bound; it does not change the gate or write to the PTY.
@Xuepoo Xuepoo added this to the v0.1.0 milestone Nov 8, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:render Area: rendering labels Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You'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 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7e358919-4e9b-4994-b6b4-49bd3ddf1fac
Commits

Reviewing files that changed from the base of the PR and between a055c38 and d8a00f9.

Files selected for processing: 3

  • crates/bitty-runtime/src/runtime/present.rs
  • crates/bitty-terminal/src/terminal_app.rs
  • crates/bitty-terminal/src/tests.rs

No actionable comments were generated in the recent review.

Walkthrough

The app now forwards redundant reveal deliveries to the runtime. The runtime queues a full redraw and immediate coalesced wake for each reveal. Regression tests cover redundant visibility events and unterminated prompts across panes and workspaces.

Changes: Redundant reveal repaint

Layer / File(s) Summary
Forward redundant reveal deliveries
crates/bitty-terminal/src/terminal_app.rs
When the surface is already visible, set_surface_gate clears the hidden-repair probe and calls the runtime visibility setter. It does not log a transition.
Queue and verify reveal repaint
crates/bitty-runtime/src/runtime/present.rs, crates/bitty-terminal/src/tests.rs
The runtime queues an immediate coalesced wake and full redraw for redundant reveals; redundant hides remain no-ops. Tests cover repeated reveals, presentation on the next tick, and prompt rendering in the primary view, a split pane, and another workspace.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant TerminalApp
  participant Runtime
  participant Presenter
  TerminalApp->>Runtime: set_surface_visibility(true)
  Runtime->>Runtime: queue_reveal_repaint
  Runtime->>Presenter: coalesced wake and full redraw
  Presenter-->>TerminalApp: present frame on next loop turn
Loading

Possibly related issues

Possibly related PRs

  • bitty-terminal/bitty#2662: This PR introduced runtime surface-visibility handling and its duplicate-delivery behavior, which this change updates for redundant reveals.
  • bitty-terminal/bitty#2700: This PR added occlusion events routed through the visibility gate; this change handles a redundant Occluded(false) delivery.
  • bitty-terminal/bitty#2834: This PR introduced the hidden-repair probe and timer state that the redundant reveal path now clears.
Merge Risk: Minimal · previous review a055c

This change makes a redundant reveal event queue a fresh frame, so prompt rows hidden during a hide/reveal cycle are redrawn. No concrete merge-blocking risk was found. The return edge was not observed on a live host, but that is normal unverified-deployment uncertainty.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix and its target: a redundant reveal edge (same-state true delivery) queues a from-truth frame. The raw summary confirms this is the main change in present.rs and terminal_app.rs…
Linked Issues check Passed Directly linked issue #3030 has three coding requirements. (1) A redundant reveal queues one from-truth frame and the next-frame wake; a redundant hide stays a no-op. In crates/bitty-runtime/src/runti…
Out of Scope Changes check Passed All changes connect to the reveal path described in #3030. The runtime change extracts queue_reveal_repaint, which the hide-to-reveal transition and the redundant reveal share. The app change in set_s…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the fix and its target: a redundant reveal edge (same-state true delivery) queues a from-truth frame. The raw summary confirms this is the main change in present.rs and terminal_app.rs, with a regression test in tests.rs. The title is specific and matches the changeset and the linked objectives. It uses a conventional commit prefix, which is acceptable.

Full details: Linked Issues check

Explanation

Directly linked issue #3030 has three coding requirements. (1) A redundant reveal queues one from-truth frame and the next-frame wake; a redundant hide stays a no-op. In crates/bitty-runtime/src/runtime/present.rs, set_surface_visibility_at now calls the new queue_reveal_repaint(now) when visible == true and surface_visible == true. That helper sets coalesced_pending, coalesced_deadline = Some(now), pending_full_redraw = true, clears hidden_repair_at, and clears the present-confirmation bound. The hide branch on the same-state path still returns with no change. (2) The frame presents on the next loop turn with no PTY write, grid resize, or surface resize. The test redundant_reveal_queues_a_from_truth_frame checks that tick_at(t0+10ms) presents the frame and clears pending_full_redraw. The prompt_reveal_tests helper assert_switch_wrote_nothing checks pending input, grid size, and surface extent. The redundant reveal path does not write to these. (3) The prompt regression tests use the AWS prompt shape (unterminated 'AWS Access Key ID [None]: '). Visible helpers cover the primary pane, split_rt for a split pane, and second_workspace_rt for a second-workspace pane. assert_same_frame compares headless_rgba against a reference runtime, and prompt_row_has_ink checks the prompt row. The split and second-workspace test bodies are truncated in the supplied diff, so their assertions are taken from the PR description. The app-layer change in crates/bitty-terminal/src/terminal_app.rs (set_surface_gate) forwards redundant reveal edges to set_surface_visibility(true) and leaves redundant hides unchanged, so the edge reaches the runtime. The bitty-terminal test tests::input_vm_boundary::reveal_edge_while_the_gate_is_open_still_presents could not be read: the diff for crates/bitty-terminal/src/tests.rs was unavailable. Its existence is taken from the PR description. This does not affect the verdict, because the core behavior is verified in the runtime code and the runtime test.

Full details: Out of Scope Changes check

Explanation

All changes connect to the reveal path described in #3030. The runtime change extracts queue_reveal_repaint, which the hide-to-reveal transition and the redundant reveal share. The app change in set_surface_gate clears hidden_repair_probe_at on a visible edge. This follows from the #2989 speculative repair that the issue's root cause names, so it belongs to the same reveal handling. The startup Resumed behavior now queues a full redraw. The PR states that the first frame is already full, so this adds no extra work. The old contract test repeated_same_visibility_deliveries_are_no_ops is renamed and updated to match the new redundant reveal behavior, and the redundant hide assertions are kept. The prompt_reveal_tests module covers the acceptance criteria of #3030. Documentation comments in present.rs and terminal_app.rs describe the same change. No change was found that is unrelated to #3030. The tests.rs diff was unavailable, so its 34-line addition is assessed only from the PR summary, which describes it as a regression test for the same behavior.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (2 skipped: 2 too large.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ac3196c7-132b-4e4b-b1a0-e07ad4b1a5c6
Commits

Reviewing files that changed from the base of the PR and between 0a6ae35 and a055c38.

Files selected for processing: 3

  • crates/bitty-runtime/src/runtime/present.rs
  • crates/bitty-terminal/src/terminal_app.rs
  • crates/bitty-terminal/src/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Xuepoo and others added 2 commits November 8, 2026 20:00
…tty#3031)

`Windows check and test` failed on four tests in this PR's own new module
(run 42473103199 job 128708284972): each helper spawned a pane with the
hardcoded unix filler `/bin/cat`, so Windows panicked before any assertion —

  pane spawns: Pty("pty i/o error: The system cannot find the file specified. (os error 2)")

at present.rs:15135/15149. The helpers were the only unix-only part of the
module; `panel_rules.rs` already gates its PTY spawns with `#[cfg(unix)]`, so
follow that: gate `split_rt`, `second_workspace_rt`, and the four split and
second-workspace reveal tests, plus `feed_pane`, whose only callers are those
tests (Windows dead_code otherwise). A hardcoded `/bin/cat` is also the
host-value class the workspace forbids in tests.

The reveal behaviour itself is platform-agnostic and stays covered by the
primary-surface cases on every platform plus these four on unix.

Verified: `cargo check -p bitty-runtime --tests --offline`;
`RUSTFLAGS=-D warnings cargo check -p bitty-runtime --tests
--target x86_64-pc-windows-gnu --offline` clean (the leg that was red);
rustfmt +stable --edition 2024 --check clean.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review — guard-dispatched reviewer, round R2, head f45d3b4

Scope: whole PR at head. Two commits (a055c38e production + 3fccb041 Windows fix), merged with main; the three-dot diff vs origin/main is 3 files, +566/-24, and is byte-identical at 3fccb041 and at the merge head, so the fix-round content is what was reviewed.

CHECK 1: PASS
Gated inside mod prompt_reveal_tests (present.rs:15274): helpers feed_pane (15312–15313), split_rt (15321–15322), second_workspace_rt (15341–15342); tests at 15458/15460, 15505/15507, 15596/15598, 15640/15642. Nothing else in present.rs gained a cfg.
All four tests genuinely need a spawned child: they call split_rt/second_workspace_rt, which do spawn_shell_for_view(pane, "/bin/cat", …), and only that spawn inserts into pane_sessions (panes.rs:610); handle_pane_bytes early-returns without a session (panes.rs:1054). feed_pane is gated because both its callers are gated and --tests runs under -D warnings (dead_code would break the Windows leg).
The two tests that can run without a PTY were NOT gated: reveal_keeps_the_unterminated_prompt_primary (15426) and reveal_shows_the_prompt_that_arrived_while_hidden (15555), both feed_primary-only.
Precedent: panel_rules.rs gates every PTY-spawning test the same way (panel_rules.rs:186, 215, 251, 268 …) and gates the then-unused require_pty import (89). Here the macro is fully qualified, so there is no import to gate; #[cfg(unix)] before #[test] instead of after is cosmetic. Pattern matches.

CHECK 2: PASS
Windows-visible tests in the module: reveal_keeps_the_unterminated_prompt_primary and reveal_shows_the_prompt_that_arrived_while_hidden.
The fixed behaviour keeps non-unix coverage that can actually fail: surface_visibility_tests::redundant_reveal_queues_a_from_truth_frame (present.rs:12342) and repeated_hides_are_no_ops_and_repeated_reveals_repaint (12295), plus the app-level reveal_edge_while_the_gate_is_open_still_presents (bitty-terminal/src/tests.rs:1437, plain #[test]).
Verified by reversion in a scratch worktree (restored afterwards, tree clean): deleting the redundant-reveal branch made exactly those two fail — panics at present.rs:12293 and 12344 — while the other 14 in that module stayed green. So the fix's coverage is not unix-only.
What Windows does lose is shape coverage (non-primary pane grid in a split / second workspace), not the fixed path.

CHECK 3: PASS
git diff origin/main...HEAD adds exactly 8 cfg attributes: #[cfg(test)] on the new module (present.rs:15273) and 7 × #[cfg(unix)] at 15312, 15321, 15341, 15458, 15505, 15596, 15640 — all between 15274 and 15683, i.e. inside mod prompt_reveal_tests. No production item is cfg'd, no spill into bitty-daemon/bitty-terminal; the pre-existing unix gates at 8745/8748/8901/13165/14602 are untouched by this diff.

CHECK 4: PASS
RUSTFLAGS=-D warnings cargo check -p bitty-runtime --tests --target x86_64-pc-windows-gnu --offline (CARGO_TARGET_DIR=…/.targets/ctx-3030-review): exit 0. The only warning: line is the bitty-terminal build-script notice "Windows target on a non-Windows host: the icon resource is not embedded" — a cargo:warning, not a rustc lint, so -D warnings is unaffected, and it predates this PR.
Probe that the command really compiles the gated module: a temporary compile_error! inside mod prompt_reveal_tests made the same command fail with could not compile bitty-runtime (lib test); probe reverted, tree clean.
Linux subset on the same target dir: 6 passed, 0 failed, 0 ignored (all six prompt_reveal_tests ran and passed). I used the lib unit-test target (--lib), which owns these tests; the bare invocation additionally builds ~25 integration-test binaries and hit my local tool timeout, not a failure. cargo fmt --check -p bitty-runtime -p bitty-terminal is clean.

CHECK 5: PASS
(a) One full frame + one wake: queue_reveal_repaint (present.rs:2660–2666) sets coalesced_pending, coalesced_deadline = Some(now) — already open, so present_coalescing_deadline (2183–2194) hands it to the embedder — and pending_full_redraw, which forces full_frame (3892) and bypasses the no-damage early return (3856). Both flags are one-shot, consumed by the commit (7812 clears the coalesced pair; a full redraw is built once).
(b) Gate unchanged: the redundant branch (2564–2575) returns before self.surface_visible = visible (2590); the app forwards through set_surface_visibility(true) (terminal_app.rs:1459), which lands on the same-state path again. The new tests assert is_surface_visible() after the edge.
(c) No PTY write: 2660–2666 touches only present bookkeeping (coalesced*, pending_full_redraw, hidden_repair_at, confirmation bound); the prompt tests pin pending_input_len / grids / surface extent unchanged.
(d) Redundant HIDE still a no-op: inner if visible guard; the transition hide branch (2604–2642) is untouched, and repeated_hides… (12295) still asserts no redraw and no deadline after a second hide.
No same-state loop: the only reveal-proof sources are native edges (Resumed terminal_app.rs:4911, Occluded(false) 4965) and the input path, which early-returns once visible (terminal_app.rs:1479–1481). The hidden-repair probe only fires while hidden, and the speculative reopen is settled either by the reveal frame's commit (7812) or by a hide (2641). Nothing in the runtime re-emits a reveal edge, so each proof buys one bounded frame, not a cycle.

Non-blocking observations:

  • One switch-back can now build two full frames: Resumed and Occluded(false) for the same transition both reach the gate (the app already documents that race, terminal_app.rs:4956) and the second is no longer filtered. Bounded and intended, just a cost.
  • The four gated tests are the only split/second-workspace shape coverage, so Windows keeps the fix's coverage but loses that shape.

CI at review time: on head f45d3b4, run 42478253630 had "Linux Wayland" and "Quality gates (1)" red with a setup-step exit 127 ("Unable to locate executable file: undefined") and no test assertion; that cannot originate from this diff (it touches no workflow, and main ca5a96f is green). The Windows leg was still pending. Re-check CI before merge.

VERDICT: APPROVE

@Xuepoo
Xuepoo merged commit 545b843 into main Nov 8, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-3030/fix-prompt-reveal branch November 8, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:render Area: rendering fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render: an unterminated prompt line vanishes after a workspace hide and reveal

1 participant