Skip to content

wait for project session readiness before continuing e2e tests - #18837

Merged
kevinushey merged 1 commit into
mainfrom
bugfix/e2e-project-close-readiness
Sep 16, 2026
Merged

kevinushey merged 1 commit into
mainfrom
bugfix/e2e-project-close-readiness

Conversation

@kevinushey

@kevinushey kevinushey commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Intent

Fix premature returns from the project-switch E2E helpers found while investigating the macOS assistant/restart failure in PR #18828.

closeProjectIfOpen() could return when the new session reported no active project but had not completed deferred initialization. A subsequent openProject() could observe that outgoing session's ready flag, then the replacement session's project path, and return before the replacement was ready. The recorded first close returned before the no-project assistant backend finished starting; the next close hung.

Approach

  • Require readiness and the expected project identity in the same browser evaluation, for both open and close.
  • Check console idle after the replacement session is ready, rather than accepting the outgoing session's idle console.
  • Keep the existing session timeouts and modal handling.

This fixes confirmed helper races. The original macOS hang lost its trace during watchdog shutdown, so the change is not yet proof that every cause of the #18394 session-transition failure is resolved.

Automated Tests

  • Two controlled browser lifecycle regressions: both fail against the original helpers with ready === false, and both pass with this change.
  • The close regression also delays the new session's idle console until after readiness.
  • close_project_after_open.test.ts: passed against the original macOS PR build (99.9.9-pr+1027, R 4.6.1), using the fixed helper.
  • npm run typecheck and git diff --check passed.

QA Notes

Run restart-under-agent.test.ts on macOS with Posit Assistant active, plus the project open/close suites. Confirm that all restart cycles complete without the heartbeat watchdog firing. The local machine has no Posit Assistant credential store, so the authenticated restart scenario remains for CI; the ordinary project-close check above did not enable the assistant.

Documentation

Test harness change only; no user documentation or NEWS entry needed.

@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:18 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:18 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:18 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:18 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:22 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:22 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:29 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:29 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:29 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:29 — with GitHub Actions Active
@kevinushey
kevinushey deployed to e2e-playwright September 16, 2026 01:29 — with GitHub Actions Active
@kevinushey
kevinushey marked this pull request as ready for review September 16, 2026 02:25
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
2990 1 188 4
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
✅ desktop-linux 751 0 38 2
✅ desktop-macos 758 0 33 1
❌ desktop-windows 752 1 43 1
✅ server-linux 699 0 44 0
✅ setup 28 0 20 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 43f6df7b10be2c4e57072ebe53514dea7cbbfbca - Run #1034

@kevinushey
kevinushey merged commit ff7bc1c into main Sep 16, 2026
26 of 27 checks passed
@kevinushey
kevinushey deleted the bugfix/e2e-project-close-readiness branch September 16, 2026 02:25
gtritchie added a commit that referenced this pull request Sep 17, 2026
* e2e: name the dialog blocking a project close

Cherry-picked from the e2e half of f54aaf2 (#18785) on main; the
product fix in that PR (shipping the save action in SessionInfo) is not
backported, so the "Save workspace image?" prompt this branch's sessions
can still raise stays a real possibility here.

closeProjectIfOpen waits on project.isActive() === false, and every wait
before it is satisfiable by the still-open project's console -- so a modal
the close itself raised lands there as a bare 30s waitForFunction timeout
with nothing naming the dialog. Read the visible dialog's text on timeout
and report it, carrying the original error as `cause`.

closeProjectIfOpen now returns whether dismissSaveWorkspacePrompt fired,
so a caller can assert on the prompt rather than have the sweep hide it.

* e2e: skip ai suites when the provider service is unreachable

Cherry-picked from c0f6bd8 (#18806) on main. Test-side only.

The AI gate proved the sandbox held credentials but never that the
provider could be reached, so an outage or blocked egress on the runner
failed inside the feature's own timeout instead of skipping. Probe each
provider's services from Node (utils/network.ts) as part of
requireAiCredentials, with the host list next to the provider table so
the gate, the beforeAll guard and the external-server check cannot
disagree. Under PW_AI_AUTH_STRICT an unreachable service fails instead.

For a network that degrades after the gate passed, aiServiceOutageReason
re-probes: code_suggestions turns a ghost-text or NES timeout into a
retroactive skip only when a host has since stopped answering, and
rethrows untouched otherwise. The Posit AI list includes the install
manifest on cdn.posit.co, since a timed-out manifest download leaves the
agent NotSignedIn and reads as a completion timeout.

beforeAll returns early without credentials, so the assistant setup does
not spend a minute on install prompts for tests beforeEach then skips.

* e2e: share the suggestion re-request and recover a lost bridge on open

Cherry-picked from the test-side half of 65abf11 (#18797) on main.
The two product fixes in that PR (EditorCommandManager binding load,
bounded Python discovery) are not backported, nor is the dev-launcher
GWT gating, which only affects local runs.

The re-requesting wait that #18789 gave ghost text is now
SourcePaneActions.waitForSuggestion, shared with the next-edit sites and
acceptNesRename: they still waited blindly on a provider that had already
answered "No completions available", which is terminal, so a declined
context burned the whole budget and reported as flake on every platform
at once. The re-request command has to match the kind of suggestion --
assistantRequestCompletions only asks for an at-cursor completion and its
fallback to a next-edit request is Copilot-only -- so the NES sites
re-ask through assistantAcceptNextEditSuggestion.

SourcePane.nesIndicator gives the four NES presentations one definition
in place of the or()-chain the specs each repeated.

openProject reloads once when the switched-to session never installs the
automation bridge. GWT's bootstrap has no retry, so a failed fetch of the
main cache.js leaves the window blank forever; a session that is merely
slow (bridge installed, ready still false) is left alone.

* e2e: wait for project session readiness before continuing

Cherry-picked from ff7bc1c (#18837) on main. Test-side only.

openProject's ready wait can be satisfied by the outgoing session, whose
deferred initialization completes during the switch; the incoming session
then publishes its project path before its own deferred initialization
has finished, so a helper that polls ready and the path separately can
return into a session that is still initializing. Observe both in one
predicate.

closeProjectIfOpen has the mirror problem: the project can already be
inactive while ready is still false, and returning in that interval lets
the next open race the previous session's initialization. Gate on ready
too, and move the console-idle check after it -- the earlier checks can
observe the outgoing session's console.

project-readiness.test.ts drives both helpers against a stubbed workbench
that separates project identity from deferred initialization the way a
desktop session switch does; both tests fail without the changes above.

This branch was successfully deployed

1 active deployment
e2e-playwright — 43f6df7b Deployed Sep 16, 2026 by kevinushey via windows / e2e-desktop-windows (3) #1034
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