Skip to content

test(ui): wait for bubblezone to settle before a test clicks - #30

Merged
junior merged 1 commit into
p10node:mainfrom
junior:ui-click-settle
Nov 8, 2026
Merged

junior merged 1 commit into
p10node:mainfrom
junior:ui-click-settle

Conversation

@junior

@junior junior commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

TestClickingCurrentKindLeavesDescribe failed on main right after #20 and again after #21 merged (one Go version each time, "mode = 1, want the table"), though both pull requests passed. It is a race in the test helpers, not in either change.

bubblezone's Scan hands a frame's zones to a goroutine one at a time, in screen order, and then a marker that deletes the zones the frame does not draw. waitZone returns as soon as the zone it wants has a position, so a click can come while zones further down the frame, or zones an earlier test drew (TestMain makes one manager for the whole test binary), are still where they were. handleMouse checks about a dozen zones before the sidebar rows, and one of them takes the click.

clickZone now renders again through renderSettled, which plants a zone with a scan of its own and returns once the next frame's marker has deleted it, so every zone of that frame is in place and no other is left. TestDoubleClickOpensRow, which clicks right after View(), uses it too.

Measured in golang:1.27 containers, one CPU each:

before after
internal/ui, 150 runs, with a second run beside it 2 failures 0
bubblezone's worker slowed to 50us per zone, 40 runs: TestClickingCurrentKindLeavesDescribe 40 0
the same, TestDoubleClickOpensRow 40 0

gofmt, go vet ./..., go test -short ./... and the full internal/ui tests pass on Go 1.26.10 and 1.27.3.

Not covered here: TestPluginConfirmationExecutesTheDisplayedVariableSnapshot failed once in 150 runs in the same setup. It does not click; it polls a file that a background sh writes, so it is a different race.

TestClickingCurrentKindLeavesDescribe fails now and then on main, with
"mode = 1, want the table" (runs 42427888597 and 42428228663, one Go
version each time): the sidebar click lands on another zone.

bubblezone's Scan hands a frame's zones to a goroutine one at a time,
in screen order, and then a marker that deletes the zones the frame
does not draw. waitZone returns as soon as the zone it wants has a
position, so the click can come while zones further down the frame,
or zones an earlier test drew (TestMain makes one manager for the
whole test binary), are still where they were, and handleMouse checks
a dozen of them before the sidebar rows.

clickZone now renders again through renderSettled, which plants a zone
with a scan of its own and returns once the next frame's marker has
deleted it: every zone of that frame is then in place, and no other is
left. TestDoubleClickOpensRow, which clicks right after View(), uses
it too.

On one CPU, with another such run beside it, the internal/ui package
failed this way 2 times in 150 runs before and 0 in 150 after. With
bubblezone's worker slowed to 50us per zone, the test failed in 40 of
40 runs before and 0 of 40 after, and TestDoubleClickOpensRow in 40 of
40 before and 0 of 40 after.

Signed-off-by: Adao Oliveira Jr <[email protected]>
@junior
junior requested a review from pierreneter as a code owner November 8, 2026 01:16
@junior
junior merged commit 36505a8 into p10node:main Nov 8, 2026
3 checks passed
@junior
junior deleted the ui-click-settle branch November 8, 2026 17:00
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.

2 participants