Repository navigation
Add Playwright auth setup project for Posit AI credentials - #17680
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
ReviewMedium
Low
Assessment
Net plan: take 4 findings (1, 5, 6, 7); skip 6 others (2, 3, 4, 8, 9, 10). Actions TakenCommit
|
ReviewSix review angles surfaced findings on this PR. Key items grouped by topic: Correctness / behavior
Error handling Type / shape design Style / comments Docs AssessmentNet: take 25, skip 6. Taken with reasoning:
Skipped with reasoning:
Actions TakenSingle follow-up commit (
|
…uth-setup # Conflicts: # e2e/rstudio/README.md # e2e/rstudio/playwright.config.ts
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
ReviewFive specialized agents reviewed the PR diff (code-reviewer, silent-failure-hunter, type-design-analyzer, comment-analyzer, code-simplifier), scoped to the changes this PR introduces. Highlights, most severe first. Important (several corroborated across agents):
Suggestions and hygiene: Assessment
Actions TakenCommitted in cc18975, on top of fc241d9. Correctness and error handling:
Types and deduplication: Messages, comments, terminology: By decision, not changed: success-path messages do not state "tests will run", and expired_token remains terminal, with a comment noting the slow-runner trade-off instead of a retry. Verified: tsc --noEmit passes. |
… response validation - Auth setup now writes a status file recording what happened (off/seed/flow outcome and reason); requireAiCredentials builds the skip reason from it instead of a generic "set POSIT_EMAIL/POSIT_PASSWORD" message, so a failed sign-in flow is diagnosable from the test report - Bound the sign-in flow to a deadline well under the harness test timeout, so a slow run fails through the existing skip path instead of aborting the whole suite (setup previously had no margin against its own 90s poll cap plus browser launch/login steps) - pollForToken no longer misclassifies 5xx or non-JSON error bodies as a terminal OAuth error or an unretried skip - Validate the device-code response shape so a server contract change fails loud instead of surfacing as a cryptic TypeError - Tighten PositAiOAuthEntry/PositAiAuthMode types, drop the unused oauthError field, fix a couple of inaccurate comments, and finish the @ai-tag-vs-provider terminology cleanup left over from the previous commit
ReviewFive review agents ran against the code-reviewer -- no critical or important defects confirmed (verified the storage key, on-disk store shape, and
silent-failure-hunter -- HIGH: 1. deterministic login-page breakage (e.g. a selector rename) is classified as transient, producing a permanently green setup with dark-skipped comment-analyzer -- no factually wrong comments, no rot from the prior rework rounds. Misleading rationale: 1. "waitForLoadState would hang" is inverted -- it would return immediately, not hang; 2. "only genuinely transient failures... fall through to a skip" overstates the guarantee (deterministic selector drift lands there too). Minor: 3. "earlier steps stay transient" is wrong ordering; 4. seed-mode's illustrative file list names a nonexistent type-design-analyzer -- strong overall for test infrastructure; ratings 6-9 across the board. Findings: 1. code-simplifier -- report-only, no edits made. 1. AssessmentVerified every finding against the checked-out files before taking a position.
Separately, while discussing the review, we noticed the prior commit's terminology cleanup (renaming raw " Actions Taken
|
|
Verified States Fields used: mode = A. Auth mode (
|
| Mode | Condition | Outcome (status file) | Tests |
|---|---|---|---|
| flow | valid creds (POSIT_EMAIL/POSIT_PASSWORD) |
success |
2 passed |
| flow | invalid creds | fatal -- fails loud, no status file | run fails |
| flow | no creds (POSIT_EMAIL/POSIT_PASSWORD unset) |
credentials-unset |
2 skipped |
| off | -- | off |
2 skipped |
| seed | host signed in | success (copies ~/.posit/assistant) |
2 passed |
| seed | host logged out | host-not-signed-in |
2 skipped |
| seed | kill-switch on | seed-suppressed |
2 skipped |
Footnote: the code also has a transient-authorize-failure -> flow-failed -> skip path. It's a genuine intermittent condition; it was observed skipping (5 tests, in a combined 2-file run) but I couldn't reproduce it post-fix in the 2-test harness, since the authorize-retry fix makes that path rare. Included here for completeness.
B. Kill-switch (PW_SANDBOX_NO_SEED_CREDENTIALS=1) x mode
| Mode + kill-switch | Outcome | Result |
|---|---|---|
| off | off (unaffected) |
2 skipped |
| seed | seed-suppressed (copy blocked) |
2 skipped |
| flow | success (unaffected) |
2 passed |
C. Credentials (POSIT_EMAIL / POSIT_PASSWORD) via environment file
| Source | Mechanism | Result |
|---|---|---|
.env.local |
dotenv default, shell creds stripped | success -- "injected env (2) from .env.local" |
.env.op |
PW_ENV_FILE=.env.op, shell creds stripped |
success -- "injected env (2) from .env.op" |
D. Authorize-retry fix (live flow sign-in)
8 passing flow sign-ins -- 2 headed, 6 headless -- all completing the full chain (sign-in -> tokens written -> tests run authenticated), ~2.3s each. The authorize retry held in every run.
Key point on skips: a skip here is a pass condition. When credentials aren't provisioned (off, no creds, host logged out, seed suppressed), the tests are designed to skip with a clear reason rather than run and fail -- so "skipped" above is the correct, expected outcome.
Bottom line: every mode, both kill-switch states, all credential/host conditions, and both env-file paths are verified -- each landing on its expected result (run, skip-as-designed, or fail-loud for invalid creds), plus 8/8 clean flow sign-ins confirming the authorize fix.
…matrix - Classify deterministic OAuth failures (4xx config faults, non-JSON 2xx bodies, missing token fields, a failed browser launch) as fatal so they fail the run instead of masquerading as a skip; bound the device-code fetch with its own timeout. - Make the authorize-click loop robust to the button detaching mid-click so a successful sign-in can't be misread as a fatal failure. - Validate the status file's mode and outcome against their unions on read, type PositAiAuthStatus fully, and warn on a corrupt or unreadable file. - Add exhaustiveness checks to the mode and provider dispatch. - Stop retrying the setup project so a fail-loud verdict isn't laundered into green-with-skips by a flaky retry. - Correct stale comments, and add a mode x kill-switch reference table to the README.
ReviewA five-agent review (code-reviewer, silent-failure-hunter, comment-analyzer, type-design-analyzer, code-simplifier) ran against the full PR diff. No critical or important-severity defects; the findings clustered on holes in the transient-vs-deterministic failure policy, boundary validation, and comment accuracy. Highlights: Silent-failure hunter (3 medium, 6 low)
Code reviewer (3 suggestions)
Type-design analyzer (7 findings)
Comment analyzer (3 factual errors, 5 improvements)
Code simplifier (1 actionable)
AssessmentEach finding was verified against the code in context. Taken: all of the silent-failure findings, the code-reviewer's Actions Taken
Verified by a full local matrix on installed Desktop: all four modes ( |
ReviewReviewed commit No critical or important functional issues. All five agents confirmed: the new single-file Findings:
AssessmentTook findings 1-3 as one-line fixes, verified with Discussion surfaced two more stale spots in the same family, in
Recommendation 4 (manual copy-mode verification run) is still open -- noting it here as a pre-merge step rather than resolving it as a code change. Actions Taken
All fixes verified with |
|
Follow-up review for commit ReviewReviewed with three agents (code-reviewer, comment-analyzer, silent-failure-hunter), each scoped strictly to the default-flip commit and asked to sweep the whole All three agreed: the five files the commit touched are internally consistent and correct (the The findings were all fallout the commit didn't sweep up -- messages and comments written when
AssessmentTook all findings. Rationale: the flip is a semantics change these files narrate, and every finding was either a factual inversion, a message that now misleads on a default path, or a small clarity add -- all message-level, zero dispatch-logic changes. Skipped nothing. The shared fix pattern for the runtime messages: distinguish "copy because you set it" from "copy because it's the default", and always name the Actions Taken
Committed as |
…er aiAuth, fix server-mode race
ReviewFour review agents (code-reviewer, silent-failure-hunter, comment-analyzer, type-design-analyzer) covered the full PR diff against code-reviewer (no critical/important; 2 suggestions)
silent-failure-hunter (nothing critical)
comment-analyzer
type-design-analyzer (rated the overall design strong)
AssessmentFive findings were taken, all small and independently verified against the code before fixing:
While in The remaining findings were skipped as genuinely low-value for this harness: the discriminated-union status type and the Actions Taken
Typechecked clean ( |
ReviewFour specialized agents reviewed the diff (code quality, silent failures, comments/docs, test coverage), each scoped strictly to the PR diff. All four verdicts were approve, with no critical findings. Findings that survived verification: Green-with-skips cluster (flagged independently by two agents). The deterministic/transient boundary is drawn by response shape and login step, not by root cause, and nothing consumes the auth status file as a failure. So a deterministic auth breakage (a moved endpoint, a dead authorize button, a malformed configured email) surfaces as a skip and the run stays green. Today CI has no credentials, so green-with-skips is the intended state; the risk goes live only once credentials are wired into CI. Hardening.
Comment and doc accuracy.
Deferred (not addressed here). Unit specs for the credential scrub, the OAuth classifier, the status-file round-trip, and the AssessmentEvery finding was verified in context before deciding. Nothing blocked merge. Taken:
Skipped, as documented design judgments:
Deferred: the test-authorship items above, as follow-up. Actions TakenCommit 180f00b (8 files, all under
Verification: |
Local verificationExercised the auth setup end to end in installed-desktop mode on macOS against RStudio 2026.07.1+147.pro6, covering all three credential sources, both default and strict ( Single-file (G)
Multi-file (G + AC)
What each run established
No behavior change on the default (credential-less) path, which is CI's current state: strict defaults to off, so the tests still skip cleanly. Strict only turns an unprovisioned run red once it is explicitly enabled (the intended use once credentials are wired into CI). |
Summary
Adds a Playwright
setupproject (tests/auth.setup.ts) that provisions Posit AI credentials into the per-run sandboxuser-homebefore tests run. Thedesktopandserverprojects depend onsetup, so Posit-AI-gated tests start signed in. Thesetupproject runs unconditionally, even when no Posit AI test is selected.The setup auto-detects the credential source rather than taking a mode flag:
POSIT_EMAIL/POSIT_PASSWORDset: runs the OAuth sign-in flow againstlogin.posit.cloudand writes a fresh token store; nothing is copied from the local machine.~/.posit/ai/auth/data.json) into the sandbox--no skills, workspaces, or other state.Setting exactly one of
POSIT_EMAIL/POSIT_PASSWORDis an error that fails the run. Credentials are read from environment variables only and never committed. Trace, video, and screenshot are off for the setup project to avoid capturing the login screen.Tests gate on the on-disk token store via
requireAiCredentials(), not an environment flag, so an unsigned-in sandbox skips cleanly.PW_SANDBOX_NO_SEED_CREDENTIALS=1is a kill-switch that suppresses the local-copy path (and the Copilot copy); the sign-in flow is unaffected because it copies nothing locally.Additional behavior:
aiAuthfixture option lets a test file declare signed-out state, e.g.test.use({ aiAuth: { positai: 'none', copilot: 'none' } }), by launching against a credential-stripped copy of the user home. Declaring it against an external server is an error.PW_SANDBOX_SKIP_CLEANUP, or a failed delete), teardown scrubs the copied tokens first. A cancelled run (SIGTERM) scrubs them too; only a hard kill or crash can leave tokens behind.