feat(tui): add workspace slash commands

This commit is contained in:
Felipe Coury
2026-06-12 00:33:59 -07:00
parent d4a71337cc
commit 7cc15e96a2
18 changed files with 348 additions and 10 deletions
@@ -4416,6 +4416,13 @@
"mode"
],
"type": "object"
},
"WorkspaceMutationOperation": {
"enum": [
"setWorkingDirectory",
"addWorkspaceRoot"
],
"type": "string"
}
},
"description": "Request from the client to the server.",
@@ -546,6 +546,12 @@ client_request_definitions! {
serialization: thread_id(params.thread_id),
response: v2::ThreadSettingsUpdateResponse,
},
#[experimental("thread/workspace/update")]
ThreadWorkspaceUpdate => "thread/workspace/update" {
params: v2::ThreadWorkspaceUpdateParams,
serialization: thread_id(params.thread_id),
response: v2::ThreadWorkspaceUpdateResponse,
},
#[experimental("thread/memoryMode/set")]
ThreadMemoryModeSet => "thread/memoryMode/set" {
params: v2::ThreadMemoryModeSetParams,
@@ -3712,6 +3712,30 @@ fn thread_settings_update_params_preserve_explicit_null_service_tier() {
assert_eq!(serialized_without_override.get("serviceTier"), None);
}
#[test]
fn thread_workspace_update_params_round_trip() {
let params = ThreadWorkspaceUpdateParams {
thread_id: "thread_123".to_string(),
operation: WorkspaceMutationOperation::SetWorkingDirectory,
path: "../stack-layer".to_string(),
};
let serialized = serde_json::to_value(&params).expect("params should serialize");
assert_eq!(
serialized,
json!({
"threadId": "thread_123",
"operation": "setWorkingDirectory",
"path": "../stack-layer"
})
);
assert_eq!(
serde_json::from_value::<ThreadWorkspaceUpdateParams>(serialized)
.expect("params should deserialize"),
params
);
}
#[test]
fn thread_settings_update_params_preserve_field_level_experimental_gates() {
let permissions = ThreadSettingsUpdateParams {
@@ -9,6 +9,7 @@ use super::ThreadSource;
use super::Turn;
use super::TurnEnvironmentParams;
use super::TurnItemsView;
use super::WorkspaceMutationOperation;
use super::shared::v2_enum_from_core;
use codex_experimental_api_macros::ExperimentalApi;
pub use codex_protocol::capabilities::CapabilityRootLocation;
@@ -281,6 +282,24 @@ pub struct ThreadSettingsUpdateParams {
#[ts(export_to = "v2/")]
pub struct ThreadSettingsUpdateResponse {}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadWorkspaceUpdateParams {
pub thread_id: String,
pub operation: WorkspaceMutationOperation,
pub path: String,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadWorkspaceUpdateResponse {
pub changed: bool,
pub cwd: AbsolutePathBuf,
pub runtime_workspace_roots: Vec<AbsolutePathBuf>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS, ExperimentalApi)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]