Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Windows/Linux: weekly recap card, shared image and settings

Claude9806b66fa891
diff --git a/windows/dev/recap-preview.html b/windows/dev/recap-preview.html
new file mode 100644
index 00000000..15266e2f
--- /dev/null
+++ b/windows/dev/recap-preview.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <title>Coucou — weekly recap preview</title>
+ <style>
+ html, body { overflow: auto !important; height: auto !important; }
+ body { margin: 0; background: #1b1b1f; font: 12px system-ui; color: #ddd; }
+ #root { position: relative !important; width: 720px; height: 230px; margin: 0 auto; }
+ #images { display: flex; gap: 24px; justify-content: center; padding: 8px 24px 32px; }
+ #images figure { margin: 0; text-align: center; }
+ #images img { width: 360px; border-radius: 12px; display: block; margin-bottom: 6px; }
+ </style>
+ </head>
+ <body>
+ <div id="root"></div>
+ <div id="images"></div>
+ <script type="module" src="./recap-preview.ts"></script>
+ </body>
+</html>
diff --git a/windows/dev/recap-preview.ts b/windows/dev/recap-preview.ts
new file mode 100644
index 00000000..62eda111
--- /dev/null
+++ b/windows/dev/recap-preview.ts
@@ -0,0 +1,23 @@
+// The weekly recap card in a real island, and the shared image with and
+// without project names, on the sample week of scripts/test-weekly-recap.swift.
+// `npm run dev`, then open /dev/recap-preview.html. Not shipped in the app.
+
+import "../src/style.css";
+import { Island } from "../src/island/island";
+import { Recap } from "../src/recap/recap";
+import { renderShareImage } from "../src/recap/share";
+
+const island = new Island(document.getElementById("root")!);
+await Recap.open(island);
+
+const images = document.getElementById("images")!;
+const summary = Recap.summary;
+if (summary) {
+ for (const [hide, caption] of [[false, "Shared image"], [true, "Project names hidden"]] as const) {
+ const img = document.createElement("img");
+ img.src = renderShareImage(summary, hide).toDataURL("image/png");
+ const figure = document.createElement("figure");
+ figure.append(img, caption);
+ images.append(figure);
+ }
+}
diff --git a/windows/src/core/bridge.ts b/windows/src/core/bridge.ts
index 24aaf55f..1054998f 100644
--- a/windows/src/core/bridge.ts
+++ b/windows/src/core/bridge.ts
@@ -6,6 +6,7 @@ import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { getCurrentWebview } from "@tauri-apps/api/webview";
import type { Settings } from "./state";
+import type { RecapHistory, RecapPrefs } from "../recap/summary";
export const IS_TAURI =
typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
@@ -99,6 +100,20 @@ export const Bridge = {
/** Tray → Pause. Stops the integration pollers, not just the island. */
setPaused: (paused: boolean) => call<void>("set_paused", { paused }),
+
+ // ── Weekly recap ──────────────────────────────────────────────────────────
+ /** Turns and decisions from `since` (Unix seconds) on, plus the recap prefs. */
+ recapHistory: (since: number) => call<RecapHistory>("recap_history", { since: Math.floor(since) }),
+ recapPrefs: () => call<RecapPrefs>("recap_prefs"),
+ recapSetEnabled: (enabled: boolean) => call<void>("recap_set_enabled", { enabled }),
+ recapSetHideProjects: (hide: boolean) => call<void>("recap_set_hide_projects", { hide }),
+ /** `week` is the Monday (YYYY-MM-DD) the recap opened on its own for. */
+ recapMarkShown: (week: string) => call<void>("recap_mark_shown", { week }),
+ recapClear: () => call<void>("recap_clear"),
+ /** Writes the PNG (a data URL) into Pictures or Downloads; returns its path. */
+ recapSavePng: (data: string, week: string) => callOrThrow<string>("recap_save_png", { data, week }),
+ /** Opens the folder of the image saved last. */
+ recapRevealSaved: () => call<void>("recap_reveal_saved"),
};
export interface IntegrationUpdate {
diff --git a/windows/src/core/layout.ts b/windows/src/core/layout.ts
index 6f70eea4..6821eff7 100644
--- a/windows/src/core/layout.ts
+++ b/windows/src/core/layout.ts
@@ -21,7 +21,8 @@ export type IslandViewName =
| "result"
| "note"
| "settings"
- | "greeting";
+ | "greeting"
+ | "recap";
export type BotStateName =
| "idle"
@@ -86,6 +87,10 @@ export const VIEW_LAYOUTS: Record<IslandViewName, ViewLayout> = {
note: { height: 160, botX: 60, botY: null, botDiameter: 50, agentMode: "column" },
settings: { height: 160, botX: 54, botY: null, botDiameter: 46, agentMode: "none" },
greeting: { height: 150, botX: 320, botY: 90, botDiameter: 0, agentMode: "none" },
+ // Mac: 160. The extra 24 hold the two lines with top agent, project, busiest
+ // day, longest session, permissions and questions, which the Mac card leaves
+ // to the shared image.
+ recap: { height: 184, botX: 62, botY: null, botDiameter: 58, agentMode: "column" },
};
// The upload views above are only the fallback geometry. Once a file is actually
diff --git a/windows/src/island/island.ts b/windows/src/island/island.ts
index 7fdb6180..e8512306 100644
--- a/windows/src/island/island.ts
+++ b/windows/src/island/island.ts
@@ -84,6 +84,11 @@ export class Island {
private prevViewBeforeConfused: IslandViewName = "overview";
private lastSyncedView: IslandViewName | null = null;
+ /** The launch greeting ended, or the island came out of hidden — two of the
+ * moments the Monday recap may open (see src/recap/recap.ts). */
+ onGreetingDone: (() => void) | null = null;
+ onWake: (() => void) | null = null;
+
/** Drop sequence bookkeeping: last tick played, and whether the ✓ has fired. */
private uploadTens = 0;
private uploadDone = false;
@@ -94,7 +99,10 @@ export class Island {
this.wireFsm();
this.wireInput();
this.engine.onDizzy = () => this.handleDizzy();
- this.greeting.onComplete = () => this.fsm.greetComplete();
+ this.greeting.onComplete = () => {
+ this.fsm.greetComplete();
+ this.onGreetingDone?.();
+ };
State.subscribe(() => {
this.dirty = true;
this.ensureRunning();
@@ -247,6 +255,7 @@ export class Island {
break;
}
State.notify();
+ if (from === "hidden") this.onWake?.();
};
}
diff --git a/windows/src/main.ts b/windows/src/main.ts
index f65d5e75..acdbf922 100644
--- a/windows/src/main.ts
+++ b/windows/src/main.ts
@@ -7,6 +7,7 @@ import { State, type Settings } from "./core/state";
import { Island } from "./island/island";
import { registerHookHandlers } from "./island/hooks";
import { registerIntegrationHandlers, refreshConfigured } from "./island/integrations";
+import { Recap } from "./recap/recap";
async function main() {
const root = document.getElementById("root");
@@ -43,6 +44,10 @@ async function main() {
setPaused(false);
island.alert(State.defaultView());
break;
+ case "recap":
+ setPaused(false);
+ void Recap.open(island);
+ break;
case "pause":
setPaused(!State.paused);
if (State.paused) island.fsm.forceHidden();
@@ -64,6 +69,12 @@ async function main() {
registerHookHandlers(island);
registerIntegrationHandlers(island);
+ // Monday recap: app start (greeting over), an agent starting work, waking up.
+ const checkRecap = () => void Recap.check(island);
+ island.onGreetingDone = checkRecap;
+ island.onWake = checkRecap;
+ await onEvent<null>("recap-check", checkRecap);
+
island.launch();
// In a plain browser there is no wake strip behind the cursor: make the whole
diff --git a/windows/src/recap/recap.ts b/windows/src/recap/recap.ts
new file mode 100644
index 00000000..9b38df11
--- /dev/null
+++ b/windows/src/recap/recap.ts
@@ -0,0 +1,87 @@
+// Weekly recap — when the card opens, and what it shows. Port of
+// AppDelegate.checkMondayRecap / openWeeklyRecap.
+//
+// It opens on its own once a week, on Monday from 8 am, at the first of:
+// * the launch greeting ending (the app starting that day),
+// * an agent starting work (SessionStart / UserPromptSubmit — Rust sends
+// `recap-check` when it sees one),
+// * the island waking from hidden (the user coming back to the machine).
+// And any time from the tray: "Weekly recap". Nothing here runs on a timer.
+
+import { Bridge, IS_TAURI } from "../core/bridge";
+import type { IslandViewName } from "../core/layout";
+import { State } from "../core/state";
+import {
+ DEFAULT_PREFS, dayKey, mondayOf, previousWeekStart, sampleHistory, shouldAutoShow, summarize,
+ type RecapPrefs, type WeeklySummary,
+} from "./summary";
+
+/** What the recap needs from the island. */
+export interface RecapHost {
+ alert(view: IslandViewName): void;
+}
+
+/** Views the Monday card may replace; anything else is the user busy with something. */
+const QUIET_VIEWS: ReadonlySet<IslandViewName> = new Set(["overview", "empty", "settings", "greeting"]);
+
+/** Same 1.5 s as the Mac, so it never lands on top of the event that triggered it. */
+const SHOW_DELAY_MS = 1500;
+
+class RecapController {
+ summary: WeeklySummary | null = null;
+ prefs: RecapPrefs = { ...DEFAULT_PREFS };
+ /** Bumped on every load, so the view knows to rebuild (and leave share mode). */
+ version = 0;
+ private checking = false;
+
+ /** Reads last week from Rust. A plain browser (`npm run dev`) gets the sample week. */
+ async load(now = new Date()): Promise<WeeklySummary | null> {
+ const start = previousWeekStart(now);
+ const history = IS_TAURI
+ ? await Bridge.recapHistory(start.getTime() / 1000)
+ : sampleHistory(start);
+ this.prefs = { ...DEFAULT_PREFS, ...(history?.prefs ?? {}) };
+ this.summary = history ? summarize(history, start) : null;
+ this.version++;
+ return this.summary;
+ }
+
+ /** Tray → Weekly recap. Shows the card even for an empty week. */
+ async open(host: RecapHost) {
+ await this.load();
+ host.alert("recap");
+ }
+
+ /** Monday ≥ 8 am, not shown yet this week, something to show, nobody interrupted. */
+ async check(host: RecapHost, now = new Date()) {
+ // The clock first: six days out of seven this is all that runs.
+ if (this.checking || !shouldAutoShow(now, "") || !this.quiet()) return;
+ this.checking = true;
+ try {
+ const prefs = IS_TAURI ? await Bridge.recapPrefs() : null;
+ if (!prefs?.enabled || !shouldAutoShow(now, prefs.lastShownWeek)) return;
+ if (!(await this.load(now))) return;
+ const week = dayKey(mondayOf(now));
+ window.setTimeout(() => {
+ if (!this.quiet()) return;
+ host.alert("recap");
+ void Bridge.recapMarkShown(week);
+ this.prefs.lastShownWeek = week;
+ }, SHOW_DELAY_MS);
+ } finally {
+ this.checking = false;
+ }
+ }
+
+ private quiet(): boolean {
+ if (State.paused || State.pendingApproval) return false;
+ return State.mode !== "expanded" || QUIET_VIEWS.has(State.view);
+ }
+
+ async setHideProjects(hide: boolean) {
+ this.prefs.hideProjects = hide;
+ await Bridge.recapSetHideProjects(hide);
+ }
+}
+
+export const Recap = new RecapController();
diff --git a/windows/src/recap/share.ts b/windows/src/recap/share.ts
new file mode 100644
index 00000000..7086a4cf
--- /dev/null
+++ b/windows/src/recap/share.ts
@@ -0,0 +1,261 @@
+// The 1080 × 1920 image of the week, drawn once into an offscreen canvas —
+// port of RecapShareImageView in WeeklyRecapView.swift. Same colours, sizes
+// and order; Mochi comes from the island's own engine.
+
+import { BotEngine } from "../mochi/engine";
+import { formatCount, formatDuration, weekRangeLabel, type WeeklySummary } from "./summary";
+
+export const SHARE_W = 1080;
+export const SHARE_H = 1920;
+
+const FONT = `system-ui, "Segoe UI Variable Display", "Segoe UI", "Cantarell", "Ubuntu", sans-serif`;
+const MONO = `"Cascadia Mono", "Consolas", "DejaVu Sans Mono", ui-monospace, monospace`;
+
+const INK = "#F1F2F4";
+const DIM = "#8E939C";
+const INDIGO_TEXT = "#818CF8";
+
+/** Strings drawn into the image, in one place for the translation layer. */
+const T = {
+ title: "Weekly recap",
+ timeCoding: "TIME CODING",
+ sessions: "SESSIONS",
+ files: "FILES",
+ commands: "COMMANDS",
+ topAgent: "Top agent",
+ topProject: "Top project",
+ busiestDay: "Busiest day",
+ longestSession: "Longest session",
+ approved: "Approved",
+ denied: "Denied",
+ footer: "Coucou · github.com/Louis-CFM/coucou",
+};
+
+type Ctx = CanvasRenderingContext2D;
+
+function font(x: Ctx, weight: number, size: number, family = FONT) {
+ x.font = `${weight} ${size}px ${family}`;
+}
+
+/** Shrinks the font until `text` fits in `maxW` (minimumScaleFactor). */
+function fitFont(x: Ctx, text: string, weight: number, size: number, maxW: number, minScale: number) {
+ let s = size;
+ font(x, weight, s);
+ while (x.measureText(text).width > maxW && s > size * minScale) {
+ s -= 2;
+ font(x, weight, s);
+ }
+}
+
+/** Text with letter spacing, centred on `cx` — `letterSpacing` is not everywhere yet. */
+function spaced(x: Ctx, text: string, cx: number, y: number, spacing: number) {
+ const chars = [...text];
+ const widths = chars.map((c) => x.measureText(c).width);
+ const total = widths.reduce((a, b) => a + b, 0) + spacing * (chars.length - 1);
+ let at = cx - total / 2;
+ x.textAlign = "left";
+ chars.forEach((c, i) => {
+ x.fillText(c, at, y);
+ at += widths[i] + spacing;
+ });
+}
+
+/** Cuts `text` with an ellipsis so it fits `maxW` in the current font. */
+function ellipsize(x: Ctx, text: string, maxW: number): string {
+ if (x.measureText(text).width <= maxW) return text;
+ let t = text;
+ while (t.length > 1 && x.measureText(`${t}…`).width > maxW) t = t.slice(0, -1);
+ return `${t}…`;
+}
+
+function roundRect(x: Ctx, left: number, top: number, w: number, h: number, r: number) {
+ x.beginPath();
+ x.moveTo(left + r, top);
+ x.arcTo(left + w, top, left + w, top + h, r);
+ x.arcTo(left + w, top + h, left, top + h, r);
+ x.arcTo(left, top + h, left, top, r);
+ x.arcTo(left, top, left + w, top, r);
+ x.closePath();
+}
+
+const BADGE_H = 66;
+const BADGE_GAP = 16;
+
+function badge(x: Ctx, left: number, top: number, w: number, label: string, value: string) {
+ x.fillStyle = "rgba(255,255,255,0.05)";
+ roundRect(x, left, top, w, BADGE_H, 18);
+ x.fill();
+ const mid = top + BADGE_H / 2;
+ x.textBaseline = "middle";
+ font(x, 400, 24);
+ x.fillStyle = DIM;
+ x.textAlign = "left";
+ x.fillText(label, left + 32, mid);
+ const labelW = x.measureText(label).width;
+ font(x, 600, 24);
+ x.fillStyle = INK;
+ x.textAlign = "right";
+ x.fillText(ellipsize(x, value, w - 64 - labelW - 16), left + w - 32, mid);
+}
+
+/** A still Mochi, drawn by the same engine as the island's. */
+function drawMochi(x: Ctx, cx: number, top: number, size: number) {
+ const engine = new BotEngine();
+ engine.setState("idle", true);
+ engine.update(1 / 60);
+ x.save();
+ x.translate(cx - size / 2, top);
+ engine.draw(x, size, size);
+ x.restore();
+}
+
+export function renderShareImage(s: WeeklySummary, hideProjects: boolean): HTMLCanvasElement {
+ const canvas = document.createElement("canvas");
+ canvas.width = SHARE_W;
+ canvas.height = SHARE_H;
+ const x = canvas.getContext("2d");
+ if (!x) return canvas;
+ const W = SHARE_W;
+ const cx = W / 2;
+
+ // Background: near-black with an indigo glow low in the frame.
+ x.fillStyle = "#0B0C0E";
+ x.fillRect(0, 0, W, SHARE_H);
+ const glow = x.createRadialGradient(cx, SHARE_H * 0.75, 0, cx, SHARE_H * 0.75, 900);
+ glow.addColorStop(0, "rgba(99,102,241,0.30)");
+ glow.addColorStop(0.65, "rgba(99,102,241,0)");
+ x.fillStyle = glow;
+ x.fillRect(0, 0, W, SHARE_H);
+
+ // What goes in the badge list.
+ const badges: [string, string][] = [];
+ if (s.topAgent) badges.push([T.topAgent, s.topAgent]);
+ if (!hideProjects && s.topProject) badges.push([T.topProject, s.topProject]);
+ if (s.busiestDay) badges.push([T.busiestDay, s.busiestDay]);
+ if (s.longestSessionMinutes > 1) badges.push([T.longestSession, formatDuration(s.longestSessionMinutes)]);
+ const decisions = s.permissionsAllowed + s.permissionsDenied > 0;
+ const badgeRows = badges.length + (decisions ? 1 : 0);
+ const hasLines = s.linesAdded + s.linesRemoved > 0;
+
+ // Heights of each block, so the whole stack can be centred like the VStack.
+ // Mochi's body fills ~60 % of the square the engine draws into.
+ const MOCHI = 220;
+ const MOCHI_DRAW = 320;
+ const blockH =
+ MOCHI + 20 + 62 + 6 + 36 + 14 + 29 + 80 + // Mochi, Coucou, title, range
+ 110 + 6 + 26 + // time + caption
+ 56 + 94 + // stat row
+ (hasLines ? 24 + 34 : 0) +
+ (badgeRows > 0 ? 56 + badgeRows * BADGE_H + (badgeRows - 1) * BADGE_GAP : 0);
+ const footerTop = SHARE_H - 60 - 24;
+ let y = Math.max(40, (footerTop - blockH) / 2);
+
+ x.textBaseline = "top";
+
+ drawMochi(x, cx, y + MOCHI / 2 - MOCHI_DRAW / 2 - MOCHI_DRAW * 0.02, MOCHI_DRAW);
+ y += MOCHI + 20;
+
+ x.fillStyle = INK;
+ x.textAlign = "center";
+ font(x, 900, 52);
+ x.fillText("Coucou", cx, y);
+ y += 62 + 6;
+
+ x.fillStyle = DIM;
+ font(x, 500, 30);
+ x.fillText(T.title, cx, y);
+ y += 36 + 14;
+
+ x.fillStyle = INDIGO_TEXT;
+ font(x, 400, 24);
+ x.fillText(weekRangeLabel(s), cx, y);
+ y += 29 + 80;
+
+ // Time — the headline number.
+ const time = formatDuration(s.totalMinutes);
+ x.fillStyle = INK;
+ fitFont(x, time, 900, 100, W - 120, 0.4);
+ x.textAlign = "center";
+ x.fillText(time, cx, y);
+ y += 110 + 6;
+ x.fillStyle = DIM;
+ font(x, 600, 22);
+ spaced(x, T.timeCoding, cx, y, 3);
+ y += 26 + 56;
+
+ // Sessions | files | commands
+ const stats: [string, string][] = [
+ [formatCount(s.sessionCount), T.sessions],
+ [formatCount(s.filesChanged), T.files],
+ ];
+ if (s.commandsRun > 0) stats.push([formatCount(s.commandsRun), T.commands]);
+ const rowLeft = 40;
+ const colW = (W - rowLeft * 2) / stats.length;
+ stats.forEach(([value, label], i) => {
+ const colCx = rowLeft + colW * (i + 0.5);
+ if (i > 0) {
+ x.fillStyle = "rgba(255,255,255,0.08)";
+ x.fillRect(rowLeft + colW * i, y + 7, 1, 80);
+ }
+ x.fillStyle = INK;
+ fitFont(x, value, 900, 64, colW - 24, 0.5);
+ x.textAlign = "center";
+ x.fillText(value, colCx, y);
+ x.fillStyle = DIM;
+ font(x, 600, 18);
+ spaced(x, label, colCx, y + 72, 2);
+ });
+ y += 94;
+
+ // Lines added / removed
+ if (hasLines) {
+ y += 24;
+ const plus = `+${formatCount(s.linesAdded)}`;
+ const minus = `−${formatCount(s.linesRemoved)}`;
+ font(x, 600, 28, MONO);
+ const pw = x.measureText(plus).width;
+ const mw = x.measureText(minus).width;
+ const start = cx - (pw + 24 + mw) / 2;
+ x.textAlign = "left";
+ x.fillStyle = "#4ADE80";
+ x.fillText(plus, start, y);
+ x.fillStyle = "#F87171";
+ x.fillText(minus, start + pw + 24, y);
+ y += 34;
+ }
+
+ // Badges
+ if (badgeRows > 0) {
+ y += 56;
+ const left = 60;
+ const w = W - left * 2;
+ for (const [label, value] of badges) {
+ badge(x, left, y, w, label, value);
+ y += BADGE_H + BADGE_GAP;
+ }
+ if (decisions) {
+ const half = (w - BADGE_GAP) / 2;
+ badge(x, left, y, half, T.approved, formatCount(s.permissionsAllowed));
+ badge(x, left + half + BADGE_GAP, y, half, T.denied, formatCount(s.permissionsDenied));
+ }
+ }
+
+ // Footer
+ x.textBaseline = "top";
+ x.textAlign = "center";
+ x.fillStyle = "rgba(142,147,156,0.6)";
+ font(x, 500, 20, MONO);
+ x.fillText(T.footer, cx, footerTop);
+
+ return canvas;
+}
+
+/** The canvas as a PNG data URL, for Rust to write to disk. */
+export function toPngDataUrl(canvas: HTMLCanvasElement): string {
+ return canvas.toDataURL("image/png");
+}
+
+/** The canvas as a PNG blob, for the clipboard. */
+export function toPngBlob(canvas: HTMLCanvasElement): Promise<Blob | null> {
+ return new Promise((resolve) => canvas.toBlob(resolve, "image/png"));
+}
diff --git a/windows/src/settings/main.ts b/windows/src/settings/main.ts
index 3ab9ab94..36b239dc 100644
--- a/windows/src/settings/main.ts
+++ b/windows/src/settings/main.ts
@@ -414,9 +414,55 @@ function generalSection(): HTMLElement {
h("label", { text: "Launch at startup" }),
toggle(settings.autostart, (v) => { settings.autostart = v; void save(); }),
),
+ ...recapRows(),
);
}
+/** Settings → General → Weekly recap. The prefs live with the history in Rust. */
+function recapRows(): HTMLElement[] {
+ const T = {
+ label: "Weekly recap",
+ keep: "Keep a history of my coding sessions",
+ clear: "Clear history",
+ cleared: "History cleared.",
+ about: "Counts and project names only — never commands, files or prompts. Kept on this computer for 12 weeks.",
+ };
+ const feedback = h("span", { class: "hint" });
+ const sw = toggle(true, (v) => { void Bridge.recapSetEnabled(v); });
+ void Bridge.recapPrefs().then((prefs) => {
+ if (prefs) sw.classList.toggle("on", prefs.enabled);
+ });
+ const clearBtn = h("button", {
+ class: "danger",
+ text: T.clear,
+ onclick: async () => {
+ clearBtn.disabled = true;
+ await Bridge.recapClear();
+ feedback.textContent = T.cleared;
+ window.setTimeout(() => {
+ clearBtn.disabled = false;
+ feedback.textContent = "";
+ }, 2400);
+ },
+ }) as HTMLButtonElement;
+ return [
+ h("div", { class: "row" },
+ h("label", { text: T.label }),
+ sw,
+ h("span", { class: "hint", text: T.keep }),
+ ),
+ h("div", { class: "row" },
+ h("label", {}),
+ clearBtn,
+ feedback,
+ ),
+ h("div", { class: "row" },
+ h("label", {}),
+ h("span", { class: "hint", style: "flex:1 1 0;min-width:0", text: T.about }),
+ ),
+ ];
+}
+
// ── Boot ──────────────────────────────────────────────────────────────────────
async function main() {
diff --git a/windows/src/style.css b/windows/src/style.css
index b2cf6756..76c95fb4 100644
--- a/windows/src/style.css
+++ b/windows/src/style.css
@@ -1365,3 +1365,109 @@ input[type="range"]::-webkit-slider-thumb {
.int-card.detail {
padding-top: 8px;
}
+
+/* ── Weekly recap ───────────────────────────────────────────────────────── */
+/* WeeklyRecapCardView: text from x = 116, indigo wash, chips of 17 px values. */
+
+.recap-stack {
+ padding: 4px 16px 4px 116px;
+ gap: 4px;
+}
+
+.recap-head {
+ display: flex;
+ align-items: baseline;
+ gap: 6px;
+}
+
+.recap-title {
+ font: 600 11px var(--font);
+ color: #818cf8;
+}
+
+.recap-range {
+ font: 400 10px var(--font);
+ color: var(--dim-2);
+ white-space: nowrap;
+}
+
+.recap-chips {
+ display: flex;
+ gap: 14px;
+ white-space: nowrap;
+}
+
+.recap-chip .v {
+ font: 700 17px var(--font);
+ color: var(--ink-2);
+}
+
+.recap-chip .l {
+ font: 400 9px var(--font);
+ color: var(--dim-2);
+}
+
+.recap-meta {
+ display: flex;
+ gap: 5px;
+ font: 400 11px var(--font);
+ color: var(--dim-2);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.recap-meta .n {
+ color: var(--ink-2);
+ font-weight: 600;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.recap-meta .sep {
+ color: var(--dim-4);
+}
+
+.recap-stack .actions {
+ margin-top: 3px;
+}
+
+.recap-share {
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-start;
+ gap: 16px;
+ padding: 8px 16px 8px 116px;
+}
+
+.recap-thumb {
+ flex: 0 0 64px;
+ width: 64px;
+ height: 114px;
+ border-radius: 8px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
+}
+
+.recap-share-side {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ min-width: 0;
+}
+
+.recap-status {
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+ min-height: 14px;
+ font: 400 11px var(--font);
+ color: var(--dim);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.recap-link {
+ color: #818cf8;
+ padding: 0;
+}
diff --git a/windows/src/views/recap.ts b/windows/src/views/recap.ts
new file mode 100644
index 00000000..7f0a8f16
--- /dev/null
+++ b/windows/src/views/recap.ts
@@ -0,0 +1,236 @@
+// Weekly recap card and its share panel — port of WeeklyRecapCardView and
+// RecapSharePanelView (WeeklyRecapView.swift). The Mac shares from a separate
+// panel; here the card flips to a share mode inside the island, because a
+// window created after launch comes up blank in WebView2 (see lib.rs).
+//
+// Nothing animates in this view: the image is drawn once, when share mode
+// opens or the privacy toggle changes.
+
+import { h, clear } from "./dom";
+import { Bridge } from "../core/bridge";
+import { washRGBA } from "../core/layout";
+import { Recap } from "../recap/recap";
+import { renderShareImage, toPngBlob, toPngDataUrl } from "../recap/share";
+import {
+ dayKey, formatCount, formatDuration, weekRangeLabel, type WeeklySummary,
+} from "../recap/summary";
+import type { ViewActions, ViewHost } from "./views";
+
+/** User-visible strings, in one place for the translation layer. */
+const T = {
+ title: "Weekly recap",
+ noActivity: "No activity last week",
+ noActivitySub: "Coucou counts your agent sessions as they happen — check back next Monday.",
+ coding: "coding",
+ session: "session",
+ sessions: "sessions",
+ file: "file",
+ files: "files",
+ lines: "lines",
+ commands: "commands",
+ topAgent: "Top agent",
+ topProject: "Top project",
+ busiestDay: "Busiest day",
+ longest: "Longest session",
+ permissions: "Permissions",
+ allowedDenied: (a: number, d: number) => `${a} allowed, ${d} denied`,
+ questions: "Questions",
+ shareImage: "Share image",
+ ok: "OK",
+ shareTitle: "Share your week",
+ hideProjects: "Hide project names",
+ save: "Save image",
+ copy: "Copy",
+ back: "Back",
+ saving: "Saving…",
+ savedAs: (name: string) => `Saved as ${name}`,
+ showInFolder: "Show in folder",
+ copied: "Copied — paste it anywhere.",
+ copyUnavailable: "Copying images isn't available here — use Save image.",
+};
+
+function btn(label: string, kind: "primary" | "secondary", onClick: () => void): HTMLButtonElement {
+ return h("button", { class: `btn ${kind}`, onclick: onClick }, h("span", { text: label }));
+}
+
+function chip(value: string, label: string): HTMLElement {
+ return h("div", { class: "recap-chip" },
+ h("div", { class: "v", text: value }),
+ h("div", { class: "l", text: label }),
+ );
+}
+
+/** "Label value · Label value" — values in white, like the who-row. */
+function metaLine(pairs: [string, string][]): HTMLElement | null {
+ if (pairs.length === 0) return null;
+ const el = h("div", { class: "recap-meta" });
+ pairs.forEach(([label, value], i) => {
+ if (i > 0) el.append(h("span", { class: "sep", text: "·" }));
+ el.append(h("span", { text: label }), h("span", { class: "n", text: value }));
+ });
+ return el;
+}
+
+const plural = (n: number, one: string, many: string) => (n === 1 ? one : many);
+
+export function buildRecap(actions: ViewActions): ViewHost {
+ const card = h("div", { class: "card wash recap-card" });
+ card.style.setProperty("--wash", washRGBA("indigo"));
+ const el = h("div", { class: "view" }, card);
+
+ let built = -1;
+ let shareCanvas: HTMLCanvasElement | null = null;
+
+ function summaryBody(s: WeeklySummary): HTMLElement {
+ const chips = h("div", { class: "recap-chips" },
+ chip(formatDuration(s.totalMinutes), T.coding),
+ chip(formatCount(s.sessionCount), plural(s.sessionCount, T.session, T.sessions)),
+ chip(formatCount(s.filesChanged), plural(s.filesChanged, T.file, T.files)),
+ );
+ if (s.linesAdded + s.linesRemoved > 0) {
+ chips.append(chip(`+${formatCount(s.linesAdded)} / −${formatCount(s.linesRemoved)}`, T.lines));
+ }
+ if (s.commandsRun > 0) chips.append(chip(formatCount(s.commandsRun), T.commands));
+
+ const first: [string, string][] = [];
+ if (s.topAgent) first.push([T.topAgent, s.topAgent]);
+ if (s.topProject) first.push([T.topProject, s.topProject]);
+ if (s.busiestDay) first.push([T.busiestDay, s.busiestDay]);
+ const second: [string, string][] = [];
+ if (s.longestSessionMinutes > 1) second.push([T.longest, formatDuration(s.longestSessionMinutes)]);
+ if (s.permissionsAllowed + s.permissionsDenied > 0) {
+ second.push([T.permissions, T.allowedDenied(s.permissionsAllowed, s.permissionsDenied)]);
+ }
+ if (s.questions > 0) second.push([T.questions, formatCount(s.questions)]);
+
+ return h("div", { class: "stack recap-stack" },
+ h("div", { class: "recap-head" },
+ h("span", { class: "recap-title", text: T.title }),
+ h("span", { class: "grow" }),
+ h("span", { class: "recap-range", text: weekRangeLabel(s) }),
+ ),
+ chips,
+ metaLine(first),
+ metaLine(second),
+ h("div", { class: "actions" },
+ btn(T.shareImage, "primary", () => showShare(s)),
+ btn(T.ok, "secondary", () => actions.collapse()),
+ ),
+ );
+ }
+
+ function emptyBody(): HTMLElement {
+ return h("div", { class: "stack recap-stack" },
+ h("div", { class: "title", text: T.noActivity }),
+ h("div", { class: "sub", text: T.noActivitySub }),
+ h("div", { class: "actions" }, btn(T.ok, "secondary", () => actions.collapse())),
+ );
+ }
+
+ function showSummary() {
+ clear(card);
+ card.append(Recap.summary ? summaryBody(Recap.summary) : emptyBody());
+ }
+
+ function showShare(s: WeeklySummary) {
+ const thumb = h("canvas", { class: "recap-thumb" });
+ const status = h("div", { class: "recap-status" });
+ const sw = h("button", { class: Recap.prefs.hideProjects ? "switch on" : "switch" });
+
+ const draw = () => {
+ shareCanvas = renderShareImage(s, Recap.prefs.hideProjects);
+ const dpr = Math.min(2, window.devicePixelRatio || 1);
+ thumb.width = Math.round(64 * dpr);
+ thumb.height = Math.round(114 * dpr);
+ const ctx = thumb.getContext("2d");
+ if (ctx) {
+ ctx.imageSmoothingQuality = "high";
+ ctx.drawImage(shareCanvas, 0, 0, thumb.width, thumb.height);
+ }
+ };
+
+ const say = (text: string, extra?: HTMLElement) => {
+ clear(status);
+ status.append(h("span", { text }));
+ if (extra) status.append(extra);
+ };
+
+ sw.addEventListener("click", () => {
+ const next = !Recap.prefs.hideProjects;
+ sw.classList.toggle("on", next);
+ void Recap.setHideProjects(next);
+ draw();
+ clear(status);
+ });
+
+ const save = btn(T.save, "primary", async () => {
+ if (!shareCanvas) return;
+ save.disabled = true;
+ say(T.saving);
+ try {
+ const path = await Bridge.recapSavePng(toPngDataUrl(shareCanvas), dayKey(s.weekStart));
+ const name = path.split(/[\\/]/).pop() ?? path;
+ say(T.savedAs(name), h("button", {
+ class: "link-btn recap-link",
+ text: T.showInFolder,
+ onclick: () => void Bridge.recapRevealSaved(),
+ }));
+ } catch (err) {
+ say(String(err).replace(/^Error:\s*/, ""));
+ } finally {
+ save.disabled = false;
+ }
+ });
+
+ const copy = btn(T.copy, "secondary", async () => {
+ if (!shareCanvas) return;
+ say(await copyImage(shareCanvas) ? T.copied : T.copyUnavailable);
+ });
+
+ clear(card);
+ card.append(h("div", { class: "stack recap-share" },
+ thumb,
+ h("div", { class: "recap-share-side" },
+ h("div", { class: "recap-title", text: T.shareTitle }),
+ h("div", { class: "settings-row" }, sw, h("span", { text: T.hideProjects })),
+ h("div", { class: "actions" }, save, copy, btn(T.back, "secondary", showSummary)),
+ status,
+ ),
+ ));
+ draw();
+ }
+
+ return {
+ el,
+ sync() {
+ // Rebuilt only when the recap was (re)loaded, never on every state change:
+ // that would reset share mode under the user's cursor.
+ if (built === Recap.version) return;
+ built = Recap.version;
+ shareCanvas = null;
+ showSummary();
+ },
+ };
+}
+
+/**
+ * Puts the PNG on the clipboard through the web Clipboard API — no new
+ * dependency. It needs the document focused, and the island never takes focus
+ * on its own, so it is lent focus for the duration. WebKitGTK builds without
+ * image clipboard support say no, and the caller offers Save instead.
+ */
+async function copyImage(canvas: HTMLCanvasElement): Promise<boolean> {
+ const Item = (window as { ClipboardItem?: typeof ClipboardItem }).ClipboardItem;
+ if (!Item || !navigator.clipboard?.write) return false;
+ await Bridge.focusWindow(true);
+ try {
+ const blob = await toPngBlob(canvas);
+ if (!blob) return false;
+ await navigator.clipboard.write([new Item({ "image/png": blob })]);
+ return true;
+ } catch {
+ return false;
+ } finally {
+ void Bridge.focusWindow(false);
+ }
+}
diff --git a/windows/src/views/views.ts b/windows/src/views/views.ts
index ac0ac7b6..8fdaa117 100644
--- a/windows/src/views/views.ts
+++ b/windows/src/views/views.ts
@@ -11,6 +11,7 @@ import { createMiniBot, pruneMiniBots } from "../mochi/minibots";
import { buildPrompt } from "./chat";
import { buildChoose, buildUpload, buildUploading } from "./upload";
import { renderIntegrationCard, type IntegrationCardHooks } from "./integrations";
+import { buildRecap } from "./recap";
export interface ViewActions {
setView(v: IslandViewName): void;
@@ -501,6 +502,7 @@ export function buildViews(
map.set("upload", buildUpload());
map.set("uploading", buildUploading());
map.set("choose", buildChoose(actions));
+ map.set("recap", buildRecap(actions));
// Not in the Windows v1: sending a file by email, window attach + web result.
map.set("mail", buildPlaceholder("Sending by email isn't in this version.", ""));
map.set("searching", buildPlaceholder("Claude is searching…", ""));
diff --git a/windows/tests/recap-trigger.test.mjs b/windows/tests/recap-trigger.test.mjs
new file mode 100644
index 00000000..efa3eff7
--- /dev/null
+++ b/windows/tests/recap-trigger.test.mjs
@@ -0,0 +1,103 @@
+// When the weekly recap opens on its own (src/recap/recap.ts), driven through
+// the real bridge with Rust's answers stubbed.
+
+import { afterEach, beforeEach, mock, test } from "node:test";
+import assert from "node:assert/strict";
+import { calls, internals, sent } from "./tauri.mjs";
+import { Recap } from "../src/recap/recap.ts";
+import { sampleHistory, previousWeekStart } from "../src/recap/summary.ts";
+import { State } from "../src/core/state.ts";
+
+const MONDAY_9AM = new Date(2026, 9, 5, 9, 0);
+const original = internals.invoke;
+
+let prefs;
+let history;
+let shown;
+const host = { alert: (view) => shown.push(view) };
+
+beforeEach(() => {
+ mock.timers.enable({ apis: ["setTimeout"] });
+ calls.length = 0;
+ shown = [];
+ prefs = { enabled: true, hideProjects: false, lastShownWeek: "" };
+ history = sampleHistory(previousWeekStart(MONDAY_9AM));
+ internals.invoke = async (cmd, args) => {
+ if (cmd.startsWith("recap_") && cmd !== "recap_mark_shown") calls.push([cmd, args]);
+ if (cmd === "recap_prefs") return prefs;
+ if (cmd === "recap_history") return { ...history, prefs };
+ return original(cmd, args);
+ };
+ State.mode = "hidden";
+ State.view = "overview";
+ State.paused = false;
+ State.pendingApproval = null;
+});
+
+afterEach(() => {
+ internals.invoke = original;
+ mock.timers.reset();
+});
+
+const settle = () => new Promise((resolve) => setImmediate(resolve));
+
+test("on Monday morning the recap opens once, after a short delay", async () => {
+ await Recap.check(host, MONDAY_9AM);
+ assert.deepEqual(shown, []);
+ mock.timers.tick(1500);
+ assert.deepEqual(shown, ["recap"]);
+ assert.deepEqual(sent("recap_mark_shown"), [{ week: "2026-10-05" }]);
+ assert.equal(Recap.summary.sessionCount, 6);
+ // The history was asked from last Monday on.
+ assert.equal(sent("recap_history")[0].since, previousWeekStart(MONDAY_9AM).getTime() / 1000);
+});
+
+test("not twice in the same week, not on Tuesday, not before 8", async () => {
+ prefs.lastShownWeek = "2026-10-05";
+ await Recap.check(host, MONDAY_9AM);
+ prefs.lastShownWeek = "";
+ await Recap.check(host, new Date(2026, 9, 6, 9));
+ await Recap.check(host, new Date(2026, 9, 5, 7, 30));
+ mock.timers.tick(5000);
+ assert.deepEqual(shown, []);
+});
+
+test("an empty week or a disabled history shows nothing", async () => {
+ history = { turns: [], decisions: [], prefs };
+ await Recap.check(host, MONDAY_9AM);
+ prefs = { ...prefs, enabled: false };
+ history = sampleHistory(previousWeekStart(MONDAY_9AM));
+ await Recap.check(host, MONDAY_9AM);
+ mock.timers.tick(5000);
+ assert.deepEqual(shown, []);
+ assert.deepEqual(sent("recap_mark_shown"), []);
+});
+
+test("it never covers a permission request or a chat in progress", async () => {
+ State.pendingApproval = { requestId: "r", sessionId: "s", tool: "Bash", command: "ls" };
+ await Recap.check(host, MONDAY_9AM);
+ State.pendingApproval = null;
+ State.mode = "expanded";
+ State.view = "prompt";
+ await Recap.check(host, MONDAY_9AM);
+ mock.timers.tick(5000);
+ assert.deepEqual(shown, []);
+
+ // A request arriving during the delay wins too.
+ State.mode = "hidden";
+ await Recap.check(host, MONDAY_9AM);
+ State.pendingApproval = { requestId: "r", sessionId: "s", tool: "Bash", command: "ls" };
+ mock.timers.tick(1500);
+ assert.deepEqual(shown, []);
+ assert.deepEqual(sent("recap_mark_shown"), []);
+});
+
+test("the tray opens it any day, even for an empty week", async () => {
+ history = { turns: [], decisions: [], prefs };
+ const before = Recap.version;
+ await Recap.open(host);
+ await settle();
+ assert.deepEqual(shown, ["recap"]);
+ assert.equal(Recap.summary, null);
+ assert.equal(Recap.version, before + 1);
+});