Skip to content

Commit dbb0171

Browse files
authored
fix: Fixes out of bounds issue with dropdown. (#2726)
1 parent 80091c7 commit dbb0171

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

crates/chat-cli/src/cli/chat/cli/experiment.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ async fn select_experiment(os: &mut Os, session: &mut ChatSession) -> Result<Opt
8080
experiment_labels.push(label);
8181
}
8282

83-
experiment_labels.push(String::new());
84-
experiment_labels.push(format!(
85-
"{}",
86-
style::Stylize::white("⚠ Experimental features may be changed or removed at any time")
87-
));
83+
// Show disclaimer before selection
84+
queue!(
85+
session.stderr,
86+
style::SetForegroundColor(Color::Yellow),
87+
style::Print("⚠ Experimental features may be changed or removed at any time\n\n"),
88+
style::ResetColor,
89+
)?;
8890

8991
let selection: Option<_> = match Select::with_theme(&crate::util::dialoguer_theme())
9092
.with_prompt("Select an experiment to toggle")
@@ -107,14 +109,14 @@ async fn select_experiment(os: &mut Os, session: &mut ChatSession) -> Result<Opt
107109
queue!(session.stderr, style::ResetColor)?;
108110

109111
if let Some(index) = selection {
110-
// Clear the dialoguer selection line to avoid showing old status
112+
// Clear the dialoguer selection line and disclaimer
111113
queue!(
112114
session.stderr,
113-
crossterm::cursor::MoveUp(1),
114-
crossterm::terminal::Clear(crossterm::terminal::ClearType::CurrentLine),
115+
crossterm::cursor::MoveUp(3), // Move up past selection + 2 disclaimer lines
116+
crossterm::terminal::Clear(crossterm::terminal::ClearType::FromCursorDown),
115117
)?;
116118

117-
// Skip if user selected disclaimer or empty line
119+
// Skip if user selected disclaimer or empty line (last 2 items)
118120
if index >= AVAILABLE_EXPERIMENTS.len() {
119121
return Ok(Some(ChatState::PromptUser {
120122
skip_printing_tools: false,

0 commit comments

Comments
 (0)