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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
feat: add persistent PostHog announcement cards in the sidebar (#7789)
Louis Beaumontb3acec11e826
diff --git a/apps/screenpipe-app-tauri/README.md b/apps/screenpipe-app-tauri/README.mdindex 80f40d272..577c0193b 100644--- a/apps/screenpipe-app-tauri/README.md+++ b/apps/screenpipe-app-tauri/README.md@@ -253,3 +253,49 @@ SCREENPIPE_DEV_USE_PROD_DATA=1 bun run dev:tauriRelease builds are never redirected, and the E2E harness keeps its ownisolation (`e2e/helpers/app-launcher.ts`) unchanged.++## Persistent sidebar announcements++The existing PostHog `app-announcement` payload supports an opt-in card in the+Home sidebar above the team/settings footer:++```json+{+ "id": "workflows-sidebar-v1",+ "surface": "sidebar",+ "sidebarStyle": "card",+ "kind": "news",+ "title": "Turn your work into workflows",+ "body": "Explore workflows built from your daily work.",+ "image": {+ "url": "https://docs.screenpi.pe/public/app-screenshots/home-home.png",+ "alt": "Screenpipe workspace preview"+ },+ "cta": {+ "label": "Explore workflows",+ "route": "/home?mode=workflows"+ }+}+```++Cards have a separate dismiss button and ignore `autoDismissMs` and+`dismissible: false`. Opening their CTA does not dismiss them. Without a CTA,+clicking opens the existing details dialog; closing that dialog keeps the card.+Explicit dismissal persists locally by announcement ID across app restarts.+Reusing an ID preserves dismissal, while a new ID starts a new announcement.+The flag must remain available and unexpired for the card to appear. Collapsing+the sidebar hides it without dismissing it.++The optional image uses the existing first-party HTTPS URL allowlist, requires+alt text (up to 240 characters), sends no referrer, and falls back to a text card+on invalid metadata or load failure. Markdown body media remains disabled.+Omitting `sidebarStyle` preserves the compact sidebar row. Surveys always use+that row and retain their existing submit/dismiss behavior. Other announcement+surfaces are unchanged.++Use `screenpipe-announcement-preview` in localStorage for browser-mock previews;+this QA override intentionally ignores saved dismissal on reload. Remote+per-ID persistence is covered by the hook tests. Target a compatible released+client before configuring this payload in production: older clients show the+compact sidebar row and keep their earlier CTA dismissal behavior. This source+change alone does not activate or publish an announcement.diff --git a/apps/screenpipe-app-tauri/app/(main)/home/page.tsx b/apps/screenpipe-app-tauri/app/(main)/home/page.tsxindex 6ea223a8f..a42175ba6 100644--- a/apps/screenpipe-app-tauri/app/(main)/home/page.tsx+++ b/apps/screenpipe-app-tauri/app/(main)/home/page.tsx@@ -1674,8 +1674,8 @@ function HomeContent() {<UpdateBanner variant="sidebar" className="mb-2" />- {/* Remote surveys use this quiet, non-blocking slot when their- signed payload selects surface=sidebar. */}+ {/* Remote announcements and surveys use this non-blocking slot+ when their payload selects surface=sidebar. */}<div id="announcement-sidebar-slot" /></div>diff --git a/apps/screenpipe-app-tauri/components/__tests__/announcement-sidebar-card.test.tsx b/apps/screenpipe-app-tauri/components/__tests__/announcement-sidebar-card.test.tsxnew file mode 100644index 000000000..e1e909987--- /dev/null+++ b/apps/screenpipe-app-tauri/components/__tests__/announcement-sidebar-card.test.tsx@@ -0,0 +1,41 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++import { fireEvent, render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import { AnnouncementSidebarCard } from "@/components/announcement-sidebar-card";+import { parseAnnouncement } from "@/lib/announcements";++const card = parseAnnouncement({+ id: "card", surface: "sidebar", sidebarStyle: "card",+ title: "Explore workflows", body: "See your workflows.",+ image: { url: "https://screenpipe.com/card.png", alt: "Workflow preview" },+ autoDismissMs: 1,+})!;++describe("sidebar announcement card", () => {+ it("has separate keyboard-accessible open and dismiss actions, with no timer", () => {+ vi.useFakeTimers();+ try {+ const onOpen = vi.fn(), onDismiss = vi.fn();+ render(<AnnouncementSidebarCard announcement={card} onOpen={onOpen} onDismiss={onDismiss} />);+ vi.advanceTimersByTime(60000);+ expect(onDismiss).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole("button", { name: "Read announcement: Explore workflows" }));+ expect(onOpen).toHaveBeenCalledOnce();+ expect(onDismiss).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole("button", { name: "Dismiss announcement" }));+ expect(onDismiss).toHaveBeenCalledOnce();+ expect(onOpen).toHaveBeenCalledOnce();+ } finally { vi.useRealTimers(); }+ });+ it("falls back to a text card after image failure and retries a replacement image", () => {+ const props = { onOpen: vi.fn(), onDismiss: vi.fn() };+ const { rerender } = render(<AnnouncementSidebarCard announcement={card} {...props} />);+ fireEvent.error(screen.getByRole("img"));+ expect(screen.queryByRole("img")).not.toBeInTheDocument();+ expect(screen.getByText("Explore workflows")).toBeVisible();+ rerender(<AnnouncementSidebarCard announcement={{ ...card, image: { url: "https://screenpipe.com/new.png", alt: "New preview" } }} {...props} />);+ expect(screen.getByRole("img", { name: "New preview" })).toBeVisible();+ });+});diff --git a/apps/screenpipe-app-tauri/components/__tests__/announcement-sidebar-host.test.tsx b/apps/screenpipe-app-tauri/components/__tests__/announcement-sidebar-host.test.tsxnew file mode 100644index 000000000..712c7a32b--- /dev/null+++ b/apps/screenpipe-app-tauri/components/__tests__/announcement-sidebar-host.test.tsx@@ -0,0 +1,50 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++import { fireEvent, render, screen, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { AnnouncementHost } from "@/components/announcement-host";+import { parseAnnouncement } from "@/lib/announcements";++const state = vi.hoisted(() => ({+ announcement: null as unknown,+ dismiss: vi.fn(), activateCta: vi.fn(), reportShown: vi.fn(),+ reportOpened: vi.fn(), submitSurvey: vi.fn(),+}));+vi.mock("@/lib/hooks/use-announcement", () => ({ useAnnouncement: () => state }));+vi.mock("@/lib/utils/is-primary-window", () => ({ isPrimaryWindow: () => true }));++let slot: HTMLElement;+beforeEach(() => {+ vi.clearAllMocks();+ slot = document.createElement("div");+ slot.id = "announcement-sidebar-slot";+ document.body.appendChild(slot);+ state.announcement = parseAnnouncement({ id: "card", surface: "sidebar", sidebarStyle: "card", title: "Explore workflows", body: "Details about workflows." });+});+afterEach(() => slot.remove());++describe("sidebar card host", () => {+ it("opens details on demand and closing details preserves the card", async () => {+ render(<AnnouncementHost />);+ await waitFor(() => expect(screen.getByTestId("announcement-sidebar-card")).toBeVisible());+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "Read announcement: Explore workflows" }));+ expect(screen.getByRole("dialog")).toBeVisible();+ fireEvent.click(screen.getByRole("button", { name: "Got it" }));+ await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());+ expect(state.dismiss).not.toHaveBeenCalled();+ expect(screen.getByTestId("announcement-sidebar-card")).toBeVisible();+ fireEvent.click(screen.getByRole("button", { name: "Dismiss announcement" }));+ expect(state.dismiss).toHaveBeenCalledOnce();+ });+ it("activates the configured CTA directly without opening a modal", async () => {+ state.announcement = { ...(state.announcement as object), cta: { label: "Explore", route: "/home?mode=workflows" } };+ render(<AnnouncementHost />);+ await waitFor(() => expect(screen.getByRole("button", { name: "Explore" })).toBeVisible());+ fireEvent.click(screen.getByRole("button", { name: "Explore" }));+ expect(state.activateCta).toHaveBeenCalledOnce();+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ expect(state.dismiss).not.toHaveBeenCalled();+ });+});diff --git a/apps/screenpipe-app-tauri/components/announcement-host.tsx b/apps/screenpipe-app-tauri/components/announcement-host.tsxindex a511ea2c9..d04df1ab9 100644--- a/apps/screenpipe-app-tauri/components/announcement-host.tsx+++ b/apps/screenpipe-app-tauri/components/announcement-host.tsx@@ -6,6 +6,7 @@import { X } from "lucide-react";import { createPortal } from "react-dom";+import { AnnouncementSidebarCard } from "@/components/announcement-sidebar-card";import { AnnouncementBody } from "@/components/announcement-body";import { AnnouncementBubble } from "@/components/announcement-bubble";import {@@ -275,6 +276,18 @@ export function AnnouncementSidebarPrompt({}, [slot, onShown]);if (!slot) return null;+ if (announcement.sidebarStyle === "card") {+ return createPortal(+ <AnnouncementSidebarCard+ key={announcement.id}+ announcement={announcement}+ onOpen={onOpen}+ onDismiss={onDismiss}+ />,+ slot,+ );+ }+return createPortal(<divdata-testid="announcement-sidebar"@@ -501,13 +514,21 @@ function AnnouncementHostInner() {onDismiss={dismiss}onOpen={() => {reportOpened();- setOpenedSidebarId(announcement.id);+ if (announcement.sidebarStyle === "card" && announcement.cta) {+ activateCta();+ } else {+ setOpenedSidebarId(announcement.id);+ }}}/>{sidebarOpen && (<AnnouncementModalannouncement={announcement}- onDismiss={dismiss}+ onDismiss={+ announcement.sidebarStyle === "card"+ ? () => setOpenedSidebarId(null)+ : dismiss+ }onCta={activateCta}onSubmit={submitSurvey}/>diff --git a/apps/screenpipe-app-tauri/components/announcement-sidebar-card.tsx b/apps/screenpipe-app-tauri/components/announcement-sidebar-card.tsxnew file mode 100644index 000000000..ea2fbe481--- /dev/null+++ b/apps/screenpipe-app-tauri/components/announcement-sidebar-card.tsx@@ -0,0 +1,69 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++"use client";++import { ArrowUpRight, X } from "lucide-react";+import { useState } from "react";+import { useGT } from "gt-react";+import { AnnouncementKindChip } from "@/components/announcement-kind-chip";+import type { Announcement } from "@/lib/announcements";++/** A persistent, opt-in sidebar promotion. Only the separate X dismisses it. */+export function AnnouncementSidebarCard({+ announcement,+ onOpen,+ onDismiss,+}: {+ announcement: Announcement;+ onOpen: () => void;+ onDismiss: () => void;+}) {+ const ui = useGT();+ const [failedImage, setFailedImage] = useState<string | null>(null);+ const image = announcement.image;+ const showImage = image && failedImage !== image.url;+ return (+ <div+ data-testid="announcement-sidebar-card"+ className="relative mb-3 overflow-hidden rounded-lg border border-border bg-background"+ >+ <button+ type="button"+ onClick={onOpen}+ aria-label={announcement.cta?.label ?? ui("Read announcement: {title}", { title: announcement.title })}+ className="block max-h-[35vh] w-full overflow-y-auto p-3 text-left transition-colors duration-150 hover:bg-muted/50 focus-visible:outline focus-visible:outline-1 focus-visible:-outline-offset-4 focus-visible:outline-foreground"+ >+ {showImage && (+ // Plain img preserves the remote image URL in the static desktop export.+ // eslint-disable-next-line @next/next/no-img-element+ <img+ src={image.url}+ alt={image.alt}+ referrerPolicy="no-referrer"+ onError={() => setFailedImage(image.url)}+ className="mb-3 aspect-video w-full rounded-md bg-muted object-cover"+ />+ )}+ <div className="pr-7">+ <AnnouncementKindChip kind={announcement.kind} />+ </div>+ <div className="mt-2 break-words pr-5 font-sans text-sm font-medium leading-snug">+ {announcement.title}+ </div>+ <div className="mt-2 flex items-center gap-2 text-xs text-muted-foreground">+ <span className="min-w-0 break-words">{announcement.cta?.label ?? ui("Learn more")}</span>+ <ArrowUpRight className="h-3.5 w-3.5 shrink-0" aria-hidden />+ </div>+ </button>+ <button+ type="button"+ onClick={onDismiss}+ aria-label={ui("Dismiss announcement")}+ className="absolute right-1 top-1 flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors duration-150 hover:bg-foreground hover:text-background focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-foreground"+ >+ <X className="h-3.5 w-3.5" aria-hidden />+ </button>+ </div>+ );+}diff --git a/apps/screenpipe-app-tauri/lib/__tests__/announcements.test.ts b/apps/screenpipe-app-tauri/lib/__tests__/announcements.test.tsindex d342ab668..f44b7cf25 100644--- a/apps/screenpipe-app-tauri/lib/__tests__/announcements.test.ts+++ b/apps/screenpipe-app-tauri/lib/__tests__/announcements.test.ts@@ -471,3 +471,25 @@ describe("dismissal persistence", () => {expect(selectAnnouncement(VALID, loadDismissedIds(), NOW)).toBeNull();});});+++describe("persistent sidebar card payload", () => {+ const card = { ...VALID, surface: "sidebar", sidebarStyle: "card", dismissible: false };+ it("opts in without changing existing sidebar prompts", () => {+ expect(parseAnnouncement(card)).toMatchObject({ surface: "sidebar", sidebarStyle: "card", dismissible: true });+ expect(parseAnnouncement({ ...VALID, surface: "sidebar" })?.sidebarStyle).toBeUndefined();+ expect(parseAnnouncement({ ...card, surface: "modal" })?.sidebarStyle).toBeUndefined();+ });+ it("accepts bounded image metadata on the existing HTTPS allowlist", () => {+ expect(parseAnnouncement({ ...card, image: { url: "https://screenpipe.com/card.png", alt: "Workflow preview" } })?.image).toEqual({ url: "https://screenpipe.com/card.png", alt: "Workflow preview" });+ for (const url of ["https://example.com/card.png", "javascript:alert(1)", "http://screenpipe.com/a.png", "data:image/svg+xml,test"]) {+ expect(parseAnnouncement({ ...card, image: { url, alt: "Preview" } })?.image).toBeUndefined();+ }+ expect(parseAnnouncement({ ...card, image: { url: "https://screenpipe.com/a.png", alt: "a".repeat(241) } })?.image).toBeUndefined();+ });+ it("keeps surveys on the compact opt-in prompt", () => {+ const parsed = parseAnnouncement({ ...card, cta: undefined, survey: { questions: [{ id: "source", type: "single-choice", prompt: "Where?", choices: [{ id: "a", label: "A" }, { id: "b", label: "B" }] }] } });+ expect(parsed?.survey).toBeDefined();+ expect(parsed?.sidebarStyle).toBeUndefined();+ });+});diff --git a/apps/screenpipe-app-tauri/lib/announcements.ts b/apps/screenpipe-app-tauri/lib/announcements.tsindex acb5c7566..adb370b60 100644--- a/apps/screenpipe-app-tauri/lib/announcements.ts+++ b/apps/screenpipe-app-tauri/lib/announcements.ts@@ -110,6 +110,11 @@ export interface Announcement {* "bottom-right" for card, "bottom" for bubble). undefined for* modal/sidebar. */position?: AnnouncementPosition;+ /** Opt-in persistent promotional card for surface=sidebar. Omit for the+ * existing compact prompt. Surveys always retain the compact prompt. */+ sidebarStyle?: "card";+ /** Optional first-party HTTPS image for the sidebar card. */+ image?: { url: string; alt: string };/** Stable value of a `data-announcement-anchor` attribute in the app. This* is required for `bubble` and ignored for every other surface. Remote* payloads cannot supply arbitrary CSS selectors. */@@ -438,6 +443,17 @@ export function parseAnnouncement(announcement.dismissible = true;}+ if (surface === "sidebar" && r.sidebarStyle === "card" && !r.survey) {+ announcement.sidebarStyle = "card";+ announcement.dismissible = true;+ if (r.image && typeof r.image === "object") {+ const image = r.image as Record<string, unknown>;+ const url = safeAnnouncementExternalUrl(image.url);+ const alt = boundedString(image.alt, 240);+ if (url && alt) announcement.image = { url, alt };+ }+ }+const cta = normalizeCta(r.cta, source);if (cta) announcement.cta = cta;const survey = normalizeSurvey(r.survey);diff --git a/apps/screenpipe-app-tauri/lib/hooks/__tests__/use-announcement.test.tsx b/apps/screenpipe-app-tauri/lib/hooks/__tests__/use-announcement.test.tsxindex c154985f2..c518cbe64 100644--- a/apps/screenpipe-app-tauri/lib/hooks/__tests__/use-announcement.test.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/__tests__/use-announcement.test.tsx@@ -115,6 +115,30 @@ describe("useAnnouncement", () => {vi.unstubAllEnvs();});+ it("keeps sidebar cards after CTA and remount, then persists explicit dismissal", async () => {+ flagPayload.current = { ...FLAG, surface: "sidebar", sidebarStyle: "card", cta: { label: "Explore", route: "/home?mode=workflows" } };+ const first = renderHook(() => useAnnouncement());+ await flushAnnouncementEffects();+ act(() => first.result.current.activateCta());+ expect(pushMock).toHaveBeenCalledWith("/home?mode=workflows");+ expect(first.result.current.announcement?.id).toBe(FLAG.id);+ first.unmount();+ const second = renderHook(() => useAnnouncement());+ await flushAnnouncementEffects();+ expect(second.result.current.announcement?.id).toBe(FLAG.id);+ act(() => second.result.current.dismiss());+ expect(second.result.current.announcement).toBeNull();+ second.unmount();+ const third = renderHook(() => useAnnouncement());+ await flushAnnouncementEffects();+ expect(third.result.current.announcement).toBeNull();+ third.unmount();+ flagPayload.current = { ...FLAG, id: "next-campaign", surface: "sidebar", sidebarStyle: "card" };+ const next = renderHook(() => useAnnouncement());+ await flushAnnouncementEffects();+ expect(next.result.current.announcement?.id).toBe("next-campaign");+ });+it("surfaces the PostHog flag announcement and reports it shown once", async () => {flagPayload.current = FLAG;const { result } = renderHook(() => useAnnouncement());diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-announcement.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-announcement.tsxindex 681400732..c92742a2d 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-announcement.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-announcement.tsx@@ -55,7 +55,7 @@ interface UseAnnouncementResult {announcement: Announcement | null;/** dismiss the current announcement — persists "seen" so it never returns. */dismiss: () => void;- /** act on the cta (navigate / open url) then dismiss. */+ /** Act on the CTA; persistent sidebar cards remain until dismissed. */activateCta: () => void;/** report only after a surface is actually mounted. */reportShown: () => void;@@ -247,6 +247,9 @@ export function useAnnouncement(): UseAnnouncementResult {.catch((err) => console.error("failed to open announcement url:", err));}+ // Persistent sidebar cards stay available until explicitly dismissed.+ if (announcement.sidebarStyle === "card") return;+// acting on the cta also marks it seen.setDismissedIds(markDismissed(announcement.id));setPreview(null);diff --git a/docs/pr-assets/persistent-sidebar-announcement/after-dark.png b/docs/pr-assets/persistent-sidebar-announcement/after-dark.pngnew file mode 100644index 000000000..2fee2fb75Binary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/after-dark.png differdiff --git a/docs/pr-assets/persistent-sidebar-announcement/after-detail.png b/docs/pr-assets/persistent-sidebar-announcement/after-detail.pngnew file mode 100644index 000000000..4ab0d01b3Binary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/after-detail.png differdiff --git a/docs/pr-assets/persistent-sidebar-announcement/after-light.png b/docs/pr-assets/persistent-sidebar-announcement/after-light.pngnew file mode 100644index 000000000..6abf58ae1Binary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/after-light.png differdiff --git a/docs/pr-assets/persistent-sidebar-announcement/before-detail.png b/docs/pr-assets/persistent-sidebar-announcement/before-detail.pngnew file mode 100644index 000000000..2dd810e5dBinary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/before-detail.png differdiff --git a/docs/pr-assets/persistent-sidebar-announcement/before.png b/docs/pr-assets/persistent-sidebar-announcement/before.pngnew file mode 100644index 000000000..449063f66Binary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/before.png differdiff --git a/docs/pr-assets/persistent-sidebar-announcement/compact.png b/docs/pr-assets/persistent-sidebar-announcement/compact.pngnew file mode 100644index 000000000..b1aa22e9eBinary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/compact.png differdiff --git a/docs/pr-assets/persistent-sidebar-announcement/dismissed.png b/docs/pr-assets/persistent-sidebar-announcement/dismissed.pngnew file mode 100644index 000000000..2de168928Binary files /dev/null and b/docs/pr-assets/persistent-sidebar-announcement/dismissed.png differ