Skip to content

test: stop scene and script event tests timing out on a busy runner - #656

Merged
M4n0x merged 1 commit into
mainfrom
dev/fix-ci-flaky-test
Nov 14, 2026
Merged

M4n0x merged 1 commit into
mainfrom
dev/fix-ci-flaky-test

Conversation

@M4n0x

@M4n0x M4n0x commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Problem

Since #619 fixed the hangs, 3 of 49 CI Test runs failed on tests that bound a main-actor wait with the clock. Swift Testing runs about 900 tests at once, nearly all on the main actor, so on the macOS runner a test can wait seconds for its next turn:

  • settingsSceneDrawsTheSettingsOfAPackageItInstalls failed with "the views weren't ready after a minute" in runs 43300511730, 43444323935 and 43574762026. OffscreenSnapshot.write gave the views 60 seconds of wall-clock time, and the package scene needs many main-actor turns to load its package: the test took 46 to 70 seconds even in passing runs (1.2 s alone).
  • eventBurstsFinishCurrentCommandThenRunLatestPayloadWithoutOverlap failed at ScriptEventTests.swift:69 (run 43436005366). Its startup command waits for the test to release it but timed out after 4 seconds first; the later command succeeded and cleared the error, leaving a log without end:startup:initial. It also failed once in a local full run on current main.
  • widgetActionsRunInOrderAndStoppingCancelsQueuedWork(stop: false) failed at ScriptEventTests.swift:298 (run 43192081269) the same way, with a 60-second action timeout.

Changes

  • OffscreenSnapshot.write counts its readiness checks instead of watching the clock: at most 600 checks a tenth of a second apart, so still about a minute when nothing else runs, as AGENTS.md asks for main-actor waits. --render-scenes and the docs images use it too.
  • The two commands the script event tests hold until they release them get 120 seconds, like the command in cancellingAWidgetStopsItsRunningCommand.

Testing

  • Reproduced the scene failure. Full Swift Testing suite run at background priority (taskpolicy -b swift test --skip-build --disable-xctest, about 4× slower): before, four scene tests failed with CI's exact "weren't ready after a minute"; after, those three settings scenes and the event burst test pass.
  • Proved each mechanism with a temporary probe that holds the main actor (removed before committing): 5 s after the startup command began failed the event burst test every time with the CI assertion and passed with 120 s; a 61 s hold failed the readiness wait and the stop: false widget actions case before and passed after.
  • The scene and script event suites pass in repeated normal runs and with LIBDISPATCH_COOPERATIVE_POOL_STRICT=1; scripts/check.sh --quick passes.
  • An independent investigation by a second model reached the same causes and fix.

Not covered: on macOS 27.2 locally, setupSceneDrawsTheSameStepHoweverLongItSettles fails 20–30% of runs with or without this change (its two drawings differ slightly around the selected card's glow); it has not failed on CI (macOS 26) since #528 closed. aListThatScrollsFollowsItsEndAndShowsANewEntry failed three runs on November 11 and not since; it couldn't be reproduced, so it's unchanged.

Merging

One test: commit, so any merge method works; it starts no release.

Claude Opus 5.5 via Claude Code, cross-checked by GPT-6.1-sol via Codex

Swift Testing runs about 900 tests at once on CI, nearly all on the main actor, so a test can wait
seconds for its next turn. Three tests bounded such a wait with the clock:

- Scenes gave their views 60 seconds to get ready. The package scene's views need many main-actor
  turns; it took 46 to 70 seconds in passing runs and failed three runs since #619. The wait now
  counts 600 checks a tenth of a second apart, still about a minute when nothing else runs.
- The event burst test timed out its startup command after 4 seconds, before the test released
  it. A later command cleared the error and left a log without end:startup.
- The widget actions test's first action had 60 seconds, which a 61-second hold also beat.

Both held commands now get 120 seconds, like the cancellation test's command.
@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner November 14, 2026 14:06
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

OffscreenSnapshot.write now limits readiness checks with a counter. Two script event test timeouts increase to 120 seconds, and one test gains a comment about possible startup delays.

Changes: Snapshot readiness limit

Layer / File(s) Summary
Readiness check limit
Sources/StableBar/OffscreenSnapshot.swift
The documentation describes checks every tenth of a second, capped at 600. The readiness loop replaces its 60-second deadline with a counter and retains the existing sleep.

Script event test timeouts

Layer / File(s) Summary
Extended test timeouts
Tests/StableBarTests/ScriptEventTests.swift
The event-burst test notes possible startup delays and raises its command timeout to 120 seconds. The widget-action test raises the volume timeout to 120 seconds.
Merge Risk: Minimal · up to 79058

The change makes snapshot readiness waits and two script event tests more tolerant of a busy runner. No actionable merge-blocking risk was found.

Security architecture risk: Minimal · up to 79058

The change permits longer snapshot waits on busy runners and increases two test-only command timeouts. No introduced or worsened security, cleanup, or ownership risk was identified.

Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description is thorough and follows the template. It has a Problem section that explains the failing CI runs and links the prior fix (#619). It has a Changes section that explains each change and …
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.
Full details: Description check

Explanation

The description is thorough and follows the template. It has a Problem section that explains the failing CI runs and links the prior fix (#619). It has a Changes section that explains each change and its reason. It has a Testing section that lists local repro runs, probes, and suites, and it names what was not covered. It has a Merging section that says one test: commit makes any merge method safe. It ends with the model and harness line that the template requires. The Problem section does not use a closing keyword such as "Fixes #" for an issue, but the PR cites #656 and #619 and #528 as context. This is a minor gap and does not affect completeness.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b57ad13 and 790586c.

Files selected for processing: 2

  • Sources/StableBar/OffscreenSnapshot.swift
  • Tests/StableBarTests/ScriptEventTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Before and after

main at b57ad13 → this pull request at 790586c · 156 screens drawn in one CI job · 0 changed

156 unchanged screens

docs/essentials-clock-settings-dark, docs/essentials-clock-settings-light, docs/essentials-dark, docs/essentials-light, docs/essentials-settings-dark, docs/essentials-settings-light, docs/hero-dark, docs/hero-light, docs/popups-dark, docs/popups-light, docs/settings-dark, docs/settings-light, docs/themes-dark, docs/themes-light, scenes/accessibility-guide-dark, scenes/accessibility-guide-light, scenes/app-menu-popup-dark, scenes/app-menu-popup-light, scenes/apple-menu-settings-dark, scenes/apple-menu-settings-light, scenes/bottom-bar-popup-dark, scenes/bottom-bar-popup-light, scenes/chat-popup-dark, scenes/chat-popup-light, scenes/crowded-edit-bar-dark, scenes/crowded-edit-bar-light, scenes/dock-badges-bar-dark, scenes/dock-badges-bar-light, scenes/edit-bar-wide-group-dark, scenes/edit-bar-wide-group-light, scenes/essentials-clock-popup-dark, scenes/essentials-clock-popup-light, scenes/filled-slider-popup-dark, scenes/filled-slider-popup-light, scenes/gruvbox-bar-dark, scenes/gruvbox-bar-light, scenes/horizontal-list-popup-dark, scenes/horizontal-list-popup-light, scenes/increase-contrast-bar-dark, scenes/increase-contrast-bar-light, scenes/increase-contrast-popup-dark, scenes/increase-contrast-popup-light, scenes/input-source-popup-dark, scenes/input-source-popup-light, scenes/notch-flare-bar-dark, scenes/notch-flare-bar-light, scenes/privacy-both-bar-dark, scenes/privacy-both-bar-light, scenes/privacy-hide-when-idle-bar-dark, scenes/privacy-hide-when-idle-bar-light, scenes/privacy-idle-bar-dark, scenes/privacy-idle-bar-light, scenes/privacy-microphone-bar-dark, scenes/privacy-microphone-bar-light, scenes/privacy-settings-dark, scenes/privacy-settings-light, scenes/reduce-transparency-bar-dark, scenes/reduce-transparency-bar-light, scenes/reduce-transparency-glass-bar-dark, scenes/reduce-transparency-glass-bar-light, scenes/settings-bar-dark, scenes/settings-bar-light, scenes/settings-bar-placement-bottom-dark, scenes/settings-bar-placement-bottom-light, scenes/settings-bar-placement-dark, scenes/settings-bar-placement-light, scenes/settings-crashes-dark, scenes/settings-crashes-light, scenes/settings-feedback-dark, scenes/settings-feedback-light, scenes/settings-general-dark, scenes/settings-general-light, scenes/settings-general-macos15-dark, scenes/settings-general-macos15-light, scenes/settings-general-move-dark, scenes/settings-general-move-failed-dark, scenes/settings-general-move-failed-light, scenes/settings-general-move-light, scenes/settings-general-move-moving-dark, scenes/settings-general-move-moving-light, scenes/settings-general-move-replace-dark, scenes/settings-general-move-replace-light, scenes/settings-general-setup-open-dark, scenes/settings-general-setup-open-light, scenes/settings-general-spaces-dark, scenes/settings-general-spaces-light, scenes/settings-help-dark, scenes/settings-help-light, scenes/settings-help-starred-dark, scenes/settings-help-starred-light, scenes/settings-narrow-dark, scenes/settings-narrow-light, scenes/settings-package-dark, scenes/settings-package-light, scenes/settings-package-widget-dark, scenes/settings-package-widget-light, scenes/settings-theme-dark, scenes/settings-theme-light, scenes/settings-uninstall-dark, scenes/settings-uninstall-failed-dark, scenes/settings-uninstall-failed-light, scenes/settings-uninstall-light, scenes/settings-widget-backgrounds-dark, scenes/settings-widget-backgrounds-light, scenes/settings-workspace-hidden-dark, scenes/settings-workspace-hidden-light, scenes/setup-look-below-menu-bar-dark, scenes/setup-look-dark, scenes/setup-look-no-notch-dark, scenes/setup-move-existing-dark, scenes/setup-move-failed-dark, scenes/setup-move-ready-dark, scenes/setup-move-replace-dark, scenes/setup-omniwm-connection-dark, scenes/setup-permissions-dark, scenes/setup-permissions-spaces-dark, scenes/setup-permissions-spaces-ready-dark, scenes/setup-placement-bottom-dark, scenes/setup-placement-dark, scenes/setup-touches-dark, scenes/setup-touches-macos15-dark, scenes/setup-touches-spaces-dark, scenes/setup-try-dark, scenes/setup-yabai-connection-dark, scenes/slider-end-stop-popup-dark, scenes/slider-end-stop-popup-light, scenes/stablebar-widget-bar-dark, scenes/stablebar-widget-bar-light, scenes/stablebar-widget-settings-dark, scenes/stablebar-widget-settings-light, scenes/starter-bar-dark, scenes/starter-bar-light, scenes/starter-edit-bar-dark, scenes/starter-edit-bar-light, scenes/symbol-variants-bar-dark, scenes/symbol-variants-bar-light, scenes/system-monitor-memory-bar-dark, scenes/system-monitor-memory-bar-light, scenes/system-monitor-shows-settings-dark, scenes/system-monitor-shows-settings-light, scenes/system-monitor-split-warning-bar-dark, scenes/system-monitor-split-warning-bar-light, scenes/update-popup-dark, scenes/update-popup-light, scenes/update-popup-star-github-cli-dark, scenes/update-popup-star-github-cli-light, scenes/update-popup-star-thanks-dark, scenes/update-popup-star-thanks-light, scenes/workspace-badges-bar-dark, scenes/workspace-badges-bar-light, scenes/workspace-focused-window-bar-dark, scenes/workspace-focused-window-bar-light, scenes/workspace-focused-window-padding-bar-dark, scenes/workspace-focused-window-padding-bar-light, scenes/workspace-hidden-apps-bar-dark, scenes/workspace-hidden-apps-bar-light

Visual review: 156 screens, none changed.

@M4n0x
M4n0x merged commit 25c19f5 into main Nov 14, 2026
15 checks passed
@M4n0x
M4n0x deleted the dev/fix-ci-flaky-test branch November 14, 2026 14:42
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.16.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

M4n0x added a commit that referenced this pull request Nov 17, 2026
)

completedActionCannotRestartAReplacedWidget holds a widget action until the test has reloaded the
configuration and seen the replacement widget's output. The widget set no timeout, so the action got
the default 10 seconds, and on CI the main-actor turns in between took longer: the command was
killed and store.actionErrors kept the timeout (PR #789's run took 75 seconds).

The widget now sets a 120-second timeout, as #656 gave the other held commands in this file. A
probe that held the main actor for 11 seconds after the action started failed the test the same
way before this change and passed after it.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant