Repository navigation
Description
System details
RStudio Edition : Server and Desktop (the gate runs before either is launched)
RStudio Version : 2026.08.0-daily+173 (observed during verification of #18348)
OS Version : macOS 26.6
R Version : 4.6.1
Assistant : not captured
Steps to reproduce the problem
Signed in to Posit AI locally, with POSIT_EMAIL and POSIT_PASSWORD unset so auth.setup takes the copy-the-local-store path. From e2e/rstudio/:
-
Confirm the local token store is present and its access token has not yet expired.
node -e "const d=require(require('os').homedir()+'/.posit/ai/auth/data.json'); const t=d['auth:positai:oauth'].oauthAuth.tokenData.expiresAt; console.log(t, new Date(t) > new Date() ? 'valid' : 'EXPIRED')"- Prints a timestamp and
valid.
- Prints a timestamp and
-
Run any Posit AI gated test.
npx playwright test --project=server tests/panes/posit-assistant-chat/open-chat-pane.test.ts- The setup copies the store and the test runs.
-
Wait until the access token's expiry passes without using Posit AI in the meantime. The lifetime observed here is one hour.
-
Re-run the same command.
- The setup reports
[auth-setup] not signed in to Posit AI locally and no credentials set; Posit AI tests will skip, and every Posit AI test skips. - With
PW_AI_AUTH_STRICT=1the run fails outright:PW_AI_AUTH_STRICT is set but Posit AI was not provisioned: not signed in to Posit AI locally and POSIT_EMAIL/POSIT_PASSWORD are unset.
- The setup reports
-
Open the IDE and use Posit AI once, so the client refreshes the token, then run the command a third time.
- The setup copies the store again and the tests run.
Describe the problem in detail
isStoreFileAuthenticated (e2e/rstudio/utils/auth.ts:94-100) treats an expired access token as "not signed in":
export function isStoreFileAuthenticated(file: string): boolean {
const data = readAuthStore(file);
const entry = data?.[AUTH_STORAGE_KEY];
if (!isAuthEntry(entry)) return false;
const expiresAt = new Date(entry.oauthAuth.tokenData.expiresAt);
return !Number.isNaN(expiresAt.getTime()) && expiresAt.getTime() > Date.now();
}
The store also carries a refreshToken, and the Posit AI client refreshes transparently, so a developer whose access token lapsed an hour ago is still signed in as far as the IDE is concerned. The harness disagrees, and whether Posit AI tests run ends up depending on how recently the assistant was last used rather than on whether credentials exist.
The Copilot gate in the same file defines "signed in" differently. isCopilotStoreAuthenticated (:192) counts rows in oauth_tokens and never looks at expiry, and its comment states the intent plainly: "Mirrors what 'signed in' means for the on-disk store: the agent persists a token row on sign-in and deletes it on sign-out... this checks the store, not the entitlement." By that standard the Posit AI expiry test is the odd one out, and it carries no comment explaining why it is there.
Two consequences. Locally, Posit AI tests skip for a reason that reads as user error ("not signed in to Posit AI locally") when the developer is signed in. In CI with PW_AI_AUTH_STRICT=1 and the copy path in use, a run fails or passes depending on the age of the token in the seeded store, which is not a property the suite otherwise depends on.
Observed here while verifying #18348: two runs twenty minutes apart, no change in configuration, gave "not signed in" and then a successful copy, purely because the token refreshed in between. Unrelated to the changes on that branch -- this function predates it and is untouched by it.
Describe the behavior you expected
The two providers would ideally agree on what "signed in" means, checking that a credential is present on disk rather than that it is usable at this instant. For Posit AI that would mean accepting a store whose access token has expired when a refreshToken is present, and leaving the refresh to the client, the way the Copilot gate already leaves entitlement to the server.
If the expiry check is deliberate -- for instance if a copied store with a lapsed access token cannot refresh inside the sandbox -- then it would help to say so in a comment, and to give the skip reason wording that distinguishes "your token needs refreshing" from "you are not signed in".
Activity