Preserve app-server thread working directories across platforms (#62375)

## Why

A remote app server can report a working directory in a different path
convention from the client. Decoding a Windows drive path as a client-native
absolute path can make a Unix client reject the thread response.

## What changed

Keep thread `cwd` values as server-native strings in summaries, settings,
and start, resume, and fork responses. Preserve the JSON and generated SDK
types. In the TUI, store the session directory as a `PathUri` using the
server's path convention when available. Use that directory to match diff
and skill results and to display the project name in the terminal title.

## Testing

Add regression coverage for foreign-path response round trips, diff results
matched against a remote session directory, and terminal titles derived
from a Windows path. Verify that the server rejects a working directory
that cannot be encoded as UTF-8.

GitOrigin-RevId: 600f0b531939db4cd4ec884de166224082995e00
This commit is contained in:
Eric Traut
2026-11-18 22:13:26 +00:00
committed by copyberry
parent fecf5cc672
commit b82943092c
111 changed files with 720 additions and 479 deletions
+5 -8
View File
@@ -687,7 +687,7 @@ fn sample_thread(thread_id: &str) -> Thread {
recency_at: Some(2),
status: AppServerThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
cli_version: "0.0.0".to_string(),
source: AppServerSessionSource::Exec,
can_accept_direct_input: None,
@@ -707,7 +707,7 @@ fn sample_thread_start_response() -> ClientResponsePayload {
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: AppServerAskForApproval::OnRequest,
@@ -726,7 +726,7 @@ fn sample_thread_resume_response() -> ClientResponsePayload {
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: AppServerAskForApproval::OnRequest,
@@ -749,7 +749,7 @@ fn sample_thread_fork_response() -> ClientResponsePayload {
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: AppServerAskForApproval::OnRequest,
@@ -935,10 +935,7 @@ fn track_response_ignores_unserializable_thread_responses() {
let ClientResponsePayload::ThreadStart(thread_start) = &mut response else {
panic!("expected thread/start response");
};
thread_start.cwd = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(
std::path::PathBuf::from(OsString::from_vec(vec![b'/', b'b', b'a', b'd', 0xff])),
)
.expect("non-UTF-8 Unix paths are valid absolute paths");
thread_start.thread.path = Some(OsString::from_vec(b"/bad\xff".to_vec()).into());
client.track_response(/*connection_id*/ 7, RequestId::Integer(1), &response);
+6 -5
View File
@@ -2476,11 +2476,12 @@ impl AnalyticsReducer {
out: &mut Vec<TrackEventRequest>,
) {
let session_source: SessionSource = thread.source.into();
let is_worktree =
codex_git_utils::repository_identity(thread.cwd.as_path()).and_then(|_| {
codex_git_utils::get_git_repo_root(thread.cwd.canonicalize().ok()?.as_path())
.map(|root| root.join(".git").is_file())
});
let is_worktree = thread.cwd.to_inferred_path_uri().and_then(|cwd| {
let cwd = cwd.to_abs_path().ok()?;
codex_git_utils::repository_identity(cwd.as_path())?;
codex_git_utils::get_git_repo_root(cwd.canonicalize().ok()?.as_path())
.map(|root| root.join(".git").is_file())
});
let session_id = thread.session_id;
let thread_id = thread.id;
let parent_thread_id = thread.parent_thread_id;
@@ -164,8 +164,7 @@ async fn thread_initialized_classifies_validated_linked_worktrees() {
let ClientResponsePayload::ThreadStart(start) = &mut response else {
panic!("expected thread/start response");
};
start.thread.cwd = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(cwd)
.expect("absolute checkout path");
start.thread.cwd = codex_utils_path_uri::LegacyAppPathString::from_path(cwd);
reducer
.ingest(
AnalyticsFact::ClientResponse {
+3 -3
View File
@@ -129,7 +129,7 @@ pub(super) fn sample_thread_with_metadata(
recency_at: Some(2),
status: AppServerThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
cli_version: "0.0.0".to_string(),
source,
can_accept_direct_input: None,
@@ -159,7 +159,7 @@ pub(super) fn sample_thread_start_response(
model: model.to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: AppServerAskForApproval::OnRequest,
@@ -225,7 +225,7 @@ pub(super) fn sample_thread_resume_response_with_source(
model: model.to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: AppServerAskForApproval::OnRequest,
+11
View File
@@ -382,6 +382,17 @@ pub enum AppServerRequestHandle {
Remote(crate::remote::RemoteAppServerRequestHandle),
}
impl AppServerRequestHandle {
/// Operating system reported by the app-server that serves these requests.
pub fn platform_os(&self) -> Option<&str> {
match self {
Self::InProcess(_) => Some(std::env::consts::OS),
Self::Remote(client) => client.platform_os.as_deref(),
Self::Cloud(_) => None,
}
}
}
pub enum AppServerClient {
Cloud(CloudClient),
InProcess(InProcessAppServerClient),
+2
View File
@@ -174,6 +174,7 @@ pub struct RemoteAppServerClient {
#[derive(Clone)]
pub struct RemoteAppServerRequestHandle {
command_tx: mpsc::Sender<RemoteClientCommand>,
pub(crate) platform_os: Option<String>,
}
enum SocketPeerPolicy {
@@ -536,6 +537,7 @@ impl RemoteAppServerClient {
pub fn request_handle(&self) -> RemoteAppServerRequestHandle {
RemoteAppServerRequestHandle {
command_tx: self.command_tx.clone(),
platform_os: self.metadata.platform_os.clone(),
}
}
@@ -3379,7 +3379,7 @@ mod tests {
recency_at: Some(3),
status: v2::ThreadStatus::Idle,
path: None,
cwd: cwd.clone(),
cwd: cwd.clone().into(),
cli_version: "0.0.0".to_string(),
source: v2::SessionSource::Exec,
can_accept_direct_input: None,
@@ -3394,7 +3394,7 @@ mod tests {
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd,
cwd: cwd.into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: vec![
codex_utils_path_uri::LegacyAppPathString::from_abs_path(&absolute_path(
@@ -4644,7 +4644,7 @@ mod tests {
thread_settings: v2::ThreadSettings {
disabled_plugin_ids: Vec::new(),
environments: Some(Vec::new()),
cwd: absolute_path("/tmp/repo"),
cwd: absolute_path("/tmp/repo").into(),
approval_policy: v2::AskForApproval::Never,
approvals_reviewer: v2::ApprovalsReviewer::User,
sandbox_policy: v2::SandboxPolicy::DangerFullAccess,
@@ -324,7 +324,7 @@ fn thread_resume_response_round_trips_initial_turns_page() {
recency_at: Some(1),
status: ThreadStatus::Idle,
path: None,
cwd: absolute_path("tmp"),
cwd: absolute_path("tmp").into(),
cli_version: "0.0.0".to_string(),
source: SessionSource::Exec,
can_accept_direct_input: None,
@@ -339,7 +339,7 @@ fn thread_resume_response_round_trips_initial_turns_page() {
model: "gpt-5".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: absolute_path("tmp"),
cwd: absolute_path("tmp").into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: AskForApproval::OnRequest,
@@ -5162,6 +5162,11 @@ fn thread_start_params_preserve_explicit_null_service_tier() {
#[test]
fn thread_lifecycle_responses_default_missing_optional_fields() {
let cwd = if cfg!(windows) {
"/home/alice/repo"
} else {
r"D:\repo"
};
let response = json!({
"thread": {
"id": "thread-id",
@@ -5174,7 +5179,7 @@ fn thread_lifecycle_responses_default_missing_optional_fields() {
"updatedAt": 1,
"status": { "type": "idle" },
"path": null,
"cwd": absolute_path_string("tmp"),
"cwd": cwd,
"cliVersion": "0.0.0",
"source": "exec",
"agentNickname": null,
@@ -5186,7 +5191,7 @@ fn thread_lifecycle_responses_default_missing_optional_fields() {
"model": "gpt-5",
"modelProvider": "openai",
"serviceTier": null,
"cwd": absolute_path_string("tmp"),
"cwd": cwd,
"approvalPolicy": "on-request",
"approvalsReviewer": "user",
"sandbox": { "type": "dangerFullAccess" },
@@ -5200,6 +5205,10 @@ fn thread_lifecycle_responses_default_missing_optional_fields() {
let fork: ThreadForkResponse =
serde_json::from_value(response.clone()).expect("thread/fork response");
for encoded in [json!(start), json!(resume), json!(fork)] {
assert_eq!(encoded["thread"]["cwd"], cwd);
assert_eq!(encoded["cwd"], cwd);
}
assert_eq!(start.instruction_sources, Vec::<LegacyAppPathString>::new());
assert_eq!(start.thread.parent_thread_id, None);
assert_eq!(start.thread.recency_at, None);
@@ -196,7 +196,9 @@ pub struct ThreadStartResponse {
/// Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.
#[serde(default)]
pub disabled_plugin_ids: Vec<String>,
pub cwd: AbsolutePathBuf,
#[schemars(with = "AbsolutePathBuf")]
#[ts(as = "AbsolutePathBuf")]
pub cwd: LegacyAppPathString,
/// Thread-scoped runtime workspace roots used to materialize
/// `:workspace_roots`.
#[experimental("thread/start.runtimeWorkspaceRoots")]
@@ -314,7 +316,9 @@ pub struct ThreadSettings {
/// Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.
#[serde(default)]
pub disabled_plugin_ids: Vec<String>,
pub cwd: AbsolutePathBuf,
#[schemars(with = "AbsolutePathBuf")]
#[ts(as = "AbsolutePathBuf")]
pub cwd: LegacyAppPathString,
/// Environments configured for future turns, in priority order, primary first.
/// `null` means the server does not expose the selection; [] means none are selected.
#[experimental("thread/settings.environments")]
@@ -455,7 +459,9 @@ pub struct ThreadResumeResponse {
/// Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.
#[serde(default)]
pub disabled_plugin_ids: Vec<String>,
pub cwd: AbsolutePathBuf,
#[schemars(with = "AbsolutePathBuf")]
#[ts(as = "AbsolutePathBuf")]
pub cwd: LegacyAppPathString,
/// Thread-scoped runtime workspace roots used to materialize
/// `:workspace_roots`.
#[experimental("thread/resume.runtimeWorkspaceRoots")]
@@ -672,7 +678,9 @@ pub struct ThreadForkResponse {
/// Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.
#[serde(default)]
pub disabled_plugin_ids: Vec<String>,
pub cwd: AbsolutePathBuf,
#[schemars(with = "AbsolutePathBuf")]
#[ts(as = "AbsolutePathBuf")]
pub cwd: LegacyAppPathString,
/// Thread-scoped runtime workspace roots used to materialize
/// `:workspace_roots`.
#[experimental("thread/fork.runtimeWorkspaceRoots")]
@@ -14,7 +14,7 @@ use codex_protocol::protocol::SessionSource as CoreSessionSource;
use codex_protocol::protocol::SubAgentSource as CoreSubAgentSource;
use codex_protocol::protocol::ThreadHistoryMode as CoreThreadHistoryMode;
use codex_protocol::protocol::ThreadSource as CoreThreadSource;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::LegacyAppPathString;
#[cfg(test)]
use schemars::r#gen::SchemaGenerator;
#[cfg(test)]
@@ -265,7 +265,10 @@ pub struct Thread {
/// [UNSTABLE] Path to the thread on disk.
pub path: Option<PathBuf>,
/// Working directory captured for the thread.
pub cwd: AbsolutePathBuf,
// Preserve the published SDK type for this server-native absolute path.
#[schemars(with = "codex_utils_absolute_path::AbsolutePathBuf")]
#[ts(as = "codex_utils_absolute_path::AbsolutePathBuf")]
pub cwd: LegacyAppPathString,
/// Version of the CLI that created the thread.
pub cli_version: String,
/// Originator recorded when the thread was created, independent of its current client or executor.
@@ -328,7 +331,7 @@ struct ThreadCompatibility {
recency_at: Option<i64>,
status: ThreadStatus,
path: Option<PathBuf>,
cwd: AbsolutePathBuf,
cwd: LegacyAppPathString,
cli_version: String,
originator: Option<String>,
source: SessionSource,
@@ -1320,7 +1320,13 @@ pub(crate) async fn apply_bespoke_event_handling(
let (mut config_snapshot, selected_service_tier) =
conversation.resume_config_snapshot().await;
config_snapshot.service_tier = selected_service_tier;
let thread_settings = thread_settings_from_config_snapshot(&config_snapshot);
let thread_settings = match thread_settings_from_config_snapshot(&config_snapshot) {
Ok(settings) => settings,
Err(error) => {
tracing::warn!(%conversation_id, message = %error.message, "cannot publish thread settings");
return;
}
};
let changed = {
let mut state = thread_state.lock().await;
state.note_thread_settings(thread_settings.clone())
@@ -351,7 +351,7 @@ async fn start_listener(
.await;
let is_v2_child = conversation.multi_agent_version() == Some(MultiAgentVersion::V2)
&& matches!(config_snapshot.session_source, SessionSource::SubAgent(_));
let thread_settings_baseline = thread_settings_from_config_snapshot(&config_snapshot);
let thread_settings_baseline = thread_settings_from_config_snapshot(&config_snapshot).ok();
let thread_state = Arc::clone(listener_state.state());
let (mut listener_command_rx, listener_generation, mut unloading_state, attached) = {
let (created, connection_ids, raw_events_enabled) = match &startup {
@@ -1258,7 +1258,13 @@ pub(super) async fn handle_pending_thread_resume_request(
let config_snapshot = pending.config_snapshot;
let sandbox = config_snapshot.sandbox_policy().into();
let cwd = config_snapshot.cwd().clone();
let cwd = match thread_cwd_for_api(config_snapshot.cwd()) {
Ok(cwd) => cwd,
Err(error) => {
outgoing.send_error(request_id, error).await;
return;
}
};
let ThreadConfigSnapshot {
model,
disabled_plugin_ids,
@@ -1733,7 +1733,7 @@ impl ThreadRequestProcessor {
thread.multi_agent_version(),
&config_snapshot,
session_configured.rollout_path.clone(),
);
)?;
thread.project_id = project_id.clone();
thread.daybreak_enabled = daybreak_enabled;
@@ -1778,7 +1778,7 @@ impl ThreadRequestProcessor {
);
let sandbox = config_snapshot.sandbox_policy().into();
let cwd = config_snapshot.cwd().clone();
let cwd = thread.cwd.clone();
let active_permission_profile =
thread_response_active_permission_profile(config_snapshot.active_permission_profile);
let thread_originator = config_snapshot.originator.clone();
@@ -2214,7 +2214,7 @@ impl ThreadRequestProcessor {
updated_thread,
self.config.model_provider_id.as_str(),
&self.config.cwd,
);
)?;
if let Ok(loaded_thread) = self.thread_manager.get_thread(thread_uuid).await {
thread.session_id = loaded_thread.startup_metadata().session_id.to_string();
let config_snapshot = loaded_thread.config_snapshot().await;
@@ -2272,7 +2272,7 @@ impl ThreadRequestProcessor {
.await
.map_err(|err| thread_store_mutation_error("unarchive", err))?;
let (mut thread, _) =
thread_from_stored_thread(stored_thread, fallback_provider.as_str(), &self.config.cwd);
thread_from_stored_thread(stored_thread, fallback_provider.as_str(), &self.config.cwd)?;
if let Ok(loaded_thread) = self.thread_manager.get_thread(thread_id).await {
let config_snapshot = loaded_thread.config_snapshot().await;
@@ -2932,7 +2932,7 @@ impl ThreadRequestProcessor {
stored_thread,
fallback_provider.as_str(),
&self.config.cwd,
);
)?;
data.push(thread);
}
@@ -3073,7 +3073,7 @@ impl ThreadRequestProcessor {
let data = tokio::select! {
biased;
page = &mut search => break page,
data = self.thread_search_provisional_rows(batch) => data,
data = self.thread_search_provisional_rows(batch) => data?,
};
if self.outgoing.try_send_server_notification(
crate::outgoing_message::NotificationTarget::Connection(request_id.connection_id),
@@ -3114,7 +3114,7 @@ impl ThreadRequestProcessor {
let data = tokio::select! {
biased;
() = cancellation.cancelled() => return Err(invalid_request("thread search cancelled")),
data = self.thread_search_rows(search_results) => data,
data = self.thread_search_rows(search_results) => data?,
};
Ok(ThreadSearchResponse {
data,
@@ -3126,28 +3126,28 @@ impl ThreadRequestProcessor {
fn thread_search_stored_rows(
&self,
search_results: Vec<StoredThreadSearchResult>,
) -> Vec<ThreadSearchResult> {
) -> Result<Vec<ThreadSearchResult>, JSONRPCErrorError> {
let mut data = Vec::with_capacity(search_results.len());
for result in search_results {
let (thread, _) = thread_from_stored_thread(
result.thread,
&self.config.model_provider_id,
&self.config.cwd,
);
)?;
data.push(ThreadSearchResult {
thread,
snippet: result.snippet,
});
}
data
Ok(data)
}
async fn thread_search_provisional_rows(
&self,
search_results: Vec<StoredThreadSearchResult>,
) -> Vec<ThreadSearchResult> {
let mut data = self.thread_search_stored_rows(search_results);
) -> Result<Vec<ThreadSearchResult>, JSONRPCErrorError> {
let mut data = self.thread_search_stored_rows(search_results)?;
let statuses = self
.thread_watch_manager
.loaded_statuses_for_threads(data.iter().map(|result| result.thread.id.clone()))
@@ -3157,14 +3157,14 @@ impl ThreadRequestProcessor {
result.thread.status = status.clone();
}
}
data
Ok(data)
}
async fn thread_search_rows(
&self,
search_results: Vec<StoredThreadSearchResult>,
) -> Vec<ThreadSearchResult> {
let mut data = self.thread_search_stored_rows(search_results);
) -> Result<Vec<ThreadSearchResult>, JSONRPCErrorError> {
let mut data = self.thread_search_stored_rows(search_results)?;
enrich_loaded_threads(
&self.thread_manager,
&self.thread_watch_manager,
@@ -3173,7 +3173,7 @@ impl ThreadRequestProcessor {
)
.await;
data
Ok(data)
}
async fn thread_loaded_list_response_inner(
@@ -3314,7 +3314,8 @@ impl ThreadRequestProcessor {
};
if matches!(stored_thread.history_mode, ThreadHistoryMode::Paginated) {
let (mut thread, _) =
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd);
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd)
.map_err(ThreadReadViewError::JsonRpc)?;
thread.turns = self
.paginated_thread_full_turns(thread_id)
.await
@@ -3329,7 +3330,8 @@ impl ThreadRequestProcessor {
return Ok(None);
};
let (mut thread, history) =
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd);
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd)
.map_err(ThreadReadViewError::JsonRpc)?;
if include_turns && let Some(history) = history {
thread.turns = build_legacy_api_turns_from_rollout_items(&history.items);
}
@@ -3405,6 +3407,7 @@ impl ThreadRequestProcessor {
thread
} else {
build_thread_from_loaded_snapshot(thread_id, &config_snapshot, loaded_thread)
.map_err(ThreadReadViewError::JsonRpc)?
};
self.attach_thread_name(thread_id, &mut thread).await;
if include_turns {
@@ -4690,7 +4693,7 @@ impl ThreadRequestProcessor {
model: session_configured.model,
model_provider: session_configured.model_provider_id,
service_tier: session_configured.service_tier,
cwd: session_configured.cwd,
cwd: thread_cwd_for_api(&session_configured.cwd)?,
runtime_workspace_roots: config_snapshot.workspace_roots,
instruction_sources,
approval_policy: session_configured.approval_policy.into(),
@@ -5002,7 +5005,7 @@ impl ThreadRequestProcessor {
source_thread,
config_snapshot.model_provider_id.as_str(),
/*include_turns*/ false,
);
)?;
thread_summary.session_id = existing_thread.startup_metadata().session_id.to_string();
thread_summary.thread_source = config_snapshot.thread_source.clone().map(Into::into);
apply_live_thread_settings(&mut thread_summary, &config_snapshot);
@@ -5270,9 +5273,9 @@ impl ThreadRequestProcessor {
stored_thread: StoredThread,
fallback_provider: &str,
include_turns: bool,
) -> Thread {
) -> Result<Thread, JSONRPCErrorError> {
let (mut thread, history) =
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd);
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd)?;
if include_turns && let Some(history) = history {
populate_thread_turns_from_history(
&mut thread,
@@ -5280,7 +5283,7 @@ impl ThreadRequestProcessor {
/*active_turn*/ None,
);
}
thread
Ok(thread)
}
async fn read_stored_thread_for_new_fork(
@@ -5343,12 +5346,9 @@ impl ThreadRequestProcessor {
..stored_thread
})
};
Ok(thread_from_stored_thread(
stored_thread,
fallback_provider,
&self.config.cwd,
)
.0)
thread_from_stored_thread(stored_thread, fallback_provider, &self.config.cwd)
.map(|(thread, _)| thread)
.map_err(|error| error.message)
} else {
match self
.thread_store
@@ -5359,12 +5359,13 @@ impl ThreadRequestProcessor {
})
.await
{
Ok(stored_thread) => Ok(thread_from_stored_thread(
Ok(stored_thread) => thread_from_stored_thread(
stored_thread,
fallback_provider,
&self.config.cwd,
)
.0),
.map(|(thread, _)| thread)
.map_err(|error| error.message),
Err(read_err) => {
Err(format!("failed to read thread from store: {read_err}"))
}
@@ -5378,7 +5379,8 @@ impl ThreadRequestProcessor {
thread.multi_agent_version(),
&config_snapshot,
Some(rollout_path.into()),
);
)
.map_err(|error| error.message)?;
thread.preview = preview_from_rollout_items(items);
Ok(thread)
}
@@ -6001,7 +6003,7 @@ impl ThreadRequestProcessor {
stored_thread,
fallback_model_provider.as_str(),
&self.config.cwd,
);
)?;
if include_turns && let Some(history) = history.as_ref() {
populate_thread_turns_from_history(
&mut thread,
@@ -6027,7 +6029,7 @@ impl ThreadRequestProcessor {
forked_thread.multi_agent_version(),
&config_snapshot,
/*path*/ None,
);
)?;
thread.preview = inherited_preview;
thread.forked_from_id = Some(source_thread_id.to_string());
thread.turns = ephemeral_turns;
@@ -6078,7 +6080,7 @@ impl ThreadRequestProcessor {
model: config_snapshot.model.clone(),
model_provider: session_configured.model_provider_id,
service_tier: config_snapshot.service_tier.clone(),
cwd: session_configured.cwd,
cwd: thread_cwd_for_api(&session_configured.cwd)?,
runtime_workspace_roots: config_snapshot.workspace_roots,
instruction_sources,
approval_policy: session_configured.approval_policy.into(),
@@ -6883,7 +6885,7 @@ fn thread_from_stored_thread(
thread: StoredThread,
fallback_provider: &str,
fallback_cwd: &AbsolutePathBuf,
) -> (Thread, Option<codex_thread_store::StoredThreadHistory>) {
) -> Result<(Thread, Option<codex_thread_store::StoredThreadHistory>), JSONRPCErrorError> {
let path = thread.rollout_path;
let git_info = thread.git_info.map(|info| ApiGitInfo {
sha: info.commit_hash.map(|sha| sha.0),
@@ -6941,7 +6943,7 @@ fn thread_from_stored_thread(
recency_at: Some(thread.recency_at.timestamp()),
status: ThreadStatus::NotLoaded,
path,
cwd,
cwd: thread_cwd_for_api(&cwd)?,
cli_version: thread.cli_version,
originator: thread.originator,
agent_nickname: source.get_nickname(),
@@ -6954,7 +6956,7 @@ fn thread_from_stored_thread(
daybreak_enabled: thread.daybreak_enabled,
turns: Vec::new(),
};
(thread, history)
Ok((thread, history))
}
fn summary_from_stored_thread(
@@ -7097,9 +7099,9 @@ fn build_thread_from_snapshot(
multi_agent_version: Option<codex_protocol::protocol::MultiAgentVersion>,
config_snapshot: &ThreadConfigSnapshot,
path: Option<PathBuf>,
) -> Thread {
) -> Result<Thread, JSONRPCErrorError> {
let now = time::OffsetDateTime::now_utc().unix_timestamp();
Thread {
Ok(Thread {
id: thread_id.to_string(),
environments: Some(
config_snapshot
@@ -7127,7 +7129,7 @@ fn build_thread_from_snapshot(
recency_at: Some(now),
status: ThreadStatus::NotLoaded,
path,
cwd: config_snapshot.cwd().clone(),
cwd: thread_cwd_for_api(config_snapshot.cwd())?,
cli_version: env!("CARGO_PKG_VERSION").to_string(),
originator: (!config_snapshot.originator.is_empty())
.then(|| config_snapshot.originator.clone()),
@@ -7143,7 +7145,7 @@ fn build_thread_from_snapshot(
name: None,
daybreak_enabled: None,
turns: Vec::new(),
}
})
}
fn paginate_background_terminals(
@@ -7178,7 +7180,7 @@ fn build_thread_from_loaded_snapshot(
thread_id: ThreadId,
config_snapshot: &ThreadConfigSnapshot,
loaded_thread: &CodexThread,
) -> Thread {
) -> Result<Thread, JSONRPCErrorError> {
build_thread_from_snapshot(
thread_id,
loaded_thread.startup_metadata().session_id.to_string(),
@@ -2,6 +2,26 @@ use codex_app_server_protocol::JSONRPCErrorError;
use codex_thread_store::ThreadStoreError;
use pretty_assertions::assert_eq;
#[cfg(unix)]
#[test]
fn thread_cwd_rejects_invalid_utf8() {
use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
let cwd = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(OsStr::from_bytes(
b"/workspace-\xFF",
))
.expect("absolute native path");
assert_eq!(
super::thread_cwd_for_api(&cwd).expect_err("cwd cannot be represented as a wire string"),
JSONRPCErrorError {
code: crate::error_code::INTERNAL_ERROR_CODE,
message: "cannot encode thread cwd: path contains invalid UTF-8".into(),
data: None,
}
);
}
#[test]
fn storage_failure_classification_does_not_change_mutation_error_policy() {
for error in [
@@ -241,7 +241,7 @@ mod tests {
recency_at: Some(0),
status: ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
cli_version: "0.0.0".to_string(),
source: SessionSource::Cli,
can_accept_direct_input: None,
@@ -4,6 +4,7 @@ use chrono::DateTime;
#[cfg(test)]
use chrono::Utc;
use codex_protocol::config_types::MultiAgentMode;
use codex_utils_path_uri::LegacyAppPathString;
#[cfg(test)]
pub(crate) async fn read_summary_from_rollout(
@@ -172,12 +173,20 @@ pub(crate) fn thread_response_active_permission_profile(
active_permission_profile.map(Into::into)
}
pub(super) fn thread_cwd_for_api(
cwd: &AbsolutePathBuf,
) -> Result<LegacyAppPathString, JSONRPCErrorError> {
cwd.to_str()
.map(LegacyAppPathString::from_string)
.ok_or_else(|| internal_error("cannot encode thread cwd: path contains invalid UTF-8"))
}
pub(crate) fn thread_settings_from_config_snapshot(
config_snapshot: &ThreadConfigSnapshot,
) -> ThreadSettings {
ThreadSettings {
) -> Result<ThreadSettings, JSONRPCErrorError> {
Ok(ThreadSettings {
disabled_plugin_ids: config_snapshot.disabled_plugin_ids.clone(),
cwd: config_snapshot.cwd().clone(),
cwd: thread_cwd_for_api(config_snapshot.cwd())?,
environments: Some(
config_snapshot
.environment_selections()
@@ -199,7 +208,7 @@ pub(crate) fn thread_settings_from_config_snapshot(
collaboration_mode: config_snapshot.collaboration_mode.clone(),
multi_agent_mode: MultiAgentMode::ExplicitRequestOnly,
personality: config_snapshot.personality,
}
})
}
#[cfg(test)]
@@ -289,7 +298,7 @@ pub(crate) fn summary_to_thread(
recency_at: updated_at.map(|dt| dt.timestamp()),
status: ThreadStatus::NotLoaded,
path: (!path.as_os_str().is_empty()).then_some(path),
cwd,
cwd: cwd.into(),
cli_version,
agent_nickname: source.get_nickname(),
agent_role: source.get_agent_role(),
+5 -3
View File
@@ -173,7 +173,7 @@ impl ThreadState {
shutdown_drain: watch::Receiver<bool>,
conversation: &Arc<CodexThread>,
watch_registration: WatchRegistration,
thread_settings_baseline: ThreadSettings,
thread_settings_baseline: Option<ThreadSettings>,
history_mode: ThreadHistoryMode,
) -> (mpsc::UnboundedReceiver<ThreadListenerCommand>, u64) {
if let Some(previous) = self.cancel_tx.replace(cancel_tx) {
@@ -185,7 +185,7 @@ impl ThreadState {
self.shutdown_drain = Some(shutdown_drain);
self.listener_generation = self.listener_generation.wrapping_add(1);
self.listener_shutdown = false;
self.last_thread_settings = Some(thread_settings_baseline);
self.last_thread_settings = thread_settings_baseline;
self.history_mode = history_mode;
self.evict_superseded_agent_text =
history_mode == ThreadHistoryMode::Paginated && conversation.rollout_path().is_some();
@@ -393,7 +393,9 @@ mod tests {
ThreadSettings {
disabled_plugin_ids: Vec::new(),
environments: Some(Vec::new()),
cwd: AbsolutePathBuf::from_absolute_path("/tmp").expect("absolute path"),
cwd: AbsolutePathBuf::from_absolute_path("/tmp")
.expect("absolute path")
.into(),
approval_policy: AskForApproval::OnRequest,
approvals_reviewer: ApprovalsReviewer::User,
sandbox_policy: SandboxPolicy::ReadOnly {
+1 -1
View File
@@ -110,7 +110,7 @@ async fn prompt_prefix_matches_release() -> Result<()> {
let environment = app.auto_env_params()?;
for (value, replacement) in [
(environment.cwd.as_str(), "<ENVIRONMENT_CWD>"),
(thread.cwd.to_string_lossy().as_ref(), "<CWD>"),
(thread.cwd.as_str(), "<CWD>"),
(home.path().to_string_lossy().as_ref(), "<CODEX_HOME>"),
(thread.id.as_str(), "<THREAD_ID>"),
(thread.session_id.as_str(), "<SESSION_ID>"),
@@ -4,7 +4,6 @@ use std::time::Duration;
use anyhow::Context;
use anyhow::Result;
use app_test_support::MockResponsesConfig;
use app_test_support::PathBufExt;
use app_test_support::TestAppServer;
use app_test_support::create_final_assistant_message_sse_response;
use app_test_support::create_mock_responses_server_sequence;
@@ -67,8 +66,8 @@ async fn thread_start_reports_selected_environment_metadata() -> Result<()> {
} = app_server
.start_thread(ThreadStartParams::default())
.await?;
let host_cwd = codex_home.path().to_path_buf().abs().canonicalize()?;
let cwd = cwd.canonicalize()?;
let host_cwd = codex_home.path().canonicalize()?;
let cwd = cwd.as_path().canonicalize()?;
assert_eq!(
(cwd, runtime_workspace_roots, active_permission_profile),
(
@@ -110,7 +110,7 @@ async fn thread_environments_follow_the_loaded_thread_selection() -> Result<()>
timeout(DEFAULT_READ_TIMEOUT, second.read_response(request)).await??;
let expected = Some(vec![ThreadEnvironment {
environment_id: second.auto_env_params()?.environment_id,
cwd: resumed.cwd.clone().into(),
cwd: resumed.cwd.clone(),
runtime_workspace_roots: resumed
.runtime_workspace_roots
.iter()
@@ -757,7 +757,7 @@ async fn thread_list_pagination_next_cursor_none_on_last_page() -> Result<()> {
assert_eq!(thread.model_provider, "mock_provider");
assert!(thread.created_at > 0);
assert_eq!(thread.updated_at, thread.created_at);
assert_eq!(thread.cwd, test_absolute_path("/"));
assert_eq!(thread.cwd, test_absolute_path("/").into());
assert_eq!(thread.cli_version, "0.0.0");
assert_eq!(thread.source, SessionSource::Cli);
assert_eq!(thread.git_info, None);
@@ -785,7 +785,7 @@ async fn thread_list_pagination_next_cursor_none_on_last_page() -> Result<()> {
assert_eq!(thread.model_provider, "mock_provider");
assert!(thread.created_at > 0);
assert_eq!(thread.updated_at, thread.created_at);
assert_eq!(thread.cwd, test_absolute_path("/"));
assert_eq!(thread.cwd, test_absolute_path("/").into());
assert_eq!(thread.cli_version, "0.0.0");
assert_eq!(thread.source, SessionSource::Cli);
assert_eq!(thread.git_info, None);
@@ -841,7 +841,7 @@ async fn thread_list_respects_provider_filter() -> Result<()> {
let expected_ts = chrono::DateTime::parse_from_rfc3339("2025-01-02T11:00:00Z")?.timestamp();
assert_eq!(thread.created_at, expected_ts);
assert_eq!(thread.updated_at, expected_ts);
assert_eq!(thread.cwd, test_absolute_path("/"));
assert_eq!(thread.cwd, test_absolute_path("/").into());
assert_eq!(thread.cli_version, "0.0.0");
assert_eq!(thread.source, SessionSource::Cli);
assert_eq!(thread.git_info, None);
@@ -2536,7 +2536,7 @@ async fn thread_list_includes_git_info() -> Result<()> {
};
assert_eq!(thread.git_info, Some(expected_git));
assert_eq!(thread.source, SessionSource::Cli);
assert_eq!(thread.cwd, test_absolute_path("/"));
assert_eq!(thread.cwd, test_absolute_path("/").into());
assert_eq!(thread.cli_version, "0.0.0");
Ok(())
@@ -161,7 +161,7 @@ async fn thread_read_returns_summary_without_turns() -> Result<()> {
assert_eq!(thread.model_provider, "mock_provider");
assert!(!thread.ephemeral, "stored rollouts should not be ephemeral");
assert!(thread.path.as_ref().expect("thread path").is_absolute());
assert_eq!(thread.cwd, test_absolute_path("/"));
assert_eq!(thread.cwd, test_absolute_path("/").into());
assert_eq!(thread.cli_version, "0.0.0");
assert_eq!(thread.source, SessionSource::Cli);
assert_eq!(thread.git_info, None);
@@ -901,7 +901,7 @@ async fn thread_resume_restores_startup_and_updated_runtime_workspace_roots() ->
} = timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(resume_id)).await??;
assert_eq!(
(cwd, runtime_workspace_roots),
(initial_cwd.clone(), expected_roots)
(initial_cwd.clone().into(), expected_roots)
);
Ok(())
@@ -1019,7 +1019,7 @@ sandbox = "unelevated"
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(resume_id)).await??;
assert_eq!(
(resumed.cwd, resumed.runtime_workspace_roots),
(expected_cwd.clone(), expected_roots.clone())
(expected_cwd.clone().into(), expected_roots.clone())
);
if index < 3 {
mcp.start_turn_and_wait_for_completion(TurnStartParams {
@@ -1236,7 +1236,7 @@ async fn cold_resume_workspace_roots_validate_foreign_startup_paths() -> Result<
} = timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(resume_id)).await??;
assert_eq!(
(thread.id, cwd, runtime_workspace_roots),
(thread_id, local_cwd.clone(), expected_roots)
(thread_id, local_cwd.clone().into(), expected_roots)
);
} else {
let error = timeout(
@@ -2930,7 +2930,7 @@ async fn thread_resume_returns_rollout_history() -> Result<()> {
assert_eq!(thread.model_provider, "mock_provider");
assert!(thread.path.as_ref().expect("thread path").is_absolute());
assert_eq!(thread.cwd.as_path(), cwd.as_path());
assert_eq!(cwd, test_absolute_path("/"));
assert_eq!(cwd, test_absolute_path("/").into());
assert_eq!(thread.cli_version, "0.0.0");
assert_eq!(thread.source, SessionSource::Cli);
assert_eq!(thread.git_info, None);
@@ -5211,7 +5211,10 @@ async fn thread_resume_checkpoints_settings_without_advancing_recency() -> Resul
.await?;
let ThreadResumeResponse { cwd, .. } =
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(resume_id)).await??;
assert_eq!(cwd, AbsolutePathBuf::from_absolute_path(codex_home.path())?);
assert_eq!(
cwd,
AbsolutePathBuf::from_absolute_path(codex_home.path())?.into()
);
let turn_id = mcp
.send_turn_start_request(TurnStartParams {
@@ -87,8 +87,8 @@ url = "ws://127.0.0.1:2"
let started: ThreadStartResponse = mcp.read_response(request_id).await?;
let environment_a = ThreadEnvironment {
environment_id: "remote-a".to_string(),
cwd: started.cwd.clone().into(),
runtime_workspace_roots: vec![started.cwd.clone().into()],
cwd: started.cwd.clone(),
runtime_workspace_roots: vec![started.cwd.clone()],
};
let environment_b = ThreadEnvironment {
environment_id: "remote-b".to_string(),
@@ -575,7 +575,7 @@ async fn thread_start_accepts_absolute_runtime_workspace_roots() -> Result<()> {
..
} = timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(req_id)).await??;
assert_eq!(response_cwd, cwd.abs());
assert_eq!(response_cwd, cwd.abs().into());
assert_eq!(runtime_workspace_roots, vec![extra_root.abs()]);
#[cfg(windows)]
let _ = sandbox;
@@ -3609,7 +3609,10 @@ async fn turn_start_explicit_local_environment_updates_legacy_cwd_between_turns(
mcp.read_notification("thread/settings/updated"),
)
.await??;
assert_eq!(settings_updated.thread_settings.cwd, second_cwd.abs());
assert_eq!(
settings_updated.thread_settings.cwd,
second_cwd.abs().into()
);
let command_exec_item = timeout(DEFAULT_READ_TIMEOUT, async {
loop {
+3 -2
View File
@@ -122,6 +122,7 @@ use codex_utils_absolute_path::canonicalize_existing_preserving_symlinks;
use codex_utils_cli::SharedCliOptions;
use codex_utils_oss::ensure_oss_provider_ready;
use codex_utils_oss::get_default_model_for_oss_provider;
use codex_utils_path_uri::LegacyAppPathString;
use codex_worktree::CreateWorktree;
use codex_worktree::WorktreeManager;
use codex_worktree::WorktreeSettings;
@@ -1852,7 +1853,7 @@ fn session_configured_from_thread_response(
approvals_reviewer: codex_protocol::config_types::ApprovalsReviewer,
permission_profile: PermissionProfile,
active_permission_profile: Option<codex_protocol::models::ActivePermissionProfile>,
cwd: AbsolutePathBuf,
cwd: LegacyAppPathString,
reasoning_effort: Option<codex_protocol::openai_models::ReasoningEffort>,
) -> Result<SessionConfiguredEvent, String> {
let session_id = SessionId::from_string(session_id)
@@ -1882,7 +1883,7 @@ fn session_configured_from_thread_response(
approvals_reviewer,
permission_profile,
active_permission_profile,
cwd,
cwd: AbsolutePathBuf::try_from(cwd).map_err(|err| err.to_string())?,
reasoning_effort,
network_proxy: None,
rollout_path,
+3 -3
View File
@@ -375,7 +375,7 @@ fn turn_items_for_thread_returns_matching_turn_items() {
recency_at: Some(0),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
cli_version: "0.0.0-test".to_string(),
originator: None,
source: codex_app_server_protocol::SessionSource::Exec,
@@ -896,7 +896,7 @@ fn sample_thread_start_response() -> ThreadStartResponse {
recency_at: Some(0),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: Some(PathBuf::from("/tmp/rollout.jsonl")),
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Cli,
can_accept_direct_input: None,
@@ -910,7 +910,7 @@ fn sample_thread_start_response() -> ThreadStartResponse {
model: "gpt-5.4".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: codex_app_server_protocol::AskForApproval::OnRequest,
-9
View File
@@ -546,15 +546,6 @@ fn rollout_path_is_resumable(rollout_path: &Path) -> bool {
std::fs::metadata(rollout_path).is_ok_and(|metadata| metadata.is_file() && metadata.len() > 0)
}
fn errors_for_cwd(cwd: &Path, response: &SkillsListResponse) -> Vec<SkillErrorInfo> {
response
.data
.iter()
.find(|entry| entry.cwd.as_path() == cwd)
.map(|entry| entry.errors.clone())
.unwrap_or_default()
}
#[derive(Debug, Default)]
struct InitialHistoryReplayBuffer {
retained_lines: VecDeque<crate::terminal_hyperlinks::HyperlinkLine>,
+4 -2
View File
@@ -415,7 +415,7 @@ async fn live_center_pages_visible_rows_without_wrapping() {
);
thread.updated_at -= index as i64;
if index >= 10 {
thread.cwd = test_path_buf("/tmp/second-project").abs();
thread.cwd = test_path_buf("/tmp/second-project").abs().into();
}
thread
})
@@ -477,7 +477,9 @@ async fn live_center_navigates_sections() {
ThreadStatus::Idle,
);
thread.updated_at -= index as i64;
thread.cwd = test_path_buf(&format!("/tmp/project-{}", index / 2)).abs();
thread.cwd = test_path_buf(&format!("/tmp/project-{}", index / 2))
.abs()
.into();
thread
})
.collect();
+6 -11
View File
@@ -1256,7 +1256,7 @@ impl App {
&mut self,
tui: &mut tui::Tui,
app_server: &mut AppServerSession,
cwd: Option<AbsolutePathBuf>,
cwd: Option<PathBuf>,
mut startup_draft: Option<&mut StartupDraftPump>,
) -> Option<(Config, Option<PathBuf>)> {
if self
@@ -1269,17 +1269,12 @@ impl App {
);
return None;
}
let remote = app_server.uses_remote_workspace();
let remote_cwd = cwd
.as_ref()
.filter(|_| remote)
.map(AbsolutePathBuf::to_path_buf);
let local_cwd = if remote {
self.config.cwd.to_path_buf()
let (local_cwd, remote_cwd) = if app_server.uses_remote_workspace() {
(self.config.cwd.to_path_buf(), cwd)
} else {
cwd.map_or_else(
|| self.chat_widget.config_ref().cwd.to_path_buf(),
|cwd| cwd.to_path_buf(),
(
cwd.unwrap_or_else(|| self.chat_widget.session_cwd().to_path_buf()),
None,
)
};
let mut config = match StartupDraftPump::run_with_optional_draft(
@@ -34,7 +34,7 @@ async fn modal_consumes_input_and_finishes_after_input_closes() -> color_eyre::R
.expect("materialize task"),
)?;
let mut thread = server.thread_read(id, /*include_turns*/ false).await?;
thread.cwd = test_path_buf("/tmp/project").abs();
thread.cwd = test_path_buf("/tmp/project").abs().into();
app.agents_overview.threads.insert(id, Some(thread));
}
let threads = app
@@ -407,7 +407,7 @@ async fn archiving_selects_the_next_displayed_task() -> Result<()> {
&title,
ThreadStatus::Idle,
);
thread.cwd = test_path_buf(&format!("/tmp/project-{index}")).abs();
thread.cwd = test_path_buf(&format!("/tmp/project-{index}")).abs().into();
thread.model = Some(format!("model-{index}"));
thread.updated_at = index as i64;
app.agents_overview.threads.insert(id, Some(thread.clone()));
@@ -611,7 +611,7 @@ async fn external_removals_preserve_adjacent_selection() {
if index == 1 { "Other" } else { "Task" },
ThreadStatus::Idle,
);
thread.cwd = test_path_buf(&format!("/tmp/project-{index}")).abs();
thread.cwd = test_path_buf(&format!("/tmp/project-{index}")).abs().into();
thread.model = Some(format!("model-{index}"));
thread.updated_at = index as i64;
thread
@@ -704,7 +704,7 @@ async fn hiding_tasks_keeps_selection_adjacent_in_display_order() -> Result<()>
ThreadStatus::Idle,
);
thread.name = Some(format!("{} {index}", thread.preview));
thread.cwd = test_path_buf(&format!("/tmp/project-{index}")).abs();
thread.cwd = test_path_buf(&format!("/tmp/project-{index}")).abs().into();
thread.model = Some(format!("model-{index}"));
thread.updated_at = index as i64;
thread
@@ -17,7 +17,7 @@ use codex_app_server_protocol::ThreadHistoryMode;
use codex_app_server_protocol::ThreadItemPayload;
use codex_app_server_protocol::ThreadStatus;
use codex_protocol::ThreadId;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::LegacyAppPathString;
use ratatui::style::Stylize;
use ratatui::text::Line;
use std::collections::HashMap;
@@ -40,7 +40,7 @@ pub(super) struct AgentsOverviewDetails {
pub(super) latest_prompt: Option<String>,
pub(super) lines: Vec<Line<'static>>,
pub(super) usage_lines: Vec<Line<'static>>,
pub(super) last_message: Option<(String, AbsolutePathBuf)>,
pub(super) last_message: Option<(String, LegacyAppPathString)>,
}
pub(super) fn preview_text(text: &str) -> String {
@@ -270,7 +270,7 @@ pub(super) struct HistorySearch {
pub(super) fn matches_query(thread: &Thread, query: &str) -> bool {
let name = thread.name.as_deref().unwrap_or_default();
let cwd = thread.cwd.display();
let cwd = &thread.cwd;
format!("{name} {} {cwd}", thread.preview)
.to_lowercase()
.contains(query)
@@ -342,7 +342,7 @@ async fn overview_local_enter_drops_the_displayed_cloud_list_before_detach() ->
"Local saved chat",
ThreadStatus::Idle,
);
local_row.cwd = local_session.cwd;
local_row.cwd = local_session.cwd.into();
let cloud_owner = BackendId::new();
let cloud_id = ThreadId::new();
+21 -18
View File
@@ -42,7 +42,7 @@ impl App {
&mut self,
tui: &mut tui::Tui,
app_server: &mut AppServerSession,
cwd: Option<AbsolutePathBuf>,
cwd: Option<PathBuf>,
) -> Result<AppRunControl> {
if self.reconnect.offline || self.windows_sandbox_blocks_thread_switch() {
return Ok(AppRunControl::Continue);
@@ -59,13 +59,10 @@ impl App {
StartupDraftSessionAction::NewWhileRunning,
))
});
let mut display_config = self.chat_widget.config_ref().clone();
if let Some(cwd) = cwd.as_ref() {
display_config.cwd = cwd.clone();
}
draft.apply_settings(
&crate::local_settings::LocalSettings::from(&display_config),
display_config.cwd.as_path(),
&crate::local_settings::LocalSettings::from(self.chat_widget.config_ref()),
cwd.as_deref()
.unwrap_or(&self.chat_widget.session_cwd().to_path_buf()),
);
draft.show(tui)?;
// Keep the large session-start future off the TUI's stack in dev builds.
@@ -97,7 +94,7 @@ impl App {
&mut self,
tui: &mut tui::Tui,
app_server: &mut AppServerSession,
cwd: Option<AbsolutePathBuf>,
cwd: Option<PathBuf>,
managed_worktree: Option<(
codex_worktree::WorktreeManager,
codex_worktree::ManagedWorktree,
@@ -207,15 +204,16 @@ impl App {
.insert(thread_id, selected.profile_id);
}
if let Some((manager, checkout)) = &managed_worktree {
let result =
if crate::session_resume::cwds_differ(started.session.cwd.as_path(), &checkout.cwd)
{
Err(anyhow::anyhow!(
"The server did not apply the worktree directory."
))
} else {
manager.bind_thread(&checkout.root, &thread_id.to_string())
};
let result = if crate::session_resume::cwds_differ(
&started.session.cwd.to_path_buf(),
&checkout.cwd,
) {
Err(anyhow::anyhow!(
"The server did not apply the worktree directory."
))
} else {
manager.bind_thread(&checkout.root, &thread_id.to_string())
};
if let Err(error) = result {
let _ = app_server.thread_unsubscribe(thread_id).await;
self.agents_overview_retained_worktree_error(checkout, /*title*/ None, error);
@@ -273,7 +271,12 @@ impl App {
return;
}
let Some((config, _)) = self
.agents_overview_session_config(tui, app_server, cwd, /*startup_draft*/ None)
.agents_overview_session_config(
tui,
app_server,
cwd.map(Into::into),
/*startup_draft*/ None,
)
.await
else {
return;
+10 -8
View File
@@ -721,7 +721,7 @@ pub(in crate::app) fn overview_thread(
recency_at: Some(*OVERVIEW_TIMESTAMP),
status,
path: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
cli_version: "0.0.0".to_string(),
source: parent_thread_id.map_or(SessionSource::Cli, |parent_thread_id| {
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
@@ -1740,7 +1740,7 @@ async fn worktrees_overview_groups_by_project_or_directory() {
title,
ThreadStatus::Idle,
);
thread.cwd = AbsolutePathBuf::from_absolute_path(cwd).unwrap();
thread.cwd = AbsolutePathBuf::from_absolute_path(cwd).unwrap().into();
thread
})
.collect::<Vec<_>>();
@@ -2036,9 +2036,11 @@ async fn shared_overview_shows_only_root_sessions() {
}
candidate.updated_at = index;
candidate.cwd = if index == 0 {
test_path_buf("/tmp/project-selected").abs()
test_path_buf("/tmp/project-selected").abs().into()
} else {
test_path_buf(&format!("/tmp/project-{}", index % 3)).abs()
test_path_buf(&format!("/tmp/project-{}", index % 3))
.abs()
.into()
};
candidate
})
@@ -2658,7 +2660,7 @@ async fn overview_cold_resume_honors_working_directory_selection() -> Result<()>
.session;
assert_eq!(
(app.config.cwd.clone(), observed.cwd),
(expected_cwd.clone(), expected_cwd),
(expected_cwd.clone(), expected_cwd.into()),
);
app_server.shutdown().await?;
}
@@ -3925,7 +3927,7 @@ async fn command_center_new_actions_use_selection_and_leave_metadata_text_alone(
);
let owner = BackendId::new();
app.backend_registry.observe(owner, id);
target.cwd = test_path_buf("/tmp/checkout/subdir").abs();
target.cwd = test_path_buf("/tmp/checkout/subdir").abs().into();
app.agents_overview.pins_by_backend =
[(crate::backend_id::BackendId::new(), Some(Vec::new()))].into();
let mut view = app.agents_overview_view(vec![target.clone()], Some(id));
@@ -3936,11 +3938,11 @@ async fn command_center_new_actions_use_selection_and_leave_metadata_text_alone(
for grouping_index in 0..3 {
view.handle_key_event(KeyCode::Char('n').into());
assert!(
matches!(rx.try_recv(), Ok(AppEvent::NewAgentsOverviewSession { backend_id: Some(id), cwd: Some(cwd) }) if id == owner && cwd == target.cwd)
matches!(rx.try_recv(), Ok(AppEvent::NewAgentsOverviewSession { backend_id: Some(id), cwd: Some(cwd) }) if id == owner && cwd.as_path() == target.cwd.as_path())
);
view.handle_key_event(KeyCode::Char('w').into());
assert!(
matches!(rx.try_recv(), Ok(AppEvent::NewAgentsOverviewWorktree { backend_id: Some(id), cwd: Some(cwd) }) if id == owner && cwd == target.cwd)
matches!(rx.try_recv(), Ok(AppEvent::NewAgentsOverviewWorktree { backend_id: Some(id), cwd: Some(cwd) }) if id == owner && cwd.as_path() == target.cwd.as_path())
);
view.handle_key_event(KeyCode::Char('g').into());
if grouping_index == 0 {
+5 -3
View File
@@ -533,7 +533,7 @@ impl AgentsOverviewView {
reasoning,
Line::default(),
Line::from("Project".dim()),
Line::from(row.thread.cwd.display().to_string()),
Line::from(row.thread.cwd.to_string()),
];
lines.extend(row.details.usage_lines.clone());
if let Some(branch) = row
@@ -801,7 +801,7 @@ impl BottomPaneView for AgentsOverviewView {
if self.agents_keymap.new_task.is_pressed(key) {
self.app_event_tx.send(AppEvent::NewAgentsOverviewSession {
backend_id: self.selected_row().and_then(|row| row.backend_id),
cwd: self.selected_row().map(|row| row.thread.cwd.clone()),
cwd: self.selected_row().map(|row| row.thread.cwd.to_path_buf()),
});
return;
}
@@ -809,7 +809,9 @@ impl BottomPaneView for AgentsOverviewView {
if self.worktrees_enabled {
self.app_event_tx.send(AppEvent::NewAgentsOverviewWorktree {
backend_id: self.selected_row().and_then(|row| row.backend_id),
cwd: self.selected_row().map(|row| row.thread.cwd.clone()),
cwd: self
.selected_row()
.and_then(|row| row.thread.cwd.to_inferred_abs_path()),
});
}
return;
@@ -261,7 +261,7 @@ mod tests {
ThreadSettings {
disabled_plugin_ids: Vec::new(),
environments: None,
cwd: test_path_buf("/tmp/thread-settings").abs(),
cwd: test_path_buf("/tmp/thread-settings").abs().into(),
approval_policy: codex_app_server_protocol::AskForApproval::Never,
approvals_reviewer: codex_app_server_protocol::ApprovalsReviewer::User,
sandbox_policy: codex_app_server_protocol::SandboxPolicy::ReadOnly {
+7
View File
@@ -6,6 +6,8 @@ use crate::app_server_session::AppServerStartedThread;
use crate::backend_id::BackendId;
use codex_app_server_client::AppServerRequestHandle;
use codex_protocol::ThreadId;
use codex_utils_path_uri::PathConvention;
use codex_utils_path_uri::Platform;
use std::collections::HashMap;
use std::collections::HashSet;
@@ -64,6 +66,11 @@ impl BackendRegistry {
self.connections.remove(&owner);
}
pub(super) fn thread_path_convention(&self, thread_id: ThreadId) -> Option<PathConvention> {
let handle = self.connections.get(&self.owner(thread_id)?)?;
Platform::from_platform_os(handle.platform_os()).path_convention()
}
pub(super) fn request_handle(&self, owner: BackendId) -> Option<AppServerRequestHandle> {
self.connections.get(&owner).cloned()
}
+7 -3
View File
@@ -267,20 +267,24 @@ impl App {
/// app-server RPC finishes. User-initiated skills refreshes still use the blocking app command path so
/// callers that explicitly asked for fresh skill state do not race ahead of their own refresh.
pub(super) fn refresh_startup_skills(&mut self, app_server: &AppServerSession) {
if app_server.thread_params_mode() == crate::ThreadParamsMode::Cloud {
// A remote session refreshes its skills when thread/start supplies its cwd.
if app_server.thread_params_mode() == crate::ThreadParamsMode::Cloud
|| (app_server.thread_params_mode() == crate::ThreadParamsMode::Remote
&& self.chat_widget.thread_id().is_none())
{
self.skill_load_warnings.startup_complete = true;
return;
}
let request_handle = app_server.request_handle();
let app_event_tx = self.app_event_tx.clone();
let cwd = self.config.cwd.to_path_buf();
let cwd = self.chat_widget.session_cwd().clone();
tokio::spawn(async move {
let request_id = RequestId::String(format!("startup-skills-list-{}", Uuid::new_v4()));
let result = fetch_skills_list(
request_handle,
request_id,
SkillsListParams {
cwds: vec![cwd.clone()],
cwds: vec![cwd.to_path_buf()],
force_reload: true,
},
)
+1 -1
View File
@@ -1960,7 +1960,7 @@ enabled = false
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: next_cwd.clone().abs(),
cwd: next_cwd.clone().abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
+7 -8
View File
@@ -265,7 +265,7 @@ impl App {
AppEvent::CloseMisalignmentReview => self.chat_widget.show_misalignment_policy_precaution(),
AppEvent::SkillsListLoaded { ref cwd, .. }
if app_server.thread_params_mode() == crate::ThreadParamsMode::Cloud
|| cwds_differ(cwd, self.config.cwd.as_path()) =>
|| self.chat_widget.session_cwd() != cwd =>
{
self.skill_load_warnings.startup_complete = true;
}
@@ -1411,15 +1411,14 @@ impl App {
// The Cloud preview does not have a skills catalog.
AppEvent::CodexOp(AppCommand::ListSkills { .. })
if app_server.thread_params_mode() == crate::ThreadParamsMode::Cloud => {}
AppEvent::CodexOp(AppCommand::ListSkills { cwds, force_reload: true })
AppEvent::CodexOp(AppCommand::ListSkills { cwd, force_reload: true })
if self.awaiting_side_replay(tui)
&& let Some(thread_id) = self.active_thread_id
&& self.side_pair_key(thread_id).is_some()
&& !self.thread_unavailable(thread_id) =>
{
// Session replay refreshes skill metadata. Let focus paint while that RPC is pending.
let cwd = self.chat_widget.config_ref().cwd.to_path_buf();
if cwds.contains(&cwd) {
if &cwd == self.chat_widget.session_cwd() {
let request_id = Uuid::new_v4();
app_server.pending_side_skills_refresh = Some(request_id);
let rpc_id = app_server.next_request_id();
@@ -1429,7 +1428,7 @@ impl App {
let result = background_requests::fetch_skills_list(
request_handle,
rpc_id,
SkillsListParams { cwds, force_reload: true },
SkillsListParams { cwds: vec![cwd.to_path_buf()], force_reload: true },
)
.await
.map_err(|err| format!("{err:#}"));
@@ -1661,7 +1660,7 @@ impl App {
.await?;
}
AppEvent::DiffResult(cwd, text) => {
if cwds_differ(&cwd, self.chat_widget.config_ref().cwd.as_path()) {
if &cwd != self.chat_widget.session_cwd() {
return Ok(AppRunControl::Continue);
}
// Clear the in-progress state in the bottom pane
@@ -2103,7 +2102,7 @@ impl App {
app_server.pending_side_skills_refresh = None;
if !self.awaiting_side_replay(tui)
&& self.current_displayed_thread_id() == Some(thread_id)
&& !cwds_differ(&cwd, self.chat_widget.config_ref().cwd.as_path())
&& self.chat_widget.session_cwd() == &cwd
{
self.handle_skills_list_result(
result.map_err(|err| color_eyre::eyre::eyre!(err)),
@@ -3482,7 +3481,7 @@ impl App {
};
let manager = pending.manager.clone();
let cwd = AbsolutePathBuf::try_from(checkout.cwd.clone())?;
return Box::pin(self.start_agents_overview_session(tui, app_server, Some(cwd), Some((manager, checkout)), /*startup_draft*/ None)).await;
return Box::pin(self.start_agents_overview_session(tui, app_server, Some(cwd.into()), Some((manager, checkout)), /*startup_draft*/ None)).await;
}
Err(error) => self.add_agents_overview_error(error),
}
+4 -3
View File
@@ -94,7 +94,8 @@ impl App {
store
.session
.as_ref()
.map_or_else(|| self.config.cwd.clone(), |session| session.cwd.clone()),
.map(|session| session.cwd.to_path_buf())
.unwrap_or_else(|| self.config.cwd.to_path_buf()),
store.turns.clone(),
)
};
@@ -203,7 +204,7 @@ impl App {
turns: &[Turn],
hidden_item_ids: &HashSet<(&str, &str)>,
thread_id: ThreadId,
cwd: &AbsolutePathBuf,
cwd: &std::path::Path,
visibility: RawReasoningVisibility,
) {
if hidden_item_ids.is_empty() {
@@ -289,7 +290,7 @@ impl App {
turns: &[Turn],
hidden_item_ids: &HashSet<(&str, &str)>,
thread_id: ThreadId,
cwd: &AbsolutePathBuf,
cwd: &std::path::Path,
visibility: RawReasoningVisibility,
relocate_split_images: bool,
) -> (TranscriptCells, TranscriptCells) {
+1 -1
View File
@@ -158,7 +158,7 @@ mod tests {
recency_at: Some(0),
status: ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
cli_version: "0.0.0".to_string(),
source,
can_accept_direct_input: None,
+3 -2
View File
@@ -158,8 +158,9 @@ impl App {
explicit_profile
.and_then(RuntimePermissionProfileOverride::turn_permission_profile),
);
let cwd = self.chat_widget.session_cwd().to_path_buf();
let Ok((sandbox_policy, permissions)) =
turn_permissions_overrides(permissions_override, config.cwd.as_path())
turn_permissions_overrides(permissions_override, &cwd)
else {
self.chat_widget.add_error_message(
"Couldn’t continue this chat. Review its latest status before trying again."
@@ -167,7 +168,7 @@ impl App {
);
return;
};
params.cwd = Some(config.cwd.to_path_buf());
params.cwd = Some(cwd);
params.runtime_workspace_roots =
Some(config.permissions.user_visible_workspace_roots().to_vec());
params.approval_policy = Some(config.permissions.approval_policy.value().into());
@@ -51,7 +51,7 @@ pub(in crate::app) fn attach_thread(app: &mut App, thread_id: ThreadId) {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
+1
View File
@@ -359,6 +359,7 @@ impl App {
) {
self.chat_widget.snapshot_local_images = self.app_server_target.uses_remote_workspace();
self.chat_widget.thread_params_mode = app_server.thread_params_mode();
self.chat_widget.app_server_path_convention = app_server.path_convention();
self.chat_widget.pending_cloud_turn_settings = app_server.pending_cloud_turn_settings();
self.chat_widget.set_local_worktree_operations(
!crate::uses_remote_workspace_or_environment(
+16 -4
View File
@@ -485,10 +485,16 @@ impl App {
}
(started.session, started.turns, true)
}
PreparedAttachment::ReplayOnly { thread, read_only } => {
PreparedAttachment::ReplayOnly {
thread,
cwd,
read_only,
} => {
external_writer |=
read_only == Some(crate::chatwidget::ReadOnlyThread::ExternalWriter);
let mut session = self.session_state_for_thread_read(thread_id, &thread).await;
let mut session = self
.session_state_for_thread_read(thread_id, &thread, cwd)
.await;
// Reads have no settings. Keep this cached thread's permissions rather than
// inferring them from the conversation that is currently displayed.
if let Some(channel) = self.thread_event_channels.get(&thread_id)
@@ -555,8 +561,13 @@ impl App {
}
}
let mut store = channel.store.lock().await;
if let Some(settings) = incoming.and_then(|updates| updates.settings.as_ref()) {
super::thread_settings::apply_thread_settings_to_session(&mut session, settings);
if let Some(settings) = incoming.and_then(|updates| updates.settings.as_ref())
&& let Ok(cwd) = crate::app_server_session::decode_thread_cwd(
&settings.cwd,
app_server.path_convention(),
)
{
super::thread_settings::apply_thread_settings_to_session(&mut session, settings, &cwd);
}
let live_turn = incoming.filter(|updates| updates.turn_changed).map(|_| {
(
@@ -622,6 +633,7 @@ impl App {
chat_widget.remote_connection = self.chat_widget.remote_connection.clone();
chat_widget.snapshot_local_images = self.app_server_target.uses_remote_workspace();
chat_widget.thread_params_mode = self.chat_widget.thread_params_mode;
chat_widget.app_server_path_convention = self.chat_widget.app_server_path_convention;
chat_widget.pending_cloud_turn_settings =
self.chat_widget.pending_cloud_turn_settings.clone();
chat_widget.set_local_worktree_operations(self.chat_widget.local_worktree_operations);
+1 -1
View File
@@ -983,7 +983,7 @@ impl App {
if !enter {
self.side_companions
.entry(child_thread_id)
.or_insert_with(|| SideCompanion::empty(forked.session.cwd.clone()));
.or_insert_with(|| SideCompanion::empty(forked.session.cwd.to_path_buf()));
}
let channel = self.ensure_thread_channel(child_thread_id);
channel.backend_id = Some(app_server.backend_id());
+2 -2
View File
@@ -14,7 +14,7 @@ use codex_app_server_protocol::ServerNotification;
use codex_app_server_protocol::ThreadItemPayload;
use codex_app_server_protocol::TurnStatus;
use codex_protocol::items::AsyncUserInputQuestion;
use codex_utils_absolute_path::AbsolutePathBuf;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use std::time::Instant;
@@ -59,7 +59,7 @@ impl SideCompanion {
.can_scroll_without_refresh(&self.cells, /*live_key*/ None)
}
pub(super) fn empty(cwd: AbsolutePathBuf) -> Self {
pub(super) fn empty(cwd: PathBuf) -> Self {
Self {
display: CapturedSideDisplay {
rendered_completion_turn_ids: Default::default(),
+1 -1
View File
@@ -6,7 +6,7 @@ use ratatui::layout::Rect;
#[test]
fn buffered_answer_requires_a_paint_before_wheel_input() {
let cwd = AbsolutePathBuf::try_from(std::env::current_dir().unwrap()).unwrap();
let cwd = std::env::current_dir().unwrap();
let mut pane = SideCompanion::empty(cwd);
let area = Rect::new(
/*x*/ 0, /*y*/ 0, /*width*/ 20, /*height*/ 4,
+1 -1
View File
@@ -315,7 +315,7 @@ impl App {
.as_ref()
.is_none_or(|environment| environment.is_server_local);
let cwd = if inspect_local_paths {
Some(PathUri::from_abs_path(&session.cwd))
Some(session.cwd.clone())
} else {
session
.primary_environment_cwd
+1
View File
@@ -940,6 +940,7 @@ impl App {
chat_widget.remote_connection = remote_connection;
chat_widget.snapshot_local_images = app_server_target.uses_remote_workspace();
chat_widget.thread_params_mode = app_server.thread_params_mode();
chat_widget.app_server_path_convention = app_server.path_convention();
chat_widget.pending_cloud_turn_settings = app_server.pending_cloud_turn_settings();
chat_widget.set_local_worktree_operations(!crate::uses_remote_workspace_or_environment(
&app_server_target,
+21 -18
View File
@@ -3234,7 +3234,10 @@ async fn docked_replay_finishes_while_skills_refresh_is_pending() -> Result<()>
app.chat_widget.sync_plugin_mentions_config(&app.config);
let mut tui = crate::tui::test_support::make_test_tui()?;
tui.set_owned_screen(/*owned*/ true)?;
let cwd = app.chat_widget.config_ref().cwd.to_path_buf();
let mut session = test_thread_session(parent, app.config.cwd.to_path_buf());
session.cwd = codex_utils_path_uri::PathUri::parse("file:///D:/Workspace")?;
app.chat_widget.handle_thread_session(session);
let cwd = codex_utils_path_uri::PathUri::parse("file:///D:/workspace")?;
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?;
let endpoint = crate::resolve_remote_addr(&format!("ws://{}", listener.local_addr()?))?;
@@ -3268,7 +3271,7 @@ async fn docked_replay_finishes_while_skills_refresh_is_pending() -> Result<()>
app.pending_thread_switch_resets = 1;
app.app_event_tx
.send(AppEvent::CodexOp(AppCommand::list_skills(
vec![cwd.clone()],
cwd.clone(),
/*force_reload*/ true,
)));
app.app_event_tx
@@ -3284,7 +3287,7 @@ async fn docked_replay_finishes_while_skills_refresh_is_pending() -> Result<()>
.expect("skills/list should be requested");
assert_eq!(
params,
Some(serde_json::json!({"cwds": [cwd], "forceReload": true}))
Some(serde_json::json!({"cwds": [r"D:\workspace"], "forceReload": true}))
);
assert!(!app.awaiting_side_replay(&tui));
@@ -7631,7 +7634,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
recency_at: Some(2),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: Some(rollout_path.clone()),
cwd: test_path_buf("/tmp/agent").abs(),
cwd: test_path_buf("/tmp/agent").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Unknown,
can_accept_direct_input: None,
@@ -7665,7 +7668,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
assert_eq!(session.model, "gpt-agent");
assert_eq!(session.model_provider_id, "openai");
assert_eq!(session.approval_policy, primary_session.approval_policy);
assert_eq!(session.cwd.as_path(), test_path_buf("/tmp/agent").as_path());
assert_eq!(session.cwd.to_path_buf(), test_path_buf("/tmp/agent"));
assert_eq!(
session.runtime_workspace_roots,
vec![test_path_buf("/tmp/agent").abs(), shared_root]
@@ -7751,7 +7754,7 @@ async fn inactive_thread_started_notification_preserves_primary_model_when_path_
recency_at: Some(2),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp/agent").abs(),
cwd: test_path_buf("/tmp/agent").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Unknown,
can_accept_direct_input: None,
@@ -7826,7 +7829,7 @@ async fn thread_read_session_state_does_not_reuse_primary_permission_profile() {
recency_at: Some(2),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp/read").abs(),
cwd: test_path_buf("/tmp/read").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Unknown,
can_accept_direct_input: None,
@@ -7839,19 +7842,19 @@ async fn thread_read_session_state_does_not_reuse_primary_permission_profile() {
};
let cold_session = app
.session_state_for_thread_read(read_thread_id, &thread)
.session_state_for_thread_read(read_thread_id, &thread, thread.cwd.to_inferred_path_uri())
.await;
assert!(cold_session.read_only_history);
app.primary_session_configured = Some(primary_session);
let session = app
.session_state_for_thread_read(read_thread_id, &thread)
.session_state_for_thread_read(read_thread_id, &thread, thread.cwd.to_inferred_path_uri())
.await;
assert!(session.read_only_history);
assert_eq!(session.thread_id, read_thread_id);
assert_eq!(session.model, "server-reported-model");
assert_eq!(session.cwd.as_path(), test_path_buf("/tmp/read").as_path());
assert_eq!(session.cwd.to_path_buf(), test_path_buf("/tmp/read"));
assert_eq!(
session.runtime_workspace_roots,
vec![test_path_buf("/tmp/read").abs()]
@@ -8975,7 +8978,7 @@ async fn render_clear_ui_header_after_long_transcript_for_snapshot() -> String {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::High),
@@ -9719,7 +9722,7 @@ pub(super) fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSe
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: cwd.abs(),
cwd: cwd.abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -10982,7 +10985,7 @@ async fn backtrack_selection_preserves_selected_prompt_and_requests_branch() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -11058,7 +11061,7 @@ async fn backtrack_selection_preserves_selected_prompt_and_requests_branch() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -12385,7 +12388,7 @@ async fn refreshed_snapshot_session_persists_resumed_turns() {
}],
)];
let resumed_session = ThreadSessionState {
cwd: test_path_buf("/tmp/refreshed").abs(),
cwd: test_path_buf("/tmp/refreshed").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
..initial_session.clone()
@@ -12457,7 +12460,7 @@ async fn new_session_requests_shutdown_for_previous_conversation() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -13159,7 +13162,7 @@ async fn inactive_thread_settings_notification_updates_cached_collaboration_mode
thread_settings: ThreadSettings {
disabled_plugin_ids: Vec::new(),
environments: None,
cwd: test_absolute_path("/tmp/thread-settings"),
cwd: test_absolute_path("/tmp/thread-settings").into(),
approval_policy: AskForApproval::OnRequest,
approvals_reviewer: codex_app_server_protocol::ApprovalsReviewer::AutoReview,
sandbox_policy: codex_app_server_protocol::SandboxPolicy::ReadOnly {
@@ -13239,7 +13242,7 @@ async fn clear_only_ui_reset_preserves_chat_session_state() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -363,7 +363,7 @@ async fn command_center_new_reads_server_defaults_for_actual_destination() -> Re
app.new_agents_overview_session(
&mut tui,
&mut server,
explicit_cwd.then(|| destination.path().to_path_buf().abs()),
explicit_cwd.then(|| destination.path().to_path_buf()),
)
.await?;
assert_eq!(
@@ -1191,11 +1191,8 @@ async fn command_center_new_checkout_and_worktree_preserve_source_and_default_br
.await?;
let mut tui = make_test_tui()?;
tui.pause_events();
let new_session = app.new_agents_overview_session(
&mut tui,
&mut server,
Some(selected.cwd.clone().abs()),
);
let new_session =
app.new_agents_overview_session(&mut tui, &mut server, Some(selected.cwd.clone()));
let size = std::mem::size_of_val(&new_session);
assert!(
size < 64 * 1024,
@@ -1304,7 +1301,7 @@ async fn command_center_new_checkout_and_worktree_preserve_source_and_default_br
app.start_agents_overview_session(
&mut tui,
&mut failed_server,
Some(unused.cwd.clone().abs()),
Some(unused.cwd.clone()),
Some((manager.clone(), unused.clone())),
/*startup_draft*/ None,
)
@@ -559,7 +559,7 @@ async fn widget_replacement_preserves_mention_usage_with_history_disabled() -> R
/*initial_user_message*/ None,
);
app.replace_chat_widget(ChatWidget::new_with_app_event(init));
app.chat_widget.set_skills_from_response(&skills);
app.chat_widget.set_skills_from_response(skills.clone());
app.chat_widget.insert_str("$status");
app.chat_widget.handle_key_event(KeyCode::Enter.into());
@@ -569,7 +569,7 @@ async fn widget_replacement_preserves_mention_usage_with_history_disabled() -> R
/*initial_user_message*/ None,
);
app.replace_chat_widget(ChatWidget::new_with_app_event(init));
app.chat_widget.set_skills_from_response(&skills);
app.chat_widget.set_skills_from_response(skills);
app.chat_widget.insert_str("$stat");
insta::assert_snapshot!(normalize_snapshot_paths(render_bottom_popup(
&app.chat_widget,
@@ -212,7 +212,7 @@ sandbox = "unelevated"
std::fs::create_dir(untrusted.path().join(".codex"))?;
std::fs::write(untrusted.path().join(".codex/config.toml"), "")?;
crate::config_update::write_trusted_project(server.request_handle(), untrusted.path()).await?;
app.new_agents_overview_session(&mut tui, &mut server, Some(untrusted.path().abs()))
app.new_agents_overview_session(&mut tui, &mut server, Some(untrusted.path().to_path_buf()))
.await?;
server
.thread_inject_items(
@@ -372,7 +372,7 @@ async fn embedded_session_switch_routes_background_approval_and_restores_draft()
app.start_agents_overview_session(
&mut tui,
&mut server,
Some(cwd.clone().abs()),
Some(cwd.clone()),
/*managed_worktree*/ None,
/*startup_draft*/ None,
)
@@ -387,7 +387,7 @@ async fn embedded_session_switch_routes_background_approval_and_restores_draft()
app.start_agents_overview_session(
&mut tui,
&mut server,
Some(cwd.abs()),
Some(cwd),
/*managed_worktree*/ None,
/*startup_draft*/ None,
)
@@ -547,10 +547,13 @@ stream_max_retries = 0
crate::app_server_session::ResumeModelSettings::PreserveExistingThread,
)
.await?;
for cwd in [&app.config.cwd, &other.session.cwd] {
for cwd in [
app.config.cwd.to_path_buf(),
other.session.cwd.to_path_buf(),
] {
crate::legacy_core::config::set_project_trust_level(
app.config.codex_home.as_path(),
cwd.as_path(),
&cwd,
codex_protocol::config_types::TrustLevel::Trusted,
)
.map_err(std::io::Error::other)?;
@@ -49,6 +49,35 @@ use tokio_tungstenite::tungstenite::Error as WebSocketError;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::tungstenite::error::ProtocolError;
#[tokio::test]
async fn diff_result_matches_the_server_session_cwd() -> Result<()> {
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::PathUri;
let mut app = make_test_app().await;
let (client, _commands, _events) =
codex_app_server_client::CloudClient::channel(/*capacity*/ 1);
let mut server = AppServerSession::new(
crate::backend_id::BackendId::new(),
codex_app_server_client::AppServerClient::Cloud(client),
crate::ThreadParamsMode::Cloud,
);
let mut tui = crate::tui::test_support::make_test_tui()?;
let foreign_cwd = if cfg!(windows) { "/repo" } else { r"D:\repo" };
let cwd = PathUri::try_from(LegacyAppPathString::from_string(foreign_cwd))?;
let mut session = test_thread_session(ThreadId::new(), app.config.cwd.to_path_buf());
session.cwd = cwd.clone();
app.chat_widget.handle_thread_session(session);
let stale = AppEvent::DiffResult(app.config.cwd.clone().into(), "old diff".into());
Box::pin(app.handle_event(&mut tui, &mut server, stale)).await?;
assert!(app.overlay.is_none());
let current = AppEvent::DiffResult(cwd, "current diff".into());
Box::pin(app.handle_event(&mut tui, &mut server, current)).await?;
assert!(app.overlay.is_some());
Ok(())
}
#[tokio::test]
async fn cloud_skips_skills_refresh_and_ignores_stale_local_result() -> Result<()> {
use futures::FutureExt;
@@ -74,7 +103,7 @@ async fn cloud_skips_skills_refresh_and_ignores_stale_local_result() -> Result<(
for event in [
AppEvent::CodexOp(refresh),
AppEvent::SkillsListLoaded {
cwd,
cwd: app.config.cwd.clone().into(),
result: Err("stale local skills refresh".into()),
},
] {
@@ -401,7 +430,7 @@ async fn cloud_resume_picker_reconciles_admitted_steers() -> Result<()> {
"Original",
ThreadStatus::Idle,
);
original_thread.cwd = app.config.cwd.clone();
original_thread.cwd = app.config.cwd.clone().into();
original_thread.turns = vec![test_turn(
turn_id,
TurnStatus::Completed,
@@ -415,7 +444,7 @@ async fn cloud_resume_picker_reconciles_admitted_steers() -> Result<()> {
active_flags: Vec::new(),
},
);
other_thread.cwd = app.config.cwd.clone();
other_thread.cwd = app.config.cwd.clone().into();
other_thread.turns = vec![ongoing_turn];
let (client, mut commands, _server_events) =
@@ -5999,18 +6028,18 @@ async fn change_directory_scenario() -> Result<()> {
let earlier_skills_requests = recorded_params(&requests, "skills/list");
app.submit_active_thread_op(
&mut server,
AppCommand::list_skills(vec![current.clone()], /*force_reload*/ true),
AppCommand::list_skills(current.clone().abs().into(), /*force_reload*/ true),
)
.await?;
assert_eq!(
recorded_params(&requests, "skills/list"),
earlier_skills_requests
);
let (cwd, result) = (current.clone(), Err("stale skills".into()));
let (cwd, result) = (current.clone().abs().into(), Err("stale skills".into()));
let skills = AppEvent::SkillsListLoaded { cwd, result };
let (cwd, plugins) = (current.clone(), Some(vec![]));
let plugins = AppEvent::PluginMentionsLoaded { cwd, plugins };
let diff = AppEvent::DiffResult(current.clone(), "stale diff".to_string());
let diff = AppEvent::DiffResult(current.clone().abs().into(), "stale diff".to_string());
let branch = AppEvent::SyncThreadGitBranch {
thread_id: original,
branch: "stale".to_string(),
@@ -6051,7 +6080,7 @@ async fn change_directory_scenario() -> Result<()> {
let found = |id: ThreadId| removed.iter().any(|p| p["threadId"] == id.to_string());
assert!([original, child].into_iter().all(found));
let retained = server.thread_read(original, /*include_turns*/ false);
assert_eq!(retained.await?.cwd, current.abs().canonicalize()?);
assert_eq!(retained.await?.cwd, current.abs().canonicalize()?.into());
assert_eq!(app.chat_widget.config_ref().cwd, trusted.clone().abs());
assert!(render_bottom_popup(&app.chat_widget, /*width*/ 80).contains("SessionStart"));
app.chat_widget
+1 -1
View File
@@ -1323,7 +1323,7 @@ async fn known_thread_started_preserves_session_without_reading_unmaterialized_r
recency_at: Some(2),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: Some(temp_dir.path().join("not-yet-materialized.jsonl")),
cwd: session.cwd.clone(),
cwd: session.cwd.clone().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Unknown,
can_accept_direct_input: None,
@@ -702,15 +702,13 @@ async fn fresh_startup_reads_destination_and_cleared_model_uses_catalog() -> Res
)
.await?;
assert_eq!(started.session.model, selected_model);
let cwd = started.session.cwd.to_path_buf();
assert!(
!started
.session
.permission_profile
.file_system_sandbox_policy()
.can_write_local_path_with_cwd(
started.session.cwd.as_path(),
started.session.cwd.as_path()
)
.can_write_local_path_with_cwd(&cwd, &cwd)
);
let starts = recorded_params(&requests, "thread/start");
assert_eq!(starts.len(), if remote { 1 } else { 2 });
@@ -3,6 +3,8 @@
use super::*;
use crate::history_cell::StartupWarningsCell;
use codex_app_server_protocol::McpServerStartupFailureReason;
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::PathConvention;
use pretty_assertions::assert_eq;
use tokio::sync::mpsc::UnboundedReceiver;
@@ -268,10 +270,16 @@ async fn startup_skill_load_order_preserves_runtime_error_recurrence() -> Result
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
let mut tui = crate::tui::test_support::make_test_tui()?;
let mut server = start_config_write_test_app_server(&app).await?;
let cwd = app.config.cwd.to_path_buf();
let server_cwd = r"/\repo";
let cwd =
LegacyAppPathString::from_string(server_cwd).to_path_uri(PathConvention::Posix)?;
let mut session = test_thread_session(ThreadId::new(), app.config.cwd.to_path_buf());
session.cwd = cwd.clone();
app.chat_widget.app_server_path_convention = Some(PathConvention::Posix);
app.chat_widget.handle_thread_session_quiet(session);
let response = SkillsListResponse {
data: vec![codex_app_server_protocol::SkillsListEntry {
cwd: cwd.clone(),
cwd: PathBuf::from(server_cwd),
skills: vec![],
errors: vec![SkillErrorInfo {
path: PathBuf::from("bad/SKILL.md"),
@@ -26,6 +26,7 @@ pub(crate) enum PreparedAttachment {
Live(Box<AppServerStartedThread>),
ReplayOnly {
thread: Box<Thread>,
cwd: Option<codex_utils_path_uri::PathUri>,
read_only: Option<ReadOnlyThread>,
},
}
@@ -247,8 +248,15 @@ pub(super) async fn prepare(
"Agent thread {thread_id} is not yet available for replay or live attach."
));
}
let convention = app_server.path_convention();
let cwd = match crate::app_server_session::decode_thread_cwd(&thread.cwd, convention) {
Ok(cwd) => Some(cwd),
Err(error) if convention.is_some() => return Err(error.into()),
Err(_) => None,
};
Ok(PreparedAttachment::ReplayOnly {
thread: Box::new(thread),
cwd,
read_only: if crate::session_start::is_archived_session_error(
&resume_err,
thread_id,
+1 -1
View File
@@ -763,7 +763,7 @@ mod tests {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: cwd.abs(),
cwd: cwd.abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
+15 -12
View File
@@ -12,6 +12,7 @@ use codex_app_server_protocol::ThreadStartedNotification;
use codex_app_server_protocol::TurnInterruptParams;
use codex_app_server_protocol::TurnInterruptResponse;
use codex_app_server_protocol::WarningNotification;
use codex_utils_path_uri::PathUri;
// Leave time for side-thread cleanup and unsubscribe inside the two-second exit budget.
const REALTIME_STOP_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 1);
@@ -321,7 +322,7 @@ impl App {
self.sync_side_thread_ui();
}
pub(super) async fn thread_cwd(&self, thread_id: ThreadId) -> Option<AbsolutePathBuf> {
pub(super) async fn thread_cwd(&self, thread_id: ThreadId) -> Option<PathUri> {
let channel = self.thread_event_channels.get(&thread_id)?;
let store = channel.store.lock().await;
store.session.as_ref().map(|session| session.cwd.clone())
@@ -386,6 +387,7 @@ impl App {
cwd: self
.thread_cwd(thread_id)
.await
.and_then(|cwd| cwd.to_abs_path().ok())
.unwrap_or_else(|| self.config.cwd.clone()),
changes: self
.thread_file_change_changes(thread_id, &params.turn_id, &params.item_id)
@@ -854,18 +856,15 @@ impl App {
});
Ok(true)
}
AppCommand::ListSkills { cwds, force_reload } => {
AppCommand::ListSkills { cwd, force_reload } => {
// A queued refresh can outlive the workspace it was requested for.
if !cwds
.iter()
.any(|cwd| cwd == self.chat_widget.config_ref().cwd.as_path())
{
if self.chat_widget.session_cwd() != cwd {
return Ok(true);
}
self.handle_skills_list_result(
app_server
.skills_list(codex_app_server_protocol::SkillsListParams {
cwds: cwds.clone(),
cwds: vec![cwd.to_path_buf()],
force_reload: *force_reload,
})
.await,
@@ -1461,8 +1460,13 @@ impl App {
.clone_from(&notification.thread.reasoning_effort);
session.thread_name = notification.thread.name.clone();
session.model_provider_id = notification.thread.model_provider.clone();
session
.set_cwd_retargeting_implicit_runtime_workspace_root(notification.thread.cwd.clone());
session.set_cwd_retargeting_implicit_runtime_workspace_root(
crate::app_server_session::decode_thread_cwd(
&notification.thread.cwd,
self.backend_registry.thread_path_convention(thread_id),
)
.ok()?,
);
let rollout_path = notification.thread.path.clone();
if let Some(model) = &notification.thread.model {
session.model = model.clone();
@@ -2071,8 +2075,7 @@ impl App {
#[allow(clippy::too_many_arguments)]
pub(super) fn handle_skills_list_response(&mut self, response: SkillsListResponse) {
let cwd = self.chat_widget.config_ref().cwd.clone();
let errors = errors_for_cwd(&cwd, &response);
let errors = self.chat_widget.set_skills_from_response(response);
let errors = self.skill_load_warnings.newly_active_errors(&errors);
let warnings = skill_load_warning_messages(&errors);
if self.skill_load_warnings.startup_complete {
@@ -2087,7 +2090,7 @@ impl App {
),
)));
}
self.chat_widget.handle_skills_list_response(response);
self.chat_widget.refresh_plugin_mentions();
}
fn startup_request_may_open_protected_view(&self, request: &ServerRequest) -> bool {
+14 -5
View File
@@ -74,6 +74,7 @@ impl App {
&self,
thread_id: ThreadId,
thread: &Thread,
cwd: Option<codex_utils_path_uri::PathUri>,
) -> ThreadSessionState {
let permission_profile = self.current_permission_profile();
let active_permission_profile = self.current_active_permission_profile();
@@ -108,7 +109,9 @@ impl App {
approvals_reviewer: self.config.approvals_reviewer,
permission_profile: permission_profile.clone(),
active_permission_profile: active_permission_profile.clone(),
cwd: thread.cwd.clone(),
cwd: cwd
.clone()
.unwrap_or_else(|| self.config.cwd.clone().into()),
runtime_workspace_roots: self.config.workspace_roots.clone(),
instruction_source_paths: Vec::new(),
reasoning_effort: self.chat_widget.current_reasoning_effort(),
@@ -129,7 +132,9 @@ impl App {
session.daybreak_enabled = thread.daybreak_enabled.unwrap_or(false);
session.thread_name = thread.name.clone();
session.model_provider_id = thread.model_provider.clone();
session.set_cwd_retargeting_implicit_runtime_workspace_root(thread.cwd.clone());
if let Some(cwd) = cwd {
session.set_cwd_retargeting_implicit_runtime_workspace_root(cwd);
}
session.permission_profile = permission_profile;
session.active_permission_profile = active_permission_profile;
session.instruction_source_paths = Vec::new();
@@ -200,7 +205,7 @@ mod tests {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: cwd.abs(),
cwd: cwd.abs().into(),
runtime_workspace_roots: vec![cwd.abs()],
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -452,7 +457,7 @@ mod tests {
recency_at: Some(2),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp/read").abs(),
cwd: test_path_buf("/tmp/read").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Unknown,
can_accept_direct_input: None,
@@ -468,7 +473,11 @@ mod tests {
app.chat_widget.handle_thread_session(primary_session);
let session = app
.session_state_for_thread_read(read_thread_id, &read_thread)
.session_state_for_thread_read(
read_thread_id,
&read_thread,
read_thread.cwd.to_inferred_path_uri(),
)
.await;
assert_eq!(
+11 -4
View File
@@ -215,19 +215,25 @@ impl App {
thread_id: ThreadId,
settings: &ThreadSettings,
) {
let Ok(cwd) = crate::app_server_session::decode_thread_cwd(
&settings.cwd,
self.backend_registry.thread_path_convention(thread_id),
) else {
return;
};
if let Some(blank) = self.agents_overview.blank_sessions.get_mut(&thread_id) {
apply_thread_settings_to_session(&mut blank.session, settings);
apply_thread_settings_to_session(&mut blank.session, settings, &cwd);
}
if self.primary_thread_id == Some(thread_id)
&& let Some(session) = self.primary_session_configured.as_mut()
{
apply_thread_settings_to_session(session, settings);
apply_thread_settings_to_session(session, settings, &cwd);
}
if let Some(channel) = self.thread_event_channels.get(&thread_id) {
let mut store = channel.store.lock().await;
if let Some(session) = store.session.as_mut() {
apply_thread_settings_to_session(session, settings);
apply_thread_settings_to_session(session, settings, &cwd);
}
}
}
@@ -276,6 +282,7 @@ impl App {
pub(super) fn apply_thread_settings_to_session(
session: &mut ThreadSessionState,
settings: &ThreadSettings,
cwd: &codex_utils_path_uri::PathUri,
) {
if settings.collaboration_mode.mode == ModeKind::Default {
session.model = settings.model.clone();
@@ -294,7 +301,7 @@ pub(super) fn apply_thread_settings_to_session(
session.primary_environment_cwd =
crate::session_state::primary_environment_cwd(environments);
}
session.set_cwd_retargeting_implicit_runtime_workspace_root(settings.cwd.clone());
session.set_cwd_retargeting_implicit_runtime_workspace_root(cwd.clone());
let mut collaboration_mode = settings.collaboration_mode.clone();
collaboration_mode
.settings
+1 -1
View File
@@ -126,7 +126,7 @@ pub(super) async fn load_export_transcript(
} else {
cells.extend(thread_items_to_transcript_cells(
Some(thread_id),
&thread.cwd,
thread.cwd.as_path(),
[item],
visibility,
config,
+1 -1
View File
@@ -493,7 +493,7 @@ impl App {
== config.permissions.active_permission_profile()
};
if session.thread_id == thread_id
|| crate::session_resume::cwds_differ(session.cwd.as_path(), cwd.as_path())
|| crate::session_resume::cwds_differ(&session.cwd.to_path_buf(), cwd.as_path())
|| session.runtime_workspace_roots != config.workspace_roots
|| !permissions_match
{
+4 -3
View File
@@ -20,6 +20,7 @@ use codex_protocol::models::ActivePermissionProfile;
use codex_protocol::models::PermissionProfile;
use codex_protocol::openai_models::ReasoningEffort as ReasoningEffortConfig;
use codex_protocol::request_permissions::RequestPermissionsResponse;
use codex_utils_path_uri::PathUri;
use serde::Serialize;
use serde::Serializer;
use serde_json::Value;
@@ -188,7 +189,7 @@ pub(crate) enum AppCommand {
},
ReloadUserConfig,
ListSkills {
cwds: Vec<PathBuf>,
cwd: PathUri,
force_reload: bool,
},
Compact,
@@ -357,8 +358,8 @@ impl AppCommand {
Self::ReloadUserConfig
}
pub(crate) fn list_skills(cwds: Vec<PathBuf>, force_reload: bool) -> Self {
Self::ListSkills { cwds, force_reload }
pub(crate) fn list_skills(cwd: PathUri, force_reload: bool) -> Self {
Self::ListSkills { cwd, force_reload }
}
pub(crate) fn compact() -> Self {
+5 -5
View File
@@ -322,7 +322,7 @@ pub(crate) struct CapturedSideDisplay {
pub(crate) status_line: Option<crate::bottom_pane::StatusLine>,
pub(crate) work: Option<CapturedSideWork>,
pub(crate) last_completed_agent_message: Option<(String, String)>,
pub(crate) cwd: AbsolutePathBuf,
pub(crate) cwd: PathBuf,
pub(crate) visualizations: Option<crate::inline_visualization::InlineVisualizationContext>,
}
@@ -402,7 +402,7 @@ pub(crate) enum AppEvent {
/// Create an empty thread from the command center.
NewAgentsOverviewSession {
backend_id: Option<crate::backend_id::BackendId>,
cwd: Option<AbsolutePathBuf>,
cwd: Option<PathBuf>,
},
/// Update the agents overview after a background thread listing finishes.
AgentsOverviewThreadsLoaded {
@@ -1086,7 +1086,7 @@ pub(crate) enum AppEvent {
},
/// Result of computing a `/diff` command.
DiffResult(PathBuf, String),
DiffResult(PathUri, String),
/// Open the app link view in the bottom pane.
OpenAppLink {
@@ -1379,7 +1379,7 @@ pub(crate) enum AppEvent {
/// command path because those callers expect the visible skill state to be current when their command
/// completes.
SkillsListLoaded {
cwd: PathBuf,
cwd: PathUri,
result: Result<SkillsListResponse, String>,
},
@@ -1387,7 +1387,7 @@ pub(crate) enum AppEvent {
SideReplaySkillsLoaded {
request_id: Uuid,
thread_id: ThreadId,
cwd: PathBuf,
cwd: PathUri,
result: Result<SkillsListResponse, String>,
},
+62 -24
View File
@@ -166,7 +166,11 @@ use codex_protocol::permissions::FileSystemSandboxPolicy;
use codex_protocol::permissions::NetworkSandboxPolicy;
use codex_protocol::protocol::SubAgentSource;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::LegacyAppPathStringError;
use codex_utils_path_uri::PathConvention;
use codex_utils_path_uri::PathUri;
use codex_utils_path_uri::Platform;
use color_eyre::eyre::Result;
use color_eyre::eyre::WrapErr;
use futures::FutureExt;
@@ -617,6 +621,10 @@ pub(crate) enum CloudThreadStart<'a> {
}
impl AppServerSession {
pub(crate) fn path_convention(&self) -> Option<PathConvention> {
Platform::from_platform_os(self.request_handle.platform_os()).path_convention()
}
/// Platform of the app-server process, not necessarily its executor.
pub(crate) fn app_server_platform_family(&self) -> Option<&str> {
self.connection_owner
@@ -1248,6 +1256,7 @@ impl AppServerSession {
local_settings,
config,
self.thread_params_mode(),
self.path_convention(),
)
.await?;
if let Some(permissions) = selected_permissions {
@@ -1625,6 +1634,7 @@ impl AppServerSession {
local_settings,
&config,
self.thread_params_mode(),
self.path_convention(),
)
.await?;
if let Some(permissions) = selected_permissions {
@@ -2405,9 +2415,14 @@ pub(crate) async fn start_thread_with_request_handle(
.map_err(|err| {
bootstrap_request_error("thread/start failed during TUI bootstrap", err)
})?;
let mut started =
started_thread_from_start_response(response, local_settings, &config, thread_params_mode)
.await?;
let mut started = started_thread_from_start_response(
response,
local_settings,
&config,
thread_params_mode,
Platform::from_platform_os(request_handle.platform_os()).path_convention(),
)
.await?;
started.task_tools_available = task_tools_available;
Ok(started)
}
@@ -2953,6 +2968,7 @@ async fn started_thread_from_start_response(
local_settings: &LocalSettings,
config: &Config,
thread_params_mode: ThreadParamsMode,
cwd_convention: Option<PathConvention>,
) -> Result<AppServerStartedThread> {
let blocks_direct_input = thread_blocks_direct_input(&response.thread);
let session = thread_session_state_from_thread_start_response(
@@ -2960,6 +2976,7 @@ async fn started_thread_from_start_response(
local_settings,
config,
thread_params_mode,
cwd_convention,
)
.await
.map_err(color_eyre::eyre::Report::msg)?;
@@ -2974,16 +2991,13 @@ async fn started_thread_from_start_response(
async fn started_thread_from_resume_response(
response: ThreadResumeResponse,
local_settings: &LocalSettings,
thread_params_mode: ThreadParamsMode,
cwd_convention: Option<PathConvention>,
) -> Result<AppServerStartedThread> {
let blocks_direct_input = thread_blocks_direct_input(&response.thread);
let session = thread_session_state_from_thread_resume_response(
&response,
local_settings,
thread_params_mode,
)
.await
.map_err(color_eyre::eyre::Report::msg)?;
let session =
thread_session_state_from_thread_resume_response(&response, local_settings, cwd_convention)
.await
.map_err(color_eyre::eyre::Report::msg)?;
Ok(AppServerStartedThread {
session,
turns: response.thread.turns,
@@ -2997,6 +3011,7 @@ async fn started_thread_from_fork_response(
local_settings: &LocalSettings,
config: &Config,
thread_params_mode: ThreadParamsMode,
cwd_convention: Option<PathConvention>,
) -> Result<AppServerStartedThread> {
let blocks_direct_input = thread_blocks_direct_input(&response.thread);
let session = thread_session_state_from_thread_fork_response(
@@ -3004,6 +3019,7 @@ async fn started_thread_from_fork_response(
local_settings,
config,
thread_params_mode,
cwd_convention,
)
.await
.map_err(color_eyre::eyre::Report::msg)?;
@@ -3020,6 +3036,7 @@ async fn thread_session_state_from_thread_start_response(
local_settings: &LocalSettings,
config: &Config,
thread_params_mode: ThreadParamsMode,
cwd_convention: Option<PathConvention>,
) -> Result<ThreadSessionState, String> {
let permission_profile = display_permission_profile_from_thread_response(
&response.sandbox,
@@ -3040,7 +3057,7 @@ async fn thread_session_state_from_thread_start_response(
response.approvals_reviewer.to_core(),
permission_profile,
response.active_permission_profile.clone().map(Into::into),
response.cwd.clone(),
decode_thread_cwd(&response.cwd, cwd_convention).map_err(|err| err.to_string())?,
response.runtime_workspace_roots.clone(),
response.instruction_source_path_uris(),
response.reasoning_effort.clone(),
@@ -3057,7 +3074,7 @@ async fn thread_session_state_from_thread_start_response(
async fn thread_session_state_from_thread_resume_response(
response: &ThreadResumeResponse,
local_settings: &LocalSettings,
_thread_params_mode: ThreadParamsMode,
cwd_convention: Option<PathConvention>,
) -> Result<ThreadSessionState, String> {
// The server owns restored rules. This legacy projection is for display only;
// normal turns do not send it back as an execution override.
@@ -3078,7 +3095,7 @@ async fn thread_session_state_from_thread_resume_response(
response.approvals_reviewer.to_core(),
permission_profile,
response.active_permission_profile.clone().map(Into::into),
response.cwd.clone(),
decode_thread_cwd(&response.cwd, cwd_convention).map_err(|err| err.to_string())?,
response.runtime_workspace_roots.clone(),
response.instruction_source_path_uris(),
response.reasoning_effort.clone(),
@@ -3095,6 +3112,7 @@ async fn thread_session_state_from_thread_fork_response(
local_settings: &LocalSettings,
config: &Config,
thread_params_mode: ThreadParamsMode,
cwd_convention: Option<PathConvention>,
) -> Result<ThreadSessionState, String> {
let permission_profile = display_permission_profile_from_thread_response(
&response.sandbox,
@@ -3115,7 +3133,7 @@ async fn thread_session_state_from_thread_fork_response(
response.approvals_reviewer.to_core(),
permission_profile,
response.active_permission_profile.clone().map(Into::into),
response.cwd.clone(),
decode_thread_cwd(&response.cwd, cwd_convention).map_err(|err| err.to_string())?,
response.runtime_workspace_roots.clone(),
response.instruction_source_path_uris(),
response.reasoning_effort.clone(),
@@ -3151,6 +3169,16 @@ fn display_permission_profile_from_thread_response(
}
}
pub(crate) fn decode_thread_cwd(
cwd: &LegacyAppPathString,
convention: Option<PathConvention>,
) -> Result<PathUri, LegacyAppPathStringError> {
match convention {
Some(convention) => cwd.to_path_uri(convention),
None => PathUri::try_from(cwd.clone()),
}
}
#[expect(
clippy::too_many_arguments,
reason = "session mapping keeps explicit fields"
@@ -3168,7 +3196,7 @@ async fn thread_session_state_from_thread_response(
approvals_reviewer: codex_protocol::config_types::ApprovalsReviewer,
permission_profile: PermissionProfile,
active_permission_profile: Option<ActivePermissionProfile>,
cwd: AbsolutePathBuf,
cwd: PathUri,
runtime_workspace_roots: Vec<AbsolutePathBuf>,
instruction_source_paths: Vec<PathUri>,
reasoning_effort: Option<codex_protocol::openai_models::ReasoningEffort>,
@@ -3962,7 +3990,7 @@ mod tests {
started.session.permission_profile.network_sandbox_policy(),
started.session.model.as_str(),
started.session.approval_policy,
started.session.cwd.as_path(),
started.session.cwd.to_path_buf().as_path(),
),
(
NetworkSandboxPolicy::Restricted,
@@ -5131,7 +5159,7 @@ mod tests {
recency_at: Some(2),
status: ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Cli,
can_accept_direct_input: None,
@@ -5177,7 +5205,7 @@ mod tests {
model: "gpt-5.5".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
runtime_workspace_roots: vec![
test_path_buf("/tmp/project").abs(),
test_path_buf("/tmp/project/extra").abs(),
@@ -5210,7 +5238,7 @@ mod tests {
let started = started_thread_from_resume_response(
response.clone(),
&LocalSettings::from(&config),
ThreadParamsMode::Remote,
/*cwd_convention*/ None,
)
.await
.expect("resume response should map");
@@ -5264,7 +5292,7 @@ mod tests {
let started = started_thread_from_resume_response(
response.clone(),
&LocalSettings::from(&embedded_config),
ThreadParamsMode::Embedded,
/*cwd_convention*/ None,
)
.await
.expect("embedded resume response should map");
@@ -5273,14 +5301,24 @@ mod tests {
let mut thread = response.thread.clone();
let mut empty_roots_response = response;
empty_roots_response.runtime_workspace_roots = Vec::new();
let server_cwd = r"/\repo";
empty_roots_response.cwd = LegacyAppPathString::from_string(server_cwd);
let started = started_thread_from_resume_response(
empty_roots_response,
&LocalSettings::from(&config),
ThreadParamsMode::Remote,
Some(PathConvention::Posix),
)
.await
.expect("resume response should map");
assert_eq!(started.session.runtime_workspace_roots, Vec::new());
assert_eq!(
started.session.cwd.infer_path_convention(),
Some(PathConvention::Posix)
);
assert_eq!(
started.session.cwd.inferred_native_path_string(),
server_cwd
);
// Cloud can filter every item in its newest page while older prompts remain.
thread.history_mode = ThreadHistoryMode::Paginated;
@@ -5419,7 +5457,7 @@ mod tests {
codex_protocol::config_types::ApprovalsReviewer::User,
PermissionProfile::read_only(),
/*active_permission_profile*/ None,
test_path_buf("/tmp/project").abs(),
test_path_buf("/tmp/project").abs().into(),
Vec::new(),
Vec::new(),
/*reasoning_effort*/ None,
@@ -5455,7 +5493,7 @@ mod tests {
codex_protocol::config_types::ApprovalsReviewer::User,
PermissionProfile::read_only(),
/*active_permission_profile*/ None,
test_path_buf("/tmp/project").abs(),
test_path_buf("/tmp/project").abs().into(),
Vec::new(),
Vec::new(),
/*reasoning_effort*/ None,
@@ -513,7 +513,7 @@ fn rendered_history_rows(
};
thread_items_to_transcript_cells(
Some(thread_id),
&thread.cwd,
thread.cwd.as_path(),
items.into_iter().map(|(_, item)| item),
visibility,
Some(config),
@@ -92,7 +92,7 @@ impl AppServerSession {
config.approvals_reviewer,
config.permissions.permission_profile().clone(),
config.permissions.active_permission_profile(),
thread.cwd.clone(),
super::decode_thread_cwd(&thread.cwd, self.path_convention())?,
config.workspace_roots.clone(),
Vec::new(),
thread.reasoning_effort,
@@ -199,9 +199,12 @@ impl AppServerSession {
HistoryHydrationScope::Initial,
)
.await?;
let mut started =
started_thread_from_resume_response(response, local_settings, ThreadParamsMode::Cloud)
.await?;
let mut started = started_thread_from_resume_response(
response,
local_settings,
/*cwd_convention*/ None,
)
.await?;
scoped.commit_prepared_resume().await.map_err(|err| {
bootstrap_request_error("thread/resume failed during TUI bootstrap", err)
})?;
@@ -346,12 +349,9 @@ impl AppServerSession {
let fork_parent_title = self
.fork_parent_title_from_app_server(response.thread.forked_from_id.as_deref())
.await;
let mut started = started_thread_from_resume_response(
response,
local_settings,
self.thread_params_mode(),
)
.await?;
let mut started =
started_thread_from_resume_response(response, local_settings, self.path_convention())
.await?;
started.session.fork_parent_title = fork_parent_title;
if self.task_tools_available(thread_id) {
self.remember_task_tool_thread(thread_id);
@@ -81,7 +81,7 @@ stream_max_retries = 0
app_server.remote_cwd_override = Some(remote_cwd.to_path_buf());
let started = app_server.start_thread(&client_config).await?;
let thread_id = started.session.thread_id;
assert_eq!(started.session.cwd, remote_cwd);
assert_eq!(started.session.cwd, remote_cwd.clone().into());
assert_eq!(started.session.runtime_workspace_roots, expected_roots);
let (mut chat, _sender, _events, _commands) =
@@ -178,7 +178,7 @@ stream_max_retries = 0
app_server.remote_cwd_override = None;
let started = app_server.start_thread(&client_config).await?;
let default_cwd = AbsolutePathBuf::current_dir()?;
assert_eq!(started.session.cwd, default_cwd);
assert_eq!(started.session.cwd, default_cwd.clone().into());
assert_eq!(started.session.runtime_workspace_roots, vec![default_cwd]);
app_server.shutdown().await?;
Ok(())
+5 -9
View File
@@ -102,7 +102,6 @@ use codex_app_server_protocol::ReviewTarget;
use codex_app_server_protocol::ServerNotification;
use codex_app_server_protocol::ServerRequest;
use codex_app_server_protocol::SkillMetadata;
use codex_app_server_protocol::SkillsListResponse;
use codex_app_server_protocol::ThreadGoal as AppThreadGoal;
use codex_app_server_protocol::ThreadGoalStatus as AppThreadGoalStatus;
use codex_app_server_protocol::ThreadItemPayload;
@@ -150,6 +149,7 @@ use codex_protocol::request_permissions::RequestPermissionsEvent;
use codex_protocol::user_input::ByteRange;
use codex_protocol::user_input::TextElement;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::PathConvention;
use codex_utils_path_uri::PathUri;
use crossterm::event::KeyCode;
use crossterm::event::KeyEvent;
@@ -576,6 +576,7 @@ pub(crate) struct ChatWidget {
pub(crate) initial_user_message: Option<UserMessage>,
status_account_display: Option<StatusAccountDisplay>,
pub(crate) remote_connection: Option<RemoteConnectionStatus>,
pub(crate) app_server_path_convention: Option<PathConvention>,
statusline_read: Option<statusline_reader::ActiveStatuslineRead>,
pub(crate) statusline_disconnected: bool,
/// Remote app servers cannot read image paths on the TUI host.
@@ -752,8 +753,8 @@ pub(crate) struct ChatWidget {
feedback: codex_feedback::CodexFeedback,
// Current session rollout path (if known)
current_rollout_path: Option<PathBuf>,
// Current working directory (if known)
current_cwd: Option<PathBuf>,
// Working directory of the displayed session.
current_cwd: PathUri,
primary_environment_cwd: Option<crate::session_state::EnvironmentCwd>,
// App-server-backed command runner for status-line workspace metadata lookups.
workspace_command_runner: Option<WorkspaceCommandRunner>,
@@ -1880,7 +1881,7 @@ impl ChatWidget {
fn refresh_skills_for_current_cwd(&mut self, force_reload: bool) {
self.submit_op(AppCommand::list_skills(
vec![self.config.cwd.to_path_buf()],
self.session_cwd().clone(),
force_reload,
));
}
@@ -1961,11 +1962,6 @@ impl ChatWidget {
}
}
fn on_list_skills(&mut self, ev: SkillsListResponse) {
self.set_skills_from_response(&ev);
self.refresh_plugin_mentions();
}
pub(crate) fn refresh_plugin_mentions(&mut self) {
if !self.config.features.enabled(Feature::Plugins) {
self.bottom_pane.set_plugin_mentions(/*plugins*/ None);
+2 -1
View File
@@ -69,7 +69,7 @@ impl ChatWidget {
let header = Self::placeholder_session_header_cell(&config);
let active_cell = Some(header);
let current_cwd = Some(config.cwd.to_path_buf());
let current_cwd = PathUri::from_abs_path(&config.cwd);
let effective_service_tier = crate::service_tier_resolution::effective_service_tier(
&config,
&local_settings.notices,
@@ -148,6 +148,7 @@ impl ChatWidget {
initial_user_message,
status_account_display,
remote_connection: None,
app_server_path_convention: None,
statusline_read: None,
statusline_disconnected: false,
snapshot_local_images: false,
@@ -512,7 +512,7 @@ impl ChatWidget {
cloud_submission,
client_user_message_id.clone(),
items,
self.config.cwd.to_path_buf(),
self.session_cwd().to_path_buf(),
AskForApproval::from(self.config.permissions.approval_policy.value()),
active_permission_profile,
effective_mode.model().to_string(),
@@ -164,7 +164,7 @@ impl ChatWidget {
self.permission_popup_request_id = Some(request_id);
self.app_event_tx.send(AppEvent::FetchPermissionProfiles {
request_id,
thread_cwd: self.thread_id.and(self.current_cwd.clone()),
thread_cwd: self.thread_id.map(|_| self.session_cwd().to_path_buf()),
});
}
@@ -60,10 +60,6 @@ impl ChatWidget {
}
}
pub(crate) fn handle_skills_list_response(&mut self, response: SkillsListResponse) {
self.on_list_skills(response);
}
pub(super) fn on_patch_apply_output_delta(&mut self, _item_id: String, _delta: String) {}
pub(super) fn on_guardian_review_notification(
+7 -5
View File
@@ -93,8 +93,8 @@ impl ChatWidget {
if previous_thread_id != Some(session.thread_id) || self.cloud_picker_selection.is_some() {
self.dismiss_stale_model_picker();
}
let connector_scope_changed = previous_thread_id != Some(session.thread_id)
|| self.config.cwd.as_path() != session.cwd.as_path();
let cwd_changed = self.current_cwd != session.cwd;
let connector_scope_changed = previous_thread_id != Some(session.thread_id) || cwd_changed;
self.thread_id = Some(session.thread_id);
self.read_only_history = session.read_only_history;
self.thread_settings_confirmed = session.thread_settings_confirmed;
@@ -119,7 +119,7 @@ impl ChatWidget {
self.bottom_pane
.set_queue_submissions(/*queue_submissions*/ false);
if previous_thread_id != self.thread_id {
if (previous_thread_id.is_some() || self.config.cwd != session.cwd)
if (previous_thread_id.is_some() || cwd_changed)
&& self.status_account_display == Some(StatusAccountDisplay::ApiKey)
{
self.refresh_account_scoped_models();
@@ -144,8 +144,10 @@ impl ChatWidget {
self.current_rollout_path = session.rollout_path.clone();
self.primary_environment_cwd
.clone_from(&session.primary_environment_cwd);
self.current_cwd = Some(session.cwd.to_path_buf());
self.config.cwd = session.cwd.clone();
self.current_cwd = session.cwd.clone();
if let Ok(native_cwd) = session.cwd.to_abs_path() {
self.config.cwd = native_cwd;
}
self.config.model_provider_id = session.model_provider_id.clone();
if previous_thread_id.is_none()
&& let Some(event) = crate::app::provider::refresh_list_if_present(self)
+13 -5
View File
@@ -534,12 +534,23 @@ impl ChatWidget {
fn apply_thread_settings(&mut self, mut settings: ThreadSettings) {
self.invalidate_permission_discovery();
let cwd_changed = self.config.cwd != settings.cwd;
if let Some(environments) = &settings.environments {
self.primary_environment_cwd =
crate::session_state::primary_environment_cwd(environments);
}
self.apply_thread_settings_cwd(settings.cwd.clone());
let Ok(cwd) = crate::app_server_session::decode_thread_cwd(
&settings.cwd,
self.app_server_path_convention,
) else {
tracing::warn!("Invalid cwd in thread settings");
return;
};
let cwd_changed = self.current_cwd != cwd;
self.status_line_project_root_name_cache = None;
if let Ok(local) = cwd.to_abs_path() {
self.apply_thread_settings_cwd(local);
}
self.current_cwd = cwd;
self.config.model_provider_id = settings.model_provider.clone();
self.set_daybreak_enabled(self.daybreak_enabled);
self.set_service_tier(settings.service_tier.clone());
@@ -614,9 +625,6 @@ impl ChatWidget {
if previous_cwd != cwd {
self.permission_discovery = None;
}
self.current_cwd = Some(cwd.to_path_buf());
self.status_line_project_root_name_cache = None;
if !self.config.workspace_roots.contains(&previous_cwd) {
return;
}
+19 -12
View File
@@ -13,12 +13,11 @@ use crate::mention_codec::is_mention_name_char;
use crate::mention_codec::parse_linked_tool_mention;
use crate::skills_helpers::skill_description;
use crate::skills_helpers::skill_display_name;
use codex_app_server_protocol::SkillErrorInfo;
use codex_app_server_protocol::SkillMetadata;
use codex_app_server_protocol::SkillsListEntry;
use codex_app_server_protocol::SkillsListResponse;
use codex_connectors::AppInfo;
use codex_protocol::parse_command::ParsedCommand;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::PathUri;
use codex_utils_plugins::mention_syntax::PLUGIN_TEXT_MENTION_SIGIL;
@@ -143,10 +142,26 @@ impl ChatWidget {
self.add_info_message(summary, /*hint*/ None);
}
pub(crate) fn set_skills_from_response(&mut self, response: &SkillsListResponse) {
let skills = skills_for_cwd(&self.config.cwd, &response.data);
/// Updates skills for the displayed session and returns its load errors.
pub(crate) fn set_skills_from_response(
&mut self,
response: SkillsListResponse,
) -> Vec<SkillErrorInfo> {
let (skills, errors) = response
.data
.into_iter()
.find(|entry| {
crate::app_server_session::decode_thread_cwd(
&LegacyAppPathString::from_path(&entry.cwd),
self.app_server_path_convention,
)
.is_ok_and(|cwd| cwd == self.current_cwd)
})
.map(|entry| (entry.skills, entry.errors))
.unwrap_or_default();
self.skills_all = skills;
self.set_skills(Some(enabled_skills_for_mentions(&self.skills_all)));
errors
}
pub(crate) fn annotate_skill_reads_in_parsed_cmd(
@@ -180,14 +195,6 @@ impl ChatWidget {
}
}
fn skills_for_cwd(cwd: &AbsolutePathBuf, skills_entries: &[SkillsListEntry]) -> Vec<SkillMetadata> {
skills_entries
.iter()
.find(|entry| entry.cwd.as_path() == cwd.as_path())
.map(|entry| entry.skills.clone())
.unwrap_or_default()
}
fn enabled_skills_for_mentions(skills: &[SkillMetadata]) -> Vec<SkillMetadata> {
skills
.iter()
+15 -13
View File
@@ -502,22 +502,21 @@ impl ChatWidget {
self.add_diff_in_progress();
let tx = self.app_event_tx.clone();
let runner = self.workspace_command_runner.clone();
let cwd = self
.current_cwd
.clone()
.unwrap_or_else(|| self.config.cwd.to_path_buf());
let cwd = self.session_cwd().clone();
tokio::spawn(async move {
let text = match runner {
Some(runner) => match get_git_diff(runner.as_ref(), &cwd).await {
Ok((is_git_repo, diff_text)) => {
if is_git_repo {
diff_text
} else {
"`/diff` — _not inside a git repository_".to_string()
Some(runner) => {
match get_git_diff(runner.as_ref(), &cwd.to_path_buf()).await {
Ok((is_git_repo, diff_text)) => {
if is_git_repo {
diff_text
} else {
"`/diff` — _not inside a git repository_".to_string()
}
}
Err(e) => format!("Failed to compute diff: {e}"),
}
Err(e) => format!("Failed to compute diff: {e}"),
},
}
None => "Failed to compute diff: workspace command runner unavailable"
.to_string(),
};
@@ -562,7 +561,10 @@ impl ChatWidget {
}
SlashCommand::Pwd => {
self.add_info_message(
format!("Current working directory: {}", self.config.cwd.display()),
format!(
"Current working directory: {}",
self.session_cwd().inferred_native_path_string()
),
/*hint*/ None,
);
}
+24 -21
View File
@@ -145,7 +145,7 @@ impl ChatWidget {
self.status_line_branch_pending = false;
self.status_line_branch_lookup_complete = false;
} else {
let cwd = self.status_line_cwd().to_path_buf();
let cwd = self.session_cwd().to_path_buf();
self.sync_status_line_branch_state(&cwd);
if !self.status_line_branch_lookup_complete {
self.request_status_line_branch(cwd);
@@ -157,7 +157,7 @@ impl ChatWidget {
self.status_line_git_summary_pending = false;
self.status_line_git_summary_lookup_complete = false;
} else {
let cwd = self.status_line_cwd().to_path_buf();
let cwd = self.session_cwd().to_path_buf();
self.sync_status_line_git_summary_state(&cwd);
if !self.status_line_git_summary_lookup_complete {
self.request_status_line_git_summary(cwd);
@@ -428,7 +428,7 @@ impl ChatWidget {
if !selections.uses_git_branch() {
return;
}
let cwd = self.status_line_cwd().to_path_buf();
let cwd = self.session_cwd().to_path_buf();
self.sync_status_line_branch_state(&cwd);
self.request_status_line_branch(cwd);
}
@@ -438,7 +438,7 @@ impl ChatWidget {
if !selections.uses_git_summary() {
return;
}
let cwd = self.status_line_cwd().to_path_buf();
let cwd = self.session_cwd().to_path_buf();
self.sync_status_line_git_summary_state(&cwd);
self.request_status_line_git_summary(cwd);
}
@@ -487,17 +487,16 @@ impl ChatWidget {
})
}
pub(super) fn status_line_cwd(&self) -> &Path {
self.current_cwd
.as_deref()
.unwrap_or(self.config.cwd.as_path())
/// Working directory reported by the server, falling back to config during startup.
pub(crate) fn session_cwd(&self) -> &PathUri {
&self.current_cwd
}
pub(super) fn status_line_workspace_cwd(&self) -> &Path {
pub(super) fn status_line_workspace_cwd(&self) -> PathBuf {
self.primary_environment_cwd
.as_ref()
.map(|cwd| Path::new(cwd.path.as_str()))
.unwrap_or_else(|| self.status_line_cwd())
.map(|cwd| cwd.path.to_path_buf())
.unwrap_or_else(|| self.session_cwd().to_path_buf())
}
fn workspace_directory_display(&self) -> String {
@@ -512,7 +511,7 @@ impl ChatWidget {
.as_ref()
.is_none_or(|cwd| cwd.is_server_local)
{
format_directory_display(cwd, /*max_width*/ None)
format_directory_display(&cwd, /*max_width*/ None)
} else {
cwd.display().to_string()
}
@@ -549,7 +548,14 @@ impl ChatWidget {
/// Returns a cached project-root display name for the active cwd.
fn status_line_project_root_name(&mut self) -> Option<String> {
let cwd = self.status_line_cwd().to_path_buf();
if self
.remote_connection
.as_ref()
.is_some_and(|connection| !connection.is_local_daemon)
{
return None;
}
let cwd = self.session_cwd().to_abs_path().ok()?.into_path_buf();
if let Some(cache) = &self.status_line_project_root_name_cache
&& cache.cwd == cwd
{
@@ -569,14 +575,11 @@ impl ChatWidget {
/// This prefers the cached project-root name and falls back to the current
/// directory name when no project root can be inferred.
fn terminal_title_project_name(&mut self) -> Option<String> {
let project = self.status_line_project_root_name().or_else(|| {
let cwd = self.status_line_cwd();
Some(
cwd.file_name()
.map(|name| name.to_string_lossy().to_string())
.unwrap_or_else(|| format_directory_display(cwd, /*max_width*/ None)),
)
})?;
let project = self.status_line_project_root_name().unwrap_or_else(|| {
self.session_cwd()
.basename()
.unwrap_or_else(|| self.session_cwd().inferred_native_path_string())
});
Some(Self::truncate_terminal_title_part(
project, /*max_chars*/ 24,
))
@@ -25,8 +25,7 @@ use codex_config::types::StatusLineProviderId;
use codex_config::types::StatusLineSelection;
use codex_features::Feature;
use codex_protocol::ThreadId;
use codex_utils_path_uri::LegacyAppPathString;
use std::path::PathBuf;
use codex_utils_path_uri::PathUri;
use std::time::Duration;
use tokio::sync::oneshot;
use tokio::sync::watch;
@@ -41,7 +40,7 @@ pub(super) struct ActiveStatuslineRead {
thread: Option<ThreadId>,
selection: ProviderId,
provider_from_picker: Option<StatuslineProvider>,
host_cwd: PathBuf,
host_cwd: PathUri,
startup: watch::Sender<()>,
cancel: CancellationToken,
}
@@ -145,7 +144,7 @@ impl ChatWidget {
thread: self.thread_id,
selection,
provider_from_picker,
host_cwd: self.status_line_cwd().to_owned(),
host_cwd: self.session_cwd().clone(),
startup,
cancel: CancellationToken::new(),
});
@@ -236,7 +235,7 @@ impl ActiveStatuslineRead {
self.selection.server.as_str() == id.server
&& self.selection.tool.as_str() == id.tool
})
&& self.host_cwd == chat.status_line_cwd()
&& &self.host_cwd == chat.session_cwd()
}
pub(super) fn server_ready(&self, server: &str) {
@@ -258,12 +257,11 @@ impl ActiveStatuslineRead {
let events = events.clone();
let client = owner.request_handle();
let backend = owner.backend_id();
let cwd = LegacyAppPathString::from_path(&self.host_cwd).to_inferred_path_uri();
let cwd = self.host_cwd.clone();
let cancel = self.cancel.clone();
tokio::spawn(async move {
let result: Option<Result<(), Failure>> = cancel
.run_until_cancelled(async {
let cwd = cwd.ok_or(Failure::LookupUnavailable)?;
let deadline = Instant::now() + LOOKUP_TIMEOUT;
let provider = loop {
let choice = provider_from_picker
@@ -169,12 +169,12 @@ async fn statusline_reader_waits_for_the_displayed_thread_and_keeps_its_result()
assert_eq!(footer(&chat).as_deref(), Some("Initializing…"));
let token = resumed.token;
chat.primary_environment_cwd = Some(crate::session_state::EnvironmentCwd {
path: LegacyAppPathString::from_path(chat.config.cwd.join("executor-checkout").as_path()),
path: chat.config.cwd.join("executor-checkout").into(),
is_server_local: false,
});
chat.refresh_status_line();
assert!(read_events(&mut rx).is_empty());
chat.current_cwd = Some(chat.config.cwd.join("another-project").to_path_buf());
chat.current_cwd = chat.config.cwd.join("another-project").into();
let (reply, snapshot) = oneshot::channel();
chat.handle_statusline_read(
StatuslineReadEvent {
@@ -333,7 +333,7 @@ impl ChatWidget {
usage: self.into(),
workspace: StatuslineStateWorkspace {
cwd: codex_utils_path_uri::LegacyAppPathString::from_path(
self.status_line_workspace_cwd(),
&self.status_line_workspace_cwd(),
),
},
approval,
+1 -1
View File
@@ -281,7 +281,7 @@ impl ChatWidget {
self.bottom_pane.status_elapsed().unwrap_or_default(),
)
}),
cwd: self.config.cwd.clone(),
cwd: self.session_cwd().to_path_buf(),
visualizations,
};
(stream, display)
@@ -17,7 +17,7 @@ fn thread_settings_for_test(
thread_settings: codex_app_server_protocol::ThreadSettings {
disabled_plugin_ids: Vec::new(),
environments: None,
cwd: test_path_buf("/tmp/thread-settings").abs(),
cwd: test_path_buf("/tmp/thread-settings").abs().into(),
approval_policy: AskForApproval::OnRequest,
approvals_reviewer: codex_app_server_protocol::ApprovalsReviewer::AutoReview,
sandbox_policy: codex_app_server_protocol::SandboxPolicy::ReadOnly {
@@ -65,7 +65,7 @@ pub(super) fn configured_thread_session(
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/tmp/thread-settings").abs(),
cwd: test_path_buf("/tmp/thread-settings").abs().into(),
runtime_workspace_roots: vec![test_path_buf("/tmp/thread-settings").abs()],
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -693,7 +693,7 @@ async fn statusline_workspace_follows_primary_executor_and_legacy_settings() {
let id = ThreadId::new();
chat.handle_thread_session(configured_thread_session(id));
let mut update = thread_settings_for_test("gpt-5.2", id);
let host = update.thread_settings.cwd.to_string_lossy().into_owned();
let host = update.thread_settings.cwd.to_string();
let remote = r"C:\executor\checkout";
let primary = codex_app_server_protocol::ThreadEnvironment {
environment_id: "remote".into(),
@@ -763,7 +763,7 @@ async fn thread_settings_updated_updates_visible_state_without_transcript() {
chat.set_feature_enabled(Feature::Apps, /*enabled*/ true);
let thread_id = ThreadId::new();
let mut session = configured_thread_session(thread_id);
session.cwd = test_path_buf("/tmp/original-workspace").abs();
session.cwd = test_path_buf("/tmp/original-workspace").abs().into();
session.thread_settings_confirmed = false;
chat.handle_thread_session(session);
chat.config.permissions.approval_policy =
@@ -776,11 +776,20 @@ async fn thread_settings_updated_updates_visible_state_without_transcript() {
});
let _ = drain_insert_history(&mut rx);
let remote_cwd = if cfg!(windows) {
"/home/alice/repo"
} else {
r"D:\repo"
};
let mut notification = thread_settings_for_test("gpt-5.4", thread_id);
notification.thread_settings.cwd =
codex_utils_path_uri::LegacyAppPathString::from_string(remote_cwd);
chat.handle_server_notification(
ServerNotification::ThreadSettingsUpdated(thread_settings_for_test("gpt-5.4", thread_id)),
ServerNotification::ThreadSettingsUpdated(notification),
/*replay_kind*/ None,
);
assert_eq!(chat.session_cwd().inferred_native_path_string(), remote_cwd);
assert_ne!(chat.connector_scope_generation(), previous_generation);
assert!(chat.connectors_for_mentions().is_none());
assert!(chat.connectors.mention_refresh_in_flight);
@@ -645,7 +645,7 @@ async fn submission_preserves_text_elements_and_local_images() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -758,7 +758,7 @@ async fn submission_includes_configured_active_permission_profile() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: expected_permission_profile,
active_permission_profile: Some(expected_active_permission_profile.clone()),
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -817,7 +817,7 @@ async fn submission_omits_active_permission_profile_for_legacy_snapshot() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: expected_permission_profile,
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -866,7 +866,7 @@ async fn submission_with_remote_and_local_images_keeps_local_placeholder_numberi
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -970,7 +970,7 @@ async fn enter_with_only_remote_images_submits_user_turn() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1043,7 +1043,7 @@ async fn shift_enter_with_only_remote_images_does_not_submit_user_turn() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1088,7 +1088,7 @@ async fn enter_with_only_remote_images_does_not_submit_when_modal_is_active() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1133,7 +1133,7 @@ async fn enter_with_only_remote_images_does_not_submit_when_input_disabled() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1181,7 +1181,7 @@ async fn submission_prefers_selected_duplicate_skill_path() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1304,7 +1304,7 @@ async fn bang_shell_enter_while_task_running_submits_run_user_shell_command() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -36,7 +36,7 @@ async fn resumed_initial_messages_render_history() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -90,7 +90,7 @@ async fn resumed_initial_messages_render_history() {
chat.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ true);
chat.show_welcome_banner = false;
chat.local_settings.tui.show_tooltips = false;
chat.config.cwd = configured.cwd.clone();
chat.config.cwd = configured.cwd.to_abs_path().ok().unwrap();
chat.transcript.active_cell = Some(ChatWidget::placeholder_session_header_cell(&chat.config));
configured.thread_id = ThreadId::new();
chat.handle_thread_session(configured);
@@ -201,7 +201,7 @@ async fn restored_conversation_ultra_remains_selected_after_switching_to_plan()
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::Ultra),
@@ -527,7 +527,7 @@ async fn replayed_user_message_preserves_text_elements_and_local_images() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -603,7 +603,7 @@ async fn replayed_user_message_preserves_remote_image_urls() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -709,7 +709,7 @@ async fn session_configured_syncs_widget_config_permissions_and_cwd() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: expected_permission_profile,
active_permission_profile: None,
cwd: expected_cwd.clone(),
cwd: expected_cwd.clone().into(),
runtime_workspace_roots: vec![expected_cwd.clone()],
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -734,8 +734,8 @@ async fn session_configured_syncs_widget_config_permissions_and_cwd() {
chat.handle_manage_skills_closed();
assert!(matches!(
ops.try_recv(),
Ok(AppCommand::ListSkills { cwds, force_reload: true })
if cwds == vec![expected_cwd.to_path_buf()]
Ok(AppCommand::ListSkills { cwd, force_reload: true })
if cwd == PathUri::from_abs_path(&expected_cwd)
));
let updated_profile = PermissionProfile::workspace_write();
@@ -791,7 +791,7 @@ async fn session_configured_preserves_profile_workspace_roots() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: session_permission_profile.clone(),
active_permission_profile: None,
cwd: session_cwd.clone(),
cwd: session_cwd.clone().into(),
runtime_workspace_roots: session_runtime_workspace_roots.clone(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -839,7 +839,7 @@ async fn session_configured_external_sandbox_keeps_external_runtime_policy() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: expected_permission_profile,
active_permission_profile: None,
cwd: test_path_buf("/home/user/external").abs(),
cwd: test_path_buf("/home/user/external").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -882,7 +882,7 @@ async fn replayed_user_message_with_only_remote_images_renders_history_cell() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -946,7 +946,7 @@ async fn replayed_user_message_with_only_local_images_renders_history_cell() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1307,7 +1307,7 @@ async fn replayed_reasoning_item_preserves_summary_parts_and_hides_raw_reasoning
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_project_path().abs(),
cwd: test_project_path().abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -1362,7 +1362,7 @@ async fn replayed_reasoning_item_shows_raw_reasoning_when_enabled() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_project_path().abs(),
cwd: test_project_path().abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -1178,7 +1178,7 @@ async fn required_windows_sandbox_setup_defers_configured_initial_prompt() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::workspace_write(),
active_permission_profile: None,
cwd: test_project_path().abs(),
cwd: test_project_path().abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -1631,7 +1631,7 @@ async fn permissions_selection_marks_auto_review_current_after_session_configure
approvals_reviewer: ApprovalsReviewer::AutoReview,
permission_profile: PermissionProfile::workspace_write(),
active_permission_profile: None,
cwd: test_project_path().abs(),
cwd: test_project_path().abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -1688,7 +1688,7 @@ async fn permissions_selection_marks_auto_review_current_with_custom_workspace_w
approvals_reviewer: ApprovalsReviewer::AutoReview,
permission_profile,
active_permission_profile: None,
cwd,
cwd: cwd.into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: None,
@@ -32,7 +32,7 @@ fn plan_test_session(thread_id: ThreadId) -> crate::session_state::ThreadSession
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -1248,7 +1248,7 @@ async fn submit_user_message_emits_structured_plugin_mentions_from_bindings() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -3389,6 +3389,11 @@ async fn slash_pwd_and_cwd_alias_display_current_working_directory_from_composer
let mut output = Vec::new();
for (command, side) in [("/pwd", false), ("/cwd", true), ("/pwd x", false)] {
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
if side {
chat.current_cwd =
PathUri::try_from(LegacyAppPathString::from_string(r"D:\workspace\remote"))
.expect("absolute server path");
}
chat.set_side_conversation_active(side);
chat.bottom_pane.set_task_running(!side);
chat.bottom_pane
@@ -3400,7 +3405,7 @@ async fn slash_pwd_and_cwd_alias_display_current_working_directory_from_composer
}
insta::assert_snapshot!(output.join(""), @r"
• Current working directory: /tmp/project
• Current working directory: /tmp/project
• Current working directory: D:\workspace\remote
■ Usage: /pwd
");
}
@@ -4800,7 +4800,7 @@ async fn session_configured_clears_goal_status_footer() {
approvals_reviewer: ApprovalsReviewer::User,
permission_profile: PermissionProfile::read_only(),
active_permission_profile: None,
cwd: test_path_buf("/home/user/project").abs(),
cwd: test_path_buf("/home/user/project").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_source_paths: Vec::new(),
reasoning_effort: Some(ReasoningEffortConfig::default()),
@@ -565,6 +565,17 @@ async fn missing_project_root_uses_different_status_and_title_preview_sources()
assert_eq!(status_preview, "my-project");
assert_eq!(title_preview, "project");
chat.remote_connection = crate::status::remote_connection::remote_connection_status_value(
&crate::AppServerTarget::Cloud,
/*server_version*/ None,
);
chat.current_cwd = PathUri::try_from(LegacyAppPathString::from_string(r"D:\workspace\remote"))
.expect("absolute server path");
assert_snapshot!(
title_preview_line(&mut chat, &[TerminalTitleItem::Project]),
@"remote"
);
}
#[tokio::test]

Some files were not shown because too many files have changed in this diff Show More