mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
## Why [#22581](https://github.com/openai/codex/pull/22581) started separating the chat composer’s responsibilities, but `ChatComposer` still owned the remaining editable draft state alongside footer/status presentation state. This follow-up makes those ownership lines explicit so future composer changes have a smaller blast radius and `BottomPane` does not need to keep exposing scattered draft getters. This is just a refactor. No functional or behavioral changes are intended. ## What changed - Move the remaining editable composer state into `bottom_pane/chat_composer/draft_state.rs`. - Move footer and status-row presentation state into `bottom_pane/chat_composer/footer_state.rs`. - Add an internal `ComposerDraftSnapshot` for restore flows, replacing several ad hoc `BottomPane` pass-through reads. - Rewire the related history-search and thread-input restore paths to use the extracted state. ## Verification - `RUST_MIN_STACK=8388608 cargo test -p codex-tui` - `cargo insta pending-snapshots`
46 lines
1.5 KiB
Rust
46 lines
1.5 KiB
Rust
//! Editable composer draft state kept separate from composer control flow.
|
|
|
|
use std::cell::RefCell;
|
|
use std::collections::HashMap;
|
|
|
|
use crate::bottom_pane::MentionBinding;
|
|
use crate::bottom_pane::paste_burst::PasteBurst;
|
|
use crate::bottom_pane::textarea::TextArea;
|
|
use crate::bottom_pane::textarea::TextAreaState;
|
|
|
|
pub(super) struct DraftState {
|
|
pub(super) textarea: TextArea,
|
|
pub(super) textarea_state: RefCell<TextAreaState>,
|
|
pub(super) is_bash_mode: bool,
|
|
pub(super) pending_pastes: Vec<(String, String)>,
|
|
pub(super) input_enabled: bool,
|
|
pub(super) input_disabled_placeholder: Option<String>,
|
|
pub(super) paste_burst: PasteBurst,
|
|
pub(super) disable_paste_burst: bool,
|
|
pub(super) mention_bindings: HashMap<u64, ComposerMentionBinding>,
|
|
pub(super) recent_submission_mention_bindings: Vec<MentionBinding>,
|
|
}
|
|
|
|
impl DraftState {
|
|
pub(super) fn new() -> Self {
|
|
Self {
|
|
textarea: TextArea::new(),
|
|
textarea_state: RefCell::new(TextAreaState::default()),
|
|
is_bash_mode: false,
|
|
pending_pastes: Vec::new(),
|
|
input_enabled: true,
|
|
input_disabled_placeholder: None,
|
|
paste_burst: PasteBurst::default(),
|
|
disable_paste_burst: false,
|
|
mention_bindings: HashMap::new(),
|
|
recent_submission_mention_bindings: Vec::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub(super) struct ComposerMentionBinding {
|
|
pub(super) mention: String,
|
|
pub(super) path: String,
|
|
}
|