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

feat: compact starred sessions with countdown and paginated history

Louis Beaumontdf81001e94fe
diff --git a/apps/screenpipe-app-tauri/app/globals.css b/apps/screenpipe-app-tauri/app/globals.css
index 5f63d3a0a..7f1730ba8 100644
--- a/apps/screenpipe-app-tauri/app/globals.css
+++ b/apps/screenpipe-app-tauri/app/globals.css
@@ -1171,3 +1171,12 @@
scroll-behavior: auto !important;
}
}
+
+@keyframes star-session-pulse {
+ 0% { opacity: 0; transform: scale(0.65); }
+ 55% { opacity: 1; transform: scale(1.15); }
+ 100% { opacity: 1; transform: scale(1); }
+}
+@media (prefers-reduced-motion: no-preference) {
+ .motion-safe\:animate-star-session-pulse { animation: star-session-pulse 300ms ease-out both; }
+}
diff --git a/apps/screenpipe-app-tauri/app/shortcut-reminder/page.test.tsx b/apps/screenpipe-app-tauri/app/shortcut-reminder/page.test.tsx
index 1a3a3ffb4..4e0c0719b 100644
--- a/apps/screenpipe-app-tauri/app/shortcut-reminder/page.test.tsx
+++ b/apps/screenpipe-app-tauri/app/shortcut-reminder/page.test.tsx
@@ -15,6 +15,7 @@ import ShortcutReminderPage from "./page";
import { formatShortcut } from "./format-shortcut";
const mocks = vi.hoisted(() => ({
+ starred: { active: undefined as undefined | { end: string }, now: 0 },
getRecordingHealthState: vi.fn(),
overlayRestartRecording: vi.fn(),
listen: vi.fn(),
@@ -129,6 +130,8 @@ vi.mock("@/lib/utils/tauri", () => ({
},
}));
+vi.mock("@/components/starred-sessions/use-starred-sessions", () => ({ useStarredSessions: () => mocks.starred }));
+
vi.mock("./use-overlay-data", () => ({
useOverlayData: () => ({
audioActive: false,
@@ -937,3 +940,22 @@ describe("cross-platform star controls", () => {
cleanup();
});
});
+
+it("shows remaining minutes in the star button and updates the active disclosure", async () => {
+ mocks.meetingOverlayState.active = false;
+ mocks.getRecordingHealthState.mockResolvedValue("normal");
+ mocks.starred = { active: { end: new Date(3600000).toISOString() }, now: 59000 };
+ const view = render(<ShortcutReminderPage />);
+ fireEvent.mouseEnter(await screen.findByTestId("shortcut-reminder-root"));
+ const star = await screen.findByRole("button", { name: "60 min left · click to end" });
+ expect(star).toHaveTextContent("60m");
+ fireEvent.mouseEnter(star);
+ expect(await screen.findByText("60 min left · click to end", { exact: false })).toBeVisible();
+ mocks.starred.now = 60000;
+ view.rerender(<ShortcutReminderPage />);
+ expect(screen.getByRole("button", { name: "59 min left · click to end" })).toHaveTextContent("59m");
+ mocks.starred.active = undefined;
+ view.rerender(<ShortcutReminderPage />);
+ expect(screen.getByRole("button", { name: "Starred work sessions" })).not.toHaveTextContent("59m");
+ cleanup();
+});
diff --git a/apps/screenpipe-app-tauri/app/shortcut-reminder/page.tsx b/apps/screenpipe-app-tauri/app/shortcut-reminder/page.tsx
index 79b6afb73..b34bfe740 100644
--- a/apps/screenpipe-app-tauri/app/shortcut-reminder/page.tsx
+++ b/apps/screenpipe-app-tauri/app/shortcut-reminder/page.tsx
@@ -110,6 +110,9 @@ export default function ShortcutReminderPage() {
const [expanded, setExpanded] = useState(false);
const [starError, setStarError] = useState(false);
const starredSessions = useStarredSessions();
+ const starredMinutes = starredSessions.active
+ ? Math.max(1, Math.ceil((Date.parse(starredSessions.active.end) - starredSessions.now) / 60000))
+ : 0;
const [settingsOpen, setSettingsOpen] = useState(false);
const [hoveredControl, setHoveredControl] = useState<string | null>(null);
const [overlayScale, setOverlayScale] = useState(1);
@@ -712,8 +715,8 @@ export default function ShortcutReminderPage() {
Meeting live{meetingOverlay.meetingApp ? ` · ${meetingOverlay.meetingApp}` : ""}
</span>
<button
- aria-label={ui("Starred work sessions")}
- title={ui("Starred work sessions")}
+ aria-label={starredSessions.active ? ui("{minutes} min left · click to end", { minutes: starredMinutes }) : ui("Starred work sessions")}
+ title={starredSessions.active ? ui("{minutes} min left · click to end", { minutes: starredMinutes }) : ui("Starred work sessions")}
onPointerDown={(event) => event.stopPropagation()}
onClick={() => void openStarPanel()}
className="ml-auto flex items-center justify-center px-1.5 h-full text-white/70 hover:text-white hover:bg-white/10"
@@ -774,7 +777,7 @@ export default function ShortcutReminderPage() {
}
const disclosure = hoveredControl === "star"
- ? [starredSessions.active ? "Starred session in progress" : "Star work session", starShortcut]
+ ? [starredSessions.active ? ui("{minutes} min left · click to end", { minutes: starredMinutes }) : "Star work session", starShortcut]
: hoveredControl === "search"
? ["search", searchShortcut]
: hoveredControl === "brand"
@@ -921,8 +924,8 @@ export default function ShortcutReminderPage() {
<MessageCircle style={{ width: `${12 * overlayScale}px`, height: `${12 * overlayScale}px` }} />
</button>
<button
- title={ui("Starred work sessions")}
- aria-label={ui("Starred work sessions")}
+ title={starredSessions.active ? ui("{minutes} min left · click to end", { minutes: starredMinutes }) : ui("Starred work sessions")}
+ aria-label={starredSessions.active ? ui("{minutes} min left · click to end", { minutes: starredMinutes }) : ui("Starred work sessions")}
aria-haspopup="dialog"
className={dockButtonClass}
style={dockButtonStyle}
@@ -931,7 +934,10 @@ export default function ShortcutReminderPage() {
onPointerDown={(e) => e.stopPropagation()}
onClick={() => void openStarPanel()}
>
- <Star className={starredSessions.active ? "fill-white" : ""} style={{ width: `${12 * overlayScale}px`, height: `${12 * overlayScale}px` }} />
+ <span className="flex flex-col items-center gap-px">
+ <Star className={starredSessions.active ? "fill-white" : ""} style={{ width: `${(starredMinutes ? 10 : 12) * overlayScale}px`, height: `${(starredMinutes ? 10 : 12) * overlayScale}px` }} />
+ {starredMinutes > 0 && <span className="font-mono tabular-nums leading-none" style={{ fontSize: `${7 * overlayScale}px` }}>{starredMinutes}m</span>}
+ </span>
</button>
<button
title={ui("Open timeline")}
diff --git a/apps/screenpipe-app-tauri/app/starred-sessions/page.test.tsx b/apps/screenpipe-app-tauri/app/starred-sessions/page.test.tsx
index 98ee8781a..a8eeb38d5 100644
--- a/apps/screenpipe-app-tauri/app/starred-sessions/page.test.tsx
+++ b/apps/screenpipe-app-tauri/app/starred-sessions/page.test.tsx
@@ -12,6 +12,8 @@ import { afterEach, beforeEach, expect, it, vi } from "vitest";
import Page from "./page";
const mocks = vi.hoisted(() => ({
+ resize: vi.fn(),
+ move: vi.fn(),
hide: vi.fn(),
fetch: vi.fn(),
visibility: null as null | ((e: { payload: boolean }) => void),
@@ -19,6 +21,16 @@ const mocks = vi.hoisted(() => ({
vi.mock("@/lib/utils/tauri", () => ({
commands: { hideStarredSessions: mocks.hide },
}));
+vi.mock("@tauri-apps/api/window", () => ({
+ LogicalSize: class { constructor(public width: number, public height: number) {} },
+ PhysicalPosition: class { constructor(public x: number, public y: number) {} },
+ currentMonitor: async () => ({ workArea: { position: { x: -1920, y: -1080 }, size: { width: 1920, height: 1040 } } }),
+ getCurrentWindow: () => ({
+ setSize: mocks.resize, setPosition: mocks.move,
+ outerPosition: async () => ({ x: -250, y: -160 }),
+ outerSize: async () => ({ width: 616, height: 600 }),
+ }),
+}));
vi.mock("@/lib/api", () => ({ localFetch: mocks.fetch }));
vi.mock("@/lib/hooks/use-tauri-event", () => ({
useTauriEvent: (name: string, callback: typeof mocks.visibility) => {
@@ -86,7 +98,7 @@ it("dismisses after five idle seconds without changing the saved session", async
const session = { id: "active", start: new Date().toISOString(), end: new Date(Date.now() + 3600000).toISOString(), revision: 1, hd_requested: false, has_audio: false };
mocks.fetch.mockResolvedValue({ ok: true, json: async () => ({ data: [session] }) });
render(<Page />);
- await screen.findByText("Starred session in progress");
+ await screen.findByText("Session starred");
vi.useFakeTimers();
fireEvent.pointerMove(screen.getByRole("region", { name: "Starred work sessions" }));
await act(async () => { await vi.advanceTimersByTimeAsync(4999); });
@@ -99,7 +111,8 @@ it("keeps the popup open during inline time edits", async () => {
const session = { id: "active", start: new Date().toISOString(), end: new Date(Date.now() + 3600000).toISOString(), revision: 1, hd_requested: false, has_audio: false };
mocks.fetch.mockResolvedValue({ ok: true, json: async () => ({ data: [session] }) });
render(<Page />);
- await screen.findByText("Starred session in progress");
+ await screen.findByText("Session starred");
+ fireEvent.click(screen.getByRole("button", { name: "More", exact: true }));
fireEvent.click(screen.getByRole("button", { name: "Edit session end" }));
vi.useFakeTimers();
await act(async () => { await vi.advanceTimersByTimeAsync(10000); });
@@ -114,3 +127,54 @@ it("does not auto-dismiss a storage error", async () => {
await act(async () => { await vi.advanceTimersByTimeAsync(10000); });
expect(mocks.hide).not.toHaveBeenCalled();
});
+
+it("shows the star before controls, keeps the default, and updates the same session", async () => {
+ vi.useFakeTimers();
+ let session = { id: "active", start: new Date().toISOString(), end: new Date(Date.now() + 3600000).toISOString(), revision: 1, hd_requested: false, has_audio: false };
+ mocks.fetch.mockImplementation(async (_url, init) => {
+ if (init?.method === "POST") {
+ session = { ...JSON.parse(init.body), revision: 2 };
+ return { ok: true, json: async () => session };
+ }
+ return { ok: true, json: async () => ({ data: [session] }) };
+ });
+ await act(async () => { render(<Page />); });
+ expect(screen.getByRole("status", { name: "Session starred" })).toBeVisible();
+ expect(screen.queryByRole("button", { name: "15 min" })).toBeNull();
+ await act(async () => { await vi.advanceTimersByTimeAsync(300); });
+ expect(screen.getByRole("button", { name: "60 min" })).toHaveAttribute("aria-pressed", "true");
+ await act(async () => { fireEvent.click(screen.getByRole("button", { name: "15 min" })); });
+ expect(session.id).toBe("active");
+ expect(Date.parse(session.end) - Date.parse(session.start)).toBe(15 * 60000);
+ expect(session.hd_requested).toBe(false);
+ expect(screen.getByText("15 min left")).toBeVisible();
+});
+
+it("pauses dismissal while hovered and resumes after leaving", async () => {
+ mocks.fetch.mockResolvedValue({ ok: true, json: async () => ({ data: [{ id: "active", start: new Date().toISOString(), end: new Date(Date.now() + 3600000).toISOString(), revision: 1, hd_requested: false, has_audio: false }] }) });
+ render(<Page />);
+ await screen.findByText("Session starred");
+ vi.useFakeTimers();
+ const controls = screen.getByRole("region", { name: "Starred work sessions" });
+ fireEvent.pointerEnter(controls);
+ await act(async () => { await vi.advanceTimersByTimeAsync(10000); });
+ expect(mocks.hide).not.toHaveBeenCalled();
+ fireEvent.pointerLeave(controls);
+ await act(async () => { await vi.advanceTimersByTimeAsync(5000); });
+ expect(mocks.hide).toHaveBeenCalledTimes(1);
+});
+
+it("fits expanded controls inside a negative-origin monitor work area", async () => {
+ let resized!: () => void;
+ vi.stubGlobal("ResizeObserver", class {
+ constructor(callback: () => void) { resized = callback; }
+ observe() {} disconnect() {}
+ });
+ try {
+ const { container } = render(<Page />);
+ Object.defineProperty(container.firstElementChild, "scrollHeight", { value: 300 });
+ await act(async () => { resized(); });
+ expect(mocks.resize).toHaveBeenCalledWith(expect.objectContaining({ width: 308, height: 300 }));
+ expect(mocks.move).toHaveBeenCalledWith(expect.objectContaining({ x: -616, y: -640 }));
+ } finally { cleanup(); vi.unstubAllGlobals(); }
+});
diff --git a/apps/screenpipe-app-tauri/app/starred-sessions/page.tsx b/apps/screenpipe-app-tauri/app/starred-sessions/page.tsx
index c6c2f437a..82a4b6efc 100644
--- a/apps/screenpipe-app-tauri/app/starred-sessions/page.tsx
+++ b/apps/screenpipe-app-tauri/app/starred-sessions/page.tsx
@@ -2,19 +2,71 @@
// https://screenpipe.com
"use client";
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { X } from "lucide-react";
import { commands } from "@/lib/utils/tauri";
import { useTauriEvent } from "@/lib/hooks/use-tauri-event";
-import { StarredSessionPanel } from "@/components/starred-sessions/starred-session-panel";
-import { useStarredSessions } from "@/components/starred-sessions/use-starred-sessions";
-
-function SessionControls({ onDismiss }: { onDismiss?: () => void }) {
- return <StarredSessionPanel state={useStarredSessions()} inDialog onDismiss={onDismiss} />;
-}
+import { CompactSessionControls } from "@/components/starred-sessions/compact-session-controls";
+import {
+ getCurrentWindow,
+ LogicalSize,
+ PhysicalPosition,
+ currentMonitor,
+} from "@tauri-apps/api/window";
export default function StarredSessionsPage() {
const [visible, setVisible] = useState(true);
+ const [pulsing, setPulsing] = useState(true);
+ const content = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ if (!visible || !content.current) return;
+ let disposed = false;
+ let sequence = Promise.resolve();
+ let previousHeight = 0;
+ const observer = new ResizeObserver(() => {
+ const height = Math.min(
+ 420,
+ Math.ceil(content.current?.scrollHeight ?? 128),
+ );
+ if (height === previousHeight) return;
+ previousHeight = height;
+ sequence = sequence
+ .then(async () => {
+ if (disposed) return;
+ const window = getCurrentWindow();
+ await window.setSize(new LogicalSize(308, height));
+ const monitor = await currentMonitor();
+ if (!monitor || disposed) return;
+ const position = await window.outerPosition();
+ const size = await window.outerSize();
+ const area = monitor.workArea;
+ const x = Math.max(
+ area.position.x,
+ Math.min(
+ position.x,
+ area.position.x + area.size.width - size.width,
+ ),
+ );
+ const y = Math.max(
+ area.position.y,
+ Math.min(
+ position.y,
+ area.position.y + area.size.height - size.height,
+ ),
+ );
+ if (x !== position.x || y !== position.y)
+ await window.setPosition(new PhysicalPosition(x, y));
+ })
+ .catch(() => {
+ /* A browser preview or compositor may not allow resizing. */
+ });
+ });
+ observer.observe(content.current);
+ return () => {
+ disposed = true;
+ observer.disconnect();
+ };
+ }, [visible]);
const [closeError, setCloseError] = useState(false);
useTauriEvent<boolean>("starred-sessions-visibility", (event) =>
setVisible(event.payload),
@@ -39,21 +91,25 @@ export default function StarredSessionsPage() {
}, [hide]);
if (!visible) return null;
return (
- <div className="h-screen w-screen bg-transparent p-1">
+ <div ref={content} className="w-screen bg-transparent p-1">
<section
role="dialog"
aria-label="Starred work sessions"
- className="relative max-h-full overflow-y-auto rounded-lg border border-white/20 bg-black text-white"
+ className={`relative max-h-[412px] overflow-y-auto rounded-lg border text-white ${pulsing ? "border-transparent bg-transparent" : "border-white/20 bg-black"}`}
>
- <button
- autoFocus
- aria-label="Close session controls"
- className="absolute right-3 top-3 z-10 rounded text-white/60 hover:text-white focus-visible:outline focus-visible:outline-1"
- onClick={() => void hide()}
- >
- <X className="h-4 w-4" />
- </button>
- <SessionControls onDismiss={closeError ? undefined : hide} />
+ {!pulsing && (
+ <button
+ aria-label="Close session controls"
+ className="absolute right-3 top-3 z-10 rounded text-white/60 hover:text-white focus-visible:outline focus-visible:outline-1"
+ onClick={() => void hide()}
+ >
+ <X className="h-4 w-4" />
+ </button>
+ )}
+ <CompactSessionControls
+ onDismiss={closeError ? undefined : hide}
+ onPulseChange={setPulsing}
+ />
{closeError && (
<p role="alert" className="px-3 pb-3 text-xs">
Could not close the panel. Try again.
diff --git a/apps/screenpipe-app-tauri/components/starred-sessions/compact-session-controls.tsx b/apps/screenpipe-app-tauri/components/starred-sessions/compact-session-controls.tsx
new file mode 100644
index 000000000..1aece4906
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/starred-sessions/compact-session-controls.tsx
@@ -0,0 +1,164 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import { useEffect, useState } from "react";
+import { Star } from "lucide-react";
+import { StarredSessionPanel } from "./starred-session-panel";
+import { useStarredSessions } from "./use-starred-sessions";
+
+export function CompactSessionControls({
+ onDismiss,
+ onPulseChange,
+}: {
+ onDismiss?: () => void;
+ onPulseChange?: (pulsing: boolean) => void;
+}) {
+ const state = useStarredSessions();
+ const [more, setMore] = useState(false);
+ const [pulseDone, setPulseDone] = useState(false);
+ const [hovered, setHovered] = useState(false);
+ const [keyboardFocus, setKeyboardFocus] = useState(false);
+ const [activity, setActivity] = useState(0);
+ useEffect(() => {
+ if (!state.ready || !state.active || state.error) return;
+ const timer = window.setTimeout(() => setPulseDone(true), 300);
+ return () => window.clearTimeout(timer);
+ }, [state.ready, state.active?.id, state.error]);
+ useEffect(() => {
+ if (
+ !onDismiss ||
+ !pulseDone ||
+ more ||
+ hovered ||
+ keyboardFocus ||
+ state.busy ||
+ state.error
+ )
+ return;
+ const timer = window.setTimeout(onDismiss, 5000);
+ return () => window.clearTimeout(timer);
+ }, [
+ onDismiss,
+ pulseDone,
+ more,
+ hovered,
+ keyboardFocus,
+ state.busy,
+ state.error,
+ activity,
+ state.active?.end,
+ ]);
+
+ const pulsing =
+ !state.error && (!state.ready || (!!state.active && !pulseDone));
+ useEffect(() => onPulseChange?.(pulsing), [onPulseChange, pulsing]);
+ if (pulsing)
+ return (
+ <div
+ role="status"
+ aria-label={state.ready ? "Session starred" : "Loading session"}
+ className="mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-black"
+ >
+ <Star className="h-5 w-5 fill-current motion-safe:animate-star-session-pulse" />
+ </div>
+ );
+ if (!state.active || more)
+ return (
+ <>
+ {more && (
+ <button
+ className="px-3 pt-3 text-xs text-white/70"
+ onClick={() => setMore(false)}
+ >
+ Back
+ </button>
+ )}
+ <StarredSessionPanel
+ state={state}
+ inDialog
+ onDismiss={more ? undefined : onDismiss}
+ />
+ </>
+ );
+ const session = state.active;
+ const minutesLeft = Math.max(
+ 1,
+ Math.ceil((Date.parse(session.end) - state.now) / 60000),
+ );
+ return (
+ <section
+ aria-label="Starred work sessions"
+ className="p-3 text-xs text-white/90"
+ onPointerEnter={() => setHovered(true)}
+ onPointerLeave={() => setHovered(false)}
+ onPointerMove={() => setActivity((v) => v + 1)}
+ onPointerDown={() => {
+ setKeyboardFocus(false);
+ setActivity((v) => v + 1);
+ }}
+ onFocusCapture={(e) =>
+ setKeyboardFocus(e.target.matches(":focus-visible"))
+ }
+ onBlurCapture={(e) => {
+ if (!e.currentTarget.contains(e.relatedTarget)) setKeyboardFocus(false);
+ }}
+ >
+ <div className="flex items-center gap-1.5 pr-6 font-medium">
+ <Star className="h-3.5 w-3.5 fill-current" />
+ Session starred{" "}
+ <span className="ml-auto text-[10px] font-normal text-white/60 tabular-nums">
+ {minutesLeft} min left
+ </span>
+ </div>
+ <div className="mt-2.5 grid grid-cols-4 gap-1" aria-label="Star for">
+ {[5, 15, 30, 60].map((minutes) => (
+ <button
+ key={minutes}
+ className="rounded-md border border-white/30 py-1.5 text-[11px] hover:bg-white/10 aria-pressed:bg-white aria-pressed:text-black disabled:opacity-40 focus-visible:outline focus-visible:outline-white"
+ disabled={
+ state.busy ||
+ Date.parse(session.start) + minutes * 60000 <= state.now
+ }
+ aria-pressed={
+ Math.abs(
+ Date.parse(session.end) -
+ Date.parse(session.start) -
+ minutes * 60000,
+ ) < 1000
+ }
+ onClick={() =>
+ void state.save({
+ ...session,
+ end: new Date(
+ Date.parse(session.start) + minutes * 60000,
+ ).toISOString(),
+ })
+ }
+ >
+ {minutes} min
+ </button>
+ ))}
+ </div>
+ <div className="mt-2 flex justify-between text-[10px] text-white/60">
+ <span>
+ {session.hd_requested
+ ? "HD for this session"
+ : "Using current capture settings"}
+ </span>
+ <button
+ className="text-white/80 hover:text-white"
+ onClick={() => setMore(true)}
+ >
+ More
+ </button>
+ </div>
+ {state.error && (
+ <p role="alert" className="mt-2">
+ {state.error}{" "}
+ <button onClick={() => void state.retry()} disabled={state.busy}>
+ Retry save
+ </button>
+ </p>
+ )}
+ </section>
+ );
+}
diff --git a/apps/screenpipe-app-tauri/components/starred-sessions/session-history.test.tsx b/apps/screenpipe-app-tauri/components/starred-sessions/session-history.test.tsx
new file mode 100644
index 000000000..77d830836
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/starred-sessions/session-history.test.tsx
@@ -0,0 +1,105 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import {
+ act,
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@testing-library/react";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { SessionHistory } from "./session-history";
+const mocks = vi.hoisted(() => ({ fetch: vi.fn(), emit: vi.fn() }));
+vi.mock("@/lib/api", () => ({ localFetch: mocks.fetch }));
+vi.mock("@tauri-apps/api/event", () => ({ emit: mocks.emit }));
+const rows = Array.from({ length: 20 }, (_, i) => ({
+ id: String(i),
+ start: new Date(Date.UTC(2026, 9, 9, 10, i)).toISOString(),
+ end: new Date(Date.UTC(2026, 9, 9, 10, i + 15)).toISOString(),
+ revision: 1,
+ hd_requested: false,
+ has_audio: false,
+}));
+const response = (data: unknown[]) => ({
+ ok: true,
+ json: async () => ({ data }),
+});
+const params = (index: number) =>
+ new URL(mocks.fetch.mock.calls[index][0], "http://localhost").searchParams;
+beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.fetch.mockResolvedValue(response([]));
+});
+afterEach(cleanup);
+function open() {
+ render(<SessionHistory />);
+ fireEvent.click(screen.getByRole("button", { name: "View all" }));
+}
+it("loads history only when opened and pages without duplicates", async () => {
+ mocks.fetch
+ .mockResolvedValueOnce(response(rows))
+ .mockResolvedValueOnce(
+ response([
+ rows[19],
+ { ...rows[0], id: "older", start: "2026-10-08T12:00:00.000Z" },
+ ]),
+ );
+ render(<SessionHistory />);
+ expect(mocks.fetch).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole("button", { name: "View all" }));
+ fireEvent.click(await screen.findByRole("button", { name: "Load more" }));
+ await waitFor(() => expect(screen.getAllByText("15 min")).toHaveLength(20));
+ expect(params(0).get("limit")).toBe("20");
+ expect(params(1).get("offset")).toBe("20");
+ expect(params(1).get("end_time")).toBe(params(0).get("end_time"));
+ expect(screen.queryByRole("button", { name: "Load more" })).toBeNull();
+});
+it("ignores an older response when the date filter changes", async () => {
+ let resolve!: (value: ReturnType<typeof response>) => void;
+ mocks.fetch
+ .mockReturnValueOnce(
+ new Promise((r) => {
+ resolve = r;
+ }),
+ )
+ .mockResolvedValueOnce(response([]));
+ open();
+ fireEvent.change(screen.getByLabelText("Filter sessions by date"), {
+ target: { value: "2026-10-08" },
+ });
+ await screen.findByText("No starred sessions on this date.");
+ await act(async () => {
+ resolve(response(rows));
+ });
+ expect(screen.queryByText("15 min")).toBeNull();
+ expect(params(1).get("offset")).toBe("0");
+ expect(params(1).get("start_time")).toBe(
+ new Date("2026-10-08T00:00:00").toISOString(),
+ );
+ expect(params(1).get("end_time")).toBe(
+ new Date("2026-10-09T00:00:00").toISOString(),
+ );
+});
+it("retries a failed page at the same offset and navigates to a saved session", async () => {
+ mocks.fetch
+ .mockResolvedValueOnce(response(rows))
+ .mockRejectedValueOnce(new Error("Offline"))
+ .mockResolvedValueOnce(
+ response([
+ { ...rows[0], id: "older", start: "2026-10-08T12:00:00.000Z" },
+ ]),
+ );
+ open();
+ fireEvent.click(await screen.findByRole("button", { name: "Load more" }));
+ await screen.findByRole("alert");
+ fireEvent.click(screen.getByRole("button", { name: "Retry" }));
+ await waitFor(() => expect(screen.queryByRole("alert")).toBeNull());
+ expect(params(2).get("offset")).toBe("20");
+ fireEvent.click(screen.getAllByText("15 min")[0].closest("button")!);
+ expect(mocks.emit).toHaveBeenCalledWith(
+ "navigate-to-timestamp",
+ rows[0].start,
+ );
+ expect(screen.queryByText("Starred sessions")).toBeNull();
+});
diff --git a/apps/screenpipe-app-tauri/components/starred-sessions/session-history.tsx b/apps/screenpipe-app-tauri/components/starred-sessions/session-history.tsx
new file mode 100644
index 000000000..1352de794
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/starred-sessions/session-history.tsx
@@ -0,0 +1,179 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import { useEffect, useRef, useState } from "react";
+import { Star } from "lucide-react";
+import { emit } from "@tauri-apps/api/event";
+import { localFetch } from "@/lib/api";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import type { StarredSession } from "./use-starred-sessions";
+
+export function SessionHistory() {
+ const [open, setOpen] = useState(false);
+ const [day, setDay] = useState("");
+ const [rows, setRows] = useState<StarredSession[]>([]);
+ const [hasMore, setHasMore] = useState(false);
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState<string>();
+ const cursor = useRef(0);
+ const epoch = useRef(0);
+ const requestPending = useRef(false);
+ const snapshot = useRef(new Date().toISOString());
+ async function load(reset: boolean) {
+ if (requestPending.current && !reset) return;
+ const token = reset ? ++epoch.current : epoch.current;
+ if (reset) {
+ cursor.current = 0;
+ snapshot.current = new Date().toISOString();
+ setRows([]);
+ }
+ requestPending.current = true;
+ setBusy(true);
+ setError(undefined);
+ try {
+ const params = new URLSearchParams({
+ limit: "20",
+ offset: String(cursor.current),
+ end_time: snapshot.current,
+ });
+ if (day) {
+ const start = new Date(`${day}T00:00:00`);
+ const end = new Date(start);
+ end.setDate(end.getDate() + 1);
+ params.set("start_time", start.toISOString());
+ params.set("end_time", end.toISOString());
+ }
+ const response = await localFetch(`/starred-sessions?${params}`);
+ const result = await response.json();
+ if (!response.ok || !Array.isArray(result.data))
+ throw new Error(result.error || "Could not load sessions.");
+ if (token !== epoch.current) return;
+ const next: StarredSession[] = result.data;
+ cursor.current += next.length;
+ setHasMore(next.length === 20);
+ setRows((previous) => [
+ ...new Map([...previous, ...next].map((row) => [row.id, row])).values(),
+ ]);
+ } catch (e) {
+ if (token === epoch.current)
+ setError(e instanceof Error ? e.message : "Could not load sessions.");
+ } finally {
+ if (token === epoch.current) {
+ requestPending.current = false;
+ setBusy(false);
+ }
+ }
+ }
+ useEffect(() => {
+ if (open) void load(true);
+ return () => {
+ ++epoch.current;
+ requestPending.current = false;
+ };
+ }, [open, day]);
+ return (
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <button className="ml-auto shrink-0 rounded-md border px-2 py-1.5 hover:bg-muted">
+ View all
+ </button>
+ </PopoverTrigger>
+ <PopoverContent align="end" className="w-80 max-w-[calc(100vw-2rem)] p-0">
+ <div className="border-b p-3">
+ <h3 className="mb-2 text-sm font-medium">Starred sessions</h3>
+ <label className="flex items-center gap-2 text-xs">
+ Date{" "}
+ <input
+ type="date"
+ aria-label="Filter sessions by date"
+ value={day}
+ onChange={(e) => setDay(e.target.value)}
+ className="min-w-0 flex-1 rounded border bg-background p-1.5"
+ />
+ </label>
+ {day && (
+ <button
+ className="mt-2 text-xs underline"
+ onClick={() => setDay("")}
+ >
+ All dates
+ </button>
+ )}
+ </div>
+ <div className="max-h-[min(320px,50vh)] overflow-y-auto p-2">
+ {rows.map((session, index) => (
+ <div key={session.id}>
+ {(index === 0 ||
+ new Date(rows[index - 1].start).toDateString() !==
+ new Date(session.start).toDateString()) && (
+ <p className="px-2 pb-1 pt-2 text-[10px] text-muted-foreground">
+ {new Date(session.start).toLocaleDateString(undefined, {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ })}
+ </p>
+ )}
+ <button
+ className="flex w-full items-center gap-2 rounded-md p-2 text-left text-xs hover:bg-muted"
+ onClick={() => {
+ void emit("navigate-to-timestamp", session.start);
+ setOpen(false);
+ }}
+ >
+ <Star className="h-3 w-3 fill-current" />
+ <span>
+ {new Date(session.start).toLocaleTimeString(undefined, {
+ hour: "2-digit",
+ minute: "2-digit",
+ })}
+ <span className="block pt-1 text-[10px] text-muted-foreground">
+ {Math.max(
+ 1,
+ Math.round(
+ (Date.parse(session.end) - Date.parse(session.start)) /
+ 60000,
+ ),
+ )}{" "}
+ min{session.has_audio ? " · Audio" : ""}
+ </span>
+ </span>
+ </button>
+ </div>
+ ))}
+ {!rows.length && !busy && !error && (
+ <p className="p-4 text-xs text-muted-foreground">
+ No starred sessions{day ? " on this date" : " yet"}.
+ </p>
+ )}
+ {error && (
+ <p role="alert" className="p-2 text-xs">
+ {error}{" "}
+ <button className="underline" onClick={() => void load(false)}>
+ Retry
+ </button>
+ </p>
+ )}
+ {busy ? (
+ <p role="status" className="p-2 text-xs">
+ Loading sessions…
+ </p>
+ ) : (
+ hasMore &&
+ !error && (
+ <button
+ className="mt-2 w-full rounded border p-2 text-xs hover:bg-muted"
+ onClick={() => void load(false)}
+ >
+ Load more
+ </button>
+ )
+ )}
+ </div>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/apps/screenpipe-app-tauri/components/starred-sessions/starred-timeline.tsx b/apps/screenpipe-app-tauri/components/starred-sessions/starred-timeline.tsx
index a1ea81f87..917c9b730 100644
--- a/apps/screenpipe-app-tauri/components/starred-sessions/starred-timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/starred-sessions/starred-timeline.tsx
@@ -7,6 +7,7 @@ import { emit } from "@tauri-apps/api/event";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { useTauriEvent } from "@/lib/hooks/use-tauri-event";
import { useStarredSessions } from "./use-starred-sessions";
+import { SessionHistory } from "./session-history";
import { StarredSessionPanel } from "./starred-session-panel";
export function StarredTimeline({
@@ -44,7 +45,7 @@ export function StarredTimeline({
{showStrip && (
<div
aria-label="Starred moments"
- className="flex shrink-0 items-center gap-2 overflow-x-auto border-b px-3 py-2 text-xs"
+ className="flex shrink-0 items-center gap-2 overflow-hidden border-b px-3 py-2 text-xs"
>
<button
className="flex shrink-0 items-center gap-1.5 rounded-md border px-2 py-1.5 hover:bg-muted"
@@ -57,9 +58,10 @@ export function StarredTimeline({
<Star
className={`h-3.5 w-3.5 ${state.active ? "fill-current" : ""}`}
/>
- {state.active ? "Starring" : "Star session"}
+ {state.active ? `${Math.max(1, Math.ceil((Date.parse(state.active.end) - state.now) / 60000))} min left` : "Star session"}
</button>
- {state.sessions.slice(0, 10).map((s) => (
+ <div className="hidden min-w-0 flex-1 items-center gap-1 overflow-hidden sm:flex">
+ {state.sessions.slice(0, 3).map((s) => (
<button
key={s.id}
title={`${new Date(s.start).toLocaleString()} to ${new Date(s.end).toLocaleString()}`}
@@ -77,6 +79,8 @@ export function StarredTimeline({
})}
</button>
))}
+ </div>
+ <SessionHistory />
</div>
)}
{!showStrip && (
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands/starred_sessions.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands/starred_sessions.rs
index 47abf1234..a49791544 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands/starred_sessions.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands/starred_sessions.rs
@@ -5,8 +5,8 @@ use crate::window::GatedWindowPlacement;
use tauri::{Emitter, Manager};
const LABEL: &str = "starred-sessions";
-const WIDTH: f64 = 360.0;
-const HEIGHT: f64 = 420.0;
+const WIDTH: f64 = 308.0;
+const HEIGHT: f64 = 128.0;
/// Place below the trigger, or above it at the bottom edge, in one coordinate space.
fn attached_origin(anchor: (f64, f64, f64, f64), screen: (f64, f64, f64, f64)) -> (f64, f64) {
@@ -284,6 +284,10 @@ fn show(app: &tauri::AppHandle) -> Result<(), String> {
window
}
};
+ // Reset a previously expanded panel before placing the compact controls.
+ window
+ .set_size(tauri::LogicalSize::new(WIDTH, HEIGHT))
+ .map_err(|e| e.to_string())?;
// Wayland compositors may refuse absolute placement. The controls must
// still open; the compositor chooses their position in that case.
#[cfg(target_os = "linux")]
@@ -321,15 +325,11 @@ fn show(app: &tauri::AppHandle) -> Result<(), String> {
}
window.show().map_err(|e| e.to_string())?;
panel.order_front_regardless();
- crate::window::make_panel_key_if_allowed(&panel);
- unsafe {
- crate::window::make_webview_first_responder(&panel);
- }
+ // Passive confirmation must not take keyboard focus from the current app.
}
#[cfg(not(target_os = "macos"))]
{
window.show().map_err(|e| e.to_string())?;
- crate::window::focus_window(&window);
}
let _ = window.emit("starred-sessions-visibility", true);
Ok(())
@@ -397,11 +397,11 @@ mod tests {
fn starred_panel_hugs_trigger_and_stays_on_its_display() {
assert_eq!(
attached_origin((700.0, 12.0, 22.0, 16.0), (0.0, 0.0, 1440.0, 900.0)),
- (531.0, 34.0)
+ (557.0, 34.0)
);
assert_eq!(
attached_origin((1400.0, 850.0, 22.0, 16.0), (0.0, 0.0, 1440.0, 900.0)),
- (1080.0, 424.0)
+ (1132.0, 716.0)
);
assert_eq!(
attached_origin(
@@ -420,7 +420,7 @@ mod tests {
(-2560.0, 0.0, 2560.0, 1540.0),
1.5
),
- (-1620, 861),
+ (-1581, 1299),
);
// A 200% display above the primary, with reserved space on the left.
assert_eq!(
@@ -431,14 +431,14 @@ mod tests {
),
(80, -1506),
);
- // Right edge at 125%: the entire 450px picker stays inside the work area.
+ // Right edge at 125%: the entire 385px picker stays inside the work area.
assert_eq!(
physical_origin(
(3730.0, 20.0, 28.0, 20.0),
(1920.0, 0.0, 1840.0, 1000.0),
1.25
),
- (3310, 48),
+ (3375, 48),
);
}
}
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 6bddfa66d..7369cc891 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift
@@ -95,10 +95,15 @@ public func shortcutSetHealthState(_ statePtr: UnsafePointer<CChar>?) -> Int32 {
return -2
}
+func starredMinutesLeft(until: Int64, now: TimeInterval) -> Int {
+ max(0, Int(ceil((Double(until) / 1000 - now) / 60)))
+}
+
// MARK: - Metrics data pushed from Rust
final class OverlayMetrics: ObservableObject {
@Published var starredActive: Bool = false
+ @Published var starredMinutesRemaining: Int = 0
@Published var audioActive: Bool = false
@Published var speechRatio: Double = 0
@Published var meetingActive: Bool = false
@@ -828,7 +833,9 @@ func disclosureContent(
) -> (String, String?)? {
switch control {
case "brand": return ("screenpipe", uiText("right-click"))
- case "star": return (uiText(metrics.starredActive ? "Starred session in progress" : "star work session"), starShortcut)
+ case "star": return (metrics.starredActive
+ ? uiText("{minutes} min left · click to end", ["minutes": String(metrics.starredMinutesRemaining)])
+ : uiText("star work session"), starShortcut)
case "timeline": return (uiText("timeline"), overlayShortcut)
case "chat": return (uiText("ask chat"), chatShortcut)
case "search": return (uiText("search"), searchShortcut)
@@ -1188,10 +1195,10 @@ struct ShortcutReminderView: View {
DockIconButton(icon: "bubble.left.fill", active: metrics.hoveredControl == "chat", scale: scale) {
onAction("open_chat")
}
- DockIconButton(icon: metrics.starredActive ? "star.fill" : "star", active: metrics.hoveredControl == "star", scale: scale) {
+ DockIconButton(icon: metrics.starredActive ? "star.fill" : "star", active: metrics.hoveredControl == "star", scale: scale, caption: metrics.starredActive ? "\(metrics.starredMinutesRemaining)m" : nil) {
onAction("open_starred_sessions")
}
- .accessibilityLabel(metrics.starredActive ? "Stop starred session" : "Star a work session")
+ .accessibilityLabel(metrics.starredActive ? uiText("{minutes} min left · click to end", ["minutes": String(metrics.starredMinutesRemaining)]) : uiText("Star a work session"))
DockIconButton(icon: "rectangle.split.1x2", active: metrics.hoveredControl == "timeline", scale: scale) {
onAction("open_timeline")
}
@@ -1465,12 +1472,22 @@ private struct DockIconButton: View {
let icon: String
let active: Bool
let scale: CGFloat
+ var caption: String? = nil
let action: () -> Void
var body: some View {
Button(action: action) {
- Image(systemName: icon)
- .font(.system(size: 10 * scale, weight: .medium))
+ VStack(spacing: 1 * scale) {
+ Image(systemName: icon)
+ .font(.system(size: (caption == nil ? 10 : 9) * scale, weight: .medium))
+ if let caption {
+ Text(caption)
+ .font(Brand.swiftUIMonoFont(size: 7 * scale, weight: .medium))
+ .monospacedDigit()
+ .lineLimit(1)
+ .minimumScaleFactor(0.7)
+ }
+ }
.foregroundColor(.white.opacity(active ? 1 : 0.68))
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(active ? Color.white.opacity(0.14) : Color.clear)
@@ -2182,20 +2199,26 @@ class ShortcutReminderController: NSObject, NSWindowDelegate {
DispatchQueue.main.async { [self] in
guard until != starredUntil else { return }
starredUntil = until
- starredExpiry?.cancel()
- let seconds = Double(until) / 1000 - Date().timeIntervalSince1970
- metrics.starredActive = seconds > 0
- refreshActiveDisclosure()
- if seconds > 0 {
- let expiry = DispatchWorkItem { [weak self] in
- guard let self, self.starredUntil == until else { return }
- self.metrics.starredActive = false
- self.refreshActiveDisclosure()
- }
- starredExpiry = expiry
- DispatchQueue.main.asyncAfter(deadline: .now() + seconds, execute: expiry)
- }
- }
+ refreshStarredCountdown()
+ }
+ }
+
+ private func refreshStarredCountdown() {
+ starredExpiry?.cancel()
+ let until = starredUntil
+ let seconds = Double(until) / 1000 - Date().timeIntervalSince1970
+ let minutes = starredMinutesLeft(until: until, now: Date().timeIntervalSince1970)
+ metrics.starredActive = minutes > 0
+ metrics.starredMinutesRemaining = minutes
+ refreshActiveDisclosure()
+ guard minutes > 0 else { return }
+ // Wake only at the next displayed-minute boundary, including expiry.
+ let tick = DispatchWorkItem { [weak self] in
+ guard let self, self.starredUntil == until else { return }
+ self.refreshStarredCountdown()
+ }
+ starredExpiry = tick
+ DispatchQueue.main.asyncAfter(deadline: .now() + max(0.05, seconds - Double(minutes - 1) * 60), execute: tick)
}
/// Apply a recording-health state pushed from Rust. Kept even while the
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder_tests.swift b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder_tests.swift
index 1b2166d75..09540d4ea 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder_tests.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder_tests.swift
@@ -142,7 +142,7 @@ private func testExpandedBrandCellAtRight() {
horizontal: .center,
scale: 1
)
- expect(topBrand?.0 == "brand" && topBrand?.1 == 4, "brand should be last in top dock")
+ expect(topBrand?.0 == "brand" && topBrand?.1 == 5, "brand should be last in top dock")
let search = dockControl(
at: NSPoint(x: 15, y: 47),
@@ -520,7 +520,7 @@ private func testClampWithoutDisplaysIsIdentity() {
/// Selecting a UI locale must translate labels and leave shortcut tokens intact.
private func testLocalizedDisclosure() {
- let sources = ["right-click", "star work session", "Starred session in progress", "timeline", "ask chat", "search", "mic capture", "live", "idle", "settings"]
+ let sources = ["right-click", "star work session", "{minutes} min left · click to end", "timeline", "ask chat", "search", "mic capture", "live", "idle", "settings"]
let translations = Dictionary(uniqueKeysWithValues: sources.map { source in
(SHA256.hash(data: Data(source.utf8)).prefix(8).map { String(format: "%02x", $0) }.joined(), "localized " + source)
})
@@ -535,8 +535,9 @@ private func testLocalizedDisclosure() {
if control == "timeline" { expect(content?.1 == "⌥Space", "shortcut was translated") }
}
metrics.starredActive = true
+ metrics.starredMinutesRemaining = 42
let activeStar = disclosureContent(for: "star", overlayShortcut: "", chatShortcut: "", searchShortcut: "", starShortcut: "⌥B", metrics: metrics)
- expect(activeStar?.0 == "localized Starred session in progress", "active session status must replace the start hint")
+ expect(activeStar?.0 == "localized 42 min left · click to end", "active session status must replace the start hint")
expect(activeStar?.1 == "⌥B", "active session preserves its stop shortcut")
metrics.starredActive = false
let disabledStar = disclosureContent(for: "star", overlayShortcut: "", chatShortcut: "", searchShortcut: "", starShortcut: "", metrics: metrics)
@@ -549,6 +550,12 @@ private func testLocalizedDisclosure() {
@main
struct ShortcutReminderTests {
static func main() {
+ expect(starredMinutesLeft(until: 3_600_000, now: 0) == 60, "new hour starts at 60 minutes")
+ expect(starredMinutesLeft(until: 3_600_000, now: 59.9) == 60, "round up partial minute")
+ expect(starredMinutesLeft(until: 3_600_000, now: 60) == 59, "minute boundary ticks down")
+ expect(starredMinutesLeft(until: 3_600_000, now: 3599.9) == 1, "last fraction stays active")
+ expect(starredMinutesLeft(until: 3_600_000, now: 3600) == 0, "expiry clears active state")
+ expect(starredMinutesLeft(until: 0, now: 3601) == 0, "ended session cannot be negative")
testAnchorPlacement()
testMarginScales()
testExpandedBrandCellAtRight()