Skip to content

Commit 7a80d3c

Browse files
replace /prompts with a rotating placeholder (#2314)
1 parent d3078b9 commit 7a80d3c

File tree

11 files changed

+84
-72
lines changed

11 files changed

+84
-72
lines changed

codex-rs/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/tui/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ tui-markdown = "0.3.3"
7575
unicode-segmentation = "1.12.0"
7676
unicode-width = "0.1"
7777
uuid = "1"
78+
rand = "0.9"
7879

7980
[target.'cfg(unix)'.dependencies]
8081
libc = "0.2"
@@ -84,5 +85,5 @@ libc = "0.2"
8485
chrono = { version = "0.4", features = ["serde"] }
8586
insta = "1.43.1"
8687
pretty_assertions = "1"
87-
rand = "0.8"
88+
rand = "0.9"
8889
vt100 = "0.16.2"

codex-rs/tui/src/app.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ impl App<'_> {
416416
widget.add_status_output();
417417
}
418418
}
419-
SlashCommand::Prompts => {
420-
if let AppState::Chat { widget } = &mut self.app_state {
421-
widget.add_prompts_output();
422-
}
423-
}
424419
#[cfg(debug_assertions)]
425420
SlashCommand::TestApproval => {
426421
use codex_core::protocol::EventMsg;

codex-rs/tui/src/bottom_pane/approval_modal_view.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ mod tests {
9898
app_event_tx: AppEventSender::new(tx_raw2),
9999
has_input_focus: true,
100100
enhanced_keys_supported: false,
101+
placeholder_text: "Ask Codex to do anything".to_string(),
101102
});
102103
assert_eq!(CancellationEvent::Handled, view.on_ctrl_c(&mut pane));
103104
assert!(view.queue.is_empty());

codex-rs/tui/src/bottom_pane/chat_composer.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use crate::bottom_pane::textarea::TextAreaState;
3131
use codex_file_search::FileMatch;
3232
use std::cell::RefCell;
3333

34-
const BASE_PLACEHOLDER_TEXT: &str = "Ask Codex to do anything";
3534
/// If the pasted content exceeds this number of characters, replace it with a
3635
/// placeholder in the UI.
3736
const LARGE_PASTE_CHAR_THRESHOLD: usize = 1000;
@@ -61,6 +60,7 @@ pub(crate) struct ChatComposer {
6160
pending_pastes: Vec<(String, String)>,
6261
token_usage_info: Option<TokenUsageInfo>,
6362
has_focus: bool,
63+
placeholder_text: String,
6464
}
6565

6666
/// Popup state – at most one can be visible at any time.
@@ -75,6 +75,7 @@ impl ChatComposer {
7575
has_input_focus: bool,
7676
app_event_tx: AppEventSender,
7777
enhanced_keys_supported: bool,
78+
placeholder_text: String,
7879
) -> Self {
7980
let use_shift_enter_hint = enhanced_keys_supported;
8081

@@ -91,6 +92,7 @@ impl ChatComposer {
9192
pending_pastes: Vec::new(),
9293
token_usage_info: None,
9394
has_focus: has_input_focus,
95+
placeholder_text,
9496
}
9597
}
9698

@@ -712,7 +714,7 @@ impl WidgetRef for &ChatComposer {
712714
let mut state = self.textarea_state.borrow_mut();
713715
StatefulWidgetRef::render_ref(&(&self.textarea), textarea_rect, buf, &mut state);
714716
if self.textarea.text().is_empty() {
715-
Line::from(BASE_PLACEHOLDER_TEXT)
717+
Line::from(self.placeholder_text.as_str())
716718
.style(Style::default().dim())
717719
.render_ref(textarea_rect.inner(Margin::new(1, 0)), buf);
718720
}
@@ -885,7 +887,8 @@ mod tests {
885887

886888
let (tx, _rx) = std::sync::mpsc::channel();
887889
let sender = AppEventSender::new(tx);
888-
let mut composer = ChatComposer::new(true, sender, false);
890+
let mut composer =
891+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
889892

890893
let needs_redraw = composer.handle_paste("hello".to_string());
891894
assert!(needs_redraw);
@@ -908,7 +911,8 @@ mod tests {
908911

909912
let (tx, _rx) = std::sync::mpsc::channel();
910913
let sender = AppEventSender::new(tx);
911-
let mut composer = ChatComposer::new(true, sender, false);
914+
let mut composer =
915+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
912916

913917
let large = "x".repeat(LARGE_PASTE_CHAR_THRESHOLD + 10);
914918
let needs_redraw = composer.handle_paste(large.clone());
@@ -937,7 +941,8 @@ mod tests {
937941
let large = "y".repeat(LARGE_PASTE_CHAR_THRESHOLD + 1);
938942
let (tx, _rx) = std::sync::mpsc::channel();
939943
let sender = AppEventSender::new(tx);
940-
let mut composer = ChatComposer::new(true, sender, false);
944+
let mut composer =
945+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
941946

942947
composer.handle_paste(large);
943948
assert_eq!(composer.pending_pastes.len(), 1);
@@ -973,7 +978,12 @@ mod tests {
973978

974979
for (name, input) in test_cases {
975980
// Create a fresh composer for each test case
976-
let mut composer = ChatComposer::new(true, sender.clone(), false);
981+
let mut composer = ChatComposer::new(
982+
true,
983+
sender.clone(),
984+
false,
985+
"Ask Codex to do anything".to_string(),
986+
);
977987

978988
if let Some(text) = input {
979989
composer.handle_paste(text);
@@ -1011,7 +1021,8 @@ mod tests {
10111021

10121022
let (tx, rx) = std::sync::mpsc::channel();
10131023
let sender = AppEventSender::new(tx);
1014-
let mut composer = ChatComposer::new(true, sender, false);
1024+
let mut composer =
1025+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
10151026

10161027
// Type the slash command.
10171028
for ch in [
@@ -1054,7 +1065,8 @@ mod tests {
10541065

10551066
let (tx, rx) = std::sync::mpsc::channel();
10561067
let sender = AppEventSender::new(tx);
1057-
let mut composer = ChatComposer::new(true, sender, false);
1068+
let mut composer =
1069+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
10581070

10591071
for ch in ['/', 'm', 'e', 'n', 't', 'i', 'o', 'n'] {
10601072
let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char(ch), KeyModifiers::NONE));
@@ -1093,7 +1105,8 @@ mod tests {
10931105

10941106
let (tx, _rx) = std::sync::mpsc::channel();
10951107
let sender = AppEventSender::new(tx);
1096-
let mut composer = ChatComposer::new(true, sender, false);
1108+
let mut composer =
1109+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
10971110

10981111
// Define test cases: (paste content, is_large)
10991112
let test_cases = [
@@ -1166,7 +1179,8 @@ mod tests {
11661179

11671180
let (tx, _rx) = std::sync::mpsc::channel();
11681181
let sender = AppEventSender::new(tx);
1169-
let mut composer = ChatComposer::new(true, sender, false);
1182+
let mut composer =
1183+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
11701184

11711185
// Define test cases: (content, is_large)
11721186
let test_cases = [
@@ -1232,7 +1246,8 @@ mod tests {
12321246

12331247
let (tx, _rx) = std::sync::mpsc::channel();
12341248
let sender = AppEventSender::new(tx);
1235-
let mut composer = ChatComposer::new(true, sender, false);
1249+
let mut composer =
1250+
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
12361251

12371252
// Define test cases: (cursor_position_from_end, expected_pending_count)
12381253
let test_cases = [

codex-rs/tui/src/bottom_pane/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub(crate) struct BottomPaneParams {
5858
pub(crate) app_event_tx: AppEventSender,
5959
pub(crate) has_input_focus: bool,
6060
pub(crate) enhanced_keys_supported: bool,
61+
pub(crate) placeholder_text: String,
6162
}
6263

6364
impl BottomPane<'_> {
@@ -69,6 +70,7 @@ impl BottomPane<'_> {
6970
params.has_input_focus,
7071
params.app_event_tx.clone(),
7172
enhanced_keys_supported,
73+
params.placeholder_text,
7274
),
7375
active_view: None,
7476
app_event_tx: params.app_event_tx,
@@ -352,6 +354,7 @@ mod tests {
352354
app_event_tx: tx,
353355
has_input_focus: true,
354356
enhanced_keys_supported: false,
357+
placeholder_text: "Ask Codex to do anything".to_string(),
355358
});
356359
pane.push_approval_request(exec_request());
357360
assert_eq!(CancellationEvent::Handled, pane.on_ctrl_c());
@@ -369,6 +372,7 @@ mod tests {
369372
app_event_tx: tx,
370373
has_input_focus: true,
371374
enhanced_keys_supported: false,
375+
placeholder_text: "Ask Codex to do anything".to_string(),
372376
});
373377

374378
// Create an approval modal (active view).
@@ -397,6 +401,7 @@ mod tests {
397401
app_event_tx: tx.clone(),
398402
has_input_focus: true,
399403
enhanced_keys_supported: false,
404+
placeholder_text: "Ask Codex to do anything".to_string(),
400405
});
401406

402407
// Start a running task so the status indicator replaces the composer.
@@ -446,6 +451,7 @@ mod tests {
446451
app_event_tx: tx,
447452
has_input_focus: true,
448453
enhanced_keys_supported: false,
454+
placeholder_text: "Ask Codex to do anything".to_string(),
449455
});
450456

451457
// Begin a task: show initial status.
@@ -477,6 +483,7 @@ mod tests {
477483
app_event_tx: tx,
478484
has_input_focus: true,
479485
enhanced_keys_supported: false,
486+
placeholder_text: "Ask Codex to do anything".to_string(),
480487
});
481488

482489
// Activate spinner (status view replaces composer) with no live ring.
@@ -528,6 +535,7 @@ mod tests {
528535
app_event_tx: tx,
529536
has_input_focus: true,
530537
enhanced_keys_supported: false,
538+
placeholder_text: "Ask Codex to do anything".to_string(),
531539
});
532540

533541
pane.set_task_running(true);

0 commit comments

Comments
 (0)