Skip to content

fix: refresh expired ID tokens before account switch - #134

Merged
joonshakya merged 5 commits into
Lampese:mainfrom
Jeakcey:fix/refresh-expired-id-token
Aug 27, 2026
Merged

fix: refresh expired ID tokens before account switch#134
joonshakya merged 5 commits into
Lampese:mainfrom
Jeakcey:fix/refresh-expired-id-token

Conversation

@Jeakcey

@Jeakcey Jeakcey commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Dependency

This is a stacked follow-up to #128. Please merge #128 first; this PR preserves its original commits and authorship. Once #128 lands, the remaining diff is the single follow-up commit daac4b6.

What changed

  • Treat an expired or malformed ID token as requiring refresh even when the access token is still valid.
  • Refresh the target account before writing it to auth.json from both the main UI and tray paths.
  • Persist rotated access and refresh tokens before reporting a missing or invalid ID token, so a single-use refresh token is never lost.
  • Serialize rapid tray selections with latest-request-wins behavior.
  • Add deterministic synthetic-JWT regression tests; no real credentials or logs are included.

Why

On Windows with Codex desktop 26.820.9563.0, a stored account had an ID token that expired hours earlier while its access token remained valid. Codex Switcher only checked the access token and restored the stale ID token, after which Codex returned 401 and displayed the sign-in screen. PR #128 fixes live-token reconciliation; this follow-up covers the independent partial-expiry path and switch-time refresh.

Checks

  • cargo test --manifest-path src-tauri/Cargo.toml: 39 passed
  • cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets: completed; only pre-existing warnings from the fix: preserve rotated auth tokens when switching accounts #128 base
  • pnpm build: passed
  • pnpm tauri:win build --no-bundle: passed on Windows
  • Independent code review: no remaining blocking findings

Manual A to B to A switching was not run inside this active Codex task because the switcher correctly requires Codex to be closed first. The original failure was confirmed from local token expiry metadata and desktop authentication logs without publishing credentials.

Related: #127, #128, #129

serg-shcherbak and others added 5 commits August 20, 2026 15:10
Codex can reject an expired ID token while the access token is still valid. Refresh both OAuth tokens before writing auth.json, preserve rotated refresh tokens on partial responses, and serialize rapid tray selections so the last request wins.
@joonshakya
joonshakya marked this pull request as ready for review August 27, 2026 08:00
@joonshakya
joonshakya merged commit 2c29859 into Lampese:main Aug 27, 2026
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.

3 participants