Skip to content

[profile-switcher][rust] -- [2/2] Add app-server account session lifecycle#25383

Open
dhruvgupta-oai wants to merge 11 commits into
mainfrom
dev/dhruvgupta/desktop-account-sessions-rust
Open

[profile-switcher][rust] -- [2/2] Add app-server account session lifecycle#25383
dhruvgupta-oai wants to merge 11 commits into
mainfrom
dev/dhruvgupta/desktop-account-sessions-rust

Conversation

@dhruvgupta-oai
Copy link
Copy Markdown
Contributor

@dhruvgupta-oai dhruvgupta-oai commented May 31, 2026

Summary

Adds the shipped Rust app-server lifecycle for Desktop multi-account profile switching on top of the protocol PR.

Exposes additive accountSession/login/start, accountSession/add, accountSession/list, accountSession/switch, and accountSession/logout routes; stores all saved session credentials and metadata in one account-sessions.json; keeps the active auth.json snapshot current; refreshes workspace metadata; and exchanges the bearer token when switching workspaces so backend routing uses the newly selected workspace.

The existing account/login/start and account/logout routes remain unchanged. The saved-session login route snapshots the active session before starting another browser login and does not revoke the previous session credentials. The saved-session logout route removes and revokes only the selected session.

Addresses the review findings by returning an empty saved-session list for non-ChatGPT auth bootstrap, restoring the prior auth payload for add-without-switch, preserving managed sessions during additional login, deriving canonical metadata from parsed ID-token data, revoking sessions only during saved-session logout, and removing unused account-session plan and workspace-status metadata.

Rust Stack

  1. openai/codex#25469 adds the account-session protocol.
  2. This PR

Desktop Consumer Stack

  1. openai/openai#912789 adds Desktop compatibility protocol types.
  2. openai/openai#912791 routes Desktop account session requests through Rust app server.
  3. openai/openai#912794 adds the profile account and workspace switcher.
  4. openai/openai#912795 makes token-derived selected workspace drive Desktop current-account consumers.

Validation

  • Regenerated app-server schema fixtures with just write-app-server-schema.
  • Did not run tests per requested scope.

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 726ad5b878

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/account_sessions.rs Outdated
Comment thread codex-rs/app-server/src/request_processors/account_processor.rs Outdated
Comment thread codex-rs/app-server/src/account_sessions.rs
Comment thread codex-rs/app-server/src/account_sessions.rs Outdated
Comment thread codex-rs/app-server/src/account_sessions.rs Outdated
Comment thread codex-rs/app-server/src/account_sessions.rs
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch from 1a33b2c to 66f3242 Compare June 1, 2026 00:42
@dhruvgupta-oai dhruvgupta-oai changed the title Add app server account session APIs [profile-switcher][rust] -- [3/3] Add app-server account session lifecycle Jun 1, 2026
@dhruvgupta-oai dhruvgupta-oai changed the base branch from main to dev/dhruvgupta/desktop-account-sessions-rust-storage June 1, 2026 00:42
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust-storage branch from e708601 to c4c1505 Compare June 1, 2026 02:18
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch 3 times, most recently from 714f4eb to c7f4b4b Compare June 1, 2026 17:00
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust-storage branch from 0009a7e to ffc9d4b Compare June 1, 2026 17:04
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch from c7f4b4b to 9da2781 Compare June 1, 2026 17:05
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust-storage branch from ffc9d4b to 6e0d3d5 Compare June 1, 2026 17:08
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch from 9da2781 to 9dd4b40 Compare June 1, 2026 17:08
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust-storage branch from 6e0d3d5 to cffab69 Compare June 1, 2026 19:34
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch from 9dd4b40 to 5d83164 Compare June 1, 2026 19:34
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust-storage branch from cffab69 to fd36ea0 Compare June 1, 2026 20:11
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch 3 times, most recently from e39598b to 62ac0cb Compare June 2, 2026 09:06
@dhruvgupta-oai dhruvgupta-oai changed the title [profile-switcher][rust] -- [3/3] Add app-server account session lifecycle [profile-switcher][rust] -- [2/2] Add app-server account session lifecycle Jun 2, 2026
@dhruvgupta-oai dhruvgupta-oai changed the base branch from dev/dhruvgupta/desktop-account-sessions-rust-storage to dev/dhruvgupta/desktop-account-sessions-rust-protocol June 2, 2026 09:07
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust-protocol branch from 8cf9a3d to 3ad4592 Compare June 2, 2026 09:26
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch from 62ac0cb to 9dadbb3 Compare June 2, 2026 09:26
Copy link
Copy Markdown
Contributor

@cooper-oai cooper-oai left a comment

Choose a reason for hiding this comment

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

doesn't this storage make ~/.codex/auth.json redundant/not needed?

.map_err(|e| io::Error::other(format!("persist task failed: {e}")))??;

if should_revoke_auth_tokens(previous_auth.as_ref(), &auth)
if revoke_previous_auth
Copy link
Copy Markdown
Contributor

@cooper-oai cooper-oai Jun 3, 2026

Choose a reason for hiding this comment

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

it should be up to the server (authapi) to do the revocation for switching, not the client

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i think this is existing code that i put a bool around

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah so i want to keep this minimal and not change existing code as much as i can. current app revokes the token when you login as someone new so keeping that convention for now.

Copy link
Copy Markdown
Contributor

@cooper-oai cooper-oai left a comment

Choose a reason for hiding this comment

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

do we want to do this experimentally first?

@dhruvgupta-oai
Copy link
Copy Markdown
Contributor Author

dhruvgupta-oai commented Jun 3, 2026

doesn't this storage make ~/.codex/auth.json redundant/not needed?

Yes but keeping the og json so that this is backwards compatible

do we want to do this experimentally first?

all this code is just additive APIs. Theres no actual change to the login functionality other than the bool for revoking the previous auth. The experiment / gate is gonna come from the desktop app.

EDIT: I also added some more APIS for a new logout and new login path that we can call from desktop so we can fully gate this from the front-end side.

dhruvgupta-oai added a commit that referenced this pull request Jun 3, 2026
…ocol (#25469)

## Summary

Adds the app-server v2 `accountSession/*` protocol used by the Desktop
profile switcher and the backend account metadata client needed to
populate workspace choices.

This is the protocol layer only. The app-server lifecycle and
consolidated saved-session storage are split into a follow-up PR.

## Rust Stack

1. This PR
2. [#25383](#25383) adds
app-server session lifecycle behavior and consolidated saved-session
storage.

## Validation

- Generated app-server schema fixtures are included from the existing
generation flow in the lifecycle PR where the routes are registered.
- Did not run tests per requested scope.
Base automatically changed from dev/dhruvgupta/desktop-account-sessions-rust-protocol to main June 3, 2026 19:55
@dhruvgupta-oai dhruvgupta-oai force-pushed the dev/dhruvgupta/desktop-account-sessions-rust branch from 2849fba to f784c75 Compare June 3, 2026 19:57
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.

2 participants