Skip to content

Add agent-driven GitHub Copilot sign-in for E2E credential parity - #18342

Merged
ronblum merged 15 commits into
mainfrom
test/ron/e2e-copilot-login-parity
Jul 24, 2026
Merged

ronblum merged 15 commits into
mainfrom
test/ron/e2e-copilot-login-parity

Conversation

@ronblum

@ronblum ronblum commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Brings GitHub Copilot credential handling to parity with Posit AI in the
Playwright E2E suite. Previously Copilot credentials could only be provided by
copying an already-signed-in store from the host, so a machine that had never
signed in to Copilot couldn't provision it. This adds a live device-flow
sign-in, driven by the copilot-language-server over stdio plus a trusted-click
browser authorize step, so the setup can authenticate from scratch the same way
auth.setup.ts already does for Posit AI.

Included:

  • Agent-driven Copilot device-flow sign-in wired into auth.setup.ts, with
    auto-detect: COPILOT_USER/COPILOT_PASSWORD trigger a live sign-in, else the
    host store is copied, else the provider is skipped. Fails loud on bad GitHub
    credentials and on a NotAuthorized status.
  • The credential gate reads the on-disk Copilot store (auth.db) via
    better-sqlite3 rather than the sqlite3 CLI, which is absent from PATH on
    Windows; the check fails closed so an empty pre-sign-in store no longer reads
    as authenticated.
  • Two debug switches: PW_DEBUG_AUTH_CAPTURE (screenshots/HTML) and
    PW_DEBUG_AUTH_STEPS (step narration), with account identifiers kept out of
    logs.
  • Both sign-in flows now narrate their steps consistently under
    PW_DEBUG_AUTH_STEPS, through a shared [authorize-] logger;
    previously only the GitHub flow narrated steps and Posit AI logged only on
    failure under a different prefix.
  • Setup completion messages are mode-aware: on Server they warn that the
    sandbox credentials will not reach the rsession, which reads the logged-in
    user's real home directory. This surfaces (does not fix) a pre-existing
    server-mode HOME gap that affects Posit AI too.
  • Fixes an isVisible-with-timeout race in the device-authorize flow, shares a
    single sign-in browser launcher, and documents the new environment variables
    and credential gating.

Addresses #18306.
Addresses #18334.

@ronblum ronblum added this to the 2026.08 (Yellow Yarrow) milestone Jul 23, 2026
@posit-snyk-bot

posit-snyk-bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@ronblum

ronblum commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Review

Three low-severity findings on the branch:

  1. Stale file reference (e2e/rstudio/utils/github-device-authorize.ts:11-12): the header comment pointed at prototypes/copilot-authorize.spec.ts, which no longer exists; only copilot-agent-signin.spec.ts survives, so a reader chasing the provenance lands on a missing file.

  2. sqlite3 CLI in the prototype (e2e/rstudio/prototypes/copilot-agent-signin.spec.ts): the smoke test verified auth.db via execFileSync('sqlite3', ...) -- the exact CLI dependency the main code dropped for better-sqlite3 because sqlite3 is absent from PATH on Windows. On a CLI-less host the test throws an opaque spawn ENOENT unrelated to the sign-in outcome.

  3. Tight timeout budget (e2e/rstudio/tests/auth.setup.ts): the inner Copilot-step timeouts can sum past the 270s outer deadline in a slow-but-still-succeeding run, which could misclassify the run as a login failure even though no inner step gave up.

Assessment

All three verified against the code and taken (all genuinely low severity):

  1. Confirmed dead reference.
  2. Confirmed. The prototype exists to debug sign-in including on Windows -- exactly where the CLI is missing -- so the inconsistency is worth removing.
  3. Verified: worst-case inner sum (~310s) exceeds the 270s deadline, though in practice the Authorize button arms in a few seconds. The outer deadline is deliberately under the 300s test timeout, so rather than raise it, the fix lowers the over-generous 120s Authorize-button wait.

Actions Taken

Commit 0c4cd8d:

  1. Repointed the stale comment to prototypes/copilot-agent-signin.spec.ts.
  2. Prototype now verifies the store via the exported isCopilotStoreAuthenticated(homeDir) (better-sqlite3, which also handles the Windows %LOCALAPPDATA% path); removed the sqlite3/execFileSync dependency.
  3. Lowered the Authorize-button wait from 120s to 60s (deadline and error message).

Verified: typecheck clean, and a desktop auth run (Posit AI + Copilot ghost-text) passed after the changes.

@ronblum

ronblum commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Review

Three review agents examined the PR diff (correctness, error-handling/silent-failures, comment accuracy). Deduplicated findings:

  1. Stale "up to 120s" comments for the Authorize-button wait, which the code now caps at 60s (tests/auth.setup.ts, prototypes/playwright.prototype.config.ts).
  2. No error handlers on the spawned agent process or its stdin (utils/copilot-agent.ts): a spawn failure or a write to a dead pipe could escape as an uncaught exception instead of a rejected request.
  3. When the agent dies, the surfaced error is a fixed string; exit code, signal, and stderr appear only under the debug flag.
  4. The user-code readback computed a match but submitted regardless, so a dropped keystroke surfaced only as a generic 90s timeout (utils/github-device-authorize.ts).
  5. Browser-launch failure was classified oppositely per provider: Posit AI failed loud with a remedy, Copilot skipped silently.
  6. A missing COPILOT_TOTP_SECRET on a 2FA account and a malformed base32 secret were treated as transient skips rather than deterministic config errors.
  7. The Authorize-missing fallback discarded its diagnosis, unlike the Posit AI flow, which carries a note into the skip reason.
  8. A NotAuthorized status at sign-in initiate would have been reported as a protocol change rather than an entitlement problem.
  9. A comment in utils/auth.ts still credited sandbox-setup.ts with Copilot seeding (this PR moved it to the setup project), and the README described the final page line as printing in a quiet run when it is gated behind the debug flag.

Assessment

All verified against the code; none critical. Taken in full, except the half of finding 6 that would check GitHub's 2FA-rejection banner -- that requires guessing GitHub's failure markup and can't be verified without deliberately failing 2FA, so it was skipped as flake risk; the base32 validation removes the main typo vector. The error-handling design (skip cleanly on missing credentials, fail loud on deliberately-set-but-broken credentials) was judged sound; the findings were gaps in it, not a broken design.

Actions Taken

Commit 29dd8e7:

  1. Added error handlers on the agent process and its stdin, routed into the existing fail-all path; the exit rejection now carries exit code, signal, and recent stderr.
  2. The user-code readback now throws on mismatch instead of submitting.
  3. Browser-launch failure, a missing 2FA secret, and a malformed base32 secret now fail loud (terminal error classes) with remedies.
  4. The Authorize step returns a note (page title only) that a later failure appends to its skip reason; a NotAuthorized status at initiate now gets the tailored "enable Copilot" remedy.
  5. Fixed the stale "120s" comments (now 60s), the auth.ts comment, and the README's final-page-line description.

Verified: typecheck clean, and a desktop auth run (Posit AI + Copilot ghost-text) passed after the changes.

@github-actions

github-actions Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
1889 0 357 0
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ desktop-linux 470 0 88 0
✅ desktop-macos 474 0 85 0
✅ desktop-windows 474 0 90 0
✅ server-linux 455 0 94 0
✅ setup 16 0 0 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 29619c52849c844a524f510ce40a995799af85bf - Run #329

@ronblum

ronblum commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Review

CI hit a native-module crash: better-sqlite3's addon segfaulted the
Playwright worker on macOS and Windows, always on the same 14 Copilot
code_suggestions tests. Didn't reproduce locally on any build.

Assessment

The worker crashed loading the addon (confirmed via a macOS crash report); it's
loaded in every worker via the shared fixture chain. A WASM alternative
(sql.js) was tried to drop the native addon, but it can't read the
credential token, which the copilot-language-server leaves in an
uncheckpointed WAL sidecar -- so real SQLite is required.

Actions Taken

Commit 6052d65: moved the Copilot store read into a short-lived child
process, so the worker itself never loads the addon and can't crash. Verified:
CI is now green, including the two previously-crashing jobs.

@ronblum ronblum self-assigned this Jul 24, 2026
@ronblum
ronblum merged commit 24401d3 into main Jul 24, 2026
24 checks passed
@ronblum
ronblum deleted the test/ron/e2e-copilot-login-parity branch July 24, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants