mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
tui/exec: show effective workspace roots in summaries (#22612)
## Why This PR builds on [#22611](https://github.com/openai/codex/pull/22611). After `runtimeWorkspaceRoots` moved onto thread state, the user-facing summaries were still inconsistent about which roots they showed. In particular, `/status` and the exec startup summary could under-report extra workspace roots from `--add-dir` or from profile-defined `workspace_roots`, which made the new model look incorrect even when the permissions themselves were right. ## What Changed - switched the TUI status surfaces to summarize against `Config::effective_workspace_roots()` - updated the exec human-output summary to render from the effective permission profile instead of the raw constrained profile - added focused regressions for both the TUI and exec code paths so extra workspace roots stay visible in user-facing summaries ## Verification Targeted coverage for this follow-up lives in: - `codex-rs/tui/src/status/tests.rs` - `codex-rs/exec/src/event_processor_with_human_output_tests.rs` The added regressions verify that: - status output includes profile-defined workspace roots in the effective permissions summary - exec startup output includes runtime workspace roots instead of collapsing back to `cwd` only
This commit is contained in:
@@ -902,11 +902,9 @@ fn permissions_display(config: &Config) -> String {
|
||||
}
|
||||
|
||||
let permission_profile = config.permissions.effective_permission_profile();
|
||||
let summary = summarize_permission_profile(
|
||||
&permission_profile,
|
||||
&config.cwd,
|
||||
config.permissions.workspace_roots(),
|
||||
);
|
||||
let workspace_roots = config.effective_workspace_roots();
|
||||
let summary =
|
||||
summarize_permission_profile(&permission_profile, &config.cwd, workspace_roots.as_slice());
|
||||
if let Some(details) = summary.strip_prefix("read-only")
|
||||
&& !details.contains("(network access enabled)")
|
||||
{
|
||||
|
||||
@@ -256,7 +256,7 @@ impl StatusHistoryCell {
|
||||
) -> (Self, StatusHistoryHandle) {
|
||||
let approval_policy = AskForApproval::from(config.permissions.approval_policy.value());
|
||||
let permission_profile = config.permissions.effective_permission_profile();
|
||||
let workspace_roots = config.permissions.user_visible_workspace_roots();
|
||||
let workspace_roots = config.effective_workspace_roots();
|
||||
let mut config_entries = vec![
|
||||
("workdir", config.cwd.display().to_string()),
|
||||
("model", model_name.to_string()),
|
||||
@@ -267,7 +267,11 @@ impl StatusHistoryCell {
|
||||
),
|
||||
(
|
||||
"sandbox",
|
||||
summarize_permission_profile(&permission_profile, &config.cwd, workspace_roots),
|
||||
summarize_permission_profile(
|
||||
&permission_profile,
|
||||
&config.cwd,
|
||||
workspace_roots.as_slice(),
|
||||
),
|
||||
),
|
||||
];
|
||||
if config.model_provider.wire_api == WireApi::Responses {
|
||||
@@ -291,8 +295,9 @@ impl StatusHistoryCell {
|
||||
.map(|(_, v)| v.clone())
|
||||
.unwrap_or_else(|| "<unknown>".to_string());
|
||||
let active_permission_profile = config.permissions.active_permission_profile();
|
||||
let sandbox = status_permission_summary(&permission_profile, &config.cwd, workspace_roots);
|
||||
let workspace_root_suffix = workspace_root_suffix(workspace_roots, &config.cwd);
|
||||
let sandbox =
|
||||
status_permission_summary(&permission_profile, &config.cwd, workspace_roots.as_slice());
|
||||
let workspace_root_suffix = workspace_root_suffix(workspace_roots.as_slice(), &config.cwd);
|
||||
let approval = status_approval_label(approval_policy, config.approvals_reviewer, &approval);
|
||||
let permissions = status_permissions_label(
|
||||
active_permission_profile.as_ref(),
|
||||
|
||||
@@ -463,6 +463,40 @@ async fn status_permissions_workspace_roots_show_additional_directories() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn status_permissions_workspace_roots_include_profile_defined_directories() {
|
||||
let temp_home = TempDir::new().expect("temp home");
|
||||
let mut config = test_config(&temp_home).await;
|
||||
set_workspace_cwd(&mut config, test_path_buf("/workspace/tests").abs());
|
||||
config
|
||||
.permissions
|
||||
.approval_policy
|
||||
.set(AskForApproval::OnRequest.to_core())
|
||||
.expect("set approval policy");
|
||||
let profile_root = test_path_buf("/workspace/shared").abs();
|
||||
config
|
||||
.permissions
|
||||
.set_permission_profile_from_session_snapshot_with_profile_workspace_roots(
|
||||
PermissionProfile::workspace_write_with(
|
||||
std::slice::from_ref(&profile_root),
|
||||
NetworkSandboxPolicy::Restricted,
|
||||
/*exclude_tmpdir_env_var*/ false,
|
||||
/*exclude_slash_tmp*/ false,
|
||||
),
|
||||
Some(ActivePermissionProfile::new(":workspace")),
|
||||
vec![profile_root.clone()],
|
||||
)
|
||||
.expect("set permission profile");
|
||||
|
||||
assert_eq!(
|
||||
permissions_text_for(&config),
|
||||
Some(format!(
|
||||
"Workspace [{}] (on-request)",
|
||||
profile_root.display()
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn status_permissions_broadened_workspace_profile_shows_builtin_label() {
|
||||
let temp_home = TempDir::new().expect("temp home");
|
||||
|
||||
Reference in New Issue
Block a user