Add experimental ChatGPT workspace switching to app-server (#57514)

## What changed

- Add `accountSession/list` and `accountSession/switch` for the active managed ChatGPT login, with optional workspace membership refresh.
- Validate membership and workspace policy, pause new turns, and unload running threads before switching credentials. Notify clients with `thread/closed` and `account/updated`; selecting the current workspace leaves threads running.
- Support browser sign-in for SSO through `allowBrowserLogin`, binding the callback to the requesting login and workspace. Require a separate sign-in for government workspaces.
- Preserve the selected workspace across token refresh and conditionally restore the previous workspace if routing validation fails. Guard credential writes against concurrent login or logout changes.

## Testing

Add app-server and auth tests covering workspace switching, credential preservation, policy and identity rejection, conditional rollback, stale sessions, and SSO callback validation.

GitOrigin-RevId: 1234abc33b71e69b66318da3e201fccc08867906
This commit is contained in:
dhruvgupta-oai
2026-10-27 17:04:16 +00:00
committed by copyberry
parent 27ace641fe
commit d257beb16a
30 changed files with 2050 additions and 22 deletions
@@ -1842,6 +1842,16 @@ impl MessageProcessor {
.await
.map(|response| Some(response.into()))
}
ClientRequest::AccountSessionsList { params, .. } => self
.account_processor
.list_account_sessions(params)
.await
.map(|response| Some(ClientResponsePayload::AccountSessionsList(response))),
ClientRequest::AccountSessionsSwitch { params, .. } => self
.account_processor
.switch_account_session(params, &self.thread_processor, &self.turn_admission)
.await
.map(|response| Some(ClientResponsePayload::AccountSessionsSwitch(response))),
ClientRequest::LogoutAccount { .. } => {
self.account_processor
.logout_account(request_id.clone())