Skip to main content

codetether_agent/tui/ui/webview/
header.rs

1use ratatui::{
2    Frame,
3    layout::Rect,
4    style::{Color, Modifier, Style},
5    text::{Line, Span},
6    widgets::{Block, Borders, Paragraph},
7};
8
9use crate::tui::app::state::App;
10
11pub fn render_webview_header(f: &mut Frame, app: &App, area: Rect) {
12    let model_label = app.state.last_completion_model.as_deref().unwrap_or("auto");
13    let title = format!(" CodeTether ─ {model_label} ");
14    let mode_label = if cfg!(debug_assertions) {
15        " [DEBUG]"
16    } else {
17        ""
18    };
19    let right = format!("Chat{mode_label} ");
20    let title_len = title.len() as u16;
21    let right_len = right.len() as u16;
22    let spacing = area
23        .width
24        .saturating_sub(title_len)
25        .saturating_sub(right_len);
26    let line = Line::from(vec![
27        Span::styled(
28            title,
29            Style::default()
30                .fg(Color::Cyan)
31                .add_modifier(Modifier::BOLD),
32        ),
33        Span::raw(" ".repeat(spacing as usize)),
34        Span::styled(right, Style::default().fg(Color::DarkGray)),
35    ]);
36    let block = Block::default()
37        .borders(Borders::BOTTOM)
38        .border_style(Style::default().fg(Color::DarkGray));
39    let para = Paragraph::new(line).block(block);
40    f.render_widget(para, area);
41}