refactor: simplify auth popup to show status instead of URL

This commit is contained in:
Ruben Rosario
2026-06-21 10:04:27 +01:00
parent a64fdea005
commit 1c95f5f6be
+19 -46
View File
@@ -304,12 +304,10 @@ pub fn render_device_auth_popup(
let border_color = if error.is_some() { let border_color = if error.is_some() {
Color::Red Color::Red
} else if url == "starting..." { } else if url == "starting..." || !url.is_empty() {
Color::Yellow Color::Yellow
} else if url.is_empty() {
POPUP_BORDER
} else { } else {
Color::Green POPUP_BORDER
}; };
let block = Block::default() let block = Block::default()
@@ -340,18 +338,31 @@ pub fn render_device_auth_popup(
" Press Enter to retry | Esc to cancel ", " Press Enter to retry | Esc to cancel ",
Style::default().fg(Color::DarkGray), Style::default().fg(Color::DarkGray),
))); )));
} else if url == "starting..." { } else if url == "starting..." || !url.is_empty() {
lines.push(Line::from("")); lines.push(Line::from(""));
lines.push(Line::from(Span::styled( lines.push(Line::from(Span::styled(
" Starting authorization... ", " Authorization in progress... ",
Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD), Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD),
))); )));
lines.push(Line::from("")); lines.push(Line::from(""));
lines.push(Line::from(Span::styled( lines.push(Line::from(Span::styled(
" A browser tab will open or you can copy the URL manually. ", " A browser tab should open automatically. ",
Style::default().fg(Color::White),
)));
lines.push(Line::from(Span::styled(
" If not, check that GOOGLE_CLIENT_ID and ",
Style::default().fg(Color::DarkGray), Style::default().fg(Color::DarkGray),
))); )));
} else if url.is_empty() { lines.push(Line::from(Span::styled(
" GOOGLE_CLIENT_SECRET are set correctly. ",
Style::default().fg(Color::DarkGray),
)));
lines.push(Line::from(""));
lines.push(Line::from(Span::styled(
" (Esc to cancel) ",
Style::default().fg(Color::DarkGray),
)));
} else {
lines.push(Line::from("")); lines.push(Line::from(""));
lines.push(Line::from(Span::styled( lines.push(Line::from(Span::styled(
" Google Tasks Authorization ", " Google Tasks Authorization ",
@@ -363,11 +374,6 @@ pub fn render_device_auth_popup(
Style::default().fg(Color::White), Style::default().fg(Color::White),
))); )));
lines.push(Line::from("")); lines.push(Line::from(""));
lines.push(Line::from(Span::styled(
" Set env vars GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET ",
Style::default().fg(Color::Yellow),
)));
lines.push(Line::from(""));
lines.push(Line::from(Span::styled( lines.push(Line::from(Span::styled(
" Press Enter to start ", " Press Enter to start ",
Style::default().fg(Color::Cyan), Style::default().fg(Color::Cyan),
@@ -376,39 +382,6 @@ pub fn render_device_auth_popup(
" Press Esc to skip ", " Press Esc to skip ",
Style::default().fg(Color::DarkGray), Style::default().fg(Color::DarkGray),
))); )));
} else {
lines.push(Line::from(""));
lines.push(Line::from(Span::styled(
" Authorize in your browser: ",
Style::default().fg(Color::White).add_modifier(Modifier::BOLD),
)));
lines.push(Line::from(""));
// Show a shortened version of the URL for readability
if url.len() > 70 {
let short_url: String = url.chars().take(67).collect();
lines.push(Line::from(Span::styled(
format!(" {}", short_url),
Style::default().fg(Color::Cyan),
)));
lines.push(Line::from(Span::styled(
" ... (full URL in terminal log) ",
Style::default().fg(Color::DarkGray),
)));
} else {
lines.push(Line::from(Span::styled(
format!(" {}", url),
Style::default().fg(Color::Cyan),
)));
}
lines.push(Line::from(""));
lines.push(Line::from(Span::styled(
" Waiting for browser authorization... ",
Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD),
)));
lines.push(Line::from(Span::styled(
" (Esc to cancel) ",
Style::default().fg(Color::DarkGray),
)));
} }
let paragraph = Paragraph::new(Text::from(lines)) let paragraph = Paragraph::new(Text::from(lines))