Files
codex/codex-rs/tui/src/chatwidget/warnings.rs
T
andrewgu-oai e53c444964 Warn about ignored configuration settings (#44691)
## Why

Unrecognized settings can be silently ignored, leaving typos or deprecated configuration unnoticed.

## What changed

- Collect warnings for unrecognized fields in effective configuration and requirements layers, including unknown feature keys in configuration.
- Report sources and field names without configuration values, show up to three entries, and provide migration hints for `network_proxy`, `allowed_permissions`, and `include_view_image_tool`.
- Emit project-specific warnings when starting a thread and suppress repeated startup warnings in the app server and TUI.

## Testing

Add coverage for merged configuration, disabled layers, startup and project warning delivery, omission of configuration values, and warning deduplication.

GitOrigin-RevId: 464cef87882502b19865ae10b50b6f82defb7296
2026-09-11 00:55:51 +00:00

29 lines
1.1 KiB
Rust

use std::collections::HashSet;
const FALLBACK_MODEL_METADATA_WARNING_PREFIX: &str = "Model metadata for `";
const FALLBACK_MODEL_METADATA_WARNING_SUFFIX: &str =
"` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.";
#[derive(Default)]
pub(super) struct WarningDisplayState {
/// Completed resume history does not end startup; active work does.
pub(super) startup_complete: bool,
/// Initialization config warnings may also arrive as ordinary thread warnings.
pub(super) startup_config_warnings: HashSet<String>,
fallback_model_metadata_slugs: HashSet<String>,
}
impl WarningDisplayState {
pub(super) fn should_display(&mut self, message: &str) -> bool {
!self.startup_config_warnings.contains(message)
&& fallback_model_metadata_warning_slug(message)
.is_none_or(|slug| self.fallback_model_metadata_slugs.insert(slug.to_string()))
}
}
fn fallback_model_metadata_warning_slug(message: &str) -> Option<&str> {
message
.strip_prefix(FALLBACK_MODEL_METADATA_WARNING_PREFIX)?
.strip_suffix(FALLBACK_MODEL_METADATA_WARNING_SUFFIX)
}