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.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
iPhone design pass: Mochi alive, chat composer, settings, onboarding, live timer (#232)
Louis5767d0372a37
diff --git a/CLAUDE.md b/CLAUDE.mdindex a4e7894d..c666caac 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -3,7 +3,7 @@Coucou is a native macOS app (`NotchBuddy/`); `windows/` is the Tauri version for Windows and Linux. Mochi, a small animated character living in the MacBook notch, shows AI coding agent sessions (Claude Code, Gemini CLI, Antigravity and more) and a few integrations, and lets the user approve, answer, chat and drop files from the notch.## Where things are-- `NotchBuddy/Sources/App/` — Mac-only Swift code. `NotchBuddy/Sources/CoucouKit/` — code shared with the iPhone app (Mochi's BotEngine and outfits, pills, diff, models). `NotchBuddy/Sources/Phone/` — iPhone app (`CoucouPhone` target). `NotchBuddy/Resources/sounds/` — the 28 WAV sounds. `NotchBuddy/project.yml` — XcodeGen project (never edit the `.xcodeproj` by hand).+- `NotchBuddy/Sources/App/` — Mac-only Swift code. `NotchBuddy/Sources/CoucouKit/` — code shared with the iPhone app (Mochi's BotEngine and outfits, pills, diff, models). `NotchBuddy/Sources/Phone/` — iPhone app (`CoucouPhone` target), with its widgets in `Sources/Widgets/` and the expanded approval notification in `Sources/NotificationContent/`. `NotchBuddy/Resources/sounds/` — the 28 WAV sounds. `NotchBuddy/project.yml` — XcodeGen project (never edit the `.xcodeproj` by hand).- `NotchBuddy/Sources/CoucouKit/PillCatalog.swift` — single source of truth for all declared pills (workspace tools, agents, AI providers, services). Every pill ID, color, category and subtitle lives here.- `docs/SPEC.md`, `docs/INTEGRATIONS.md` — behaviour, views, states, integrations (in French).- `design/prototype/notch-buddy.html` — original prototype, the visual source of truth. `design/captures/` — target screenshots.diff --git a/NotchBuddy/Resources/InfoNotificationContent.plist b/NotchBuddy/Resources/InfoNotificationContent.plistnew file mode 100644index 00000000..1adcb662--- /dev/null+++ b/NotchBuddy/Resources/InfoNotificationContent.plist@@ -0,0 +1,40 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>CFBundleDevelopmentRegion</key>+ <string>$(DEVELOPMENT_LANGUAGE)</string>+ <key>CFBundleDisplayName</key>+ <string>Coucou</string>+ <key>CFBundleExecutable</key>+ <string>$(EXECUTABLE_NAME)</string>+ <key>CFBundleIdentifier</key>+ <string>fr.louisraille.Coucou.NotificationContent</string>+ <key>CFBundleInfoDictionaryVersion</key>+ <string>6.0</string>+ <key>CFBundleName</key>+ <string>CoucouNotificationContent</string>+ <key>CFBundlePackageType</key>+ <string>XPC!</string>+ <key>CFBundleShortVersionString</key>+ <string>1.0</string>+ <key>CFBundleVersion</key>+ <string>2</string>+ <key>NSExtension</key>+ <dict>+ <key>NSExtensionAttributes</key>+ <dict>+ <key>UNNotificationExtensionCategory</key>+ <string>COUCOU_APPROVAL</string>+ <key>UNNotificationExtensionDefaultContentHidden</key>+ <true/>+ <key>UNNotificationExtensionInitialContentSizeRatio</key>+ <real>0.45</real>+ </dict>+ <key>NSExtensionPointIdentifier</key>+ <string>com.apple.usernotifications.content-extension</string>+ <key>NSExtensionPrincipalClass</key>+ <string>$(PRODUCT_MODULE_NAME).NotificationViewController</string>+ </dict>+</dict>+</plist>diff --git a/NotchBuddy/Sources/App/PhoneLink/LiveActivityRelay.swift b/NotchBuddy/Sources/App/PhoneLink/LiveActivityRelay.swiftindex 0c8a8162..08378c23 100644--- a/NotchBuddy/Sources/App/PhoneLink/LiveActivityRelay.swift+++ b/NotchBuddy/Sources/App/PhoneLink/LiveActivityRelay.swift@@ -46,6 +46,8 @@ final class LiveActivityRelay {private var latest: MochiActivityState?/// Set while a Live Activity runs on the iPhone(s).private var startedAt: Date?+ /// Sent with every push of an activity, so the iPhone shows the time since.+ private var activitySince: Int?/// The startedAt whose start push actually went out.private var startSent: Date?private var sent: MochiActivityState?@@ -145,6 +147,7 @@ final class LiveActivityRelay {private func begin(_ state: MochiActivityState) {let start = Date()+ activitySince = Int(start.timeIntervalSince1970)startedAt = startsent = stateretries = 0@@ -248,6 +251,8 @@ final class LiveActivityRelay {private func post(event: String, token: String, env: String, state: MochiActivityState,urgent: Bool = false, dismissAfter: Int? = nil, phoneID: String) async -> Bool {guard let url = relayURL else { return false }+ var state = state+ if state.since == nil { state.since = activitySince }var body: [String: Any] = ["token": token, "env": env, "event": event, "urgent": urgent]if let dismissAfter { body["dismissAfter"] = dismissAfter }guard let stateData = try? JSONEncoder().encode(state),diff --git a/NotchBuddy/Sources/CoucouKit/MochiActivityState.swift b/NotchBuddy/Sources/CoucouKit/MochiActivityState.swiftindex 1583bc4e..df5569c9 100644--- a/NotchBuddy/Sources/CoucouKit/MochiActivityState.swift+++ b/NotchBuddy/Sources/CoucouKit/MochiActivityState.swift@@ -17,6 +17,9 @@ struct MochiActivityState: Codable, Hashable, Sendable {var stepIndex: Intvar stepCount: Intvar others: Int // other sessions still going+ /// When Mochi left for the iPhone (Unix seconds): the iPhone counts the+ /// time from it, live. Optional so older pushes still decode.+ var since: Int? = nilvar botState: BotState { BotState(rawValue: state) ?? .idle }var isActive: Bool { ["waiting", "question", "working", "error"].contains(tone) }diff --git a/NotchBuddy/Sources/NotificationContent/NotificationViewController.swift b/NotchBuddy/Sources/NotificationContent/NotificationViewController.swiftnew file mode 100644index 00000000..ea59c811--- /dev/null+++ b/NotchBuddy/Sources/NotificationContent/NotificationViewController.swift@@ -0,0 +1,74 @@+import SwiftUI+import UIKit+import UserNotifications+import UserNotificationsUI+import CloudKit++// The expanded approval notification (long press): Mochi alive, waiting for+// your OK, with the agent and the command. The Review and Deny buttons stay+// the system's, under this view.++final class NotificationViewController: UIViewController, @preconcurrency UNNotificationContentExtension {+ private var host: UIHostingController<ApprovalNotificationView>?++ func didReceive(_ notification: UNNotification) {+ let content = notification.request.content+ let note = CKNotification(fromRemoteNotificationDictionary: content.userInfo) as? CKQueryNotification+ let pillId = content.userInfo["pillId"] as? String+ ?? note?.recordFields?["pillId"] as? String ?? "integration_claude"+ let card = ApprovalNotificationView(pillId: pillId, title: content.title, message: content.body)+ if let host {+ host.rootView = card+ } else {+ let host = UIHostingController(rootView: card)+ host.view.backgroundColor = .clear+ addChild(host)+ host.view.frame = self.view.bounds+ host.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]+ self.view.addSubview(host.view)+ host.didMove(toParent: self)+ self.host = host+ }+ preferredContentSize = CGSize(width: self.view.bounds.width, height: 190)+ }+}++struct ApprovalNotificationView: View {+ let pillId: String+ let title: String+ let message: String++ private var pill: PillDefinition? { PillCatalog.definition(for: pillId) }++ /// The command alone, without the "Waiting for your OK: " the local notification adds.+ private var command: String {+ let prefix = "Waiting for your OK: "+ return message.hasPrefix(prefix) ? String(message.dropFirst(prefix.count)) : message+ }++ var body: some View {+ HStack(alignment: .top, spacing: 14) {+ MochiLive(state: .approval, bodyHex: pill?.color ?? "#FFFFFF")+ .padding(6)+ .frame(width: 76, height: 76)+ .background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: 18))+ VStack(alignment: .leading, spacing: 6) {+ Text(title == "Coucou" ? (pill?.name ?? "Coucou") : title)+ .font(.headline)+ Text("Waiting for your OK")+ .font(.subheadline.weight(.semibold))+ .foregroundStyle(.orange)+ Text(command)+ .font(.footnote.monospaced())+ .lineLimit(4)+ .padding(8)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: 10))+ }+ }+ .padding(16)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)+ .background(Color(white: 0.08))+ .preferredColorScheme(.dark)+ }+}diff --git a/NotchBuddy/Sources/Phone/AboutView.swift b/NotchBuddy/Sources/Phone/AboutView.swiftnew file mode 100644index 00000000..82d7b4e9--- /dev/null+++ b/NotchBuddy/Sources/Phone/AboutView.swift@@ -0,0 +1,144 @@+import SwiftUI+import UIKit++/// Settings and About: how the iPhone is linked, the links Apple and people+/// look for, and the setup guide again.+struct AboutView: View {+ let link: PhoneLink+ @State private var showGuide = false++ private var version: String {+ let info = Bundle.main.infoDictionary+ let short = info?["CFBundleShortVersionString"] as? String ?? "?"+ let build = info?["CFBundleVersion"] as? String ?? "?"+ return "\(short) (\(build))"+ }++ var body: some View {+ List {+ Section {+ HStack(spacing: 14) {+ MochiLive(state: .idle)+ .padding(6)+ .frame(width: 64, height: 64)+ .background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: 16))+ VStack(alignment: .leading, spacing: 2) {+ Text("Coucou").font(.title3.weight(.semibold))+ Text("Version \(version)").font(.footnote).foregroundStyle(.secondary)+ }+ }+ .padding(.vertical, 4)+ }++ Section("Connection") {+ LabeledContent("iCloud") {+ Label(iCloudText, systemImage: link.status == .ready ? "checkmark.icloud" : "exclamationmark.icloud")+ .foregroundStyle(link.status == .ready ? .green : .orange)+ }+ LabeledContent("Notifications") {+ Text(link.notificationsAllowed == false ? "Off" : "On")+ .foregroundStyle(link.notificationsAllowed == false ? .orange : .secondary)+ }+ LabeledContent("Live Activities") {+ Text(LiveActivityLink.shared.activitiesEnabled ? "On" : "Off")+ .foregroundStyle(LiveActivityLink.shared.activitiesEnabled ? Color.secondary : Color.orange)+ }+ if link.notificationsAllowed == false || !LiveActivityLink.shared.activitiesEnabled {+ Button("Open iPhone Settings") {+ if let url = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(url) }+ }+ }+ Button("How to connect your Mac") { showGuide = true }+ }++ Section("Coucou") {+ Link("Website", destination: URL(string: "https://louis-cfm.github.io/coucou/")!)+ Link("Support", destination: URL(string: "https://louis-cfm.github.io/coucou/support.html")!)+ Link("Privacy Policy", destination: URL(string: "https://louis-cfm.github.io/coucou/privacy.html")!)+ Link("Terms", destination: URL(string: "https://louis-cfm.github.io/coucou/terms.html")!)+ }++ Section {+ Text("No account, no analytics, no ads. Your sessions travel through your own private iCloud, encrypted with your keys.")+ .font(.footnote)+ .foregroundStyle(.secondary)+ }+ }+ .navigationTitle("Settings")+ .sheet(isPresented: $showGuide) { OnboardingView() }+ }++ private var iCloudText: String {+ switch link.status {+ case .ready: "Linked"+ case .starting: "Connecting…"+ case .zoneMissing: "Waiting for your Mac"+ case .noAccount: "Not signed in"+ case .failed: "Can't reach iCloud"+ }+ }+}++/// First launch: what Coucou needs on the Mac to show anything here.+struct OnboardingView: View {+ @Environment(\.dismiss) private var dismiss++ var body: some View {+ ScrollView {+ VStack(alignment: .leading, spacing: 26) {+ VStack(alignment: .leading, spacing: 12) {+ MochiLive(state: .finished)+ .frame(width: 88, height: 88)+ Text("Your agents, in your pocket")+ .font(.largeTitle.weight(.bold))+ Text("Coucou on iPhone shows what Claude Code, Cursor, Codex and your services are doing on your Mac. Three things to set up, once.")+ .font(.body)+ .foregroundStyle(.secondary)+ }+ step(1, "Coucou on your Mac",+ "Install Coucou for Mac (Mac App Store or the website) and set up its Claude Code hooks.",+ icon: "laptopcomputer")+ step(2, "Turn on the iPhone switch",+ "On the Mac: Coucou Settings → General → iPhone → \"Show my agent sessions on my iPhone\".",+ icon: "switch.2")+ step(3, "Same Apple Account",+ "Sign in to iCloud with the same Apple Account on both. Your sessions go through your private iCloud, encrypted.",+ icon: "icloud")+ VStack(alignment: .leading, spacing: 6) {+ Text("Then, from here").font(.headline)+ Text("• Allow or deny a command, with Face ID\n• See what Claude did, file by file\n• Write or dictate the next instruction (GitHub version on the Mac)\n• Mochi in your Dynamic Island when your Mac is locked")+ .font(.callout)+ .foregroundStyle(.secondary)+ }+ }+ .padding(24)+ }+ .background(Color.black)+ .safeAreaInset(edge: .bottom) {+ Button {+ dismiss()+ } label: {+ Text("Got it").font(.headline).frame(maxWidth: .infinity).padding(.vertical, 6)+ }+ .buttonStyle(.borderedProminent)+ .controlSize(.large)+ .padding(.horizontal, 24)+ .padding(.bottom, 12)+ }+ .preferredColorScheme(.dark)+ }++ private func step(_ number: Int, _ title: String, _ text: String, icon: String) -> some View {+ HStack(alignment: .top, spacing: 14) {+ Image(systemName: icon)+ .font(.title3)+ .foregroundStyle(.tint)+ .frame(width: 44, height: 44)+ .background(Color(white: 0.14), in: RoundedRectangle(cornerRadius: 12))+ VStack(alignment: .leading, spacing: 3) {+ Text("\(number). \(title)").font(.headline)+ Text(text).font(.callout).foregroundStyle(.secondary)+ }+ }+ }+}diff --git a/NotchBuddy/Sources/Phone/ApprovalCard.swift b/NotchBuddy/Sources/Phone/ApprovalCard.swiftindex 25111d5e..b6f1324b 100644--- a/NotchBuddy/Sources/Phone/ApprovalCard.swift+++ b/NotchBuddy/Sources/Phone/ApprovalCard.swift@@ -64,6 +64,7 @@ struct ApprovalCard: View {if decision == .allow {guard await OwnerCheck.confirm(reason: "Allow this command on your Mac") else {error = "Face ID didn't confirm. Nothing was sent."+ Haptics.warning()return}}@@ -71,7 +72,9 @@ struct ApprovalCard: View {if await link.decide(decision, fingerprint: session.approvalFingerprint, pillId: session.id,summary: String(summary.prefix(200))) {sent = decision+ if decision == .allow { Haptics.success() } else { Haptics.impact() }} else {+ Haptics.error()error = link.lastPong ?? "Couldn't reach iCloud."}}@@ -91,7 +94,7 @@ struct ReviewSheet: View {VStack(alignment: .leading, spacing: 16) {if let session {HStack(spacing: 12) {- MochiStill(state: session.state)+ MochiLive(state: session.state).padding(6).frame(width: 52, height: 52).background(Color.mochiTile(hex: session.color), in: RoundedRectangle(cornerRadius: 14))@@ -127,30 +130,66 @@ struct ReviewSheet: View {struct HistoryView: View {let link: PhoneLink+ /// Newest day first, each day's decisions newest first.+ private var days: [(day: Date, logs: [DecisionLog])] {+ let calendar = Calendar.current+ let grouped = Dictionary(grouping: link.history) { calendar.startOfDay(for: $0.date) }+ return grouped.keys.sorted(by: >).map { (day: $0, logs: grouped[$0]!.sorted { $0.date > $1.date }) }+ }+var body: some View {List {if link.history.isEmpty {- Text("No decision yet.").foregroundStyle(.secondary)- }- ForEach(link.history) { log in- HStack(alignment: .firstTextBaseline, spacing: 10) {- Image(systemName: log.decision == .allow ? "checkmark.circle.fill" : "xmark.circle.fill")- .foregroundStyle(log.decision == .allow ? .green : .red)- VStack(alignment: .leading, spacing: 2) {- Text(log.summary)- .font(.callout.monospaced())- .lineLimit(3)- HStack(spacing: 4) {- Text(PillCatalog.definition(for: log.pillId)?.name ?? log.pillId)- Text("·")- Text(log.date, format: .dateTime.day().month().hour().minute())- }- .font(.caption)+ VStack(spacing: 10) {+ MochiLive(state: .sleeping).frame(width: 56, height: 56)+ Text("No decision yet").font(.headline)+ Text("Commands you allow or deny from your iPhone show up here. They stay on this iPhone.")+ .font(.footnote).foregroundStyle(.secondary)- }+ .multilineTextAlignment(.center)+ }+ .frame(maxWidth: .infinity)+ .padding(.vertical, 24)+ .listRowBackground(Color.clear)+ }+ ForEach(days, id: \.day) { day in+ Section(Self.dayTitle(day.day)) {+ ForEach(day.logs) { log in row(log) }}}}.navigationTitle("History")}++ private func row(_ log: DecisionLog) -> some View {+ let pill = PillCatalog.definition(for: log.pillId)+ return HStack(alignment: .top, spacing: 12) {+ MochiStill(state: log.decision == .allow ? .finished : .error, bodyHex: pill?.color ?? "#FFFFFF")+ .padding(3)+ .frame(width: 34, height: 34)+ .background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: 9))+ VStack(alignment: .leading, spacing: 3) {+ Text(log.summary)+ .font(.callout.monospaced())+ .lineLimit(3)+ HStack(spacing: 6) {+ Label(log.decision == .allow ? "Allowed" : "Denied",+ systemImage: log.decision == .allow ? "checkmark.circle.fill" : "xmark.circle.fill")+ .foregroundStyle(log.decision == .allow ? .green : .red)+ Text(pill?.name ?? log.pillId).foregroundStyle(.secondary)+ Spacer(minLength: 0)+ Text(log.date, format: .dateTime.hour().minute()).foregroundStyle(.tertiary)+ }+ .font(.caption)+ }+ }+ .padding(.vertical, 2)+ }++ static func dayTitle(_ day: Date) -> String {+ let calendar = Calendar.current+ if calendar.isDateInToday(day) { return "Today" }+ if calendar.isDateInYesterday(day) { return "Yesterday" }+ return day.formatted(.dateTime.weekday(.wide).day().month(.wide))+ }}diff --git a/NotchBuddy/Sources/Phone/Haptics.swift b/NotchBuddy/Sources/Phone/Haptics.swiftnew file mode 100644index 00000000..35129c11--- /dev/null+++ b/NotchBuddy/Sources/Phone/Haptics.swift@@ -0,0 +1,10 @@+import UIKit++/// Small taps under the finger for the actions that reach the Mac.+@MainActor+enum Haptics {+ static func success() { UINotificationFeedbackGenerator().notificationOccurred(.success) }+ static func warning() { UINotificationFeedbackGenerator().notificationOccurred(.warning) }+ static func error() { UINotificationFeedbackGenerator().notificationOccurred(.error) }+ static func impact() { UIImpactFeedbackGenerator(style: .medium).impactOccurred() }+}diff --git a/NotchBuddy/Sources/Phone/HomeView.swift b/NotchBuddy/Sources/Phone/HomeView.swiftindex 0ff7b80e..c24a2184 100644--- a/NotchBuddy/Sources/Phone/HomeView.swift+++ b/NotchBuddy/Sources/Phone/HomeView.swift@@ -5,6 +5,7 @@ import SwiftUIstruct HomeView: View {let link: PhoneLink@State private var path: [String] = []+ @AppStorage("onboardingDone") private var onboardingDone = falsevar body: some View {NavigationStack(path: $path) {@@ -53,6 +54,10 @@ struct HomeView: View {ReviewSheet(link: link, fingerprint: fingerprint)}}+ // First launch: how to connect the Mac.+ .fullScreenCover(isPresented: Binding(get: { !onboardingDone }, set: { if !$0 { onboardingDone = true } })) {+ OnboardingView()+ }.toolbar {ToolbarItem(placement: .topBarLeading) {NavigationLink {@@ -61,6 +66,13 @@ struct HomeView: View {Image(systemName: "clock.arrow.circlepath")}}+ ToolbarItem(placement: .topBarTrailing) {+ NavigationLink {+ AboutView(link: link)+ } label: {+ Image(systemName: "gearshape")+ }+ }#if DEBUG// Test screens, in builds run from Xcode only (the link test has its own "Kit" button).ToolbarItem(placement: .topBarTrailing) {@@ -83,7 +95,7 @@ struct NotchHeader: View {var body: some View {HStack(spacing: 14) {- MochiStill(state: sessions.leadState)+ MochiLive(state: sessions.leadState).frame(width: 52, height: 52)VStack(alignment: .leading, spacing: 3) {Text(headline)@@ -128,7 +140,7 @@ struct SessionRow: View {var body: some View {HStack(spacing: 12) {- MochiStill(state: session.state)+ MochiLive(state: session.state, fps: 20).padding(4).frame(width: 40, height: 40).background(Color.mochiTile(hex: session.color), in: RoundedRectangle(cornerRadius: 11))@@ -136,7 +148,11 @@ struct SessionRow: View {Text(session.title).font(.body.weight(.semibold)).lineLimit(1)- Text(session.pillName)+ // The agent under the project name; for a session without a project+ // name (title is the agent already), what runs in it.+ Text(session.title == session.pillName+ ? (PillCatalog.definition(for: session.id)?.sessionSubtitle ?? session.pillName)+ : session.pillName).font(.subheadline).foregroundStyle(.secondary)}diff --git a/NotchBuddy/Sources/Phone/InstructionComposer.swift b/NotchBuddy/Sources/Phone/InstructionComposer.swiftindex a671075d..2acc86af 100644--- a/NotchBuddy/Sources/Phone/InstructionComposer.swift+++ b/NotchBuddy/Sources/Phone/InstructionComposer.swift@@ -15,20 +15,24 @@ struct InstructionComposer: View {@State private var dictation = Dictation()@FocusState private var focused: Bool+ /// A bar at the bottom of the session screen, like a chat.var body: some View {- VStack(alignment: .leading, spacing: 10) {- Text("Send to Claude").font(.subheadline.weight(.semibold)).foregroundStyle(.secondary)+ VStack(alignment: .leading, spacing: 6) {if session.acceptsInstructions {composerstatus} else {- Text("To continue this session from your iPhone, turn on \"Let my iPhone send instructions to Claude Code\" in Coucou's Settings on your Mac (GitHub version), then start a turn in VS Code.")- .font(.footnote)+ Label("To write to Claude from here, turn on \"Let my iPhone send instructions to Claude Code\" in Coucou's Settings on your Mac (GitHub version).",+ systemImage: "info.circle")+ .font(.caption).foregroundStyle(.secondary)}}- .padding(16)- .background(Color(white: 0.11), in: RoundedRectangle(cornerRadius: 22))+ .padding(.horizontal, 16)+ .padding(.top, 10)+ .padding(.bottom, 8)+ .background(.bar)+ .overlay(alignment: .top) { Divider() }.onChange(of: dictation.transcript) { _, words inif dictation.isRecording { text = dictation.prefix + words }}@@ -83,9 +87,6 @@ struct InstructionComposer: View {Label("Sent. Your Mac picks it up within 15 s.", systemImage: "paperplane.fill").font(.caption).foregroundStyle(.secondary)}- } else {- Text("Face ID sends it. It continues this conversation on your Mac, in its folder.")- .font(.caption).foregroundStyle(.secondary)}}@@ -99,13 +100,16 @@ struct InstructionComposer: View {error = nilguard await OwnerCheck.confirm(reason: "Send this instruction to Claude Code on your Mac") else {error = "Face ID didn't confirm. Nothing was sent."+ Haptics.warning()return}if await link.sendInstruction(instruction, pillId: session.id) {sentAt = .nowtext = ""+ Haptics.success()} else {error = link.lastPong ?? "Couldn't reach iCloud."+ Haptics.error()}}}diff --git a/NotchBuddy/Sources/Phone/MochiLive.swift b/NotchBuddy/Sources/Phone/MochiLive.swiftnew file mode 100644index 00000000..533fa126--- /dev/null+++ b/NotchBuddy/Sources/Phone/MochiLive.swift@@ -0,0 +1,37 @@+import QuartzCore+import SwiftUI++/// Mochi alive, as in the Mac's notch: he blinks, looks around and reacts to+/// his state (a hop when a task finishes). Same BotEngine as the Mac. Draws+/// only while on screen, at a capped frame rate.+struct MochiLive: View {+ let state: BotState+ var bodyHex: String = "#FFFFFF"+ /// Lower for small, numerous Mochi (list rows).+ var fps: Double = 30++ @StateObject private var engine = BotEngine()+ @State private var visible = false++ var body: some View {+ TimelineView(.animation(minimumInterval: 1 / fps, paused: !visible)) { timeline in+ Canvas { context, size in+ _ = timeline.date+ let dt = min(0.05, max(0, CACurrentMediaTime() - engine.lastTime))+ engine.update(dt: dt)+ engine.draw(context: context, size: size)+ }+ }+ .aspectRatio(1, contentMode: .fit)+ .onAppear {+ engine.isMini = true+ engine.bodyColor = cgColorFromHex(bodyHex)+ engine.setState(state, force: true)+ visible = true+ }+ .onDisappear { visible = false }+ .onChange(of: state) { _, newState in engine.setState(newState) }+ .onChange(of: bodyHex) { _, hex in engine.bodyColor = cgColorFromHex(hex) }+ .accessibilityHidden(true)+ }+}diff --git a/NotchBuddy/Sources/Phone/ServiceViews.swift b/NotchBuddy/Sources/Phone/ServiceViews.swiftindex d6ad1fc6..cb7a02a5 100644--- a/NotchBuddy/Sources/Phone/ServiceViews.swift+++ b/NotchBuddy/Sources/Phone/ServiceViews.swift@@ -77,7 +77,7 @@ struct ServiceMochi: View {var body: some View {let color = PillCatalog.definition(for: pillId)?.color ?? "#C0C4CC"- MochiStill(state: tone?.botState ?? .sleeping, bodyHex: color)+ MochiLive(state: tone?.botState ?? .sleeping, bodyHex: color, fps: 20).padding(4).background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: corner))}diff --git a/NotchBuddy/Sources/Phone/SessionDetailView.swift b/NotchBuddy/Sources/Phone/SessionDetailView.swiftindex e5e989a0..f7e6ed51 100644--- a/NotchBuddy/Sources/Phone/SessionDetailView.swift+++ b/NotchBuddy/Sources/Phone/SessionDetailView.swift@@ -19,9 +19,6 @@ struct SessionDetailView: View {waiting(title: "Question", text: session.question, monospaced: false, color: .cyan,footnote: "Answer on your Mac for now.")}- if session.id == "integration_claude" || session.id == "agent_cursor" {- InstructionComposer(link: link, session: session)- }if let turn {LastTurnView(turn: turn, working: session.isWorking)} else if !session.steps.isEmpty {@@ -34,14 +31,6 @@ struct SessionDetailView: View {.textSelection(.enabled)}}- if !session.cwd.isEmpty {- card(title: "Folder") {- Text(session.cwd)- .font(.footnote.monospaced())- .foregroundStyle(.secondary)- .textSelection(.enabled)- }- }}.padding(16)} else if let turn {@@ -59,6 +48,13 @@ struct SessionDetailView: View {}}.background(Color.black)+ // The composer stays at the bottom, like a chat.+ .safeAreaInset(edge: .bottom) {+ if let session, session.id == "integration_claude" || session.id == "agent_cursor" {+ InstructionComposer(link: link, session: session)+ }+ }+ .scrollDismissesKeyboard(.interactively).navigationTitle(session?.title ?? "Session").navigationBarTitleDisplayMode(.inline).refreshable { await link.refresh() }@@ -66,12 +62,13 @@ struct SessionDetailView: View {private func header(_ session: SessionItem) -> some View {HStack(spacing: 16) {- MochiStill(state: session.state)+ MochiLive(state: session.state).padding(10).frame(width: 84, height: 84).background(Color.mochiTile(hex: session.color), in: RoundedRectangle(cornerRadius: 22))VStack(alignment: .leading, spacing: 4) {- Text("\(session.pillName) · \(session.title)")+ // "VS Code · coucou", or just "VS Code" when there's no project name.+ Text(session.title == session.pillName ? session.pillName : "\(session.pillName) · \(session.title)").font(.headline)Text(session.statusText).font(.subheadline.weight(.semibold))@@ -85,11 +82,28 @@ struct SessionDetailView: View {}.font(.caption).foregroundStyle(.secondary)+ if !session.cwd.isEmpty {+ Label(Self.shortPath(session.cwd), systemImage: "folder")+ .font(.caption2.monospaced())+ .foregroundStyle(.tertiary)+ .lineLimit(1)+ .truncationMode(.head)+ .textSelection(.enabled)+ }}Spacer(minLength: 0)}}+ /// "/Users/louis/Documents/hi" → "~/Documents/hi".+ static func shortPath(_ path: String) -> String {+ let parts = path.split(separator: "/", omittingEmptySubsequences: true)+ if parts.count >= 2, parts[0] == "Users" {+ return "~/" + parts.dropFirst(2).joined(separator: "/")+ }+ return path+ }+private func waiting(title: String, text: String, monospaced: Bool, color: Color, footnote: String) -> some View {VStack(alignment: .leading, spacing: 10) {Text(title).font(.subheadline.weight(.semibold)).foregroundStyle(color)diff --git a/NotchBuddy/Sources/Widgets/MochiLiveActivity.swift b/NotchBuddy/Sources/Widgets/MochiLiveActivity.swiftindex 5c8f0b7c..e3ceeefb 100644--- a/NotchBuddy/Sources/Widgets/MochiLiveActivity.swift+++ b/NotchBuddy/Sources/Widgets/MochiLiveActivity.swift@@ -40,10 +40,18 @@ struct MochiLiveActivity: Widget {}}DynamicIslandExpandedRegion(.bottom) {- if state.stepCount > 0 {- StepsBar(index: state.stepIndex, count: state.stepCount, color: state.toneColor)- .padding(.horizontal, 4)+ HStack(spacing: 10) {+ if state.stepCount > 0 {+ StepsBar(index: state.stepIndex, count: state.stepCount, color: state.toneColor)+ }+ if let since = state.sinceDate, state.isActive {+ Text(since, style: .timer)+ .font(.caption.monospacedDigit())+ .foregroundStyle(.secondary)+ .frame(width: 52, alignment: .trailing)+ }}+ .padding(.horizontal, 4)}} compactLeading: {MochiStill(state: state.botState)@@ -79,9 +87,18 @@ struct LockScreenActivityView: View {Text("+\(state.others)").font(.subheadline).foregroundStyle(.secondary)}}- Text(stale ? "Your Mac went quiet" : state.statusText)- .font(.subheadline.weight(.semibold))- .foregroundStyle(stale ? Color.secondary : state.toneColor)+ HStack(spacing: 6) {+ Text(stale ? "Your Mac went quiet" : state.statusText)+ .font(.subheadline.weight(.semibold))+ .foregroundStyle(stale ? Color.secondary : state.toneColor)+ // Counts up live, without any push.+ if let since = state.sinceDate, state.isActive, !stale {+ Text("·").foregroundStyle(.secondary)+ Text(since, style: .timer)+ .font(.subheadline.monospacedDigit())+ .foregroundStyle(.secondary)+ }+ }if state.stepCount > 0 && !stale {StepsBar(index: state.stepIndex, count: state.stepCount, color: state.toneColor)}@@ -111,6 +128,8 @@ struct StepsBar: View {}extension MochiActivityState {+ var sinceDate: Date? { since.map { Date(timeIntervalSince1970: TimeInterval($0)) } }+var toneColor: Color {switch tone {case "waiting": .orangediff --git a/NotchBuddy/project.yml b/NotchBuddy/project.ymlindex e419ecaa..9be7314e 100644--- a/NotchBuddy/project.yml+++ b/NotchBuddy/project.yml@@ -113,6 +113,7 @@ targets:excludes:- "Phone/**"- "Widgets/**"+ - "NotificationContent/**"- path: Assets.xcassetsbuildPhase: resources- path: Resources/sounds@@ -166,6 +167,7 @@ targets:excludes:- "Phone/**"- "Widgets/**"+ - "NotificationContent/**"- path: Assets.xcassetsbuildPhase: resources- path: Resources/sounds@@ -217,6 +219,7 @@ targets:deploymentTarget: "18.0"dependencies:- target: CoucouWidgets+ - target: CoucouNotificationContentsources:- path: Sources/Phonetype: group@@ -321,3 +324,49 @@ targets:OTHER_CODE_SIGN_FLAGS: ""SKIP_INSTALL: YESAPPLICATION_EXTENSION_API_ONLY: YES++ # The expanded approval notification: Mochi alive, with the command.+ CoucouNotificationContent:+ type: app-extension+ platform: iOS+ deploymentTarget: "18.0"+ sources:+ - path: Sources/NotificationContent+ type: group+ - path: Sources/CoucouKit+ type: group+ - path: Sources/Phone/MochiLive.swift+ - path: Sources/Phone/MacStubs.swift+ info:+ path: Resources/InfoNotificationContent.plist+ properties:+ CFBundleName: CoucouNotificationContent+ CFBundleDisplayName: Coucou+ CFBundleIdentifier: fr.louisraille.Coucou.NotificationContent+ CFBundleVersion: "2"+ CFBundleShortVersionString: "1.0"+ CFBundlePackageType: XPC!+ NSExtension:+ NSExtensionPointIdentifier: com.apple.usernotifications.content-extension+ NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).NotificationViewController+ NSExtensionAttributes:+ UNNotificationExtensionCategory: COUCOU_APPROVAL+ UNNotificationExtensionInitialContentSizeRatio: 0.45+ UNNotificationExtensionDefaultContentHidden: true+ settings:+ base:+ PRODUCT_BUNDLE_IDENTIFIER: fr.louisraille.Coucou.NotificationContent+ PRODUCT_NAME: CoucouNotificationContent+ INFOPLIST_FILE: Resources/InfoNotificationContent.plist+ IPHONEOS_DEPLOYMENT_TARGET: "18.0"+ TARGETED_DEVICE_FAMILY: "1"+ SUPPORTS_MACCATALYST: NO+ CODE_SIGN_STYLE: Automatic+ CODE_SIGN_IDENTITY: "Apple Development"+ DEVELOPMENT_TEAM: 256AUJ9555+ CODE_SIGNING_REQUIRED: YES+ CODE_SIGNING_ALLOWED: YES+ ENABLE_HARDENED_RUNTIME: NO+ OTHER_CODE_SIGN_FLAGS: ""+ SKIP_INSTALL: YES+ APPLICATION_EXTENSION_API_ONLY: YESdiff --git a/relay/src/index.ts b/relay/src/index.tsindex 6cff4f85..ed403eda 100644--- a/relay/src/index.ts+++ b/relay/src/index.ts@@ -90,6 +90,9 @@ function validate(body: RelayRequest): string | null {const value = body.state[key];if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 999) return `state.${key}`;}+ const since = body.state["since"];+ if (since !== undefined && since !== null &&+ (typeof since !== "number" || !Number.isInteger(since) || since < 1_600_000_000 || since > 4_000_000_000)) return "state.since";if (body.dismissAfter !== undefined &&(typeof body.dismissAfter !== "number" || !Number.isInteger(body.dismissAfter) ||body.dismissAfter < 0 || body.dismissAfter > 4 * 3600)) return "dismissAfter";@@ -101,6 +104,8 @@ function buildPayload(body: RelayRequest) {// Only the known fields, so nothing else rides along.const state: Record<string, unknown> = {};for (const key of [...STATE_STRINGS, ...STATE_NUMBERS]) state[key] = body.state[key];+ // When Mochi left for the iPhone: the activity counts the time from it.+ if (typeof body.state["since"] === "number") state["since"] = body.state["since"];const aps: Record<string, unknown> = {timestamp: now,