mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
* iPhone: Liquid Glass, tabs, zoom transitions, gestures, icons, Spotlight, Focus - Tabs (Agents, Services, History, Search) with the agent that needs you above them, like Music's mini player (iOS 26). - Liquid Glass cards and buttons on iOS 26, the dark material before; the island at the top grows Allow / Deny when a command waits (glass morphing). - The Mochi tile zooms into the session; the agent's color moves softly behind it (MeshGradient); the header shrinks as the list scrolls. - Symbols that move with the state; Apple Pay's drawn checkmark on Allow. - Swipe right to allow (Face ID), left to deny; long press for a peek at the last turn. - Search through every turn; finished turns in Spotlight (local index, can be turned off). - Dark and tinted app icons, and Mochi in five other colors to pick. - A Coucou Focus filter: only approvals and questions during a Focus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Approval panel the iOS way, a softer session glow, Live Activity alerts - The island grows a glass panel under it when a command waits: who asks, the command, a quiet Deny and a bright Allow (Face ID). Same buttons in the session's approval card; no more red and green blocks. - The session's glow is softer, and white or grey agents (VS Code, Cursor) glow in deep blue instead of a grey haze. - "Waiting for your OK" and questions now update the Live Activity with an alert, so the Dynamic Island opens and the Lock Screen lights up; the iPhone allows frequent Live Activity updates so they aren't held back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Live Activity: log every change of phase and its push, retry again after a success The update retries were capped for the whole activity: after ten waits for a token, a later "waiting for your OK" could stay on the Mac. The count now starts again after each update that goes out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Floating glass composer, no tabs in a session, Live Activity started again when it didn't come up - The instruction field is one glass capsule with the language and the mic inside and a round send button next to it, like Messages on iOS 26; shortcuts are glass pills; no bar behind, the list fades out under it. - A session takes the whole screen: the tab bar and the mini player hide. - When iOS didn't bring the Live Activity up (no update token) and an agent then waits for your OK or asks a question, the Mac starts it again with that state, once per request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Live Activity: spend fewer starts iOS allows only so many push-to-start activities an hour; every lock started one and every unlock ended it, so after many locks the iPhone stopped bringing it up. Now a working agent leaves for the iPhone once the Mac has stayed locked for 20 s (right away when it waits for you), and an unlock ends the activity only after 30 s, so locking again reuses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Session screen: field fixed at the bottom, no tabs, keyboard away on scroll or tap The tab bar shrank and grew while scrolling (minimize on scroll) and the mini player sat between it and the field, so the field moved up and down. The mini player and the minimizing are gone, the tabs hide inside a session, and scrolling or tapping the conversation puts the keyboard away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Keyboard: only a tap on the conversation puts it away, not a tap on the field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Services up close on the iPhone, with actions run by the Mac When a service's screen opens, the iPhone asks the Mac (ServiceAction record); the Mac reads the service's API with the key in its Keychain and writes a ServiceDetail record, encrypted: figures, lists and the actions it offers on each item. - Vercel: deployments and projects; redeploy, promote to production, cancel a build. - GitHub: your pull requests (squash and merge), reviews asked of you (approve), CI on your latest repos (re-run failed jobs). - Stripe: balance, payments, payouts, subscriptions and MRR (read only). - Resend: latest emails and how they went, domains (read only). - Cal.com: upcoming bookings; cancel one. - n8n: workflows (turn on / off) and runs (retry a failed one). - Notion: pages and databases edited lately (read only). Actions need Face ID on the iPhone; the Mac runs one only if it offered it on that item in the last detail it sent, asked in the last 5 minutes. Nothing that moves money or sends an email can be asked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Services: fixes from an API and logic review - Vercel: "Promote to production" rebuilds the preview for production (POST /v13/deployments with target production), as the Vercel CLI does; /v10/promote only promotes production builds. - Stripe: pending paired with available by currency; MRR per currency, metered and tiered prices left out, decimal prices read, labelled as an estimate; every page of subscriptions (up to 1 000); full zero-decimal currency list; partly refunded and uncaptured charges shown as such; a list that can't be read says why instead of showing zeros. - Resend: suppressed emails count as not delivered; domain badges without underscores; a sending-only key gets a clear message. - Cal.com is read only: cancelling emails the guest and can refund or charge them. - n8n: every page of workflows; archived ones not offered "Turn on"; a clear message when the instance is too old to retry a run. - The Mac takes a request only if it could delete it from iCloud, tells the iPhone when an action isn't offered any more, is woken by the CloudKit push (one check a minute in case one is missed) instead of every 10 s, downloads only the request fields, and deletes its details when the iPhone sync is turned off. - The iPhone waits for the result of this action (not an older one) and plays the success haptic only when it worked; leaving a service screen stops its checks; "Asking your Mac…" says so when the Mac doesn't answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * Services: Cal.com bookings found again, a cleaner service screen - The Mac's Cal.com poller asked the v2 API with start / end, which aren't its parameters, so it found no booking: it now uses afterStart / beforeEnd (the notch and the iPhone's summary show the call again). - Service screen: the figures in one strip; one line per item (title, badge, subtitle and date), a tap opens it on the web, its actions in a "…" menu or a long press (with Open and Copy link); the reason card only when something needs a look. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * iPhone: Mochi moves at the screen's rate (up to 120 Hz) Mochi was drawn at 30 frames a second (20 in lists) on screens that run at 60 or 120 Hz, which made him stutter. He now follows the screen's rate, the app may use ProMotion's 120 Hz like the Mac's notch, list rows are capped at 60, and the agent's glow moves at 30 instead of 10. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * iPhone: an opening with Mochi alone, who then flies to his tile While the app loads, Mochi sits alone in the middle of a black screen, looks left and right, then up with big round eyes, small eyes, a bar, a blink, and back at you (at least 2.4 s, up to 4 s while iCloud answers). Then he flies to the VS Code session's tile (or the island at the top) as the black fades, and the real one takes over there. The first launch opens on the setup guide instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * iPhone intro: fluid eyes driven by the engine, no blink Mochi's opening now moves through smooth curves (gaze, tilt, eye size and height) instead of swapping eye shapes, and never closes his eyes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * iPhone intro: a lively Mochi that hides the first sync Mochi now pops in and plays a little show driven by springs: quick glances and slow drifts, eyes that pop round, shrink or squint, a body that leans, hops and squashes along. The intro ends once the first iCloud fetch is over (between 2.4 s and 6 s), which now starts without waiting for the notification prompt, so the home screen behind is already in sync when he flies to his tile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p * README and site: Coucou on iPhone, App Store install Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p --------- Co-authored-by: Claude <noreply@anthropic.com>
338 lines
12 KiB
Swift
338 lines
12 KiB
Swift
import SwiftUI
|
|
import QuartzCore
|
|
|
|
// The opening: Mochi alone on black while the app loads. He pops in and looks
|
|
// around like the greeting on the Mac (without the hands): quick glances and
|
|
// slow ones, eyes that pop round, shrink or squint to a bar, his body leaning,
|
|
// hopping and squashing along. It hides the first iCloud fetch: as soon as
|
|
// it's over he finishes with a little hop and flies to his spot on the home
|
|
// screen, the VS Code session's tile (or the island at the top), and the home
|
|
// screen behind is already up to date.
|
|
|
|
/// Where the intro's Mochi lands. The tile reports its frame on screen.
|
|
@MainActor
|
|
@Observable
|
|
final class IntroLanding {
|
|
static let shared = IntroLanding()
|
|
|
|
var tileFrame: CGRect?
|
|
var headerFrame: CGRect?
|
|
/// The intro is over: the real Mochi on the home screen show again.
|
|
var landed = false
|
|
|
|
var target: CGRect? { tileFrame ?? headerFrame }
|
|
}
|
|
|
|
extension View {
|
|
/// Reports this view's frame as the intro's landing spot; hidden until he lands.
|
|
func introLanding(_ kind: IntroLandingKind) -> some View {
|
|
modifier(IntroLandingModifier(kind: kind))
|
|
}
|
|
}
|
|
|
|
enum IntroLandingKind { case tile, header }
|
|
|
|
private struct IntroLandingModifier: ViewModifier {
|
|
let kind: IntroLandingKind
|
|
private var landing: IntroLanding { .shared }
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.opacity(landing.landed || !isTarget ? 1 : 0)
|
|
.onGeometryChange(for: CGRect.self) { $0.frame(in: .global) } action: { frame in
|
|
switch kind {
|
|
case .tile: landing.tileFrame = frame
|
|
case .header: landing.headerFrame = frame
|
|
}
|
|
}
|
|
.onDisappear {
|
|
if kind == .tile { landing.tileFrame = nil }
|
|
}
|
|
}
|
|
|
|
/// Only the spot he actually flies to is hidden.
|
|
private var isTarget: Bool {
|
|
switch kind {
|
|
case .tile: true
|
|
case .header: landing.tileFrame == nil
|
|
}
|
|
}
|
|
}
|
|
|
|
struct IntroView: View {
|
|
/// True once the first iCloud fetch is over.
|
|
let ready: Bool
|
|
let onFinished: () -> Void
|
|
|
|
@State private var flightStart: Date?
|
|
@State private var fade = false
|
|
@State private var engine = IntroEngine()
|
|
private var landing: IntroLanding { .shared }
|
|
|
|
/// He plays at least this long, even when everything is already there,
|
|
/// and never keeps the app waiting longer than `maximum`.
|
|
private let minimum: TimeInterval = 2.4
|
|
private let maximum: TimeInterval = 6
|
|
private let size: CGFloat = 132
|
|
|
|
var body: some View {
|
|
GeometryReader { proxy in
|
|
let center = CGPoint(x: proxy.size.width / 2, y: proxy.size.height / 2)
|
|
let target = landing.target
|
|
let flying = flightStart != nil
|
|
ZStack {
|
|
Color.black
|
|
.opacity(fade ? 0 : 1)
|
|
TimelineView(.animation) { timeline in
|
|
Canvas { context, size in
|
|
let now = timeline.date
|
|
// Over 0.4 s of the flight his face settles back to neutral.
|
|
let settle = flightStart.map { min(1, now.timeIntervalSince($0) / 0.4) } ?? 0
|
|
engine.draw(context: context, size: size, settle: settle)
|
|
}
|
|
}
|
|
.frame(width: flying ? (target?.width ?? size) : size,
|
|
height: flying ? (target?.height ?? size) : size)
|
|
.position(flying ? CGPoint(x: target?.midX ?? center.x, y: target?.midY ?? center.y) : center)
|
|
.opacity(flying && target == nil ? 0 : 1)
|
|
}
|
|
.ignoresSafeArea()
|
|
}
|
|
.ignoresSafeArea()
|
|
.allowsHitTesting(!fade)
|
|
.task {
|
|
try? await Task.sleep(for: .seconds(minimum))
|
|
var waited = minimum
|
|
while !ready && waited < maximum {
|
|
try? await Task.sleep(for: .milliseconds(100))
|
|
waited += 0.1
|
|
}
|
|
// Everything is there: a last hop looking at you, then off he goes.
|
|
engine.finish()
|
|
try? await Task.sleep(for: .milliseconds(480))
|
|
withAnimation(.spring(duration: 0.7, bounce: 0.22)) { flightStart = Date() }
|
|
withAnimation(.easeOut(duration: 0.5).delay(0.12)) { fade = true }
|
|
try? await Task.sleep(for: .milliseconds(700))
|
|
landing.landed = true
|
|
onFinished()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// A damped spring: stiff ones snap (a glance), soft ones drift (a slow look).
|
|
private struct Spring {
|
|
var value: CGFloat
|
|
var velocity: CGFloat = 0
|
|
var target: CGFloat
|
|
/// Stiffness and damping of the move in progress.
|
|
var k: CGFloat = 200
|
|
var c: CGFloat = 26
|
|
|
|
init(_ value: CGFloat) {
|
|
self.value = value
|
|
target = value
|
|
}
|
|
|
|
mutating func go(_ target: CGFloat, _ motion: Motion) {
|
|
self.target = target
|
|
k = motion.k
|
|
c = motion.c
|
|
}
|
|
|
|
mutating func step(_ dt: CGFloat) {
|
|
velocity += (k * (target - value) - c * velocity) * dt
|
|
value += velocity * dt
|
|
}
|
|
}
|
|
|
|
/// How a move happens.
|
|
private struct Motion {
|
|
var k: CGFloat
|
|
var c: CGFloat
|
|
/// A glance: very fast, a hint of overshoot.
|
|
static let snap = Motion(k: 900, c: 42)
|
|
/// A normal look.
|
|
static let look = Motion(k: 260, c: 28)
|
|
/// A slow, curious drift.
|
|
static let drift = Motion(k: 55, c: 14)
|
|
/// Eyes popping open: bouncy.
|
|
static let pop = Motion(k: 520, c: 16)
|
|
/// Squinting: quick, no bounce.
|
|
static let squint = Motion(k: 700, c: 52)
|
|
/// Reopening after a squint: slow.
|
|
static let ease = Motion(k: 90, c: 17)
|
|
}
|
|
|
|
/// Mochi's face and body for the opening, drawn by the same engine as
|
|
/// everywhere else, driven here by a little show of moves. Each move has its
|
|
/// own speed, his body follows where he looks (leans, drifts, tilts with the
|
|
/// motion) and hops land with a squash, so it never feels mechanical. The
|
|
/// eyes stay the same pill and only change size and height: no blink.
|
|
@MainActor
|
|
final class IntroEngine {
|
|
private let bot: BotEngine = {
|
|
let bot = BotEngine()
|
|
bot.isMini = true
|
|
bot.bodyColor = cgColorFromHex("#FFFFFF")
|
|
bot.setState(.idle, force: true)
|
|
return bot
|
|
}()
|
|
|
|
private enum Body { case none, hop, squash, shiver }
|
|
|
|
private struct Beat {
|
|
var x: CGFloat = 0, y: CGFloat = 0
|
|
var gaze: Motion = .look
|
|
var eyes: CGFloat = 1, open: CGFloat = 1
|
|
var eyeMotion: Motion = .look
|
|
var body: Body = .none
|
|
/// How long he stays on it.
|
|
var hold: Double
|
|
}
|
|
|
|
/// The show, in order, then random moves from `idle` while iCloud is still busy.
|
|
private static let show: [Beat] = [
|
|
Beat(eyes: 1.05, eyeMotion: .pop, hold: 0.42), // hello
|
|
Beat(x: -0.75, y: 0.05, gaze: .snap, hold: 0.5), // glance left
|
|
Beat(x: 0.62, y: 0.16, gaze: .drift, eyes: 0.82, eyeMotion: .drift, hold: 0.75), // slowly to the right
|
|
Beat(x: 0.08, y: -0.45, gaze: .look, eyes: 1.42, eyeMotion: .pop, body: .hop, hold: 0.55), // up, big round eyes
|
|
Beat(x: 0.28, y: 0.04, gaze: .look, eyes: 1.05, open: 0.2, eyeMotion: .squint, body: .squash, hold: 0.5), // a bar
|
|
Beat(x: -0.42, y: 0.32, gaze: .drift, eyes: 0.74, eyeMotion: .ease, hold: 0.55), // small, down left
|
|
Beat(x: 0.7, y: -0.04, gaze: .snap, eyes: 0.9, hold: 0.16), // double take…
|
|
Beat(x: 0, y: 0, gaze: .snap, eyes: 1.25, eyeMotion: .pop, body: .shiver, hold: 0.45), // …at you
|
|
]
|
|
private static let idle: [Beat] = [
|
|
Beat(x: -0.6, y: -0.2, gaze: .snap, eyes: 1.15, eyeMotion: .pop, hold: 0.5),
|
|
Beat(x: 0.55, y: 0.25, gaze: .drift, eyes: 0.8, eyeMotion: .drift, hold: 0.6),
|
|
Beat(x: 0.15, y: -0.4, gaze: .look, eyes: 1.35, eyeMotion: .pop, body: .hop, hold: 0.5),
|
|
Beat(x: -0.2, y: 0.05, gaze: .look, open: 0.22, eyeMotion: .squint, body: .squash, hold: 0.45),
|
|
Beat(x: 0.7, y: 0, gaze: .snap, hold: 0.35),
|
|
Beat(x: -0.35, y: 0.3, gaze: .drift, eyes: 0.72, eyeMotion: .ease, hold: 0.55),
|
|
]
|
|
private static let last = Beat(x: 0, y: 0, gaze: .look, eyes: 1.12, eyeMotion: .pop, body: .hop, hold: 10)
|
|
|
|
private var yaw = Spring(0), pitch = Spring(0)
|
|
private var eyes = Spring(0.6), open = Spring(1)
|
|
private var sx = Spring(0.25), sy = Spring(0.25)
|
|
private var lean = Spring(0), tilt = Spring(0)
|
|
/// Height off the ground (negative is up) and its speed, with gravity.
|
|
private var oy: CGFloat = 0, oyVelocity: CGFloat = 0
|
|
/// A hop waiting for its crouch to end.
|
|
private var launchAt: Double?
|
|
private var shiverUntil: Double = 0
|
|
|
|
private var index = 0
|
|
private var nextBeat: Double?
|
|
private var lastTime: Double?
|
|
private var lastIdle = -1
|
|
private var finishing = false
|
|
|
|
init() {
|
|
// He pops in from nothing.
|
|
sx.go(1, .pop)
|
|
sy.go(1, .pop)
|
|
}
|
|
|
|
/// The app is ready: back to looking at you, one last hop.
|
|
func finish() {
|
|
guard !finishing else { return }
|
|
finishing = true
|
|
play(Self.last, at: CACurrentMediaTime())
|
|
}
|
|
|
|
private func play(_ beat: Beat, at now: Double) {
|
|
yaw.go(beat.x * 0.62, beat.gaze)
|
|
pitch.go(beat.y * 0.5, beat.gaze)
|
|
eyes.go(beat.eyes, beat.eyeMotion)
|
|
open.go(beat.open, beat.open < 0.5 ? .squint : beat.eyeMotion)
|
|
// The body leans the way he looks, a little behind his eyes.
|
|
lean.go(beat.x * 0.14, beat.gaze.k > 500 ? .look : .drift)
|
|
tilt.go(beat.x * 0.07, .drift)
|
|
// A quick glance jolts the body.
|
|
if beat.gaze.k > 500 {
|
|
sx.velocity += 0.9
|
|
sy.velocity -= 0.9
|
|
}
|
|
switch beat.body {
|
|
case .hop:
|
|
// Crouch first, then jump.
|
|
sx.velocity += 2.2
|
|
sy.velocity -= 2.6
|
|
launchAt = now + 0.1
|
|
case .squash:
|
|
sx.velocity += 1.8
|
|
sy.velocity -= 2.0
|
|
case .shiver:
|
|
shiverUntil = now + 0.28
|
|
case .none:
|
|
break
|
|
}
|
|
nextBeat = now + beat.hold
|
|
}
|
|
|
|
private func advance(_ now: Double) {
|
|
if finishing { return }
|
|
if index < Self.show.count {
|
|
play(Self.show[index], at: now)
|
|
index += 1
|
|
} else {
|
|
var pick = Int.random(in: 0..<Self.idle.count)
|
|
if pick == lastIdle { pick = (pick + 1) % Self.idle.count }
|
|
lastIdle = pick
|
|
play(Self.idle[pick], at: now)
|
|
}
|
|
}
|
|
|
|
private func step(_ now: Double) {
|
|
let dt = CGFloat(min(1.0 / 30, now - (lastTime ?? now)))
|
|
lastTime = now
|
|
if now >= nextBeat ?? 0 { advance(now) }
|
|
|
|
if let launch = launchAt, now >= launch {
|
|
launchAt = nil
|
|
oyVelocity = -2.3
|
|
sx.velocity -= 2.4 // stretched in the air
|
|
sy.velocity += 3.0
|
|
}
|
|
// Two half steps: the stiff springs stay stable at any frame rate.
|
|
for _ in 0..<2 {
|
|
let h = dt / 2
|
|
yaw.step(h); pitch.step(h)
|
|
eyes.step(h); open.step(h)
|
|
sx.step(h); sy.step(h)
|
|
lean.step(h); tilt.step(h)
|
|
if oy < 0 || oyVelocity < 0 {
|
|
oyVelocity += 15 * h
|
|
oy += oyVelocity * h
|
|
if oy >= 0 {
|
|
// Landing: squash with the speed he had.
|
|
sx.velocity += oyVelocity * 0.9
|
|
sy.velocity -= oyVelocity * 1.1
|
|
oy = 0
|
|
oyVelocity = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func draw(context: GraphicsContext, size: CGSize, settle: Double) {
|
|
let now = CACurrentMediaTime()
|
|
step(now)
|
|
let keep = CGFloat(1 - settle)
|
|
// A slow breath, on top of the moves.
|
|
let breath = CGFloat(sin(now * 2.4)) * 0.022
|
|
let shiver = now < shiverUntil ? CGFloat(sin(now * 70)) * 0.035 * CGFloat((shiverUntil - now) / 0.28) : 0
|
|
bot.yaw = yaw.value * keep
|
|
bot.pitch = pitch.value * keep
|
|
bot.es = 1 + (eyes.value - 1) * keep
|
|
bot.open = 1 + (open.value - 1) * keep
|
|
bot.ox = (lean.value + shiver) * keep
|
|
bot.oy = oy * keep
|
|
// Leaning into the motion: he tilts with how fast his gaze moves.
|
|
bot.tilt = (tilt.value - yaw.velocity * 0.012) * keep
|
|
bot.sx = 1 + (sx.value - 1 - breath * 0.6) * keep
|
|
bot.sy = 1 + (sy.value - 1 + breath) * keep
|
|
bot.draw(context: context, size: size)
|
|
}
|
|
}
|