Skip to content

fix(test): stabilize flaky file-browser follow test - #81

Merged
GOODBOY008 merged 1 commit into
mainfrom
fix/file-browser-follow-flake
Aug 13, 2026
Merged

fix(test): stabilize flaky file-browser follow test#81
GOODBOY008 merged 1 commit into
mainfrom
fix/file-browser-follow-flake

Conversation

@GOODBOY008

Copy link
Copy Markdown
Owner

Problem

The returns to the same terminal directory after manual navigation on the next prompt test in integrated-file-browser-keyboard.test.tsx flakes intermittently on Windows and macOS CI (3 observed failures) at findByTitle('/home') — the same file has a documented history of timing flakes (prior fix in fc2ff27).

Root cause

On mount, two loads race:

  • the safety-net load of /home (initial committedPathRef), and
  • the follow load of /srv/app (from terminalWorkingDirectory).

If the follow's setCurrentPath('/srv/app') hasn't committed when the test clicks Home:

  1. navigateTo('/home') no-opscurrentPath is still the initial /home, and navigateTo early-returns on path === currentPath.
  2. The waitFor('/home' called) passes spuriously via the mount's safety-net call (it only checks "called with", not count).
  3. The pending follow load then commits /srv/app, so findByTitle('/home') times out.

This window is microtask-tight, which is why it only manifests under CI CPU contention.

Fix

  • Wait for the follow to fully commit (findByTitle('/srv/app')) before clicking Home — so the navigation can't no-op.
  • Require the Home click to trigger its own load (assert 2 /home calls: mount safety-net + navigation) instead of a bare "called with", which the mount call alone satisfies.

Verification

  • Reproduced locally with a 0–30ms jitter on the follow invoke: original test 14/30 failures, fixed test 0/30 failures.
  • Full suite green locally: 565 tests pass, tsc clean.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings August 8, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes a flaky integration test for IntegratedFileBrowser directory-following behavior by ensuring the test waits for the follow navigation to commit before performing a Home navigation, and by strengthening assertions to confirm the Home click triggers a distinct load.

Changes:

  • Wait for the follow directory (/srv/app) to render in the breadcrumb before clicking Home to prevent a no-op navigation race.
  • Replace a “called with” assertion with an explicit call-count assertion to ensure the Home action triggers its own /home load (in addition to the mount safety-net load).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@GOODBOY008 GOODBOY008 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: verified against the linked CI failure (run 31673056116)

Reproduced the failure on main @ 9a5ec2f. The linked run failed on windows-latest with TestingLibraryElementError: Unable to find an element with the title: /home. in IntegratedFileBrowser terminal directory following > returns to the same terminal directory after manual navigation on the next prompt (5234ms) — despite the timeout: 5000 / 15000 band-aids already on main (#83/#84). Confirms the flake is event ordering, not slowness.

Root cause checked against the component code (integrated-file-browser.tsx):

  • navigateTo early-returns on path === currentPath (line 708) — clicking Home while currentPath is still the initial /home is a silent no-op.
  • The follow load commits setCurrentPath('/srv/app') only after its invoke resolves (lines 632–634) — that's the race window.
  • The mount safety-net load (/home) satisfies a bare toHaveBeenCalledWith('/home'), masking the no-op. Analysis is accurate.

Fix verified empirically (same 0–30ms jitter on the /srv/app invoke as described in the PR body):

  • base 9a5ec2f + jitter: 20/25 pass, 5 failures with the exact CI error signature.
  • PR head + jitter: 25/25 pass.
  • Full suite on PR head: 565/565 pass.

Merge check: 3-way merge-tree of main + PR head is conflict-free. The merged result keeps both the ordering fix and main's generous timeouts (they coexist — the PR predates those commits, so nothing is silently dropped). The count assertions are deterministic: exactly one mount /home load (main load effect skips on mount via prevConnectionIdRef) + one from the Home navigation.

Non-blocking: the branch is 3 commits behind main (#82/#83/#84). The merge is clean, but a rebase would let CI validate against the latest main before merging.

The "returns to the same terminal directory after manual navigation on
the next prompt" test flaked intermittently on Windows and macOS CI at
findByTitle('/home'): the follow load of /srv/app and the mount
safety-net load of /home race, and if the follow's setCurrentPath had
not committed when the test clicked Home, navigateTo('/home') no-ops on
the initial '/home' state. The waitFor for the /home call then passes
spuriously via the mount's safety-net call, and the pending follow load
lands on /srv/app — so findByTitle('/home') times out.

Reproduced locally with a 0-30ms jitter on the follow invoke: 14/30
failures on the original test, 0/30 with this fix.

- Wait for the follow to fully commit (breadcrumb renders /srv/app)
  before clicking Home, so the navigation can't no-op.
- Require the Home click to trigger its own load (2 /home calls: mount
  safety-net + navigation) instead of a bare "called with".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@GOODBOY008
GOODBOY008 force-pushed the fix/file-browser-follow-flake branch from 5b5f5a2 to 897733b Compare August 13, 2026 08:48
@GOODBOY008
GOODBOY008 merged commit e114841 into main Aug 13, 2026
4 checks passed
@GOODBOY008
GOODBOY008 deleted the fix/file-browser-follow-flake branch August 13, 2026 08:56
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