Repository navigation
Description
Priority: P1 | Area: render | Labels: fix,P1,area:render | Milestone: v0.1.0 | RFC: none | Task: CTX-1905
Report
After agy (Antigravity CLI) leaves its Swarm view with Esc, the pane keeps showing stale content: only (roughly) the first row updates, everything the application draws afterwards is invisible.
Decisive evidence, captured from the live pane while the screen was stale:
-
bitty ctl terminal text t:1returned the complete, correct grid — the conversation, the Swarm board line,esc to cancel, the status line. So the terminal state is right and the screen is wrong.● Swarm(Koma Website, Docs & Packaging R2 CI/CD) Done · 36 posts · alt+s board · alt+x dismiss ──────────────────────────────────────────────────────────────────────────────── esc to cancel accept-edits · Gemini 4 Hydrogen · medium · AI: Out of credits -
bitty ctl terminal list→scrollback_lines: 10000,retained_heap_bytes: 98,692,125,child_state: unreaped. -
bitty ctl panel list→p:1 v:1 155x40+0+0 tiled yes(geometry correct, pane focused). -
The owner's discriminator: dragging the window size, or splitting and unsplitting the pane, makes the whole screen appear immediately. A resize or layout edit recovers the visible output; this does not by itself distinguish incomplete paint from a submitted frame the compositor did not sample.
The live evidence points downstream of Terminal Truth, in the paint/presentation path, but does not establish which defect caused this incident.
Why this is not the same as #3259
#3259 (scroll margins leaking out of the alternate screen) is a real, separately reproduced state-machine defect, and it is fixed in #3260. It cannot explain this report: here the grid is correct at the moment the screen is stale, so nothing about the state machine's content is wrong.
Relationship to earlier defects
- render: a pane with text in its grid can present a completely empty frame #3032 — a pane whose grid held text presented a completely empty leaf; fixed by [CTX-1746] fix(render): never present an empty leaf when the pane grid holds text (bitty#3032) #3043 ("never present an empty leaf when the pane grid holds text"), which also added an empty-leaf retry bound. Pane state signature there was also ~93 MB retained and an unreaped child.
- fix(runtime,pty,platform,config): coalesce large synchronized TUI frames without intermediate top-to-bottom redraws and fix non-ASCII remote input #3122 — coalescing large synchronized TUI frames without intermediate top-to-bottom redraws.
- fix(term-state): prevent inline TUI status-bar staircasing and border duplication during panel resize drag #3103 — inline TUI status-bar staircasing during a resize drag (inline-viewport bookkeeping).
- fix(platform,runtime,term-state): fix Wayland ANR under high-rate PTY output, workspace-switch scroll reset, wide-char backspace cursor skip, and Shift+Enter encoding #3096 — a workspace switch snapping a scrolled viewport to live.
This report differs from #3032 in shape: not an empty leaf, but a partially stale one — a subset of rows updates while the rest keeps an older frame.
Reproduced failure and fix scope
- A headless fake-presenter regression reproduces a generic failure: the worker accepts successive full frames but no compositor confirmation arrives. After three fast corrective repaints, an open visibility gate could park with no frame owed, no confirmation deadline, and no full redraw pending. The gate is permission to attempt a present, not proof that a surface is being sampled or that it is not occluded.
- CTX-1905 retains the three fast repairs from render: a present that never reaches the compositor leaves a stale frame and nothing retries it #2989. Once exhausted, an open, non-speculative gate keeps a five-second retry deadline for at most one same-extent Configure and full repaint per interval. A closed gate does not run the slow retry; the existing bounded blind-probe/park behavior from render: a present that never reaches the compositor leaves a stale frame and nothing retries it #2989 and fix(runtime,render,platform): resolve Hyprland workspace switch frame freeze and reduce font heap footprint #3116 remains. A compositor confirmation settles the loop. Applied Configure resets the fast miss budget, but does not restore the fast cadence during the outstanding slow repair episode.
- The same task prevents paint-only reuse of a retained leaf at a different extent and prevents no-draw/empty-layout paths from consuming text-bearing primary or pane damage. These are separate, app-agnostic defects. A headless comparison of damage-only and full redraws found pixel parity in the tested alt-screen, synchronized-update, scroll, and pane cases; the audit did not find missing source damage.
Live incident: still unconfirmed
The reporter’s exact agy Swarm escape bytes have not been captured. The available logs for installed Bitty 0.0.45 contain first misses, but no second or third misses; they do not establish that the fast budget was exhausted in this incident. The deterministic regression proves the generic present-park defect, not the reporter’s application sequence.
A worker Configure rebuilds the GPU surface configuration; it does not reset winit’s FrameCallbackState::Requested. The fake backend verifies Configure and retry, not that a particular compositor samples the new buffer or resumes its callback stream. An explicit-sync or compositor stall remains a separate possibility; use the unconfirmed-present, repair outcome, and existing acquire counters to distinguish what happened without logging terminal content.
Acceptance
- The deterministic regressions fail before the fix and pass after it: visible budget exhaustion, same-origin retained extent, and no-draw primary and pane damage.
- A visible surface retries from truth across multiple slow intervals with one repair each; a hidden surface does not reconfigure, and confirmation stops the retry.
- Representative incremental frames remain pixel-identical to full redraws of the same truth.
Activity
Xuepoo commentedon Nov 19, 2026
Scope update: the owner asked us to treat agy as a trigger example, not an app-specific bug. Diagnose the shared damage/present path across TUI classes (synchronized updates, alternate-screen transitions, coalescing, scroll/resize, hidden/reveal, retained-frame reuse). Include every analogous case that can be reproduced headlessly and shares the confirmed root cause; track plausible but unproven risks separately. Do not add agy-specific behavior. Acceptance requires at least one regression that fails before the systemic fix and passes after, plus broader invariant tests that prevent the same loss through other update paths.
Xuepoo commentedon Nov 19, 2026
Owner confirmed the discriminator: resizing the window or splitting/unsplitting the pane immediately restores the missing content. This makes the partial-damage/full-redraw diagnosis confirmed, not just a hypothesis. The investigation scope is intentionally systemic: audit shared TUI update paths and include other reproducible cases with the same root cause; do not special-case agy.
Xuepoo commentedon Nov 19, 2026
Diagnosis round 1 (no code changes, no commits)
Ran against
04253d4c. Everything below is headless and app-agnostic: three independent harnesses, driven through the real present path.The headline: I could not find a place where the damage is lost. Every shape I could construct — including alternate-screen entry/exit, an exit inside an open
?2026window, exit+print in one batch, realagy/hermes/vim/lesscaptures, a 155x42 grid with deep scrollback and 40 synchronized full-screen frames in one tick, a scrolled viewport, and a split pane with its own session — paints a frame that is byte-identical to a whole-frame redraw of the same Terminal Truth. That is strong negative evidence, and it moves the ranking to the one mechanism that does reproduce: a committed frame the compositor never samples, after which the runtime parks with nothing owed.1. Confirmed defect (A) — a visible surface parks after the confirmation budget
crates/bitty-runtime/src/runtime/present.rs:2494-2504A present that the driver accepted but the compositor never sampled consumes its damage, commits (
commit_present,present.rs:8360-8408), and armspresent_confirm_at(:2425). Each expiry above rebuilds and re-presents once, up toPRESENT_CONFIRM_REPAIR_LIMIT(:118). Every later commit re-arms the bound and burns it at:2494without arming anything: nopending_full_redraw, nopresent_confirm_at, no coalesced wake.present_owed()is false (:2336), so the loop parks. The surface keeps whatever buffer the compositor last sampled.Reproduction (fake presenter, deterministic; the only failure in this round):
It asserts the issue's own acceptance property for a visible surface:
present_owed() || present_confirm_deadline().is_some() || pending_full_redraw. It fails today.Control::new(false)is a healthy backend (no blocked acquire): every frame commits, only the frame callback never arrives.The existing
an_unconfirming_surface_stops_after_the_repair_budgetpins the park as intended for an occluded surface. The defect is the missing visible/occluded discrimination: a compositor that stops sampling a mapped surface is indistinguishable from an occluded one here, and "stop trying" is the wrong answer for a visible one.2. Why a resize heals — exact mechanism
crates/bitty-runtime/src/runtime/resize.rs:516-541+:557presenter.resize(surface_extent, opacity)sends aConfigureto thebitty-presentworker. The worker callsbackend.configure(), i.e. a new surface/swapchain configuration (bitty-render/src/present.rs:1067-1095→worker_loop:718-753). The buffer the compositor is holding is no longer what the next commit targets.self.present_confirm_at = None; self.present_confirm_misses = 0;— the park is cleared, so the confirmation/repair machinery is live again.self.pending_full_redraw = true;→full_frame(present.rs:4111) → every leaf re-renders with a full-extent damage rect (present.rs:4973-4981) and the composite is submitted withDamageCarry::full()(:8739).allocations != last_presented_allocations(present.rs:4001) forcespending_full, so the new commit is a complete frame — and, unlike a resize, it does not reset the budget, which is why split/unsplit is not a reliable heal and resize is.3. The other four questions
Does the alt-screen exit full-grid damage survive? Yes.
switch_alt_screenpushesdamage_grid_rect(0,0,h-1,w-1)on both edges (state.rs:4045,:4102), and there is no "whole grid damaged" flag that a later smaller set can overwrite:damage_grid_rectappends tobatch_rects(state.rs:4409-4416),finalize_batchcoalesces by union (state.rs:2106-2127,damage.rs:134-241), so a full rect can only ever be widened.resizeis the only path that clears the batch buffers (state.rs:809-811) and it emits its own full-grid damage in the same generation. Cases A (exit then print), B (exit and print in one batch) and C (exit inside?2026h) all compare equal to a full redraw.inline_top_row? Refuted.switch_alt_screencallsclear_inline_viewport()on both edges (state.rs:4034,:4097) and it clearsinline_top_row,sync_frame_cols,sync_frame_stale,saw_unsynced_lf(:4339-4344). The synchronized-update branch only records it when!alt_screen_active()(:3952-3969).state.rsis the only file that mentions it — the runtime keeps no copy — and its only effect is the #3103 right-margin clip (:4366-4371), which truncates content, not damage (your grid was correct, so this cannot be it anyway).Who loses the damage, then? In the composition path, nobody, by construction: a leaf with any damage re-renders its whole viewport (the only
Damageit is handed is a full-extent rect,present.rs:4973-4981), and a leaf with no damage is reused. The only partial leaf repaint in the tree is the CTX-1207 scroll region-copy (present.rs:1683-2030), which fails closed to the full render on every gating condition and is exactly the pathbitty-render/tests/paint_diff.rsdocuments as having no differential coverage. My scroll cases (F, and the 900-line / one-row-live-shape cases) cover it and pass.The retained leaf cache. One real gap: the reuse gate checks atlas epochs, scroll offset, fade, non-empty fills and the glyphless-leaf refusal, but compares
content_sizeonly on the translation branch (present.rs:4529-4535):Reachable only on a paint-only frame whose painted bounds differ (bounds interpolation with a fixed origin, e.g. a
Resize/Movetween during a transition,layout_focus.rs:918-958): the last interpolated frame stores a retained list at the interpolated extent, and the first final frame (bounds_active == false) can reuse it at the wrong extent with no damage and no full redraw. Same-origin resizes are normally masked by the grid reflow emitting full damage, which is why this ranks below the park. No frame-hash/atlas-epoch cache exists that could alias across a content change.#3043's retry bound is not implicated:
EMPTY_LEAF_RETRY_LIMIT(present.rs:3675-3745) only decides whether a leaf that rendered empty owes a rebuild; it can never make a damaged leaf present stale.4. Ranked set
present.rs:2494grep 'present unconfirmed'on stderr; if present, this is itpresent_unconfirmed/acquirecounters climb togetherWAYLAND_DEBUG=1capture + presenter telemetry; ifacquiretimeouts climb instead, it is the driver path, not Bittycontent_sizeat an unchanged origin.present.rs:4531content_size, same origin → must re-rendermark_frame_presentedadvances the primary and every pane generation on the paths that paint nothing (present.rs:8531,:8712,:4084, panes at:2100-2105)5. Reproduction I built, and what it asserts
recording/3262-diag/in thebittycheckout (untracked, not committed):diag_3262_stale_rows.rs— the issue's shape, 6 cases (alt exit, same-batch exit+print, exit inside?2026h, plain increment, full repaint then one-row change, scroll+print). Oracle: after a committed present,hide → tick → show → tickrebuilds from truth; RGBA must be byte-identical. Truth is asserted unchanged across the oracle so a content change can never masquerade as a paint defect. Passes (no stale rows).diag_3262_fuzz.rs— 600 random op scripts (print, CUP, ED/EL, IL/DL, ICH/DCH/ECH, SU/SD/IND/RI, DECSTBM,?47/?1049,?2026), compared after every committed present. Passes.diag_3262_replay.rs— real captures: agy help, vim, less, hermes ×3, with the real system font stack (shaped path, not the fake rasterizer). 764 committed frames. Passes.diag_3262_panes.rs— split pane with its own session, pane alt round trip, sync-wrapped exit, mixed primary/pane prints. Passes.diag_3262_live_shape.rs— 155x42, 900-line history, 40 synchronized full-screen frames in one tick, alt round trip, one-row update, scrolled viewport + output. Passes.diag_3262_source_damage.rs— 300 random scripts at theStateboundary; every changed cell must be inside a reportedGridrect (or the rows of aScrollmotion). Passes (source damage is complete).in_crate_present_confirm_probe.rs— the failing probe in §1.6. Smallest fix
returnatpresent.rs:2494with a long-interval, bounded surface-incarnation repair whilesurface_visible: armpending_full_redraw, ask the presenter for aConfigure(presenter.resize(same_extent, opacity)— the same healreflow_to_gridperforms, which also resetspresent_confirm_misses), present from truth, and cap the attempts with a loud, rate-limited line plus a telemetry counter. Keep the current park for a genuinely hidden surface (!surface_visible), so the occluded contract (an_unconfirming_surface_stops_after_the_repair_budget) still holds and no frame-source storm is introduced.content_sizecomparison above thedx == 0 && dy == 0early return in the reuse gate.:8531,:8712) armpending_full_redrawinstead of consuming the generations when the grid holds text.Tests that pin it:
present_confirm_park_reconfigures_a_visible_surface(in-crate, from the probe) +an_occluded_surface_still_parks.damage_only_present_equals_full_redraw(the 6 shapes),captured_tui_transcripts_never_present_stale_rows(agy/vim/less/hermes),pane_damage_only_present_equals_full_redraw,scroll_copy_repaint_equals_full_redraw(closes the documented gap inpaint_diff.rs).retained_reuse_requires_content_size,nothing_drawn_does_not_consume_damage_when_text_exists.7. Blast radius and scope
State, the composite and the presenter directly.Suggested split: keep #3262 as the umbrella; CTX-1904 lands the F1 fix + a
bitty ctl/telemetry probe forpresent_unconfirmed/park state; a follow-up lands F2+F4; a follow-up makes the differential harness a permanent gate. To separate #1 from #2 on the live host I need two things from the report: the stderr lines matchingpresent unconfirmed by the compositor, and aWAYLAND_DEBUG=1capture of the frozen interval (or just the same stale screen reproduced after a workspace switch-away/back, which reconfigures surfaces like a resize does).Xuepoo commentedon Nov 19, 2026
Implementation scope is now CTX-1905 and covers three app-agnostic findings, each with a separate discriminating regression: (F1) visible surface parks after confirmation misses; (F2) same-origin retained leaf reuse skips content_size comparison; (F3) no-draw paths consume generations while text remains unpainted. The implementation must preserve the genuinely-occluded park and prove each regression fails before its fix. Plausible explicit-sync/compositor stalls remain unconfirmed and will be telemetry/follow-up, not folded into an unproven workaround. The exact agy Swarm byte stream is still not captured, so this task fixes the reproduced generic present defects without claiming that F1 is confirmed as the sole live trigger.