codetether_agent/tui/ui/chat_view/
suggestions.rs1use ratatui::{
4 Frame,
5 layout::Rect,
6 style::{Color, Style},
7 text::{Line, Span},
8 widgets::{Block, Borders, List, ListItem, ListState},
9};
10
11use crate::tui::app::state::App;
12
13pub fn render_suggestions(f: &mut Frame, app: &App, area: Rect) {
22 let items: Vec<ListItem<'static>> = app
23 .state
24 .slash_suggestions
25 .iter()
26 .enumerate()
27 .map(|(idx, cmd)| {
28 let prefix = if idx == app.state.selected_slash_suggestion {
29 "▶ "
30 } else {
31 " "
32 };
33 ListItem::new(Line::from(vec![
34 Span::raw(prefix),
35 Span::styled(cmd.clone(), Style::default().fg(Color::Cyan).bold()),
36 ]))
37 })
38 .collect();
39 let mut list_state = ListState::default();
40 if !app.state.slash_suggestions.is_empty() {
41 list_state.select(Some(app.state.selected_slash_suggestion));
42 }
43 let list = List::new(items)
44 .block(Block::default().borders(Borders::ALL).title(" Commands "))
45 .highlight_style(Style::default().bg(Color::DarkGray).fg(Color::Cyan).bold());
46 f.render_stateful_widget(list, area, &mut list_state);
47}