Skip to main content

codetether_agent/tui/ui/webview/
mod.rs

1pub mod chat;
2pub mod header;
3pub mod layout;
4pub mod layout_mode;
5pub mod sidebar;
6pub mod status;
7
8use ratatui::Frame;
9
10use crate::tui::app::state::App;
11
12/// Render the full webview chat layout. Returns `false` if terminal too small.
13pub fn render(f: &mut Frame, app: &mut App) -> bool {
14    let area = f.area();
15    if chat::terminal_too_small(area) {
16        status::render_too_small(f, area);
17        return false;
18    }
19    let show_inspector = false;
20    let main = layout::webview_main_chunks(area);
21    header::render_webview_header(f, app, main[0]);
22    let body = layout::webview_body_chunks(main[1], show_inspector);
23    sidebar::render_webview_sidebar(f, app, body[0]);
24    let center_area = body.get(1).copied().unwrap_or(main[1]);
25    let max_w = center_area.width.saturating_sub(4) as usize;
26    let lines = app
27        .state
28        .get_or_build_message_lines(max_w)
29        .unwrap_or_default();
30    let vis = center_area.height.saturating_sub(2) as usize;
31    app.state.chat_last_max_scroll = lines.len().saturating_sub(vis);
32    chat::render_webview_chat_center(f, app, center_area, &lines);
33    chat::render_webview_input(f, app, main[2]);
34    status::render_webview_status(f, app, main[3]);
35    true
36}