feat: synchronize runtime workspace roots in thread settings

This commit is contained in:
Edward Frazer
2026-05-30 18:54:28 -07:00
parent dd74e192f6
commit 61299d9752
20 changed files with 439 additions and 27 deletions
@@ -4583,6 +4583,16 @@
}
]
},
"runtimeWorkspaceRoots": {
"default": null,
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
},
"type": [
"array",
"null"
]
},
"sandboxPolicy": {
"$ref": "#/definitions/SandboxPolicy"
},
@@ -17688,6 +17688,16 @@
}
]
},
"runtimeWorkspaceRoots": {
"default": null,
"items": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
"type": [
"array",
"null"
]
},
"sandboxPolicy": {
"$ref": "#/definitions/v2/SandboxPolicy"
},
@@ -15512,6 +15512,16 @@
}
]
},
"runtimeWorkspaceRoots": {
"default": null,
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
},
"type": [
"array",
"null"
]
},
"sandboxPolicy": {
"$ref": "#/definitions/SandboxPolicy"
},
@@ -332,6 +332,16 @@
}
]
},
"runtimeWorkspaceRoots": {
"default": null,
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
},
"type": [
"array",
"null"
]
},
"sandboxPolicy": {
"$ref": "#/definitions/SandboxPolicy"
},
@@ -11,4 +11,4 @@ import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
import type { SandboxPolicy } from "./SandboxPolicy";
export type ThreadSettings = { cwd: AbsolutePathBuf, approvalPolicy: AskForApproval, approvalsReviewer: ApprovalsReviewer, sandboxPolicy: SandboxPolicy, activePermissionProfile: ActivePermissionProfile | null, model: string, modelProvider: string, serviceTier: string | null, effort: ReasoningEffort | null, summary: ReasoningSummary | null, collaborationMode: CollaborationMode, personality: Personality | null, };
export type ThreadSettings = { cwd: AbsolutePathBuf, runtimeWorkspaceRoots: Array<AbsolutePathBuf> | null, approvalPolicy: AskForApproval, approvalsReviewer: ApprovalsReviewer, sandboxPolicy: SandboxPolicy, activePermissionProfile: ActivePermissionProfile | null, model: string, modelProvider: string, serviceTier: string | null, effort: ReasoningEffort | null, summary: ReasoningSummary | null, collaborationMode: CollaborationMode, personality: Personality | null, };
@@ -3167,6 +3167,7 @@ mod tests {
thread_id: "thr_123".to_string(),
thread_settings: v2::ThreadSettings {
cwd: absolute_path("/tmp/repo"),
runtime_workspace_roots: None,
approval_policy: v2::AskForApproval::Never,
approvals_reviewer: v2::ApprovalsReviewer::User,
sandbox_policy: v2::SandboxPolicy::DangerFullAccess,
@@ -3192,6 +3193,12 @@ mod tests {
crate::experimental_api::ExperimentalApi::experimental_reason(&notification),
Some("thread/settings/updated")
);
assert_eq!(
serde_json::to_value(notification)
.expect("thread settings notification should serialize")
.pointer("/params/threadSettings/runtimeWorkspaceRoots"),
Some(&serde_json::Value::Null)
);
}
#[test]
@@ -3644,6 +3644,16 @@ fn thread_settings_update_params_preserve_explicit_null_service_tier() {
#[test]
fn thread_settings_update_params_preserve_field_level_experimental_gates() {
let runtime_workspace_roots = ThreadSettingsUpdateParams {
thread_id: "thread_123".to_string(),
runtime_workspace_roots: Some(vec![PathBuf::from("repo")]),
..Default::default()
};
assert_eq!(
crate::experimental_api::ExperimentalApi::experimental_reason(&runtime_workspace_roots),
Some("thread/settings/update.runtimeWorkspaceRoots")
);
let permissions = ThreadSettingsUpdateParams {
thread_id: "thread_123".to_string(),
permissions: Some(":workspace".to_string()),
@@ -234,6 +234,11 @@ pub struct ThreadSettingsUpdateParams {
/// Override the working directory for subsequent turns.
#[ts(optional = nullable)]
pub cwd: Option<PathBuf>,
/// Replace the thread's runtime workspace roots for subsequent turns.
/// Relative paths are resolved against the effective cwd.
#[experimental("thread/settings/update.runtimeWorkspaceRoots")]
#[ts(optional = nullable)]
pub runtime_workspace_roots: Option<Vec<PathBuf>>,
/// Override the approval policy for subsequent turns.
#[experimental(nested)]
#[ts(optional = nullable)]
@@ -290,6 +295,10 @@ pub struct ThreadSettingsUpdateResponse {}
#[ts(export_to = "v2/")]
pub struct ThreadSettings {
pub cwd: AbsolutePathBuf,
// New servers populate this field. `None` accepts older payloads that
// predate runtime workspace root synchronization.
#[serde(default)]
pub runtime_workspace_roots: Option<Vec<AbsolutePathBuf>>,
pub approval_policy: AskForApproval,
pub approvals_reviewer: ApprovalsReviewer,
pub sandbox_policy: SandboxPolicy,