Files
codex/codex-rs/tui/src/config_update_tests.rs
T
Eric Traut 3acd71fedb Surface TUI config write error causes (#26537)
## Summary

TUI config writes currently wrap app-server failures with local context
like `config/batchWrite failed in TUI`, but several user-visible paths
only render the outer error. That hides the actionable app-server
message, such as validation constraints or read-only `CODEX_HOME`
failures, leaving users with a dead-end diagnostic.

This change adds a small formatter next to the TUI config write helpers
that renders the error source chain, then uses it for model persistence,
feature persistence, project trust, status line writes, hook trust, and
hook enablement.

Fixes #26077
2026-06-05 08:32:07 -07:00

41 lines
1.2 KiB
Rust

use super::*;
use color_eyre::eyre::WrapErr;
use pretty_assertions::assert_eq;
use std::path::Path;
#[test]
fn app_scoped_key_path_quotes_dotted_app_ids() {
assert_eq!(
app_scoped_key_path("plugin.linear", "enabled"),
"apps.\"plugin.linear\".enabled"
);
}
#[test]
fn trusted_project_edit_targets_project_trust_level() {
assert_eq!(
trusted_project_edit(Path::new("/workspace/team.project")),
ConfigEdit {
key_path: "projects.\"/workspace/team.project\".trust_level".to_string(),
value: serde_json::json!("trusted"),
merge_strategy: MergeStrategy::Replace,
}
);
}
#[test]
fn format_config_error_preserves_server_validation_message() {
let err = Err::<(), _>(color_eyre::eyre::eyre!(
"config/batchWrite failed: Invalid configuration: features.fast_mode=true violates \
managed requirements; allowed set [fast_mode=false]"
))
.wrap_err("config/batchWrite failed in TUI")
.unwrap_err();
assert_eq!(
format_config_error(&err),
"config/batchWrite failed in TUI: config/batchWrite failed: Invalid configuration: \
features.fast_mode=true violates managed requirements; allowed set [fast_mode=false]"
);
}