Skip to content

thread-focus-mode.spec.ts: anchor-preservation test assumes a session-wide invariant the feature doesn't guarantee - #65

Merged
ALLiDoizCode merged 2 commits into
mainfrom
sandcastle/issue-56
Aug 3, 2026
Merged

thread-focus-mode.spec.ts: anchor-preservation test assumes a session-wide invariant the feature doesn't guarantee#65
ALLiDoizCode merged 2 commits into
mainfrom
sandcastle/issue-56

Conversation

@toon-backlog-bot

Copy link
Copy Markdown

Fixes the flaky anchor-preservation assertion in thread-focus-mode.spec.ts by re-capturing the scroll anchor before the second toggle instead of assuming it stays valid across the whole test session, and renames the anchor variables to reflect which toggle each one precedes.

Part of #56

This PR was produced by the sandcastle agent:implement runner and is awaiting human review.

🤖 Generated with Claude Code

…-focus-mode spec (buzz#56)

Fixes thread-focus-mode.spec.ts's "focus and split preserve reading context
and interaction ownership" test, which flaked ~2/3 of isolated repeat-each
runs at main HEAD (per #36's investigation).

Root cause (per issue #56, product-owner call confirmed in issue comments):
useThreadViewModeSwitch.changeThreadViewMode restores whatever row was
top-visible at the moment of EACH toggle click — a per-toggle contract, not
a session-wide one. The test captured `anchorId` once before the first
toggle and reused it for both toBeInViewport() assertions, so the second
assertion failed whenever intervening interactions (sidebar click, mention
autocomplete open/dismiss) legitimately moved scroll position between the
two toggles.

Fix: fix the spec, not the product (per the dispatched call — session-wide
anchor preservation is not a guarantee the feature makes). Re-capture a
fresh `secondAnchorId` via topVisibleMessageId(body) immediately before the
second toggle ("Expand thread"), matching what changeThreadViewMode itself
does at click time. The first assertion is untouched.

Out of scope (per issue): the useAnchoredScroll.ts / scrollToMessageImperative
virtualized-branch side-finding — needs its own repro and issue.

Files changed:
- desktop/tests/e2e/thread-focus-mode.spec.ts

Verification: fmt-check, desktop-tauri-fmt-check, clippy, test-unit,
desktop-check, desktop-test, desktop-build, web-check, web-build all pass.

Note: this sandbox has no browser/display, so the Playwright spec itself
(and the ~15x --repeat-each proof the issue asks for) could not be run here.
Needs CI or a reviewer with a display to confirm the flake is gone.

Closes #56

Signed-off-by: Jonathan Green <dev.jonathan.green@gmail.com>
…precede

anchorId/secondAnchorId were ordinal names that didn't say what each
captured value was for; anchorIdBeforeFocusToggle/anchorIdBeforeSplitToggle
make the intent clear without needing the comment to carry it, matching the
before/after anchor naming used elsewhere in this test suite.

Signed-off-by: Jonathan Green <dev.jonathan.green@gmail.com>
@ALLiDoizCode
ALLiDoizCode merged commit c94f670 into main Aug 3, 2026
22 checks passed
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.

1 participant