Skip to content

test(tui): de-flake near-tail journal-jump scroll assertion#108

Open
dracic wants to merge 1 commit into
bmad-code-org:mainfrom
dracic:fix/tui-journal-jump-flaky-wait
Open

test(tui): de-flake near-tail journal-jump scroll assertion#108
dracic wants to merge 1 commit into
bmad-code-org:mainfrom
dracic:fix/tui-journal-jump-flaky-wait

Conversation

@dracic

@dracic dracic commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

De-flake test_journal_jump_near_tail_does_not_chase_growing_log, which intermittently failed in CI with assert 188 == 0. Test-only change.

Why

The jump handler (_jump_to_log_event_scroll_log_to) defers its scroll via a set_timer until the RichLog flushes its lines and grows tall enough to scroll. The test waited on a bare is_vertical_scroll_end, which is trivially true in the pre-flush empty state (scroll_y == max_scroll_y == 0). On a fast capture it sampled anchored = 0 before the deferred scroll landed at the tail; the delayed jump then moved the view to 188, tripping assert 188 == 0.

The 188 was the legit jump landing (old content max), never tail-chasing — the product anchor (_log_follow_tail = False) was already correct. This is a test-synchronization race, not a product bug.

How

  • Gate the wait on max_scroll_y > 0 and is_vertical_scroll_end so anchored is sampled only after content is actually rendered at the tail. This is the tail-variant of the 0 < scroll_y < max_scroll_y guard the sibling test_journal_enter_jumps_to_log_position already uses.
  • Add @pytest.mark.flaky(reruns=2, reruns_delay=1), matching the two sibling journal-jump tests, for the orthogonal exclusive-poll-supersede stall the until docstring documents.

Testing

Ran the target 5× with flaky reruns disabled (-p no:flaky) → 5/5 green, so the wait fix alone is deterministic; the marker is belt-and-suspenders. Ruff check + format clean. No other test in the suite uses the bare-scroll-end wait pattern.

Summary by CodeRabbit

  • Tests
    • Improved a timing-sensitive terminal navigation test to better account for delayed log rendering.
    • Marked the test as flaky to reduce false failures in CI.
    • Strengthened the wait condition so it verifies the log has finished loading and reached the end before continuing.

The jump handler defers its scroll via a set_timer until the RichLog
flushes its lines and grows tall enough to scroll. The test waited on a
bare `is_vertical_scroll_end`, which is trivially true in the pre-flush
empty state (scroll_y == max_scroll_y == 0), so on a fast capture it
sampled anchored=0 before the deferred scroll landed at the tail. The
delayed jump then moved the view to 188, tripping `assert 188 == 0`.

Gate the wait on `max_scroll_y > 0 and is_vertical_scroll_end` so it
samples only after the content is actually rendered at the tail - the
tail-variant of the `0 < scroll_y < max_scroll_y` guard its sibling
jump test already uses. Also add the flaky marker its two sibling
journal-jump tests carry for the orthogonal poll-supersede stall.

No product change; the anchor logic was already correct.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ccd9933e-e53e-4cfc-8c64-43acd1aa1ab0

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0a308 and ff5ce6c.

📒 Files selected for processing (1)
  • tests/test_tui_app.py

Walkthrough

The journal jump test is marked flaky and now waits for the log pane to render scrollable content before checking that it is at the vertical end.

Changes

Journal jump test

Layer / File(s) Summary
Strengthen journal jump synchronization
tests/test_tui_app.py
Marks the near-tail journal jump test as flaky and waits for both non-zero scroll range and vertical-end positioning after the jump.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

I’m a bunny who waits by the log’s bright tail,
For flushed little lines before tests set sail.
With scroll range awake and timing made right,
The journal jump lands at the end just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main test-only change: de-flaking the near-tail journal-jump scroll assertion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant