mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
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:
committed by
copyberry
parent
27ace641fe
commit
d257beb16a
@@ -0,0 +1,34 @@
|
||||
//! Unloads old-workspace runtimes while turn admission is paused by the account switch.
|
||||
//! Resuming a thread builds fresh policy and transport state for the new workspace.
|
||||
|
||||
use super::*;
|
||||
|
||||
impl ThreadRequestProcessor {
|
||||
pub(crate) async fn unload_for_workspace_switch(&self) -> Result<(), JSONRPCErrorError> {
|
||||
let report = self
|
||||
.thread_manager
|
||||
.shutdown_all_threads_bounded(Duration::from_secs(/*secs*/ 10))
|
||||
.await;
|
||||
for thread_id in report.completed {
|
||||
self.finalize_thread_teardown(thread_id).await;
|
||||
self.outgoing
|
||||
.send_server_notification(ServerNotification::ThreadClosed(
|
||||
codex_app_server_protocol::ThreadClosedNotification {
|
||||
thread_id: thread_id.to_string(),
|
||||
},
|
||||
))
|
||||
.await;
|
||||
}
|
||||
// A delegated child may have started while its parent was shutting down.
|
||||
// Never replace credentials until every runtime has stopped.
|
||||
if !report.submit_failed.is_empty()
|
||||
|| !report.timed_out.is_empty()
|
||||
|| !self.thread_manager.list_thread_ids().await.is_empty()
|
||||
{
|
||||
return Err(internal_error(
|
||||
"Some threads are still running; retry the workspace switch",
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user