mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Restore collaboration mode when resuming threads (#45519)
## Why Resuming a thread initialized its collaboration mode to Default, losing the saved Plan mode and its developer instructions. Reconnecting clients also lacked a server-reported mode to reconcile changes made by another client. ## What changed - Restore the saved collaboration mode from the latest matching `ThreadSettingsApplied` event, falling back to the last legacy `TurnContext`. Apply the effective model and reasoning effort while retaining the saved mode and developer instructions. - Include `collaborationMode` in `thread/resume` responses and update the generated schemas and bindings. - Use the restored mode in the TUI, including the first prompt after resume. Prefer the server's mode when restoring disconnected input, while preserving the local selection for older servers that omit it. ## Testing Add regression coverage for persisted and legacy collaboration modes, model and reasoning-effort overrides, the resumed Plan mode display and first prompt, and reconnect behavior with and without a server-reported mode. GitOrigin-RevId: ed064516e7fae1c1668152ab448f510cbcacfe06
This commit is contained in:
1 parent
7c73903be2
commit
91d54f1667
22 files changed
+309
-13
No files matched your search
@@ -51,11 +51,20 @@ async fn reconnect_restores_history_permissions_and_keeps_old_input_paused() ->
|
||||
app.chat_widget.set_collaboration_mask(
|
||||
crate::collaboration_modes::plan_mask(app.model_catalog.as_ref()).unwrap(),
|
||||
);
|
||||
let expected_mode = app.chat_widget.effective_collaboration_mode().with_updates(
|
||||
let cached_mode = app.chat_widget.effective_collaboration_mode().with_updates(
|
||||
Some("gpt-test".into()),
|
||||
Some(None),
|
||||
/*developer_instructions*/ None,
|
||||
);
|
||||
// A newer server can report a mode changed by another client while disconnected.
|
||||
let server_mode = (!recovered_queue).then(|| CollaborationMode {
|
||||
mode: ModeKind::Default,
|
||||
settings: Settings {
|
||||
developer_instructions: Some("Updated by another client".into()),
|
||||
..cached_mode.settings.clone()
|
||||
},
|
||||
});
|
||||
let expected_mode = server_mode.clone().unwrap_or(cached_mode);
|
||||
let expected_submitted_mode = expected_mode.clone();
|
||||
assert!(!app.model_catalog.collaboration_modes.is_empty());
|
||||
if edit_offline {
|
||||
@@ -118,8 +127,12 @@ async fn reconnect_restores_history_permissions_and_keeps_old_input_paused() ->
|
||||
let params = request.params.as_ref().unwrap();
|
||||
assert_eq!(params["threadId"], id.to_string());
|
||||
assert!(params["model"].is_null());
|
||||
Some(json!({"result": {"thread": thread, "model": "gpt-test", "modelProvider": "test-provider", "cwd": cwd,
|
||||
"approvalPolicy": "never", "approvalsReviewer": "user", "sandbox": {"type": "dangerFullAccess"}, "reasoningEffort": null}}))
|
||||
let mut result = json!({"thread": thread, "model": "gpt-test", "modelProvider": "test-provider", "cwd": cwd,
|
||||
"approvalPolicy": "never", "approvalsReviewer": "user", "sandbox": {"type": "dangerFullAccess"}, "reasoningEffort": null});
|
||||
if let Some(mode) = &server_mode {
|
||||
result["collaborationMode"] = json!(mode);
|
||||
}
|
||||
Some(json!({"result": result}))
|
||||
}
|
||||
"thread/read" => Some(json!({"result": {"thread": thread}})),
|
||||
"thread/list" | "thread/loaded/list" => Some(json!({"result": {"data": [], "nextCursor": null}})),
|
||||
|
||||
@@ -1814,6 +1814,10 @@ impl App {
|
||||
replay_filter::snapshot_has_pending_interactive_request(&snapshot);
|
||||
self.chat_widget
|
||||
.set_queue_autosend_suppressed(/*suppressed*/ true);
|
||||
let has_resumed_collaboration_mode = snapshot
|
||||
.session
|
||||
.as_ref()
|
||||
.is_some_and(|session| session.collaboration_mode.is_some());
|
||||
if let Some(session) = snapshot.session {
|
||||
if session.reasoning_effort != Some(ReasoningEffortConfig::Ultra) {
|
||||
self.chat_widget
|
||||
@@ -1867,7 +1871,12 @@ impl App {
|
||||
.send(AppEvent::EndInitialHistoryReplayBuffer);
|
||||
}
|
||||
if recovered_input.is_some() {
|
||||
let mode = has_resumed_collaboration_mode
|
||||
.then(|| self.chat_widget.effective_collaboration_mode());
|
||||
self.chat_widget.restore_reconnected_input(recovered_input);
|
||||
if let Some(mode) = mode {
|
||||
self.chat_widget.set_effective_collaboration_mode(mode);
|
||||
}
|
||||
}
|
||||
self.restore_realtime_replay_state_after_replay(
|
||||
&replayed_final_items,
|
||||
|
||||
Reference in new issue
Block a user