steer_tui/tui/widgets/setup/
completion.rs

1use crate::tui::state::{AuthStatus, SetupState};
2use crate::tui::theme::{Component, Theme};
3use ratatui::{
4    buffer::Buffer,
5    layout::{Alignment, Rect},
6    style::Modifier,
7    text::{Line, Span},
8    widgets::{Block, Borders, Paragraph, Widget},
9};
10
11pub struct CompletionWidget;
12
13impl CompletionWidget {
14    pub fn render(area: Rect, buf: &mut Buffer, state: &SetupState, theme: &Theme) {
15        let mut lines = vec![];
16
17        // Add padding
18        let vertical_padding = (area.height.saturating_sub(12)) / 2;
19        for _ in 0..vertical_padding {
20            lines.push(Line::from(""));
21        }
22
23        // Success message
24        lines.push(Line::from(Span::styled(
25            "✓ Setup Complete!",
26            theme.style(Component::SetupSuccessIcon),
27        )));
28        lines.push(Line::from(""));
29
30        // Show authenticated providers
31        let authenticated_providers: Vec<_> = state
32            .auth_providers
33            .iter()
34            .filter(|(_, status)| {
35                matches!(status, AuthStatus::ApiKeySet | AuthStatus::OAuthConfigured)
36            })
37            .map(|(provider, _)| provider.display_name())
38            .collect();
39
40        if !authenticated_providers.is_empty() {
41            lines.push(Line::from(Span::styled(
42                "Authenticated Providers:",
43                theme
44                    .style(Component::SetupHeader)
45                    .add_modifier(Modifier::BOLD),
46            )));
47            for provider in authenticated_providers {
48                lines.push(Line::from(format!("  • {provider}")));
49            }
50        } else {
51            lines.push(Line::from("No providers authenticated yet."));
52        }
53
54        lines.push(Line::from(""));
55        lines.push(Line::from("Your authentication has been configured."));
56        lines.push(Line::from(""));
57
58        // Instructions
59        lines.push(Line::from(vec![
60            Span::raw("Press "),
61            Span::styled("Enter", theme.style(Component::SetupKeyBinding)),
62            Span::raw(" to start using Steer"),
63        ]));
64
65        let paragraph = Paragraph::new(lines)
66            .block(
67                Block::default()
68                    .borders(Borders::ALL)
69                    .border_style(theme.style(Component::SetupBorder))
70                    .title(" Setup Complete "),
71            )
72            .alignment(Alignment::Center);
73
74        Widget::render(paragraph, area, buf);
75    }
76}