Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(overlay): stop the meeting toast floating in dead space

Louis Beaumont692189f4c982
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift
index 0d9a6f87f..4fc8945f6 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift
@@ -437,7 +437,10 @@ private let kBaseDisclosureGap: CGFloat = 4
private let kBaseTranscriptW: CGFloat = 320
private let kBaseTranscriptH: CGFloat = 142
private let kBaseNotificationW: CGFloat = 340
-private let kBaseNotificationH: CGFloat = 44
+/// Title + body measure ~23pt and the action buttons are 22pt, so this leaves a
+/// ~5pt gutter instead of the ~10pt of dead air a 44pt row used to have. Keeps
+/// the toast in the same density family as the 30pt dock it hangs off.
+private let kBaseNotificationH: CGFloat = 34
private let kRestingOpacity: Double = 0.50
private let kAnimDur: Double = 0.2
private let kDockControls = ["search", "chat", "timeline", "audio", "settings"]
@@ -1893,6 +1896,7 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
hoverHideWorkItem = nil
metrics.isHovering = true
refreshTranscriptPanelVisibility()
+ positionNotificationPanelIfVisible()
} else {
metrics.hoveredControl = nil
disclosurePanel?.orderOut(nil)
@@ -2001,6 +2005,7 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
hoverHideWorkItem = nil
metrics.isHovering = true
refreshTranscriptPanelVisibility()
+ positionNotificationPanelIfVisible()
} else {
scheduleHoverExit()
}
@@ -2019,6 +2024,7 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
self.disclosurePanel?.orderOut(nil)
// A pinned card is the one thing hover exit must not take away.
self.refreshTranscriptPanelVisibility()
+ self.positionNotificationPanelIfVisible()
}
hoverHideWorkItem = work
// Bridge between the chip and the card. The corridor is continuous now,
@@ -2598,6 +2604,13 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
}
}
+ /// The toast hangs off the bar, so it has to move when the bar changes size
+ /// between the resting chip and the hovered dock.
+ private func positionNotificationPanelIfVisible() {
+ guard notificationPanel?.isVisible == true else { return }
+ positionNotificationPanel()
+ }
+
/// Sit the notification against the pill on the side the disclosure opens,
/// aligned to the pill's edge so it visibly belongs to it.
private func positionNotificationPanel() {
@@ -2605,9 +2618,14 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
let visible = panel.screen?.visibleFrame ?? NSScreen.main?.visibleFrame ?? panel.frame
let width = toast.frame.width
let height = toast.frame.height
+ // Anchor to the *visible* bar, not the window. The window stays at the
+ // expanded size while the resting chip is only 16pt of it, so anchoring
+ // Y to the window edge left a ~46pt hole between the chip and the toast
+ // even though X was already measured off the chip. Same rect the
+ // transcript card uses, so the two attachments hang the same way.
let pill = overlayHoverRect(
in: panel.frame,
- expanded: false,
+ expanded: metrics.isHovering || metrics.forceExpanded,
disclosureDown: metrics.disclosureDown,
horizontal: metrics.horizontal,
scale: gOverlayScale
@@ -2622,8 +2640,8 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
let margin = anchorMargin(scale: gOverlayScale)
let x = min(max(preferredX, visible.minX + margin), visible.maxX - width - margin)
let preferredY = metrics.disclosureDown
- ? panel.frame.minY - height - margin
- : panel.frame.maxY + margin
+ ? pill.minY - height - margin
+ : pill.maxY + margin
let y = min(max(preferredY, visible.minY + margin), visible.maxY - height - margin)
toast.setFrameOrigin(NSPoint(x: x, y: y))
}
diff --git a/crates/screenpipe-overlay-win/src/layout.rs b/crates/screenpipe-overlay-win/src/layout.rs
index f52f47c73..43937f202 100644
--- a/crates/screenpipe-overlay-win/src/layout.rs
+++ b/crates/screenpipe-overlay-win/src/layout.rs
@@ -59,7 +59,10 @@ pub const BASE_GAP: f32 = 4.0;
pub const BASE_TRANSCRIPT_W: f32 = 320.0;
pub const BASE_TRANSCRIPT_H: f32 = 142.0;
pub const BASE_NOTIFICATION_W: f32 = 340.0;
-pub const BASE_NOTIFICATION_H: f32 = 44.0;
+/// Title + body are two 14pt rows and the action buttons are 22pt, so this
+/// leaves a ~3pt gutter instead of the ~8pt of dead air a 44pt row used to
+/// have. Keeps the toast in the same density family as the 30pt dock.
+pub const BASE_NOTIFICATION_H: f32 = 34.0;
pub const RESTING_OPACITY: f32 = 0.50;
/// Room around the content for the drop shadow. Layered windows composite the
@@ -509,6 +512,36 @@ mod tests {
}
}
+ #[test]
+ fn the_notification_row_hugs_its_content() {
+ // Two 14pt text rows, or a 22pt action button, is everything the row
+ // has to hold. Whatever is left over reads as an empty black band, so
+ // keep the gutter small — this row used to be 44pt tall.
+ let content = (14.0f32 * 2.0).max(22.0);
+ let gutter = BASE_NOTIFICATION_H - content;
+ assert!(
+ (0.0..=8.0).contains(&gutter),
+ "notification row should hug its content, got {gutter}pt of gutter"
+ );
+
+ // And the button has to stay centred in it, whatever the height is.
+ let s = OverlayState {
+ notification: parse(
+ r#"{"id":"m","title":"meeting detected","body":"zoom — product sync","actions":[
+ {"label":"open note","action":"deeplink","primary":true}]}"#,
+ )
+ .ok(),
+ ..Default::default()
+ };
+ let l = compute(&s);
+ let n = l.notification.unwrap();
+ let (_, btn) = notification_action_rects(&s, n, l.scale)[0];
+ assert!(
+ ((btn.y - n.y) - (n.bottom() - btn.bottom())).abs() < 0.01,
+ "action button is not centred in the row: {btn:?} in {n:?}"
+ );
+ }
+
#[test]
fn scale_multiplies_the_dock_but_barely_moves_the_resting_chip() {
let small = compute(&OverlayState::default()).primary;
diff --git a/crates/screenpipe-overlay-win/src/render.rs b/crates/screenpipe-overlay-win/src/render.rs
index 691c3361a..7c001d294 100644
--- a/crates/screenpipe-overlay-win/src/render.rs
+++ b/crates/screenpipe-overlay-win/src/render.rs
@@ -671,11 +671,12 @@ impl Renderer {
let text_x = r.x + pad + 20.0 * s;
let text_w = (text_right - text_x - 8.0 * s).max(20.0);
let has_body = !n.body.is_empty();
- let title_rect = if has_body {
- Rect::new(text_x, r.y + 6.0 * s, text_w, 14.0 * s)
- } else {
- Rect::new(text_x, r.y, text_w, r.h)
- };
+ // Centre the text block in whatever height the row has rather than
+ // pinning rows to fixed offsets, so the gutters stay even.
+ let line = 14.0 * s;
+ let block = if has_body { line * 2.0 } else { line };
+ let text_top = r.y + (r.h - block) / 2.0;
+ let title_rect = Rect::new(text_x, text_top, text_w, line);
// Meeting titles are user data and routinely longer than the row.
self.mono_text(
rt,
@@ -693,7 +694,7 @@ impl Renderer {
8.5 * s,
DWRITE_FONT_WEIGHT_NORMAL,
Align::Leading,
- Rect::new(text_x, r.y + 20.0 * s, text_w, 14.0 * s),
+ Rect::new(text_x, text_top + line, text_w, line),
white(0.60),
);
}