Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions crates/cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ pub fn decode_browser_preview_image(b64: &str) -> Option<std::sync::Arc<image::R

#[derive(Debug, Clone)]
pub struct BrowserPreviewState {
pub preview: agentd_protocol::BrowserPreview,
pub hide_after: Instant,
pub hover_started: Option<Instant>,
/// When this preview first arrived — drives the matrix-rain
Expand Down Expand Up @@ -1414,7 +1413,6 @@ impl App {
self.browser_previews.insert(
session_id,
BrowserPreviewState {
preview,
hide_after: now + BROWSER_PREVIEW_TTL,
hover_started: None,
decoded,
Expand Down Expand Up @@ -5303,13 +5301,6 @@ mod tests {
app.browser_previews.insert(
"s1".into(),
BrowserPreviewState {
preview: agentd_protocol::BrowserPreview {
url: "http://example.com".into(),
title: None,
image: String::new(),
width: 32,
height: 24,
},
hide_after: Instant::now() + Duration::from_secs(60),
hover_started: None,
decoded: Some(std::sync::Arc::new(image::RgbaImage::from_pixel(
Expand Down
29 changes: 3 additions & 26 deletions crates/cli/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,6 @@ fn render_browser_preview_overlay(
let Some(preview_state) = preview else {
return (None, None);
};
let preview = &preview_state.preview;
if area.width < 40 || area.height < 12 {
return (None, None);
}
Expand All @@ -2390,17 +2389,16 @@ fn render_browser_preview_overlay(
return (None, None);
}

let caption_rows = 1;
let max_inner_w = max_w.saturating_sub(2).max(1) as u32;
let max_inner_h = max_h.saturating_sub(2 + caption_rows).max(1) as u32;
let max_inner_h = max_h.saturating_sub(2).max(1) as u32;

let scale = (max_inner_w as f32 / w as f32).min((max_inner_h as f32 * 2.0) / h as f32);
let out_w = ((w as f32 * scale).round() as u32).clamp(1, max_inner_w) as u16;
let out_h_px = ((h as f32 * scale).round() as u32).clamp(1, max_inner_h * 2) as u16;
let rows = out_h_px.div_ceil(2);

let panel_w = out_w + 2;
let panel_h = rows + caption_rows + 2;
let panel_h = rows + 2;

let panel = Rect {
x: area.x + area.width.saturating_sub(panel_w + 1),
Expand Down Expand Up @@ -2439,7 +2437,7 @@ fn render_browser_preview_overlay(
x: inner.x,
y: inner.y,
width: inner.width,
height: inner.height.saturating_sub(caption_rows),
height: inner.height,
};
if let Some(img) = preview_state.decoded.as_ref() {
// Same dial-up reveal/erase as the matrix wallpaper, in sync.
Expand All @@ -2456,27 +2454,6 @@ fn render_browser_preview_overlay(
paint_resized_half_blocks(f, image_area, &resized, 1.0, row_frac);
}
}
if inner.height > 0 {
let caption = preview
.title
.as_deref()
.filter(|s| !s.is_empty())
.unwrap_or(&preview.url);
let caption = truncate_to_width(caption, inner.width as usize);
let caption_area = Rect {
x: inner.x,
y: inner.y + inner.height - 1,
width: inner.width,
height: 1,
};
f.render_widget(
Paragraph::new(Line::from(Span::styled(
caption,
Style::default().fg(theme.dim),
))),
caption_area,
);
}
(Some(panel), Some(close_bounds))
}

Expand Down
Loading