Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix(tui): restore cancelled prompt cursor at end (#26457)

Felipe Coury679a944dbcdd
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index 5a39b53aa9..6ebfac4335 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -1258,6 +1258,11 @@ impl ChatComposer {
self.draft.textarea.cursor() + if self.draft.is_bash_mode { 1 } else { 0 }
}
+ #[cfg(test)]
+ pub(crate) fn cursor(&self) -> usize {
+ self.current_cursor()
+ }
+
fn history_navigation_cursor(&self) -> usize {
if self.draft.is_bash_mode && self.draft.textarea.cursor() == 0 {
0
diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs
index 9bada615f6..cdd4c752d3 100644
--- a/codex-rs/tui/src/bottom_pane/mod.rs
+++ b/codex-rs/tui/src/bottom_pane/mod.rs
@@ -786,6 +786,7 @@ impl BottomPane {
local_image_paths,
mention_bindings,
);
+ self.composer.move_cursor_to_end();
self.request_redraw();
}
@@ -824,6 +825,11 @@ impl BottomPane {
self.composer.current_text()
}
+ #[cfg(test)]
+ pub(crate) fn composer_cursor(&self) -> usize {
+ self.composer.cursor()
+ }
+
pub(crate) fn composer_draft_snapshot(&self) -> chat_composer::ComposerDraftSnapshot {
self.composer.draft_snapshot()
}
diff --git a/codex-rs/tui/src/chatwidget/tests/composer_submission.rs b/codex-rs/tui/src/chatwidget/tests/composer_submission.rs
index f3e32b2eb4..154add1d67 100644
--- a/codex-rs/tui/src/chatwidget/tests/composer_submission.rs
+++ b/codex-rs/tui/src/chatwidget/tests/composer_submission.rs
@@ -730,6 +730,7 @@ async fn queued_restore_with_remote_images_keeps_local_placeholder_mapping() {
});
assert_eq!(chat.bottom_pane.composer_text(), text);
+ assert_eq!(chat.bottom_pane.composer_cursor(), text.len());
assert_eq!(chat.bottom_pane.composer_text_elements(), text_elements);
assert_eq!(chat.bottom_pane.composer_local_images(), local_images);
assert_eq!(chat.remote_image_urls(), remote_image_urls);