[codex] Dedupe fallback model metadata warnings (#21090)

Fixes #21070.

This is a small cleanup around model metadata handling for
gateway/provider model names. It follows the report and proposed
direction from @dkbush by keeping the fallback metadata warning useful
without repeating it every turn, and by tightening the existing
provider-prefix lookup path.

- Track fallback metadata warning slugs in session state so each
unresolved model warns once per session.
- Keep warning emission outside the session-state lock and preserve the
existing warning text.
- Allow one-segment provider prefixes with hyphenated provider IDs,
while preserving the multi-segment rejection behavior.
- Add focused coverage for warning dedupe and hyphenated provider-prefix
metadata matching.

Testing:

- Ran `just fmt`.
- Ran `git diff --check`.
- Added tests for the new warning dedupe and provider-prefix lookup
behavior.
This commit is contained in:
canvrno-oai authored and GitHub committed 2026-05-06 13:11:44 -07:00
1 parent 63a27ad6c6
commit d5f0b6d63a
6 files changed
+82 -6

No files matched your search

+9 -1
View File
@@ -351,6 +351,8 @@ use self::status_surfaces::TerminalTitleStatusKind;
mod user_messages;
use self::user_messages::PendingSteerCompareKey;
use self::user_messages::UserMessageDisplay;
mod warnings;
use self::warnings::WarningDisplayState;
pub(crate) use crate::branch_summary::StatusLineGitSummary;
use crate::streaming::chunking::AdaptiveChunkingPolicy;
use crate::streaming::commit_tick::CommitTickScope;
@@ -780,6 +782,7 @@ pub(crate) struct ChatWidget {
plan_type: Option<PlanType>,
codex_rate_limit_reached_type: Option<RateLimitReachedType>,
rate_limit_warnings: RateLimitWarningState,
warning_display_state: WarningDisplayState,
rate_limit_switch_prompt: RateLimitSwitchPromptState,
add_credits_nudge_email_in_flight: Option<AddCreditsNudgeCreditType>,
adaptive_chunking: AdaptiveChunkingPolicy,
@@ -3133,7 +3136,11 @@ impl ChatWidget {
}
fn on_warning(&mut self, message: impl Into<String>) {
self.add_to_history(history_cell::new_warning_event(message.into()));
let message = message.into();
if !self.warning_display_state.should_display(&message) {
return;
}
self.add_to_history(history_cell::new_warning_event(message));
self.request_redraw();
}
@@ -4941,6 +4948,7 @@ impl ChatWidget {
plan_type: initial_plan_type,
codex_rate_limit_reached_type: None,
rate_limit_warnings: RateLimitWarningState::default(),
warning_display_state: WarningDisplayState::default(),
rate_limit_switch_prompt: RateLimitSwitchPromptState::default(),
add_credits_nudge_email_in_flight: None,
adaptive_chunking: AdaptiveChunkingPolicy::default(),