Skip to content

Stop a test attaching to a shell document Bloom does not drive (BL-16799) - #8297

Merged
hatton merged 2 commits into
masterfrom
BL-16799-shell-document
Sep 3, 2026
Merged

Stop a test attaching to a shell document Bloom does not drive (BL-16799)#8297
hatton merged 2 commits into
masterfrom
BL-16799-shell-document

Conversation

@hatton

@hatton hatton commented Sep 3, 2026

Copy link
Copy Markdown
Member

More than one document in a run carries the workspace root's markup, so the
fixture's findShellPage returned whichever the debugging protocol listed first.
When that was not the document Bloom drives, the test was silently broken
rather than failing: its own clicking and typing worked, an expect on what it
typed passed, and every page Bloom loaded went into a document it could not
see. The symptom was a 60-second wait in goToPage for a page Bloom's own log
said it had shown. This is the flake in publish-text-languages.spec.ts.

Three parts.

The new e2e/shellUrl endpoint reports the URL of the browser holding the
document Bloom drives, which WorkspaceView records under --e2e when it builds
that browser. findShellPage now returns the page whose URL has the same file
name, and resolves it again after bloomApp.restart. It compares file names
because Bloom and the debugging protocol escape the rest of the URL
differently, and the workspace rewrites its own query string as the user moves
around.

The top bar carries data-testid="workspace-top-bar", so the candidates are
found by a marker of its own rather than by [role="tablist"]. When the endpoint
never answers, which is what an old Bloom.exe in output/Debug does, the fixture
falls back to the first page carrying that marker and says so.

Under --e2e, every browser built on the UI thread shares one
CoreWebView2Environment, so those documents live in one browser process with
one remote-debugging listener. Before, each environment was given the same port
number and only the first process to start could listen on it, so which browser
a test could reach depended on startup timing. The sharing is deliberately
limited to the UI thread: an environment belongs to the thread that created it,
and handing it to a browser built on the thread serving an API call hangs that
thread, which is what publishing a BloomPUB does.

Trims the AUTOMATION-DEBT.md entry "The top bar has no stable test ids" to the
tab half, which BL-16799-tab-test-ids finishes. Adds "A test can attach to a
shell document Bloom does not drive", because nobody knows why a run has a
second workspace root document at all, and that is what makes the test-side
check necessary.

Verified: BloomExe builds clean, and the e2e suite type checks.

This is one of eleven stacked pull requests (BL-16799)

Each one pays down one entry of src/BloomE2E/AUTOMATION-DEBT.md, and each branches off the one before it. Base: BL-16799-toolbox-registration. Review only this pull request's own commit; the ones below it are reviewed in their own pull requests. The first six change test and tooling code only; the last five also change product code.

  1. BL-16799-automation-scripts — Make the bloom-automation scripts safe to ask for help
  2. BL-16799-vr-collect-failures — Report every failed image comparison in a visual-regression case, not the first
  3. BL-16799-component-tests-in-ci — Run the component-tester Playwright suites nightly
  4. BL-16799-vite-port — Let an e2e run test the working tree's front end
  5. BL-16799-type-in-one-call — Type into a text box in one call, not one key press per character
  6. BL-16799-page-screenshot — Capture a whole book page from a test
  7. BL-16799-toolbox-registration — Register the toolbox tools from one list both callers share
  8. BL-16799-shell-document — Stop a test attaching to a shell document Bloom does not drive
  9. BL-16799-tab-test-ids — Click a workspace tab by a test id, not by its localized label
  10. BL-16799-page-change — Refuse a page change the Edit tab cannot do, and wait before asking
  11. BL-16799-collection-languages — Set a collection's languages through an e2e hook, not by writing XML

Replaces #8276, which did all of this in one pull request.

Verification of the whole stack, at its tip: the C# suite passes (3338 passed, 13 skipped), the front-end vitest suite passes (781 passed, 5 skipped), and the src/BloomE2E suite passes against a Vite dev server on the working tree (36 passed, 0 skipped, 8.2 minutes). Each pull request also has its own type check and lint.

🤖 Generated with Claude Code

Devin review


This change is Reviewable

More than one document in a run carries the workspace root's markup, so the
fixture's findShellPage returned whichever the debugging protocol listed first.
When that was not the document Bloom drives, the test was silently broken
rather than failing: its own clicking and typing worked, an expect on what it
typed passed, and every page Bloom loaded went into a document it could not
see. The symptom was a 60-second wait in goToPage for a page Bloom's own log
said it had shown. This is the flake in publish-text-languages.spec.ts.

Three parts.

The new e2e/shellUrl endpoint reports the URL of the browser holding the
document Bloom drives, which WorkspaceView records under --e2e when it builds
that browser. findShellPage now returns the page whose URL has the same file
name, and resolves it again after bloomApp.restart. It compares file names
because Bloom and the debugging protocol escape the rest of the URL
differently, and the workspace rewrites its own query string as the user moves
around.

The top bar carries data-testid="workspace-top-bar", so the candidates are
found by a marker of its own rather than by [role="tablist"]. When the endpoint
never answers, which is what an old Bloom.exe in output/Debug does, the fixture
falls back to the first page carrying that marker and says so.

Under --e2e, every browser built on the UI thread shares one
CoreWebView2Environment, so those documents live in one browser process with
one remote-debugging listener. Before, each environment was given the same port
number and only the first process to start could listen on it, so which browser
a test could reach depended on startup timing. The sharing is deliberately
limited to the UI thread: an environment belongs to the thread that created it,
and handing it to a browser built on the thread serving an API call hangs that
thread, which is what publishing a BloomPUB does.

Trims the AUTOMATION-DEBT.md entry "The top bar has no stable test ids" to the
tab half, which BL-16799-tab-test-ids finishes. Adds "A test can attach to a
shell document Bloom does not drive", because nobody knows why a run has a
second workspace root document at all, and that is what makes the test-side
check necessary.

Verified: BloomExe builds clean, and the e2e suite type checks.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@hatton
hatton force-pushed the BL-16799-shell-document branch from 275d66c to 64e91dc Compare September 3, 2026 19:40
Master moved while this stack was open, so each branch merges the one below it.
The conflicts were all in src/BloomE2E/AUTOMATION-DEBT.md: master gave the table
of this stack a pull-request column and annotated each promise with its number,
while this branch deletes its own row and replaces or deletes its own promise.
The merge keeps both, taking this branch text where the two describe the same
entry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BaWw4EHWrbFF2fNJvMJVC8
// makes its browsers on the thread serving the API call, waited forever and the preview
// never appeared.
if (env == null && Program.RunningE2eTests && Program.RunningOnUiThread)
env = _environmentForE2eTests;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Devin] Bug: Concurrent initialization defeats environment sharing

When UI browsers initialize together, InitWebView sees the shared slot empty before any creation finishes. Each creates another process, so automation can still attach incorrectly.

(src/BloomExe/WebView2Browser.cs:507)

`${SHELL_MARKER} alone. If this test fails oddly, check that output/Debug holds a ` +
`Bloom.exe new enough to have that endpoint.`,
);
return markerOnlyMatch;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Devin] Bug: Stale builds restore wrong-document attachment

When e2e/shellUrl is unavailable, findShellPage returns the first marked document despite multiple candidates. Tests can drive an abandoned document and fail misleadingly.

(src/BloomE2E/fixtures/bloomTest.ts:211)

@hatton

hatton commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

[Claude Opus 5 from Hatton's machine during devin-review]

Consulted Devin on 2026-09-03 22:45 UTC up to commit 4dae623436708516597c51408884c68c31727770.

Base automatically changed from BL-16799-toolbox-registration to master September 3, 2026 23:05
@hatton
hatton merged commit a90fd54 into master Sep 3, 2026
1 check 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