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.

Weekly recap (#264)

Louis9b144d55b527
diff --git a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
index 9147161d..ba4927b8 100644
--- a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
+++ b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 01B96F947DF2BDC352E8526D /* WeeklyRecapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 888B3E1420BCB6292BDC8117 /* WeeklyRecapView.swift */; };
0329E76BA4A8FEEA8A6D76E7 /* ClaudeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A83D5410BD030B243ADDCFF4 /* ClaudeService.swift */; };
0393CA5466F52252378F0346 /* ServiceSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84ECC59BE7CDDEE348FC7096 /* ServiceSnapshot.swift */; };
0408FE7F86EBEE61CAED32DA /* TurnRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2DFAEAF1DD1CBF03D3C314E /* TurnRecorder.swift */; };
@@ -107,6 +108,7 @@
78B3C6814431B2DD9D1F4949 /* SoundEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE21C2B315D37AA70ED45E9 /* SoundEngine.swift */; };
78F045A55E6F4EEA5787EEEF /* MochiStill.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045E7300878138F0AC385920 /* MochiStill.swift */; };
78FCEDC8F78B683AB10E6529 /* NotionPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE03E03D1804B0B92C5C2DAD /* NotionPoller.swift */; };
+ 7A449E237CAAB62758508C7C /* RecapStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78FB882D49084DEA6A10DB4D /* RecapStore.swift */; };
7C75CCB3DC0116D8D3B12313 /* AskQuestion.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBB84A66045EB20CAC93A8A6 /* AskQuestion.swift */; };
7CF3242DAD44B442297116E5 /* Decisions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 369F5AFDE37A03A1C25EB262 /* Decisions.swift */; };
7D50086C2D8B6AEA0BD138FC /* QuestionPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C6993B34A0FFF8E3D454ADC /* QuestionPayload.swift */; };
@@ -159,6 +161,7 @@
B3EC9CF3C8BD629C3530E8F1 /* sounds in Resources */ = {isa = PBXBuildFile; fileRef = C066E2B991AA4F56B2724263 /* sounds */; };
B5D8D34DD7A72F340030EF46 /* MacStubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B66D0C664FB9FF74517AAF5 /* MacStubs.swift */; };
B605F976F4141435F27CF266 /* IslandRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15A1A8206F73376F4CAF2057 /* IslandRootView.swift */; };
+ B69DE31E2B0C2E35594CAA87 /* RecapStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78FB882D49084DEA6A10DB4D /* RecapStore.swift */; };
B733A76DD197F6D6D949284C /* HotKeyCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1218B86E249691AF44F819AC /* HotKeyCenter.swift */; };
B7C93262AA9D5DEAA0B79C7C /* MacStubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B66D0C664FB9FF74517AAF5 /* MacStubs.swift */; };
B7ED198C941104866BB3BC57 /* Haptics.swift in Sources */ = {isa = PBXBuildFile; fileRef = F86B99CF65C5E4BC887888C6 /* Haptics.swift */; };
@@ -228,6 +231,7 @@
F9445A71BBF9E4D20224238E /* QuestionPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C6993B34A0FFF8E3D454ADC /* QuestionPayload.swift */; };
FAD78D74C6906D4EC8AA4101 /* UploadSequenceEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */; };
FB063FE6B8A4BB8FBAAF56CB /* LiveActivityLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FA2D136C81C6D930C5357BD /* LiveActivityLink.swift */; };
+ FB58020A389126865363C342 /* WeeklyRecapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 888B3E1420BCB6292BDC8117 /* WeeklyRecapView.swift */; };
FBBC4CDE82B5886A83A27D7A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 506824380E9C80B9BC6DCE72 /* Assets.xcassets */; };
FDF87CF7C5F703EDD9A7CC14 /* CloudProbe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28323DC20034A281F6829884 /* CloudProbe.swift */; };
FEFEF1EBAB0E6CA74A33C10B /* SafeWebURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2FDED98F7F6C755A72C97A3 /* SafeWebURL.swift */; };
@@ -316,6 +320,7 @@
6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadSequenceEngine.swift; sourceTree = "<group>"; };
708E1FD9894461B4AD727DB1 /* CoucouIntents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoucouIntents.swift; sourceTree = "<group>"; };
71718D1B87A39A4879DD2A9D /* VercelPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VercelPoller.swift; sourceTree = "<group>"; };
+ 78FB882D49084DEA6A10DB4D /* RecapStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecapStore.swift; sourceTree = "<group>"; };
79A7807ADD0963FF260D1FAD /* MochiWardrobe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MochiWardrobe.swift; sourceTree = "<group>"; };
79D8DD79C3DD9BBC584B3CB2 /* HookServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HookServer.swift; sourceTree = "<group>"; };
7C1A7D5CBE2AC084A10C5FF3 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
@@ -324,6 +329,7 @@
84ECC59BE7CDDEE348FC7096 /* ServiceSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceSnapshot.swift; sourceTree = "<group>"; };
871CA2BADC67D97C97C7009D /* error.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = error.wav; sourceTree = "<group>"; };
8790ACE9F73BD74640A0F20C /* LocalChat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalChat.swift; sourceTree = "<group>"; };
+ 888B3E1420BCB6292BDC8117 /* WeeklyRecapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeeklyRecapView.swift; sourceTree = "<group>"; };
8ACB4350729C6513824D1ADF /* ColorHex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorHex.swift; sourceTree = "<group>"; };
8BF22817EC70748F2D1FB2E7 /* ClaudePlanGauge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClaudePlanGauge.swift; sourceTree = "<group>"; };
8CB8B6E5E9DA6164F979E88F /* GithubPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubPoller.swift; sourceTree = "<group>"; };
@@ -424,6 +430,7 @@
B89DA1A0C21AE3535A1760BB /* N8nPoller.swift */,
F1BD8F3CAA60CF37640759E1 /* NotchBuddyApp.swift */,
BE03E03D1804B0B92C5C2DAD /* NotionPoller.swift */,
+ 78FB882D49084DEA6A10DB4D /* RecapStore.swift */,
61B5FDDE03F5F711146937E2 /* ResendPoller.swift */,
B2FDED98F7F6C755A72C97A3 /* SafeWebURL.swift */,
7C1A7D5CBE2AC084A10C5FF3 /* SettingsView.swift */,
@@ -435,6 +442,7 @@
6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */,
F4A13AEE6E06F46CEC9D908C /* UserIdentity.swift */,
71718D1B87A39A4879DD2A9D /* VercelPoller.swift */,
+ 888B3E1420BCB6292BDC8117 /* WeeklyRecapView.swift */,
E91B733ADC638E14E9BB6EFA /* WindowContextCapture.swift */,
9207F9B32D9C7844F5332A31 /* PhoneLink */,
);
@@ -806,6 +814,7 @@
BDD8A210DD6D9DA2D15BC5EE /* PillCatalog.swift in Sources */,
CD05A497A7D0B3D723D92C06 /* QuestionPayload.swift in Sources */,
93AB64BF47D6D1EE7DB4C22B /* QuestionRelay.swift in Sources */,
+ 7A449E237CAAB62758508C7C /* RecapStore.swift in Sources */,
967B525F7D3837F31D740D18 /* ResendPoller.swift in Sources */,
6FC65C190ED614C664C9BC17 /* SafeWebURL.swift in Sources */,
2A30FA2F046492E22A1C5719 /* ServiceDetail.swift in Sources */,
@@ -824,6 +833,7 @@
FAD78D74C6906D4EC8AA4101 /* UploadSequenceEngine.swift in Sources */,
8A6B3688D6B3BF728D106D8B /* UserIdentity.swift in Sources */,
118FC4AE0AC74D84B4A134D8 /* VercelPoller.swift in Sources */,
+ 01B96F947DF2BDC352E8526D /* WeeklyRecapView.swift in Sources */,
2875610F701376BD65573386 /* WindowContextCapture.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -953,6 +963,7 @@
13663D98590927AF71C17628 /* PillCatalog.swift in Sources */,
535EC818E1DAF0FA588545D8 /* QuestionPayload.swift in Sources */,
9AEFD05D0A39D4AF3C091B3A /* QuestionRelay.swift in Sources */,
+ B69DE31E2B0C2E35594CAA87 /* RecapStore.swift in Sources */,
EB23ED9F1C12EA8B54A76A91 /* ResendPoller.swift in Sources */,
FEFEF1EBAB0E6CA74A33C10B /* SafeWebURL.swift in Sources */,
8C9AF392DAE8F2098A7BE7B6 /* ServiceDetail.swift in Sources */,
@@ -971,6 +982,7 @@
ECECA2F225E82B7C951658D7 /* UploadSequenceEngine.swift in Sources */,
63F9F3AAC881D3EDDDD8AED9 /* UserIdentity.swift in Sources */,
0E83C1DD4D20E7FB7A904450 /* VercelPoller.swift in Sources */,
+ FB58020A389126865363C342 /* WeeklyRecapView.swift in Sources */,
2CC2E3B688B15BBEB3AE3BCE /* WindowContextCapture.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/NotchBuddy/Sources/App/AppDelegate.swift b/NotchBuddy/Sources/App/AppDelegate.swift
index bca82b95..e3825201 100644
--- a/NotchBuddy/Sources/App/AppDelegate.swift
+++ b/NotchBuddy/Sources/App/AppDelegate.swift
@@ -18,6 +18,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
NSApp.setActivationPolicy(.accessory)
setupMenuBarItem()
setupIsland()
+ #if DEBUG
+ let debugMenu = NSMenu(title: "Debug")
+ debugMenu.addItem(NSMenuItem(title: "Render recap image", action: #selector(renderRecapImage), keyEquivalent: ""))
+ let debugMenuItem = NSMenuItem(title: "Debug", action: nil, keyEquivalent: "")
+ debugMenuItem.submenu = debugMenu
+ NSApp.mainMenu?.addItem(debugMenuItem)
+ #endif
#if PHONE_LINK
CloudProbe.shared.startIfEnabled()
#endif
@@ -36,6 +43,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let menu = NSMenu()
menu.addItem(withTitle: "Open Coucou", action: #selector(openIsland), keyEquivalent: "")
menu.addItem(.separator())
+ menu.addItem(withTitle: "Weekly recap", action: #selector(openWeeklyRecap), keyEquivalent: "")
menu.addItem(withTitle: "Settings…", action: #selector(openSettings), keyEquivalent: ",")
menu.addItem(.separator())
menu.addItem(withTitle: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
@@ -49,6 +57,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
islandController?.expand(to: .overview)
}
+ @objc private func openWeeklyRecap() {
+ islandController?.expand(to: .recap)
+ }
+
private var settingsWindow: NSWindow?
@objc private func openSettingsFromNotification(_ notification: Notification) {
@@ -96,6 +108,63 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
win.setFrame(frame, display: true)
}
+ // MARK: - Debug helpers
+
+ #if DEBUG
+ @objc func renderRecapImage() {
+ let summary = RecapStore.shared.weeklySummary() ?? WeeklySummary(
+ weekStart: Date(), weekEnd: Date(),
+ totalMinutes: 300, sessionCount: 6,
+ filesChanged: 31, linesAdded: 1217, linesRemoved: 312,
+ commandsRun: 54, questionsAnswered: 11,
+ permissionsAllowed: 4, permissionsDenied: 1,
+ topAgent: "Claude Code", topProject: "coucou",
+ busiestDay: "Friday", longestSessionMinutes: 300
+ )
+ let view = RecapShareImageView(summary: summary, hideProjects: false)
+ let renderer = ImageRenderer(content: view)
+ renderer.proposedSize = ProposedViewSize(width: 1080, height: 1920)
+ renderer.scale = 1
+ guard let cg = renderer.cgImage else { return }
+ let img = NSImage(cgImage: cg, size: NSSize(width: 1080, height: 1920))
+ let url = FileManager.default.homeDirectoryForCurrentUser
+ .appendingPathComponent("Desktop/coucou-recap-debug.png")
+ if let tiff = img.tiffRepresentation,
+ let rep = NSBitmapImageRep(data: tiff),
+ let png = rep.representation(using: .png, properties: [:]) {
+ try? png.write(to: url)
+ NSWorkspace.shared.open(url)
+ }
+ }
+ #endif
+
+ // MARK: - Weekly recap trigger
+
+ /// On Monday ≥ 8 am, show the recap card once (if there is activity to display).
+ /// Called from greetComplete, SessionStart/UserPromptSubmit hooks, and on wake.
+ func checkMondayRecap() {
+ let cal = Calendar(identifier: .iso8601)
+ let now = Date()
+ // weekday in ISO 8601 calendar: 2 = Monday
+ guard cal.component(.weekday, from: now) == 2,
+ cal.component(.hour, from: now) >= 8 else { return }
+ // Don't interrupt a pending approval or question
+ let s = AppState.shared
+ guard s.pendingApproval == nil, s.pendingQuestion == nil else { return }
+ let weekYear = cal.component(.yearForWeekOfYear, from: now)
+ let weekNum = cal.component(.weekOfYear, from: now)
+ let weekKey = weekYear * 100 + weekNum
+ let lastShown = UserDefaults.standard.integer(forKey: "recapLastShownWeek")
+ guard weekKey != lastShown else { return }
+ guard RecapStore.shared.weeklySummary() != nil else { return }
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { [weak self] in
+ let s = AppState.shared
+ guard s.pendingApproval == nil, s.pendingQuestion == nil else { return }
+ self?.islandController?.expand(to: .recap)
+ UserDefaults.standard.set(weekKey, forKey: "recapLastShownWeek")
+ }
+ }
+
// MARK: - Island setup
private func setupIsland() {
@@ -113,8 +182,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
NotificationCenter.default.addObserver(self, selector: #selector(openSettingsFromNotification(_:)),
name: .openFullSettings, object: nil)
// After the greeting ends, fly Mochi back to the desktop if it was there at last quit
- NotificationCenter.default.addObserver(forName: .greetComplete, object: nil, queue: .main) { _ in
+ NotificationCenter.default.addObserver(forName: .greetComplete, object: nil, queue: .main) { [weak self] _ in
DesktopMochiController.shared.launchFlyIfNeeded()
+ self?.checkMondayRecap()
+ }
+ // Check for Monday recap on wake and when a new session/prompt arrives
+ NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification,
+ object: nil, queue: .main) { [weak self] _ in
+ self?.checkMondayRecap()
+ }
+ NotificationCenter.default.addObserver(forName: .checkMondayRecap, object: nil, queue: .main) { [weak self] _ in
+ self?.checkMondayRecap()
}
#if !APPSTORE
_ = MusicController.shared
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swift
index 4a1047e9..77be0d30 100644
--- a/NotchBuddy/Sources/App/AppState.swift
+++ b/NotchBuddy/Sources/App/AppState.swift
@@ -61,6 +61,14 @@ final class AppState: ObservableObject {
didSet { UserDefaults.standard.set(soundEnabled, forKey: "soundEnabled") }
}
+ // Weekly recap — persisted
+ @Published var recapEnabled: Bool = (UserDefaults.standard.object(forKey: "recapEnabled") as? Bool) ?? true {
+ didSet { UserDefaults.standard.set(recapEnabled, forKey: "recapEnabled") }
+ }
+ @Published var recapHideProjects: Bool = UserDefaults.standard.bool(forKey: "recapHideProjects") {
+ didSet { UserDefaults.standard.set(recapHideProjects, forKey: "recapHideProjects") }
+ }
+
// Mochi outfit selection — persisted
@Published var mochiOutfitSelection: Outfit = .auto {
didSet { Outfit.stored = mochiOutfitSelection }
diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swift
index 0837f95d..21aedfdf 100644
--- a/NotchBuddy/Sources/App/HookServer.swift
+++ b/NotchBuddy/Sources/App/HookServer.swift
@@ -43,6 +43,7 @@ final class HookServer: @unchecked Sendable {
private var pendingQuestionFD: Int32 = -1 // held open while user answers AskUserQuestion
private var questionFDSource: (any DispatchSourceRead)? = nil // monitors pendingQuestionFD
private var questionPillId: String = "" // pill that owns the pending question
+ private var questionSessionId: String = "" // sessionId for the pending question (recap tracking)
private var focusBeforeQuestion: String? = nil // saved focus to restore after question
private var activeSessionId: String? = nil // current Claude Code session
private var focusBeforeApproval: String? = nil // saved focus to restore after approval
@@ -127,6 +128,8 @@ final class HookServer: @unchecked Sendable {
pendingQuestionFD = -1
let source = questionFDSource
questionFDSource = nil
+ let sid = questionSessionId
+ questionSessionId = ""
if fd >= 0, let data = try? JSONSerialization.data(withJSONObject: ["permissionDecision": "answer", "answers": answers], options: .withoutEscapingSlashes),
let json = String(data: data, encoding: .utf8) {
Task.detached { [weak self] in
@@ -136,6 +139,7 @@ final class HookServer: @unchecked Sendable {
} else {
source?.cancel()
}
+ if !sid.isEmpty { RecapStore.shared.recordQuestionAnswered(sessionId: sid) }
dismissQuestionCard(note: "")
}
@@ -376,6 +380,11 @@ final class HookServer: @unchecked Sendable {
}
let focused = state.focusId == agentId
+ // For sessions that carry no id, derive a unique key from pill + cwd so that
+ // concurrent anonymous sessions are tracked independently in RecapStore.
+ let recapSessionId = (sessionId == "unknown" || sessionId.isEmpty)
+ ? "\(agentId)+\(cwd)"
+ : sessionId
#if PHONE_LINK
// The iPhone's "last turn" (prompt, actions, diffs, answer).
@@ -423,6 +432,7 @@ final class HookServer: @unchecked Sendable {
if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }
if let idx = state.tasks.firstIndex(where: { $0.id == agentId }) { state.tasks[idx].finalLine = nil }
nbLog("SessionStart \(isExternalAgent ? agentId : projectName) (\(sessionId.prefix(8)))")
+ NotificationCenter.default.post(name: .checkMondayRecap, object: nil)
if state.isPresent { expandIfNeeded(to: .overview) }
SoundEngine.shared.play("work")
@@ -434,12 +444,15 @@ final class HookServer: @unchecked Sendable {
if let prompt = payload["prompt"] as? String, !prompt.isEmpty {
appendStep(id: agentId, step: String(prompt.prefix(60)))
}
+ RecapStore.shared.userPromptSubmit(sessionId: recapSessionId, pillId: agentId, project: projectName)
+ NotificationCenter.default.post(name: .checkMondayRecap, object: nil)
if state.isPresent { expandIfNeeded(to: .overview) }
case "PreToolUse":
activeSessionId = sessionId
let tool = payload["tool_name"] as? String ?? "Tool"
if let idx = state.tasks.firstIndex(where: { $0.id == agentId }) { state.tasks[idx].finalLine = nil }
+ RecapStore.shared.preToolUse(sessionId: recapSessionId, tool: tool)
// AskUserQuestion is handled via the dedicated --ask hook.
// Skip state/step update here to avoid flickering over the question card.
guard tool != "AskUserQuestion" else { break }
@@ -459,6 +472,7 @@ final class HookServer: @unchecked Sendable {
let idx = state.appendSessionDiff(diff, for: agentId)
let step = String.makeDiffStep(filename: diff.name, added: diff.added, removed: diff.removed, diffId: idx)
appendStep(id: agentId, step: step)
+ RecapStore.shared.recordFileDiff(sessionId: recapSessionId, path: diff.name, added: diff.added, removed: diff.removed)
}
case "PostToolUseFailure":
@@ -487,6 +501,7 @@ final class HookServer: @unchecked Sendable {
state.tasks[idx].finalLine = finalText
}
}
+ RecapStore.shared.stop(sessionId: recapSessionId)
SoundEngine.shared.play("finish")
if focused {
expandIfNeeded(to: .finished)
@@ -503,6 +518,7 @@ final class HookServer: @unchecked Sendable {
}
case "StopFailure":
+ RecapStore.shared.stop(sessionId: recapSessionId)
state.updateTask(id: agentId, state: .error)
SoundEngine.shared.play("error")
if focused {
@@ -513,6 +529,7 @@ final class HookServer: @unchecked Sendable {
case "Interrupt":
// Codex: user stopped the turn
+ RecapStore.shared.stop(sessionId: recapSessionId)
activeSessionId = nil
state.updateTask(id: agentId, state: .idle)
clearPillBadge(id: agentId)
@@ -522,6 +539,7 @@ final class HookServer: @unchecked Sendable {
if let idx = state.tasks.firstIndex(where: { $0.id == agentId }) { state.tasks[idx].finalLine = nil }
state.clearSessionDiffs(for: agentId)
state.removeTask(id: agentId)
+ RecapStore.shared.sessionEnd(sessionId: recapSessionId)
case "SubagentStart":
appendStep(id: agentId, step: "+ subagent")
@@ -783,6 +801,7 @@ final class HookServer: @unchecked Sendable {
let pillId = state.pendingApproval?.pillId ?? "integration_claude"
state.pendingApproval = nil
state.isPinned = false
+ RecapStore.shared.recordDecision(pillId: pillId, decision: decision)
state.updateTask(id: pillId, state: .working)
clearPillBadge(id: pillId)
// Restore focus to the pill that was focused before the approval card appeared.
@@ -848,6 +867,9 @@ final class HookServer: @unchecked Sendable {
pendingQuestionFD = fd
activeSessionId = sessionId
questionPillId = pillId
+ questionSessionId = (sessionId == "unknown" || sessionId.isEmpty)
+ ? "\(pillId)+\(cwd)"
+ : sessionId
upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd)
state.updateTask(id: pillId, state: .question)
diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swift
index e73907c3..8dec3597 100644
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@ -26,6 +26,7 @@ struct IslandViewContent: View {
case .settings: SettingsIslandView(state: state)
case .greeting: EmptyView() // GreetingCanvasView overlaid in IslandRootView
case .wardrobe: WardrobeView(state: state)
+ case .recap: WeeklyRecapCardView(state: state)
}
}
}
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index c49e37ff..4aebdfad 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -1133,6 +1133,7 @@ extension Notification.Name {
static let musicReveal = Notification.Name("notchBuddy.musicReveal")
// Greeting ↔ IslandWindowController
static let greetComplete = Notification.Name("notchBuddy.greetComplete")
+ static let checkMondayRecap = Notification.Name("notchBuddy.checkMondayRecap")
static let greetingHover = Notification.Name("notchBuddy.greetingHover")
static let greetingInterrupt = Notification.Name("notchBuddy.greetingInterrupt")
static let openWardrobeFromDesktop = Notification.Name("notchBuddy.openWardrobeFromDesktop")
diff --git a/NotchBuddy/Sources/App/RecapStore.swift b/NotchBuddy/Sources/App/RecapStore.swift
new file mode 100644
index 00000000..4e5337df
--- /dev/null
+++ b/NotchBuddy/Sources/App/RecapStore.swift
@@ -0,0 +1,316 @@
+import Foundation
+
+// MARK: - Persisted data models
+
+struct RecapTurn: Codable {
+ var pillId: String
+ var project: String
+ var start: Date
+ var end: Date
+ var filesChanged: Int
+ var linesAdded: Int
+ var linesRemoved: Int
+ var commandsRun: Int
+ var questions: Int
+}
+
+struct RecapDecision: Codable {
+ var pillId: String
+ var date: Date
+ var decision: String // "allow", "always", "deny", "ask"
+}
+
+private struct RecapData: Codable {
+ var turns: [RecapTurn] = []
+ var decisions: [RecapDecision] = []
+ var schemaVersion: Int = 1
+}
+
+// MARK: - Weekly summary
+
+struct WeeklySummary {
+ var weekStart: Date
+ var weekEnd: Date
+ var totalMinutes: Int
+ var sessionCount: Int
+ var filesChanged: Int
+ var linesAdded: Int
+ var linesRemoved: Int
+ var commandsRun: Int
+ var questionsAnswered: Int
+ var permissionsAllowed: Int
+ var permissionsDenied: Int
+ var topAgent: String? // pill display name
+ var topProject: String?
+ var busiestDay: String?
+ var longestSessionMinutes: Int
+}
+
+// MARK: - In-progress turn draft (keyed by sessionId)
+
+private struct TurnDraft {
+ var pillId: String
+ var project: String
+ var start: Date
+ var lastEvent: Date
+ var changedPaths: Set<String> = []
+ var linesAdded: Int = 0
+ var linesRemoved: Int = 0
+ var commandsRun: Int = 0
+ var questions: Int = 0
+}
+
+// MARK: - Store
+
+@MainActor
+final class RecapStore {
+ static let shared = RecapStore()
+
+ private var data = RecapData()
+ /// Keyed by sessionId so concurrent sessions from the same agent are tracked separately.
+ private var drafts: [String: TurnDraft] = [:]
+
+ private static let storageURL: URL = {
+ let support = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
+ return support.appendingPathComponent("NotchBuddy/recap.json")
+ }()
+
+ private init() { load() }
+
+ // MARK: - Event recording
+
+ func userPromptSubmit(sessionId: String, pillId: String, project: String) {
+ guard isEnabled else { return }
+ pruneStale()
+ if drafts[sessionId] == nil {
+ drafts[sessionId] = TurnDraft(pillId: pillId, project: project, start: .now, lastEvent: .now)
+ } else {
+ drafts[sessionId]?.lastEvent = .now
+ }
+ }
+
+ func preToolUse(sessionId: String, tool: String) {
+ guard isEnabled, var draft = drafts[sessionId] else { return }
+ draft.lastEvent = .now
+ switch tool {
+ case "Bash", "Execute", "mcp__ide__executeCode":
+ draft.commandsRun += 1
+ default:
+ break
+ }
+ drafts[sessionId] = draft
+ }
+
+ /// Called after a file diff is computed in PostToolUse.
+ func recordFileDiff(sessionId: String, path: String, added: Int, removed: Int) {
+ guard isEnabled, var draft = drafts[sessionId] else { return }
+ draft.lastEvent = .now
+ draft.changedPaths.insert(path)
+ draft.linesAdded += added
+ draft.linesRemoved += removed
+ drafts[sessionId] = draft
+ }
+
+ /// Called when the user sends answers from the notch (not when the question is asked).
+ func recordQuestionAnswered(sessionId: String) {
+ guard isEnabled, var draft = drafts[sessionId] else { return }
+ draft.lastEvent = .now
+ draft.questions += 1
+ drafts[sessionId] = draft
+ }
+
+ func stop(sessionId: String) {
+ guard isEnabled, let draft = drafts.removeValue(forKey: sessionId) else { return }
+ let turn = RecapTurn(
+ pillId: draft.pillId,
+ project: draft.project,
+ start: draft.start,
+ end: .now,
+ filesChanged: draft.changedPaths.count,
+ linesAdded: draft.linesAdded,
+ linesRemoved: draft.linesRemoved,
+ commandsRun: draft.commandsRun,
+ questions: draft.questions
+ )
+ data.turns.append(turn)
+ prune()
+ save()
+ }
+
+ func sessionEnd(sessionId: String) {
+ drafts.removeValue(forKey: sessionId)
+ }
+
+ func recordDecision(pillId: String, decision: String) {
+ guard isEnabled else { return }
+ data.decisions.append(RecapDecision(pillId: pillId, date: .now, decision: decision))
+ prune()
+ save()
+ }
+
+ // MARK: - Query
+
+ /// Returns a summary for the last completed week (Mon–Sun, ISO 8601).
+ /// Pass a custom `weekStart` (Monday 00:00 local) to query a different week.
+ func weeklySummary(for weekStart: Date? = nil) -> WeeklySummary? {
+ // ISO 8601 calendar: weeks start on Monday regardless of locale.
+ let cal = Calendar(identifier: .iso8601)
+ let start: Date
+ if let ws = weekStart {
+ start = ws
+ } else {
+ // Previous Monday 00:00 local
+ var comps = cal.dateComponents([.yearForWeekOfYear, .weekOfYear], from: Date())
+ comps.weekday = 2 // Monday (weekday 2 in Gregorian/ISO, Sunday=1)
+ let thisMonday = cal.date(from: comps)!
+ start = cal.date(byAdding: .weekOfYear, value: -1, to: thisMonday)!
+ }
+ let end = cal.date(byAdding: .day, value: 7, to: start)!
+
+ let turns = data.turns.filter { $0.start >= start && $0.start < end }
+ let decisions = data.decisions.filter { $0.date >= start && $0.date < end }
+ guard !turns.isEmpty else { return nil }
+
+ // Merge overlapping intervals to avoid double-counting parallel sessions.
+ let totalSecs = mergedTotalSeconds(turns)
+ let allowed = decisions.filter { $0.decision == "allow" || $0.decision == "always" }.count
+ let denied = decisions.filter { $0.decision == "deny" }.count
+
+ // Top agent by session count
+ var countByAgent: [String: Int] = [:]
+ for t in turns { countByAgent[t.pillId, default: 0] += 1 }
+ let topAgentId = countByAgent.max { $0.value < $1.value }?.key
+ let topAgent = topAgentId.flatMap { PillCatalog.definition(for: $0)?.name } ?? topAgentId
+
+ // Top project by session count
+ var countByProject: [String: Int] = [:]
+ for t in turns where !t.project.isEmpty { countByProject[t.project, default: 0] += 1 }
+ let topProject = countByProject.max { $0.value < $1.value }?.key
+
+ // Busiest day
+ var countByWeekday: [Int: Int] = [:]
+ for t in turns { countByWeekday[cal.component(.weekday, from: t.start), default: 0] += 1 }
+ let dayNames = [1: "Sunday", 2: "Monday", 3: "Tuesday", 4: "Wednesday",
+ 5: "Thursday", 6: "Friday", 7: "Saturday"]
+ let busiestDay = countByWeekday.max { $0.value < $1.value }.flatMap { dayNames[$0.key] }
+
+ let longestSecs = turns.map { $0.end.timeIntervalSince($0.start) }.max() ?? 0
+
+ return WeeklySummary(
+ weekStart: start,
+ weekEnd: cal.date(byAdding: .second, value: -1, to: end)!,
+ totalMinutes: Int(totalSecs / 60),
+ sessionCount: turns.count,
+ filesChanged: turns.reduce(0) { $0 + $1.filesChanged },
+ linesAdded: turns.reduce(0) { $0 + $1.linesAdded },
+ linesRemoved: turns.reduce(0) { $0 + $1.linesRemoved },
+ commandsRun: turns.reduce(0) { $0 + $1.commandsRun },
+ questionsAnswered: turns.reduce(0) { $0 + $1.questions },
+ permissionsAllowed: allowed,
+ permissionsDenied: denied,
+ topAgent: topAgent,
+ topProject: topProject,
+ busiestDay: busiestDay,
+ longestSessionMinutes: Int(longestSecs / 60)
+ )
+ }
+
+ // MARK: - Persistence
+
+ var isEnabled: Bool {
+ UserDefaults.standard.object(forKey: "recapEnabled") as? Bool ?? true
+ }
+
+ func clearHistory() {
+ data = RecapData()
+ drafts = [:]
+ try? FileManager.default.removeItem(at: Self.storageURL)
+ }
+
+ private func load() {
+ guard let raw = try? Data(contentsOf: Self.storageURL) else { return }
+ do {
+ data = try JSONDecoder().decode(RecapData.self, from: raw)
+ prune()
+ } catch {
+ // Rename corrupt file so it's not silently lost, then start fresh.
+ let fmt = DateFormatter()
+ fmt.locale = Locale(identifier: "en_US_POSIX")
+ fmt.dateFormat = "yyyyMMdd-HHmmss"
+ let corrupt = Self.storageURL.deletingPathExtension()
+ .appendingPathExtension("corrupt-\(fmt.string(from: Date()))")
+ try? FileManager.default.moveItem(at: Self.storageURL, to: corrupt)
+ }
+ }
+
+ private func save() {
+ pruneStale()
+ persist()
+ }
+
+ private func persist() {
+ let dir = Self.storageURL.deletingLastPathComponent()
+ try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ if let encoded = try? JSONEncoder().encode(data) {
+ try? encoded.write(to: Self.storageURL, options: .atomic)
+ }
+ }
+
+ private func prune() {
+ guard let cutoff = Calendar.current.date(byAdding: .weekOfYear, value: -12, to: .now) else { return }
+ data.turns = data.turns.filter { $0.start >= cutoff }
+ data.decisions = data.decisions.filter { $0.date >= cutoff }
+ }
+
+ /// Finalises drafts with no events for 2+ hours (agent crashed or forgot to Stop).
+ /// Instead of discarding them, persists them as completed turns so they count in the recap.
+ private func pruneStale() {
+ let cutoff = Date().addingTimeInterval(-2 * 3600)
+ var staleKeys: [String] = []
+ for (key, draft) in drafts where draft.lastEvent < cutoff {
+ let turn = RecapTurn(
+ pillId: draft.pillId,
+ project: draft.project,
+ start: draft.start,
+ end: draft.lastEvent,
+ filesChanged: draft.changedPaths.count,
+ linesAdded: draft.linesAdded,
+ linesRemoved: draft.linesRemoved,
+ commandsRun: draft.commandsRun,
+ questions: draft.questions
+ )
+ data.turns.append(turn)
+ staleKeys.append(key)
+ }
+ for key in staleKeys { drafts.removeValue(forKey: key) }
+ if !staleKeys.isEmpty {
+ prune()
+ persist()
+ }
+ }
+
+ // MARK: - Interval merging (prevents double-counting parallel sessions)
+
+ private func mergedTotalSeconds(_ turns: [RecapTurn]) -> Double {
+ let sorted = turns.filter { $0.end > $0.start }.sorted { $0.start < $1.start }
+ var total: Double = 0
+ var segStart: Date? = nil
+ var segEnd: Date? = nil
+ for t in sorted {
+ if let end = segEnd {
+ if t.start <= end {
+ segEnd = max(end, t.end)
+ } else {
+ total += segEnd!.timeIntervalSince(segStart!)
+ segStart = t.start
+ segEnd = t.end
+ }
+ } else {
+ segStart = t.start
+ segEnd = t.end
+ }
+ }
+ if let e = segEnd, let s = segStart { total += e.timeIntervalSince(s) }
+ return total
+ }
+}
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index ebc58524..0b2fc5cc 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -316,6 +316,20 @@ struct SettingsView: View {
.padding(6)
}
+ GroupBox("Weekly recap") {
+ VStack(alignment: .leading, spacing: 10) {
+ Toggle("Keep a history of my coding sessions", isOn: $state.recapEnabled)
+ Text("Stored locally on your Mac. Nothing leaves your Mac. Retained for 12 weeks.")
+ .font(.system(size: 11))
+ .foregroundColor(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ Toggle("Hide project names in shared images", isOn: $state.recapHideProjects)
+ .disabled(!state.recapEnabled)
+ Button("Clear history") { RecapStore.shared.clearHistory() }
+ }
+ .padding(6)
+ }
+
#if PHONE_LINK
GroupBox("iPhone") {
VStack(alignment: .leading, spacing: 6) {
diff --git a/NotchBuddy/Sources/App/WeeklyRecapView.swift b/NotchBuddy/Sources/App/WeeklyRecapView.swift
new file mode 100644
index 00000000..849dc673
--- /dev/null
+++ b/NotchBuddy/Sources/App/WeeklyRecapView.swift
@@ -0,0 +1,368 @@
+import AppKit
+import SwiftUI
+
+// MARK: - Notch card
+
+struct WeeklyRecapCardView: View {
+ @ObservedObject var state: AppState
+ @State private var summary: WeeklySummary? = nil
+
+ var body: some View {
+ ZStack {
+ CardBackground(wash: .indigo)
+ VStack(alignment: .leading, spacing: 5) {
+ if let s = summary {
+ HStack(spacing: 0) {
+ Text("Weekly recap")
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundColor(Color(hex: "#818CF8"))
+ Spacer(minLength: 6)
+ Text(weekRangeLabel(s))
+ .font(.system(size: 10))
+ .foregroundColor(Color(hex: "#8E939C"))
+ .lineLimit(1)
+ }
+ HStack(spacing: 14) {
+ statChip(formatDuration(s.totalMinutes), label: "coding")
+ statChip("\(s.sessionCount)", label: s.sessionCount == 1 ? "session" : "sessions")
+ statChip("\(s.filesChanged)", label: s.filesChanged == 1 ? "file" : "files")
+ if s.commandsRun > 0 {
+ statChip("\(s.commandsRun)", label: "commands")
+ }
+ if s.linesAdded + s.linesRemoved > 0 {
+ statChip("+\(s.linesAdded) / -\(s.linesRemoved)", label: "lines")
+ }
+ if s.questionsAnswered > 0 {
+ statChip("\(s.questionsAnswered)", label: s.questionsAnswered == 1 ? "question" : "questions")
+ }
+ }
+ HStack(spacing: 8) {
+ PrimaryButton("Share image") { shareImage(s) }
+ SecondaryButton("OK") {
+ NotificationCenter.default.post(name: .islandCollapse, object: nil)
+ }
+ }
+ } else {
+ Text("No activity last week")
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundColor(Color(hex: "#F1F2F4"))
+ SecondaryButton("OK") {
+ NotificationCenter.default.post(name: .islandCollapse, object: nil)
+ }
+ }
+ }
+ .padding(.leading, 116)
+ .padding(.trailing, 16)
+ .padding(.vertical, 4)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ .onAppear { summary = RecapStore.shared.weeklySummary() }
+ .onChange(of: state.view) { _, newView in
+ if newView == .recap { summary = RecapStore.shared.weeklySummary() }
+ }
+ }
+
+ private func statChip(_ value: String, label: String) -> some View {
+ VStack(alignment: .leading, spacing: 1) {
+ Text(value)
+ .font(.system(size: 17, weight: .bold))
+ .foregroundColor(Color(hex: "#F1F2F4"))
+ Text(label)
+ .font(.system(size: 9))
+ .foregroundColor(Color(hex: "#8E939C"))
+ }
+ }
+
+ private func weekRangeLabel(_ s: WeeklySummary) -> String {
+ let fmt = DateFormatter()
+ fmt.dateFormat = "MMM d"
+ return "\(fmt.string(from: s.weekStart)) – \(fmt.string(from: s.weekEnd))"
+ }
+
+ private func shareImage(_ s: WeeklySummary) {
+ RecapSharePanel.show(summary: s, hideProjects: state.recapHideProjects)
+ }
+
+ private func formatDuration(_ minutes: Int) -> String {
+ if minutes < 60 { return "\(minutes)m" }
+ let h = minutes / 60
+ let m = minutes % 60
+ return m == 0 ? "\(h)h" : "\(h)h \(m)m"
+ }
+}
+
+// MARK: - Share panel
+
+@MainActor
+enum RecapSharePanel {
+ private static var window: NSWindow?
+
+ static func show(summary: WeeklySummary, hideProjects: Bool) {
+ if let w = window, w.isVisible { w.makeKeyAndOrderFront(nil); return }
+ let win = NSPanel(
+ contentRect: NSRect(x: 0, y: 0, width: 440, height: 540),
+ styleMask: [.titled, .closable, .fullSizeContentView],
+ backing: .buffered, defer: false
+ )
+ win.title = "Weekly recap"
+ win.titlebarAppearsTransparent = true
+ win.isMovableByWindowBackground = true
+ let host = NSHostingView(rootView: RecapSharePanelView(summary: summary, hideProjects: hideProjects))
+ host.sizingOptions = [.minSize]
+ win.contentView = host
+ win.isReleasedWhenClosed = false
+ win.center()
+ window = win
+ win.makeKeyAndOrderFront(nil)
+ NSApp.activate(ignoringOtherApps: true)
+ }
+}
+
+// MARK: - Share panel view
+
+private struct RecapSharePanelView: View {
+ let summary: WeeklySummary
+ let hideProjects: Bool
+ @State private var nsImage: NSImage? = nil
+ @State private var copied = false
+
+ var body: some View {
+ VStack(spacing: 16) {
+ Group {
+ if let img = nsImage {
+ Image(nsImage: img)
+ .resizable()
+ .aspectRatio(contentMode: .fit)
+ .cornerRadius(12)
+ .shadow(color: .black.opacity(0.3), radius: 12, y: 4)
+ } else {
+ RoundedRectangle(cornerRadius: 12)
+ .fill(Color(hex: "#141518"))
+ .overlay(ProgressView())
+ }
+ }
+ .frame(maxHeight: 380)
+
+ HStack(spacing: 10) {
+ Button(copied ? "Copied!" : "Copy image") {
+ guard let img = nsImage else { return }
+ NSPasteboard.general.clearContents()
+ NSPasteboard.general.writeObjects([img])
+ copied = true
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { copied = false }
+ }
+ .buttonStyle(.borderedProminent)
+
+ Button("Save…") {
+ guard let img = nsImage else { return }
+ let panel = NSSavePanel()
+ panel.nameFieldStringValue = "coucou-weekly-recap.png"
+ panel.allowedContentTypes = [.png]
+ panel.begin { result in
+ guard result == .OK, let url = panel.url else { return }
+ if let tiff = img.tiffRepresentation,
+ let rep = NSBitmapImageRep(data: tiff),
+ let png = rep.representation(using: .png, properties: [:]) {
+ try? png.write(to: url)
+ }
+ }
+ }
+ .buttonStyle(.bordered)
+
+ Button("Share…") {
+ guard let img = nsImage else { return }
+ guard let view = NSApp.keyWindow?.contentView else { return }
+ let picker = NSSharingServicePicker(items: [img])
+ picker.show(relativeTo: .zero, of: view, preferredEdge: .minY)
+ }
+ .buttonStyle(.bordered)
+ }
+ }
+ .padding(20)
+ .onAppear { renderImage() }
+ }
+
+ private func renderImage() {
+ let shareView = RecapShareImageView(summary: summary, hideProjects: hideProjects)
+ let renderer = ImageRenderer(content: shareView)
+ renderer.proposedSize = ProposedViewSize(width: 1080, height: 1920)
+ renderer.scale = 1
+ if let cgImage = renderer.cgImage {
+ nsImage = NSImage(cgImage: cgImage, size: NSSize(width: 1080, height: 1920))
+ }
+ }
+}
+
+// MARK: - Share image (1080×1920)
+
+struct RecapShareImageView: View {
+ let summary: WeeklySummary
+ let hideProjects: Bool
+
+ // Static BotEngine for the Mochi snapshot — idle state, no animation needed.
+ @StateObject private var mochiEngine = BotEngine()
+
+ var body: some View {
+ ZStack {
+ Color(hex: "#0B0C0E")
+ RadialGradient(
+ gradient: Gradient(stops: [
+ .init(color: Color(hex: "#6366F1").opacity(0.30), location: 0),
+ .init(color: Color.clear, location: 0.65)
+ ]),
+ center: UnitPoint(x: 0.5, y: 0.75),
+ startRadius: 0,
+ endRadius: 900
+ )
+ VStack(spacing: 0) {
+ Spacer()
+
+ // Mochi character
+ Canvas { context, size in
+ mochiEngine.draw(context: context, size: size)
+ }
+ .frame(width: 200, height: 200)
+ .padding(.bottom, 20)
+
+ Text("Coucou")
+ .font(.system(size: 52, weight: .black, design: .rounded))
+ .foregroundColor(Color(hex: "#F1F2F4"))
+ Text("Weekly recap")
+ .font(.system(size: 30, weight: .medium))
+ .foregroundColor(Color(hex: "#8E939C"))
+ .padding(.top, 6)
+ Text(weekRangeLabel)
+ .font(.system(size: 24))
+ .foregroundColor(Color(hex: "#818CF8"))
+ .padding(.top, 14)
+ .padding(.bottom, 80)
+
+ // Primary stat — time
+ VStack(spacing: 6) {
+ Text(formatDuration(summary.totalMinutes))
+ .font(.system(size: 100, weight: .black, design: .rounded))
+ .foregroundColor(Color(hex: "#F1F2F4"))
+ .minimumScaleFactor(0.4)
+ .lineLimit(1)
+ Text("TIME CODING")
+ .font(.system(size: 22, weight: .semibold))
+ .foregroundColor(Color(hex: "#8E939C"))
+ .tracking(3)
+ }
+
+ // Secondary stats
+ HStack(spacing: 0) {
+ statBlock("\(summary.sessionCount)", label: "SESSIONS")
+ statDivider()
+ statBlock("\(summary.filesChanged)", label: "FILES")
+ if summary.commandsRun > 0 {
+ statDivider()
+ statBlock("\(summary.commandsRun)", label: "COMMANDS")
+ }
+ }
+ .padding(.top, 56)
+ .padding(.horizontal, 40)
+
+ // Lines added / removed
+ if summary.linesAdded + summary.linesRemoved > 0 {
+ HStack(spacing: 24) {
+ Text("+\(summary.linesAdded)")
+ .font(.system(size: 28, weight: .semibold, design: .monospaced))
+ .foregroundColor(Color(hex: "#4ADE80"))
+ Text("−\(summary.linesRemoved)")
+ .font(.system(size: 28, weight: .semibold, design: .monospaced))
+ .foregroundColor(Color(hex: "#F87171"))
+ }
+ .padding(.top, 24)
+ }
+
+ // Badges
+ VStack(spacing: 16) {
+ if let agent = summary.topAgent {
+ recapBadge("Top agent", value: agent)
+ }
+ if !hideProjects, let project = summary.topProject {
+ recapBadge("Top project", value: project)
+ }
+ if let day = summary.busiestDay {
+ recapBadge("Busiest day", value: day)
+ }
+ if summary.longestSessionMinutes > 1 {
+ recapBadge("Longest session", value: formatDuration(summary.longestSessionMinutes))
+ }
+ if summary.permissionsAllowed + summary.permissionsDenied > 0 {
+ HStack(spacing: 16) {
+ recapBadge("Approved", value: "\(summary.permissionsAllowed)")
+ recapBadge("Denied", value: "\(summary.permissionsDenied)")
+ }
+ }
+ }
+ .padding(.top, 56)
+ .padding(.horizontal, 60)
+
+ Spacer()
+
+ Text("Coucou · github.com/Louis-CFM/coucou")
+ .font(.system(size: 20, weight: .medium, design: .monospaced))
+ .foregroundColor(Color(hex: "#8E939C").opacity(0.6))
+ .padding(.bottom, 60)
+ }
+ }
+ .frame(width: 1080, height: 1920)
+ }
+
+ @ViewBuilder
+ private func statBlock(_ value: String, label: String) -> some View {
+ VStack(spacing: 8) {
+ Text(value)
+ .font(.system(size: 64, weight: .black, design: .rounded))
+ .foregroundColor(Color(hex: "#F1F2F4"))
+ .minimumScaleFactor(0.5)
+ .lineLimit(1)
+ Text(label)
+ .font(.system(size: 18, weight: .semibold))
+ .foregroundColor(Color(hex: "#8E939C"))
+ .tracking(2)
+ }
+ .frame(maxWidth: .infinity)
+ }
+
+ @ViewBuilder
+ private func statDivider() -> some View {
+ Rectangle()
+ .fill(Color.white.opacity(0.08))
+ .frame(width: 1, height: 80)
+ }
+
+ @ViewBuilder
+ private func recapBadge(_ label: String, value: String) -> some View {
+ HStack(spacing: 16) {
+ Text(label)
+ .font(.system(size: 24))
+ .foregroundColor(Color(hex: "#8E939C"))
+ Spacer()
+ Text(value)
+ .font(.system(size: 24, weight: .semibold))
+ .foregroundColor(Color(hex: "#F1F2F4"))
+ .lineLimit(1)
+ .truncationMode(.tail)
+ }
+ .padding(.horizontal, 32)
+ .padding(.vertical, 18)
+ .background(Color.white.opacity(0.05))
+ .cornerRadius(18)
+ }
+
+ private var weekRangeLabel: String {
+ let fmt = DateFormatter()
+ fmt.dateFormat = "MMM d"
+ return "\(fmt.string(from: summary.weekStart)) – \(fmt.string(from: summary.weekEnd))"
+ }
+
+ private func formatDuration(_ minutes: Int) -> String {
+ if minutes < 60 { return "\(minutes)m" }
+ let h = minutes / 60
+ let m = minutes % 60
+ return m == 0 ? "\(h)h" : "\(h)h \(m)m"
+ }
+}
diff --git a/NotchBuddy/Sources/CoucouKit/IslandTypes.swift b/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
index 60fbbe1a..0c435d0a 100644
--- a/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
+++ b/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
@@ -11,7 +11,7 @@ enum IslandMode: String, CaseIterable {
enum IslandView: String, CaseIterable {
case overview, empty, approval, question, error, finished
case confused, upload, uploading, choose, mail, prompt
- case searching, result, note, settings, greeting, wardrobe
+ case searching, result, note, settings, greeting, wardrobe, recap
}
// MARK: - Bot State
@@ -189,6 +189,7 @@ enum IslandConst {
// Greeting: bot drawn by GreetingCanvasView; no BotPlacement needed
.greeting: ViewLayout(height: 150, botX: 320, botY: 90, botDiameter: 0, agentMode: .none),
.wardrobe: ViewLayout(height: 160, botX: 68, botY: nil, botDiameter: 58, agentMode: .none),
+ .recap: ViewLayout(height: 160, botX: 62, botY: nil, botDiameter: 58, agentMode: .column),
]
// Project colors — keyed by lowercase display name or slug
diff --git a/scripts/test-weekly-recap.swift b/scripts/test-weekly-recap.swift
new file mode 100644
index 00000000..1cbb1d12
--- /dev/null
+++ b/scripts/test-weekly-recap.swift
@@ -0,0 +1,139 @@
+#!/usr/bin/env swift
+// test-weekly-recap.swift
+// Fills recap.json with one fake week of activity so the weekly recap card has something to show.
+// Usage: swift scripts/test-weekly-recap.swift
+// After running, open Coucou and choose "Weekly recap" from the menu bar, or wait for Monday ≥ 8 am.
+//
+// NOTE: To render the real RecapShareImageView to a PNG, use the Debug menu in the app (DEBUG builds
+// only): Debug → "Render recap image". This saves ~/Desktop/coucou-recap-debug.png and opens it.
+// The standalone script cannot import the app module, so image rendering is done via the app.
+
+import Foundation
+
+// MARK: - Mirror the Codable models from RecapStore.swift
+
+struct RecapTurn: Codable {
+ var pillId: String
+ var project: String
+ var start: Date
+ var end: Date
+ var filesChanged: Int
+ var linesAdded: Int
+ var linesRemoved: Int
+ var commandsRun: Int
+ var questions: Int
+}
+
+struct RecapDecision: Codable {
+ var pillId: String
+ var date: Date
+ var decision: String
+}
+
+struct RecapData: Codable {
+ var turns: [RecapTurn]
+ var decisions: [RecapDecision]
+ var schemaVersion: Int
+}
+
+// MARK: - Target path
+
+let support = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
+let recapURL = support.appendingPathComponent("NotchBuddy/recap.json")
+
+// Load existing data (if any) so we don't clobber other weeks.
+var data: RecapData
+if let raw = try? Data(contentsOf: recapURL),
+ let decoded = try? JSONDecoder().decode(RecapData.self, from: raw) {
+ data = decoded
+ print("Loaded \(data.turns.count) existing turns.")
+} else {
+ data = RecapData(turns: [], decisions: [], schemaVersion: 1)
+ print("Starting fresh.")
+}
+
+// MARK: - Fake data: one week ago Mon–Sun
+
+let cal = Calendar.current
+var comps = cal.dateComponents([.yearForWeekOfYear, .weekOfYear], from: Date())
+comps.weekday = 2
+let thisMonday = cal.date(from: comps)!
+let lastMonday = cal.date(byAdding: .weekOfYear, value: -1, to: thisMonday)!
+
+func makeDate(dayOffset: Int, hour: Int, minute: Int = 0) -> Date {
+ cal.date(byAdding: .second, value: dayOffset * 86400 + hour * 3600 + minute * 60, to: lastMonday)!
+}
+
+let fakeTurns: [RecapTurn] = [
+ // Monday: long Claude Code session
+ RecapTurn(pillId: "integration_claude", project: "coucou",
+ start: makeDate(dayOffset: 0, hour: 9),
+ end: makeDate(dayOffset: 0, hour: 11, minute: 30),
+ filesChanged: 8, linesAdded: 312, linesRemoved: 87,
+ commandsRun: 14, questions: 2),
+ // Monday: afternoon session
+ RecapTurn(pillId: "integration_claude", project: "coucou",
+ start: makeDate(dayOffset: 0, hour: 14),
+ end: makeDate(dayOffset: 0, hour: 15, minute: 45),
+ filesChanged: 3, linesAdded: 95, linesRemoved: 20,
+ commandsRun: 5, questions: 0),
+ // Tuesday: Gemini CLI
+ RecapTurn(pillId: "agent_gemini", project: "side-project",
+ start: makeDate(dayOffset: 1, hour: 10),
+ end: makeDate(dayOffset: 1, hour: 11),
+ filesChanged: 2, linesAdded: 50, linesRemoved: 10,
+ commandsRun: 3, questions: 1),
+ // Wednesday: Claude Code
+ RecapTurn(pillId: "integration_claude", project: "coucou",
+ start: makeDate(dayOffset: 2, hour: 9, minute: 30),
+ end: makeDate(dayOffset: 2, hour: 12),
+ filesChanged: 5, linesAdded: 180, linesRemoved: 60,
+ commandsRun: 8, questions: 3),
+ // Thursday: short burst
+ RecapTurn(pillId: "integration_claude", project: "coucou",
+ start: makeDate(dayOffset: 3, hour: 16),
+ end: makeDate(dayOffset: 3, hour: 17),
+ filesChanged: 1, linesAdded: 40, linesRemoved: 5,
+ commandsRun: 2, questions: 0),
+ // Friday: longest session
+ RecapTurn(pillId: "integration_claude", project: "coucou",
+ start: makeDate(dayOffset: 4, hour: 8),
+ end: makeDate(dayOffset: 4, hour: 13),
+ filesChanged: 12, linesAdded: 540, linesRemoved: 130,
+ commandsRun: 22, questions: 5),
+]
+
+let fakeDecisions: [RecapDecision] = [
+ RecapDecision(pillId: "integration_claude", date: makeDate(dayOffset: 0, hour: 9, minute: 30), decision: "allow"),
+ RecapDecision(pillId: "integration_claude", date: makeDate(dayOffset: 0, hour: 10), decision: "allow"),
+ RecapDecision(pillId: "integration_claude", date: makeDate(dayOffset: 2, hour: 10), decision: "deny"),
+ RecapDecision(pillId: "integration_claude", date: makeDate(dayOffset: 4, hour: 9), decision: "always"),
+ RecapDecision(pillId: "integration_claude", date: makeDate(dayOffset: 4, hour: 10), decision: "allow"),
+]
+
+// Remove any existing turns for the same week to avoid duplicates
+let weekEnd = cal.date(byAdding: .day, value: 7, to: lastMonday)!
+data.turns = data.turns.filter { $0.start < lastMonday || $0.start >= weekEnd }
+data.decisions = data.decisions.filter { $0.date < lastMonday || $0.date >= weekEnd }
+
+data.turns += fakeTurns
+data.decisions += fakeDecisions
+
+// MARK: - Write
+
+let encoder = JSONEncoder()
+encoder.outputFormatting = .prettyPrinted
+
+try FileManager.default.createDirectory(at: recapURL.deletingLastPathComponent(),
+ withIntermediateDirectories: true)
+let encoded = try encoder.encode(data)
+try encoded.write(to: recapURL, options: .atomic)
+
+print("Wrote \(fakeTurns.count) test turns to \(recapURL.path)")
+print("Total activity: ~\(fakeTurns.reduce(0) { $0 + Int($1.end.timeIntervalSince($1.start) / 60) }) minutes")
+print("")
+print("Open Coucou → menu bar → 'Weekly recap' to see the card.")
+print("Or run `open \(recapURL.deletingLastPathComponent().path)` to inspect the file.")
+print("")
+print("To render the share card PNG, use the Debug menu in a DEBUG build of the app:")
+print(" Debug → 'Render recap image' → saves ~/Desktop/coucou-recap-debug.png")