Files
codex/codex-rs/tui/src/chatwidget/empty_state_policy.rs
T
Abhinav 55c099a142 Keep chats accessible across model provider changes (#58202)
## Why

Switching model providers can hide saved chats from resume lookup or prevent them from opening. Keep their history readable when the server rejects resuming because of a provider mismatch, missing configuration, or policy conflict.

## What changed

- Include all providers in the resume picker, named resume lookup, and `resume --last`, while retaining provider filtering for fork lookup.
- Open chats with provider errors as read-only history and show an explanation with recovery shortcuts: `c` to continue in a new chat, `n` to start fresh, and `Esc` to choose another chat.
- Continuing in a new chat prepares an editable, unsent prompt referencing the saved conversation.
- Preserve drafts and rejected prompts or steers, suppress automatic submission, and retry provider admission when reopening the chat.

## Testing

Add coverage for cross-provider discovery, read-only history, configuration recovery, continuation drafts, rejected input recovery, error rendering, and Escape handling during transcript browsing.

GitOrigin-RevId: 5aaa7a404b9a6231101599adef18d2f1e4a8020a
2026-10-30 00:45:30 +00:00

40 lines
1.4 KiB
Rust

//! Gate decoration on startup-only live content and an ordinary, locally editable composer.
//! Content eligibility is latched off independently of temporary view ownership.
use super::*;
use crate::empty_state_animation::ComposerState;
use crate::empty_state_animation::is_startup_cell;
impl ChatWidget {
pub(crate) fn empty_state_composer(&self) -> Option<ComposerState> {
let startup_only = self
.transcript
.active_cell
.as_deref()
.into_iter()
.chain(
self.realtime_conversation
.pending_history_cells
.iter()
.chain(self.realtime_conversation.live_transcript_cells())
.map(AsRef::as_ref),
)
.all(is_startup_cell);
if !startup_only
|| self.is_user_turn_pending_or_running()
|| self.initial_user_message.is_some()
{
self.empty_state_animation.borrow_mut().dismiss();
}
match self.external_editor_state {
ExternalEditorState::Requested | ExternalEditorState::Active => None,
ExternalEditorState::Closed
if !self.external_writer_view && !self.has_provider_error() =>
{
self.bottom_pane.empty_state_composer()
}
ExternalEditorState::Closed => None,
}
}
}