Files
codex/codex-rs/tui/src/chatwidget/empty_state_policy.rs
T
Benjamin Carlsson 2bad26e03f Centralize TUI read-only view checks (#61353)
## What changed

Add `ChatWidget::is_read_only_view()` and use it for read-only guards across input handling, navigation, transcript rendering, and session restoration. The new helper delegates to `is_external_writer_view()`, preserving existing behavior.

GitOrigin-RevId: c8fd66526f502d79be306a19ee261e79c5abcd57
2026-11-13 18:50:28 +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.is_read_only_view() && !self.has_provider_error() =>
{
self.bottom_pane.empty_state_composer()
}
ExternalEditorState::Closed => None,
}
}
}