diff --git a/gui/tests/codex-account-pool-target-switch.test.tsx b/gui/tests/codex-account-pool-target-switch.test.tsx index c0f34182ab0..34117fe5beb 100644 --- a/gui/tests/codex-account-pool-target-switch.test.tsx +++ b/gui/tests/codex-account-pool-target-switch.test.tsx @@ -143,7 +143,12 @@ async function switchTarget(targetKey: string, releasePrevious: () => void) { configureApiTargets(relay("/same", targetKey)); actEnvironment(false); try { - root!.render(); + // A timer scheduled before React commits can win the race on a loaded runner. + // Observe the layout commit itself; release the old read in that same phase so + // the regression still exercises the interval before passive effects run. + await new Promise(resolve => { + root!.render( { releasePrevious(); resolve(); }} />); + }); await new Promise(resolve => setTimeout(resolve, 0)); } finally { actEnvironment(true);