mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Centralize transcript overlay input routing (#62384)
## What changed Use `Overlay::input_transcript` to determine which overlay handles transcript interaction keys and which keymap context applies during search and selection. Apply runtime keymap bindings through `Overlay` so the app can refresh them without matching the transcript variant directly. GitOrigin-RevId: 3592ddb62a6bddb760e2923604faff41a28cd150
This commit is contained in:
@@ -1036,9 +1036,9 @@ impl App {
|
||||
return Ok(AppRunControl::Continue);
|
||||
}
|
||||
let transcript_owns_input = match (&event, &self.overlay) {
|
||||
(TuiEvent::Key(key), Some(Overlay::Transcript(overlay))) => {
|
||||
overlay.owns_interaction_key(*key)
|
||||
}
|
||||
(TuiEvent::Key(key), Some(overlay)) => overlay
|
||||
.input_transcript()
|
||||
.is_some_and(|view| view.owns_interaction_key(*key)),
|
||||
(TuiEvent::Key(key), None) => {
|
||||
tui.is_owned_screen()
|
||||
&& self.chat_widget.no_modal_or_popup_active()
|
||||
|
||||
@@ -94,7 +94,7 @@ impl App {
|
||||
self.chat_widget
|
||||
.observe_config_editor_transition_key_event(key_event);
|
||||
self.transcript_view.set_keymap_bindings(&self.keymap);
|
||||
if let Some(Overlay::Transcript(overlay)) = &mut self.overlay {
|
||||
if let Some(overlay) = &mut self.overlay {
|
||||
overlay.set_keymap_bindings(&self.keymap);
|
||||
}
|
||||
if self.overlay.is_none() && self.chat_widget.handle_quick_dial_menu(key_event) {
|
||||
@@ -102,7 +102,11 @@ impl App {
|
||||
}
|
||||
let contexts = self.key_chord_contexts(tui);
|
||||
let select_mode_chord = self.select_mode_owns_chord(tui, key_event);
|
||||
if (matches!(&self.overlay, Some(Overlay::Transcript(overlay)) if overlay.owns_interaction_key(key_event))
|
||||
if (self
|
||||
.overlay
|
||||
.as_ref()
|
||||
.and_then(Overlay::input_transcript)
|
||||
.is_some_and(|view| view.owns_interaction_key(key_event))
|
||||
|| (tui.is_owned_screen()
|
||||
&& self.overlay.is_none()
|
||||
&& !self.focused_sidebar_chooser(tui)
|
||||
@@ -285,16 +289,16 @@ impl App {
|
||||
use crate::keymap::KeymapContextSet;
|
||||
|
||||
if let Some(overlay) = &self.overlay {
|
||||
let contexts = match overlay {
|
||||
Overlay::Transcript(view) if view.is_search_editing() => {
|
||||
let contexts = match overlay.input_transcript() {
|
||||
Some(view) if view.is_search_editing() => {
|
||||
KeymapContextSet::new(KeymapContext::Editor)
|
||||
}
|
||||
Overlay::Transcript(view) if view.is_select_mode() => {
|
||||
Some(view) if view.is_select_mode() => {
|
||||
KeymapContextSet::transcript().with_transcript_select()
|
||||
}
|
||||
_ if self.backtrack.overlay_preview_active => KeymapContextSet::browsing(),
|
||||
Overlay::Transcript(_) => KeymapContextSet::transcript(),
|
||||
_ => KeymapContextSet::new(KeymapContext::Pager),
|
||||
Some(_) => KeymapContextSet::transcript(),
|
||||
None => KeymapContextSet::new(KeymapContext::Pager),
|
||||
};
|
||||
return contexts.with_voice_toggle(&self.keymap);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Transcript selection chord routing kept outside the central application input path.
|
||||
|
||||
use super::super::*;
|
||||
use crate::pager_overlay::TranscriptOverlay;
|
||||
|
||||
impl App {
|
||||
pub(crate) fn transcript_select_exit_key(event: &TuiEvent) -> Option<KeyBinding> {
|
||||
@@ -15,27 +16,24 @@ impl App {
|
||||
}
|
||||
|
||||
pub(super) fn select_mode_owns_chord(&self, tui: &tui::Tui, key_event: KeyEvent) -> bool {
|
||||
let select_mode = matches!(
|
||||
&self.overlay,
|
||||
Some(Overlay::Transcript(overlay)) if overlay.is_select_mode()
|
||||
) || (tui.is_owned_screen()
|
||||
&& self.overlay.is_none()
|
||||
&& (self.focused_document().map_or_else(
|
||||
|| self.transcript_view.is_select_mode(),
|
||||
super::super::sidebar_document::Document::is_select_mode,
|
||||
)));
|
||||
let transcript = self.overlay.as_ref().and_then(Overlay::input_transcript);
|
||||
let select_mode = transcript.is_some_and(TranscriptOverlay::is_select_mode)
|
||||
|| (tui.is_owned_screen()
|
||||
&& self.overlay.is_none()
|
||||
&& (self.focused_document().map_or_else(
|
||||
|| self.transcript_view.is_select_mode(),
|
||||
super::super::sidebar_document::Document::is_select_mode,
|
||||
)));
|
||||
if !select_mode {
|
||||
return false;
|
||||
}
|
||||
let contexts = self.key_chord_contexts(tui);
|
||||
let search_editing = matches!(
|
||||
&self.overlay,
|
||||
Some(Overlay::Transcript(overlay)) if overlay.is_search_editing()
|
||||
) || (self.overlay.is_none()
|
||||
&& self.focused_document().map_or_else(
|
||||
|| self.transcript_view.is_search_editing(),
|
||||
super::super::sidebar_document::Document::is_search_editing,
|
||||
));
|
||||
let search_editing = transcript.is_some_and(TranscriptOverlay::is_search_editing)
|
||||
|| (self.overlay.is_none()
|
||||
&& self.focused_document().map_or_else(
|
||||
|| self.transcript_view.is_search_editing(),
|
||||
super::super::sidebar_document::Document::is_search_editing,
|
||||
));
|
||||
let (code, modifiers) =
|
||||
crate::key_hint::normalize_key_parts(key_event.code, key_event.modifiers);
|
||||
let fixed_search_control = search_editing
|
||||
|
||||
@@ -48,6 +48,14 @@ pub(crate) enum Overlay {
|
||||
}
|
||||
|
||||
impl Overlay {
|
||||
/// Use for input routing. Only the coding transcript should receive live thread history.
|
||||
pub(crate) fn input_transcript(&self) -> Option<&TranscriptOverlay> {
|
||||
match self {
|
||||
Self::Transcript(view) => Some(view),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new_transcript(
|
||||
cells: Vec<Arc<dyn HistoryCell>>,
|
||||
keymap: PagerKeymap,
|
||||
|
||||
@@ -33,6 +33,14 @@ pub(crate) struct TranscriptOverlay {
|
||||
is_done: bool,
|
||||
}
|
||||
|
||||
impl Overlay {
|
||||
pub(crate) fn set_keymap_bindings(&mut self, keymap: &RuntimeKeymap) {
|
||||
if let Self::Transcript(view) = self {
|
||||
view.set_keymap_bindings(keymap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TranscriptOverlay {
|
||||
pub(crate) fn bookmark(&mut self) -> TranscriptBookmark {
|
||||
self.view.bookmark(&self.cells)
|
||||
|
||||
Reference in New Issue
Block a user