Skip to content

auth: log automatic sign-outs [10/10] - #22959

Merged
sergiou87 merged 40 commits into
developmentfrom
short-lived-tokens-10-sign-out-log
Oct 7, 2026
Merged

sergiou87 merged 40 commits into
developmentfrom
short-lived-tokens-10-sign-out-log

Conversation

@sergiou87

@sergiou87 sergiou87 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Description

Restores a log line when Desktop signs an account out on its own.

On development, a 401 for an account's current token went through AppStore._removeAccount, which logs [AppStore] removing account <login> (<name>) from store. With credential handling moved into AccountsStore, automatic sign-outs skip that path, so user logs no longer said which account was removed.

All automatic sign-outs (a 401 on the current token, a refresh the server rejects or an unusable renewal response, a renewed token that can't be saved) now go through AccountsStore.requireSignIn, which logs:

[AccountsStore] signing out account <login> (<name>) because its credentials can no longer be used

It's logged only when an account is actually retired, so stale or duplicate requests stay silent. It contains no token. Callers already log the specific cause. Signing out by hand still logs through AppStore._removeAccount.

Follow-up to @niik's non-blocking feedback on #22937.

Stack

Merge in order, starting with 1. Each PR builds, passes tests, and keeps production behavior on its own.

  1. auth: add OAuth refresh-token protocol primitives [1/10] #22917 - OAuth protocol primitives
  2. auth: handle rejected API tokens in AccountsStore [2/10] #22937 - Token invalidation in AccountsStore
  3. auth: add versioned secure-storage format for credentials [3/10] #22938 - Versioned credential storage
  4. auth: coordinate OAuth token renewal in AccountsStore [4/10] #22939 - Coordinated token renewal
  5. auth: hand Git fresh credentials [5/10] #22940 - Git credentials
  6. auth: resolve private image tokens through the renderer [6/10] #22941 - Private images
  7. auth: let Copilot sessions renew GitHub tokens [7/10] #22942 - Copilot SDK sessions
  8. auth: request refreshable OAuth tokens at sign-in [8/10] #22943 - Sign-in with refreshable tokens (behind flag)
  9. docs: describe refresh-token rollout and recovery [9/10] #22919 - Rollout and recovery documentation
  10. auth: log automatic sign-outs [10/10] #22959 - Log automatic sign-outs (this PR)

Validation

  • tsc, lint and the account lifecycle tests pass. No test is added for a log line.

Release notes

Notes: no-notes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The log may use stale account details, and its promised behavior lacks regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Restores account-identifying logs for automatic sign-outs handled by AccountsStore.

Changes:

  • Logs successful automatic account retirement without exposing credentials.
File Description
app/​src/​lib/​stores/​accounts-store.ts Adds automatic sign-out logging.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/src/lib/stores/accounts-store.ts Resolved
Comment thread app/src/lib/stores/accounts-store.ts Resolved
sergiou87 added a commit that referenced this pull request Oct 2, 2026
`requireSignIn` receives the `Account` held by the credential
session, which is captured at sign-in or startup. `refresh()` can
later replace the store's entry with updated profile data (a renamed
login or a new display name) without touching that snapshot, so the
sign-out log could show stale identity details.

Log `retired` instead: it is the account entry `retireAccount`
actually found and removed from the store, so the log names the
account the user saw. Same message, no token.

Addresses review feedback on #22959.

Co-authored-by: Copilot <[email protected]>
@sergiou87
sergiou87 requested a balanced review from Copilot October 2, 2026 12:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused logging change correctly uses the retired account snapshot and matches the described behavior.

Review effort: Balanced
Findings: None

Resolved since last review (2)

sergiou87 added a commit that referenced this pull request Oct 2, 2026
`requireSignIn` receives the `Account` held by the credential
session, which is captured at sign-in or startup. `refresh()` can
later replace the store's entry with updated profile data (a renamed
login or a new display name) without touching that snapshot, so the
sign-out log could show stale identity details.

Log `retired` instead: it is the account entry `retireAccount`
actually found and removed from the store, so the log names the
account the user saw. Same message, no token.

Addresses review feedback on #22959.

Co-authored-by: Copilot <[email protected]>
@sergiou87
sergiou87 force-pushed the short-lived-tokens-10-sign-out-log branch from 9c9e48c to 9d8fb07 Compare October 2, 2026 12:25
niik
niik previously approved these changes Oct 2, 2026

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This restores the intended automatic-sign-out observability at the correct boundary. The log fires only after successful retirement, remains silent for stale/duplicate invalidations and manual sign-out, uses the authoritative retired account entry, and exposes no credential material.

Non-blocking follow-up: the PR description overstates cause-level diagnostics—the new line identifies which account was signed out, but callers do not consistently log whether the cause was an active-token 401, refresh rejection, malformed renewal, or persistence failure.

sergiou87 and others added 5 commits October 5, 2026 13:35
Copilot features (commit message generation, conflict resolution,
quota) run in the Copilot SDK runtime, which gets a GitHub token when
the client is created. A short-lived token can expire while a client
or session is still in use, and the runtime can't renew it by itself.

CopilotStore now:

- gets a fresh token from AccountsStore before creating a
  CopilotClient and before requesting quota;
- remembers which account created each client, and when creating a
  session for a refreshable account, passes a `gitHubTokenProvider`
  built by `createCopilotTokenProvider`.

The SDK calls that provider for the session's first token
("initial") and again when the current one nears expiry ("refresh").
It stores `now + expiresIn` as the token's deadline and asks again
once an hour or less remains. It never calls back because a token was
rejected, and it rejects any token with an hour or less left, failing
the session with no fallback. So the provider:

- only answers for the account's own GitHub host;
- renews with a 61-minute margin, which clears the SDK's one-hour
  threshold with room for IPC transit;
- returns the access token and its remaining lifetime, never the
  refresh token;
- throws a clear error when the lifetime is still an hour or less, or
  unknown. Guessing a lifetime could leave the SDK using a dead token
  until the guessed deadline.

Accounts with plain tokens get no provider, so the SDK keeps using the
static token as before and nothing changes for existing accounts.

Tests cover keeping the static token mode for plain accounts, meeting
the one-hour margin without exposing refresh tokens, and refusing
other hosts and signed-out accounts.

Co-authored-by: Copilot <[email protected]>
`fetchQuotaSnapshots` receives the caller's `Account` snapshot, whose
token can be one that has since been rotated away or is about to
expire. This branch changed it to ask `AccountsStore` for a fresh
account right before calling `client.rpc.account.getQuota` and to send
that token instead of `account.token`. The existing quota test uses a
plain, non-refreshable token and ignores the request argument, so
reverting that line would not fail any test.

The new test "requests quota with a renewed token for an expiring
account" in `copilot-store-test.ts` (inside "CopilotStore quota
snapshots", which already enables the preview feature):

- Builds an `AccountsStore` whose renewal returns `new-access`, and a
  `CopilotStore` on top of it with `createClient` replaced by a fake
  whose `getQuota` records the `gitHubToken` it is called with.
- Adds the account with a refreshable credential that expires now, so
  any request for a fresh token must renew it.
- Asserts the quota is returned and that `getQuota` was called exactly
  once, with `new-access`.

Because the fake `createClient` skips the renewal the real one does,
the call inside `fetchQuotaSnapshots` is the only thing that can
produce the renewed token: the test fails when that line is reverted
to `account.token` and passes with it. No source changes.

Addresses review feedback on #22942. The other finding (a test for
attaching the token provider to sessions) is intentionally not
addressed here.

Co-authored-by: Copilot <[email protected]>
Desktop's main process adds an `Authorization` header to requests for
GitHub Enterprise avatars and private repository images, using the
tokens the renderer sends with `update-accounts`. With short-lived
tokens, that snapshot can hold an expired access token, and only the
renderer's AccountsStore can renew it.

The image filter now asks the renderer for the token to use on each
authenticated image request:

- main (`authenticated-image-token-resolver.ts`) sends
  `resolve-image-token` with a request id, the endpoint and the token
  it knows about to the main window, and waits up to 35 seconds for
  `resolved-image-token`. Replies from other windows, stale or unknown
  request ids, and senders that aren't trusted are ignored. Pending
  requests for an endpoint that disappears from `update-accounts`
  (sign-out) are failed right away;
- the renderer (`authenticated-image-token-handler.ts`, installed in
  index.tsx) answers with `AccountsStore.resolveToken`, which renews
  the token if needed. Failures are logged without the error, which
  can contain credentials, and answered with null;
- the filter only uses the reply if the account on that origin is
  still the same sign-in (tracked with a per-origin session symbol
  that survives token rotation but not sign-out). Otherwise, or if
  resolution fails or times out, the request is cancelled rather than
  sent with a stale token or none.

For existing plain tokens, `resolveToken` returns the token unchanged,
so images authenticate as before. The difference is one IPC round trip
per authenticated image request, and a cancelled request (a broken
image) instead of an unauthenticated one when the renderer can't
answer.

Supporting changes:

- `update-accounts` is only accepted from the main window's
  WebContents, now exposed as `AppWindow.webContents`;
- `OrderedWebRequest.onBeforeSendHeaders` now returns a listener's
  `{ cancel: true }` response. It used to break out of the loop and
  return the request details, so a cancellation was silently dropped
  and the request went ahead. No existing listener cancelled, so only
  the new image cancellations are affected;
- the two new channels are added to the IPC channel contract.

Tests cover the filter (header injection, origin mapping for
github.com, cancellation on failure, sign-out and account changes
while resolving), the main-process resolver (timeouts, foreign or
stale replies, sign-out), and the renderer handler.

Co-authored-by: Copilot <[email protected]>
The shared setup helper in refresh-token-consumers-test now takes the
initial credential instead of only its expiry, since the Git credential
tests also need plain tokens and long-lived refreshable ones. Update the
Copilot provider test that still passed an expiry timestamp, which no
longer type-checks after merging that change.

Also cover the case leases are most likely to affect for Copilot. Its token
provider asks for more than an hour of validity, because the SDK only asks
for a new token once less than an hour remains. If a Copilot session starts
during the token's last hour while a Git operation holds a lease on it, the
provider must wait for Git to release the token and then return a renewed
one, rather than receive the held token and fail with "GitHub returned
credentials without enough lifetime for a Copilot session". The new test
leases the token, checks that the provider neither resolves nor renews while
the lease is held, then releases it and expects the renewed token after a
single renewal.

Co-authored-by: Copilot <[email protected]>
This is the change that makes Desktop create short-lived, refreshable
credentials. Earlier changes taught AccountsStore to store, renew and
revoke them, and taught the API client, Git, private images and
Copilot to use them. It is gated by `enableShortLivedTokens`
(development and preview builds only), so production sign-in is
unchanged.

With the flag on, the OAuth authorization URL for github.com and
GHE.com (data residency) adds the `offline_access` scope, which asks
GitHub for an expiring access token plus a refresh token. GitHub
Enterprise Server never gets the scope, and the other scopes are kept
as they are.

SignInStore now completes the browser sign-in itself:

- it exchanges the code with `exchangeOAuthToken` against the HTML
  endpoint, keeping the refresh token and both expiry times, and
  replaces api.ts's `requestOAuthToken`;
- it fetches the user with `fetchUser(..., isNewAuthorization = true)`,
  so the new token is used as-is instead of going through
  AccountsStore's token resolution and invalidation meant for
  installed accounts;
- it saves the account and full credential with
  `AccountsStore.addAccount`, and only reports success after the
  credential is saved. If saving fails, sign-in reports an error
  instead of pretending to succeed;
- it ignores a duplicate callback for the same OAuth state while one
  is being handled, and checks that the sign-in attempt is still the
  current one after the exchange, after fetching the user and after
  saving;
- it revokes, in the background and without waiting, a token that was
  issued but never installed: the user cancelled or restarted before
  it was saved, or fetching the user failed. A token whose save has
  started is kept, as in development, where saving always completes.

AppStore no longer adds the account itself when sign-in succeeds; it
only logs and starts loading repositories for the welcome flow.

Tests cover the OAuth scopes per host and flag value, the exchange
metadata, success only after saving without exposing refresh tokens
in public state, storage failures, duplicate callbacks, cancellation
at each step, revocation of abandoned tokens (bounded, without
blocking the result), and mismatched OAuth state.

Co-authored-by: Copilot <[email protected]>
sergiou87 and others added 20 commits October 5, 2026 16:02
Desktop requires 61 minutes of remaining validity for Copilot, while the SDK refreshes cached credentials at its one-hour preflight margin. Reporting the full lifetime left a one-minute interval in which a second session could rotate the token while the first session still considered the old, revoked token reusable.

Share the SDK margin and IPC safety-buffer constants between token acquisition and lifetime reporting. Subtract the 60-second buffer from expiresIn, so both consumers reach the same renewal deadline. Preserve fractional seconds instead of flooring: a token with 3660.5 seconds remaining must still advertise 3600.5 seconds rather than fall onto the SDK rejection boundary.

Reject credentials whose buffered lifetime is unknown or no longer exceeds one hour. Keep Desktop as the renewal owner and continue returning only an access token and lifetime, never refresh credentials.

Add deterministic coverage for staggered sessions, the fractional boundary, inclusive renewal at 61 minutes, undersized renewed credentials, and missing lifetime metadata. The three new bug reproductions failed before the fix; all 14 consumer tests now pass.

Validation: yarn test app/test/unit/refresh-token-consumers-test.ts passed (14 tests); yarn -s lint:fix passed; npx --no-install tsc -p . --noEmit --skipLibCheck passed. skipLibCheck avoids existing dependency declaration conflicts without skipping application type checking.
Matching an endpoint and numeric account ID allowed an existing Copilot provider to adopt credentials from a later sign-in as the same user. Looking up the original token on every callback would also be insufficient if a subsequent sign-in reused that token string.

Add a credential-session-bound access-token getter that captures the actual issuing session once. It follows normal rotation within that session, permanently rejects retirement, and returns an access token and expiry from one coherent credential snapshot. Recheck after asynchronous acquisition so concurrent renewal cannot hand out an obsolete token or pair it with replacement metadata. Replace the now-unused separate expiry lookup with this bounded API.

Construct each client's Copilot provider before asynchronous credential acquisition and retain it for all SDK sessions created by that client. Do not reconstruct the provider from account identity at session creation. Preserve generic fresh-account lookup semantics and the legacy static-token authentication mode. This does not introduce a lease for an entire Copilot invocation.

Cover normal renewal, same-user sign-in with different and identical token strings, obsolete account snapshots, retirement while waiting for a Git lease, concurrent renewal during handoff, and retirement during handoff. Three provider regressions failed before the fix and now pass.

Validation: yarn test app/test/unit/credential-sessions-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/stores/copilot-store-test.ts passed (80 tests); yarn test app/test/unit/accounts-store-test.ts passed (4 tests); yarn -s lint:fix passed; npx --no-install tsc -p . --noEmit --skipLibCheck passed.
Provider-only tests cannot prove that CopilotStore actually passes the callback to SDK-created sessions. Add isolated store coverage that runs the public commit-message entry point through the real client-creation and session-wiring code, without replacing private methods or manually populating the provider map.

Capture constructor options while returning real SDK client instances, then intercept SDK session creation at its configuration boundary. A sentinel error stops execution before runtime startup. Keep module mocks in a separate test file so existing statically imported store tests are unaffected. A BYOK model request bypasses unrelated model discovery, not authentication or production client/session construction.

Verify that refreshable credentials attach an invokable callback, advertise the buffered lifetime, rotate within the same sign-in, and never expose a refresh token. Verify that legacy credentials retain the static client token and attach no callback. Simulate same-user sign-in with the same token string during asynchronous credential lookup: the pending client's provider must remain retired, while a newly created client's provider succeeds.

Mutation checks proved these tests exercise the production wiring: omitting gitHubTokenProvider failed both refreshable tests, and moving provider binding after asynchronous credential lookup failed the pending-client test. Both temporary mutations were removed, with no remaining production diff.

Validation: yarn test app/test/unit/accounts-store-test.ts app/test/unit/credential-sessions-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/stores/copilot-store-test.ts app/test/unit/stores/copilot-store-credentials-test.ts passed (87 tests); yarn -s lint:fix passed; npx --no-install tsc -p . --noEmit --skipLibCheck passed.
Explain how Desktop's 61-minute validity requirement and the lifetime reported to the SDK share a renewal deadline: subtract the one-minute safety buffer and preserve fractional seconds. Record explicit failure for unknown or insufficient buffered lifetimes rather than inventing metadata.

Document provider ownership by the originating credential session, coherent token/expiry snapshots, and permanent retirement across same-user sign-in or access-token-string reuse. A later sign-in requires a newly created client.

Keep the remaining limitation explicit: these changes do not give an entire Copilot invocation a token lease, so an already-running SDK request can still be affected by another consumer rotating the pair.

Validation: npx --no-install markdownlint docs/technical/oauth.md --config .markdownlint.js --rules .markdownlint-rules.js passed; git diff --check passed.
A provider created after a same-user sign-in can otherwise adopt the new
credential session when GitHub reuses the access-token text. Looking up
historical tokens protects providers that were already bound, but cannot
identify which sign-in an older Account snapshot originally represented.

Associate Account objects with their originating credential session in an
owner-held WeakMap. Each snapshot keeps its first association permanently.
Restore returns a distinct installed snapshot when given an already-known
object, and adding an account does not reassign a previously bound input.
No session marker is added to Account fields or persisted account JSON.

Preserve the association when publishing renewed tokens, returning fresh
or leased accounts, refreshing profile metadata, and emitting redacted
invalidation accounts. Reject copies that change account identity or are
already associated with another session. Refreshability and bound getters
now use this association rather than matching token text or current user.

Reject unknown and retired snapshots when creating a bound token getter,
including legacy Copilot authentication paths. Ordinary endpoint/user-ID
fresh-account lookup deliberately retains its current-session behavior.

Cover late getter/provider creation after same-token replacement, immutable
copy propagation and reassociation, and sign-in replacement while built-in
Copilot model discovery is pending. The three original reproductions failed
before this fix; all focused tests now pass.

Validation:
- yarn test app/test/unit/accounts-store-test.ts app/test/unit/account-token-lifecycle-test.ts app/test/unit/credential-sessions-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/stores/copilot-store-test.ts app/test/unit/stores/copilot-store-credentials-test.ts: 133 passed, 0 failed.
- yarn -s lint:fix: passed.
- npx --no-install tsc -p . --noEmit --skipLibCheck: passed; skipLibCheck avoids existing dependency declaration conflicts.
- git diff --check: passed.
Capture a coherent credential context at commit-message generation entry,
before model discovery or any other asynchronous preparation. The static
client token getter and SDK session provider both retain the originating
account session instead of resolving whichever same-user sign-in is current
when preparation eventually finishes.

Pass that context through client construction. Check the runtime path first,
then acquire the session-bound static token immediately before handing it to
the SDK constructor. Retirement during runtime preparation now rejects both
refreshable and legacy clients before any SDK client or session is created.
This ordering also avoids rotating credentials for an unavailable runtime.

Metadata clients capture their own context at creation. Quota retrieval keeps
that context across SDK startup and uses its bound getter for the quota RPC,
rather than adopting credentials from a replacement sign-in. Static and
metadata token acquisition retain the ordinary ten-minute refresh margin;
only SDK session providers use the existing sixty-one-minute margin.

Preserve cancellation priority for already-aborted generation, the existing
client/session teardown behavior, and no-op conflict resolution without any
resolvable files. Install real accounts in cancellation fixtures that had
previously bypassed credential setup through private client stubs.

Replace the old fresh-account lookup injection with a real runtime-path
preparation boundary, covering same-token replacement for both credential
modes and successful use of the newly signed-in snapshot afterward. Add
quota-startup retirement and metadata-margin coverage. Verify both getters
are bound before model discovery begins. Removing early operation binding
makes that assertion fail; the temporary mutation has been restored.

Validation:
- The three preparation/startup regressions failed before this change.
- yarn test app/test/unit/accounts-store-test.ts app/test/unit/account-token-lifecycle-test.ts app/test/unit/credential-sessions-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/stores/copilot-store-test.ts app/test/unit/stores/copilot-store-credentials-test.ts: 137 passed, 0 failed.
- yarn -s lint:fix: passed.
- npx --no-install tsc -p . --noEmit --skipLibCheck: passed; existing dependency declaration conflicts remain excluded.
- git diff --check: passed.

These changes do not add invocation-long Copilot token leases or claim to
validate native SDK cached-token rollover against the live service.
Bring immutable account-session associations and operation-entry credential binding into the sign-in layer. Preserve the published stack history; the two fixes carry their focused regression coverage and descriptive implementation commits.
Carry the sign-in integration and its Copilot session-lineage fixes into the documentation layer without rebasing published branches. OAuth lifecycle notes will describe the stronger snapshot identity and asynchronous operation binding.
Describe the credential owner's non-serialized account-session association,
including propagation through token, lease, and profile snapshots. Clarify
that replacement sign-ins create distinct snapshots and that bound getters
reject unknown or retired origins even when access-token text is reused.
Ordinary current-account lookup semantics remain intentionally available.

Document operation-entry binding before commit-message model discovery,
session-bound static authentication after runtime preparation, and quota
credential checks across SDK startup. Distinguish metadata's ordinary
refresh margin from the longer SDK-session preflight margin.

Retain the explicit warning that Copilot does not hold invocation-long token
leases. Add live SDK cached-token rollover and long-running invocations to
manual rollout validation; mock-boundary tests do not prove native rollover.

Validation:
- npx --no-install markdownlint docs/technical/oauth.md --config .markdownlint.js --rules .markdownlint-rules.js: passed.
- git diff --check: passed.
…t logging

Keep the final stack layer current with immutable account-session tracking, early operation credential binding, their regression tests, and updated OAuth rollout notes. Preserve published history and existing sign-out logging behavior.

Resolve the AccountsStore invalidation-event conflict by retaining the credential-driven sign-out log and inheriting the redacted account snapshot's original session association. Neither behavior is dropped. Repository lint auto-fix and staged whitespace checks passed.
Commit-message cancellation previously could not finish while model discovery
or static client authentication awaited a token leased by Git. The abort check
only ran after initialization, leaving generation state and the commit button
blocked until the lease ended or approached expiry.

Extract the existing session-cancellation pattern into a private typed waiter.
Use it for model discovery, client construction, and session creation. Abort
rejects only this operation's wait; shared renewal and cached model discovery
continue for other consumers. Do not start work for an already-aborted signal.

Track result ownership across completion/abort races. Stop a client delivered
after cancellation and disconnect abandoned sessions exactly once. Observe
late failures without unhandled rejections and log abandoned-result cleanup
failures explicitly. Keep normal handoff and teardown behavior unchanged.

Add production-boundary coverage with a real credential lease: cancellation
settles while the lease remains held, no SDK client is constructed prematurely,
and an independent consumer still receives the shared renewed token. After
release, the abandoned client is stopped once without creating a session.
Cover late runtime-path failure and strengthen model-discovery coverage to
cancel before resolving its shared promise instead of masking the stalled wait.

Validation:
- Three regressions failed before implementation.
- yarn test app/test/unit/stores/copilot-store-test.ts app/test/unit/stores/copilot-store-credentials-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/credential-sessions-test.ts: 94 passed, 0 failed.
- yarn -s lint:fix: passed.
- npx --no-install tsc -p . --noEmit --skipLibCheck: passed; existing dependency declaration conflicts remain excluded.
- git diff --check: passed.
Conflict resolution previously waited for SDK session creation without
observing cancellation. A token with forty-five minutes remaining can satisfy
static client authentication yet block the session provider's sixty-one-minute
preflight behind a Git lease. Cancelling left the chunk pending and delayed
client/session cleanup until that unrelated lease ended.

Use the scoped cancellation waiter for conflict client initialization and the
cancellation-aware session creator for every chunk, including validation retries.
Stop abandoned clients and disconnect sessions delivered after cancellation.
Translate the shared helper's cancellation error into the conflict-specific
abort type so cancelled operations are never retried or reported as transport
failures. Normal failure stages and validation retry behavior remain unchanged.

Reject already-aborted work before credential preparation, but preserve the
existing empty result when all files are skipped, including aborted no-op calls.
Retain the post-handoff abort check for sessions the caller already owns.

Add production-boundary regressions for pending client preparation, an actual
credential lease during forty-five-minute session preflight, and already-aborted
requests with no installed account. Assert cancellation settles before lease
release, client shutdown is immediate, late session disconnection happens once,
no new chunk is attempted, and a parallel credential consumer still completes
through the shared renewal. Cover completion/abort races and aborted no-op work.

Validation:
- Three conflict regressions failed before implementation.
- yarn test app/test/unit/stores/copilot-store-test.ts app/test/unit/stores/copilot-store-credentials-test.ts app/test/unit/refresh-token-consumers-test.ts app/test/unit/credential-sessions-test.ts: 98 passed, 0 failed.
- yarn -s lint:fix: passed.
- npx --no-install tsc -p . --noEmit --skipLibCheck: passed; existing dependency declaration conflicts remain excluded.
- git diff --check: passed.
Bring client/model preparation cancellation and conflict session preflight cancellation into the dependent sign-in branch. Preserve shared credential renewal and Git lease ownership while cleaning up clients and sessions that complete after a caller aborts.
Integrate both independently tested cancellation fixes through the existing sign-in stack without rewriting published history. Keep caller-local abort behavior, conflict error classification, and late-resource cleanup aligned with the documented OAuth lifecycle.
Explain that commit-message generation and conflict resolution can leave client
and SDK session preparation promptly even when Git holds the token lease needed
by renewal. Generation can also leave shared model discovery without waiting for
that shared work to complete.

Cancellation affects only the caller's wait: it neither aborts shared credential
renewal/model discovery nor releases another operation's lease. Document cleanup
of late clients and sessions, and the distinction between conflict aborts and
retryable/transport errors.

Keep the existing warning that Copilot has no invocation-long lease and that an
already-running SDK request can still fail after token rotation. Native cached-
token rollover and long-running invocations still need live rollout validation.

Validation:
- npx --no-install markdownlint docs/technical/oauth.md --config .markdownlint.js --rules .markdownlint-rules.js: passed.
- git diff --check: passed.
- Documentation-only change; source behavior is covered by the two preceding cancellation commits and their 98 passing focused tests.
…gging

Carry the independently committed initialization and conflict-session cancellation fixes, their lease/late-cleanup regressions, and OAuth lifecycle documentation through the final dependent branch. Preserve published history and the existing sign-out log and account-snapshot identity handling.
@williammartin
williammartin removed their request for review October 6, 2026 14:14
Base automatically changed from short-lived-tokens to development October 7, 2026 15:22
@sergiou87
sergiou87 merged commit c2d018e into development Oct 7, 2026
9 checks passed
@sergiou87
sergiou87 deleted the short-lived-tokens-10-sign-out-log branch October 7, 2026 15:49
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.

5 participants