Skip to content

test(ui): make AppUI resize/cache tests environment-independent#8

Merged
lavindeep merged 1 commit into
ui-reworkfrom
fix/ui-resize-test-flake
Jun 27, 2026
Merged

test(ui): make AppUI resize/cache tests environment-independent#8
lavindeep merged 1 commit into
ui-reworkfrom
fix/ui-resize-test-flake

Conversation

@lavindeep

Copy link
Copy Markdown
Owner

A monitor's gate run flagged test_resize_rerenders_ansi failing on ui-rework (ansi_80 == ansi_40), though local + PR CI were green — a flaky, environment-dependent assertion.

Cause

The resize and cache-invalidation tests asserted byte-inequality of the rendered ANSI. That conflates two things:

  • whether AppUI re-rendered (what AppUI owns), and
  • whether Rich produced different bytes for the two widths (terminal / Rich-version dependent).

In an environment where Rich doesn't honor the explicit Console(width=...), both widths render identical bytes → the value-inequality assertion fails spuriously, even though AppUI re-rendered correctly.

Fix

Assert the contract AppUI actually owns: a width/content change is a cache miss that yields a fresh render object (object identity, not byte value), mirroring test_cache_hit_at_same_width's is. The resize test also pins the cache key to the new width. The visible re-wrap stays a live-checklist item.

Verified red-first: a width-insensitive cache (no re-render) returns the same cached object and the identity assertion fails. Full gate green locally (1314 passed, mypy --strict clean).

The resize and cache-invalidation tests asserted byte-inequality of the
rendered ANSI (ansi_80 != ansi_40). That conflates two things: whether
AppUI re-rendered (what AppUI controls) and whether Rich produced
different bytes for the two widths (terminal/Rich-version dependent).
In an environment where Rich does not honor the explicit Console width,
both widths render identical bytes and the value-inequality assertion
fails spuriously — even though AppUI re-rendered correctly.

Assert the contract AppUI actually owns instead: a width or content
change is a cache miss that yields a fresh render object (identity, not
value), mirroring test_cache_hit_at_same_width's 'is'. The resize test
also pins the cache key to the new width. Verified red-first: a
width-insensitive cache (no re-render) returns the same cached object
and the identity assertion fails. The visible re-wrap stays a
live-checklist item.
@lavindeep lavindeep merged commit 9cc126a into ui-rework Jun 27, 2026
2 checks passed
@lavindeep lavindeep deleted the fix/ui-resize-test-flake branch June 27, 2026 23:33
lavindeep added a commit that referenced this pull request Jul 2, 2026
test(ui): make AppUI resize/cache tests environment-independent
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