Skip to content

test(tui): fix decision-toast notification race on py3.14#14

Merged
pbean merged 1 commit into
mainfrom
fix/tui-decision-toast-test-race
Jun 26, 2026
Merged

test(tui): fix decision-toast notification race on py3.14#14
pbean merged 1 commit into
mainfrom
fix/tui-decision-toast-test-race

Conversation

@pbean

@pbean pbean commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

What

The post-merge CI run for #13 failed a single job — test (py3.14) — on tests/test_tui_app.py::test_decision_banner_shows_and_clears. 3.11–3.13 passed. The failure is a test-timing race, not a product bug.

Root cause

The test waits for screen.decision_pending, then synchronously asserts the decision toast is in app._notifications:

await until(pilot, lambda: screen.decision_pending is not None)
...
assert any("reopen the cache work?" in m for m in notifications(app))

But the toast is emitted with self.notify(), which posts a message onto textual's async pump. decision_pending (_decision) is set synchronously in _apply, while the notification only lands in app._notifications a tick later when the pump processes the Notify message. So the bare assert can run before the notification is observable. Under CI's parallel IO contention the py3.14 runner lost that race; the faster interpreters happened to win it.

Fix

Wait for the toast via until() instead of asserting synchronously — the exact pattern every other notification test in this file already uses (e.g. test_attach_without_tmux_notifies). One line, test-only, no product change.

Verification

Ran the full tests/test_tui_app.py module on both py3.13 and py3.14 (CI-matching uv sync --locked --all-extras): 39 passed on each.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated an app interaction test to better handle delayed notification delivery.
    • Improved test reliability by waiting for the expected message to appear before asserting on it.

`test_decision_banner_shows_and_clears` asserted the decision toast was
present synchronously, right after waiting for `decision_pending`. But the
toast is emitted via `self.notify()`, which posts a message onto textual's
async pump — it only lands in `app._notifications` a tick after `_decision`
is set in the same `_apply` call. The bare assert could therefore run before
the pump processed the Notify message; under CI's parallel IO contention this
flaked on py3.14 (3.11–3.13 happened to win the race).

Wait for the toast via `until()` instead, matching every other notification
test in this file (e.g. `test_attach_without_tmux_notifies`). Pure test-timing
fix — no product change. Verified green on py3.13 and py3.14.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 26, 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: 26f5fdc9-1865-4075-98b3-b9c10e9c15c4

📥 Commits

Reviewing files that changed from the base of the PR and between afc55d7 and 7e4fd35.

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

Walkthrough

The TUI test now waits for the decision-question notification to appear before asserting banner behavior, using an async loop around the notification check.

Changes

TUI decision banner test timing

Layer / File(s) Summary
Async notification assertion
tests/test_tui_app.py
test_decision_banner_shows_and_clears now waits for the expected decision-question text in notifications(app) before proceeding.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A bunny hopped by, ears all perked up,
Waiting for toasts in a tiny test cup 🐇
No race, no fuss, just a patient little hop,
Then poof — the banner appeared on top!
Hooray for async, with a sniff and a cheer!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 change: fixing a TUI test race around decision-toast notifications on Python 3.14.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tui-decision-toast-test-race

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.

@pbean pbean merged commit b9dca02 into main Jun 26, 2026
7 checks passed
@pbean pbean deleted the fix/tui-decision-toast-test-race branch June 26, 2026 00:35
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