cmux NEXT: NewTabStyleSwitchTests awaits the style save instead of counting yields
Merged
TE
23d ago+9+9+0123456789-3-3-0123456789
Summary
Fixes the base red CmuxNextAppTests.NewTabStyleSwitchTests.aStylePickedOnThePageIsSavedForEveryNewTab() on feat-cmux-next (newTabTemplate โ .terminal at lines 42 and 50, expected .threads; on the fleet run below, line 44 failed too).
The test was wrong, not the product.
- #20336 brought back the style pick on the New Tab page. Its stated behavior: a pick shows the new style and is saved as
tabs.newTabTemplate(newTab.setTemplateโNewTabPage.saveTemplate, through the settings schema); Terminal and unknown values are ignored. The product still does exactly this. Nothing in that path (NewTabPage.saveTemplate,AgentPaneModel, request decoding,SettingsController, the agent-settable table) changed after #20336 merged.tabs.newTabTemplateis inagentSettableKeys, so the.caller("page")write is allowed.setSettingwrites the file and then awaitsreloadAfterWrite()before it returns. - The test waited for the save by counting yields: up to 400
Task.yield()calls, then 50.saveTemplateruns in aTask, and the reload reads the file on aTask.detached. Yields on the main actor do not wait for that work, so a loaded mini can run out of yields before the snapshot is adopted. The red matches this: the whole test took 0.034 s, and :42, :44 and :50 failed with the file still unwritten. The save (several actor hops, a file read and an atomic write, then a detached reload) had not run when the yields ran out. With the save awaited, the same product code saves.threadsand ignores Terminal and the unknown value (green below), so the product is right. - Fix: the test keeps each save
Taskthe page handler starts and awaits it before reading the snapshot. The assertions are unchanged. It also checks that exactly one save started for the pick and three after the Terminal and unknown picks, so it is stricter than before. No product code changes.
Testing
- Red, base (d978983563a6), fleet
run-swift-testing-suites.sh Packages/macOS/CmuxNext: 284 passed, 1 failed:NewTabStyleSwitchTestsfailed after 0.034 s at :42, :44 and :50. The snapshot was.terminal, and the file still held{"tabs":{"newTabTemplate":"terminal"}}because the save had not run when the yields ran out (aws-m4pro-8, step 9fbe4440a0f51ea166ee3b72). - Green, this head (da73f4f0289f), same command: 285 passed, 0 failed:
NewTabStyleSwitchTestspassed (aws-m4pro-6, step 4001691fa09080a5b7de1a00). - Guards: check-theme-scope, check-system-blue, crash_ratchet,
check-app-size.sh --base,check-no-godfiles.sh --base(all output read; only base-only lines) and lint-ios-package-conventions: all ok. check-concurrency reports one violation, inCmuxNextHomeEngine/HomeBrainHost.swift:197(base, not this PR).
Changelog
none
๐ค Generated with Claude Code
Summary by cubic
Fixes the flaky NewTabStyleSwitchTests by awaiting the style save tasks directly instead of counting Task.yield() calls, which don't wait for the detached reload task that adopts the snapshot.
Bug Fixes
- The test now keeps each save
Taskand awaits it before reading the settings snapshot, so the assertions run after the write and its reload complete. - Added assertions that exactly one save starts for the page style pick and three after the Terminal and unknown picks.