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
Greeting v2: drop in, bounce, slide aside and wave
Clauded02f82031c62
diff --git a/windows/src/core/sound.ts b/windows/src/core/sound.tsindex b5178554..afe9342a 100644--- a/windows/src/core/sound.ts+++ b/windows/src/core/sound.ts@@ -1,5 +1,5 @@// SoundEngine — port of SoundEngine.swift.-// The 28 WAVs are the macOS app's own files (see SOUNDS_DIR in vite.config.ts);+// The 29 WAVs are the macOS app's own files (see SOUNDS_DIR in vite.config.ts);// they are served at /sounds/<name>.wav. Default volume 0.12, slider range 0–0.2,// exactly like the Mac player, and several sounds may overlap.@@ -7,7 +7,7 @@ export const SOUND_NAMES = ["peek", "open", "close", "hover", "blip", "slap", "annoyed", "dizzy", "greet","work", "finish", "error", "approval", "question", "approve", "gulp", "tick","send", "love", "pop", "proud", "wink", "yawn", "attach", "think", "search",- "rate", "sleep",+ "rate", "sleep", "greeting",] as const;export type SoundName = (typeof SOUND_NAMES)[number];@@ -21,6 +21,8 @@ class SoundEngine {private buffers = new Map<string, AudioBuffer>();private loading: Promise<void> | null = null;private idleTimer: number | null = null;+ /** Sounds still playing, by name, so one can be faded out (the greeting). */+ private playing = new Map<string, Set<{ src: AudioBufferSourceNode; gain: GainNode }>>();/** Creates the context and decodes every WAV. Safe to call more than once. */preload(): Promise<void> {@@ -97,9 +99,37 @@ class SoundEngine {if (ctx.state === "suspended") void ctx.resume();const src = ctx.createBufferSource();src.buffer = buf;- src.connect(master);+ const gain = ctx.createGain();+ src.connect(gain);+ gain.connect(master);+ const voice = { src, gain };+ let voices = this.playing.get(name);+ if (!voices) this.playing.set(name, (voices = new Set()));+ voices.add(voice);+ src.onended = () => {+ voices.delete(voice);+ gain.disconnect();+ };src.start();}++ /** Fades every playing copy of `name` to silence over `seconds`, then stops it. */+ fadeOut(name: string, seconds: number) {+ const ctx = this.ctx;+ const voices = this.playing.get(name);+ if (!ctx || !voices) return;+ const t = ctx.currentTime;+ for (const { src, gain } of voices) {+ gain.gain.cancelScheduledValues(t);+ gain.gain.setValueAtTime(gain.gain.value, t);+ gain.gain.linearRampToValueAtTime(0, t + seconds);+ try {+ src.stop(t + seconds);+ } catch {+ /* already stopped */+ }+ }+ }}export const Sound = new SoundEngine();diff --git a/windows/src/mochi/greeting.ts b/windows/src/mochi/greeting.tsindex 682f60a2..c0f74a82 100644--- a/windows/src/mochi/greeting.ts+++ b/windows/src/mochi/greeting.ts@@ -1,27 +1,24 @@-// The launch "coucou" — port of GreetingCanvasView.swift.+// The launch "coucou" (greeting v2) — port of GreetingCanvasView.swift.+// Mochi drops into the island, bounces, slides to the side and waves hello with+// a quick little hand, then comes back and settles in the compact island.// Everything is laid out in the same 640×150 reference space as on macOS.+import { closeCurve } from "../core/anim";import { Sound } from "../core/sound";import { COMPACT_W, NOTCH_H, NOTCH_W } from "../core/layout";-// ── Timing (mirrors greeting-v2.html `T`) ─────────────────────────────────────+// ── Timing (GT in the Swift file) ─────────────────────────────────────────────const T = {- grow: 0.45,- squint0: 0.6,- squint1: 0.82,- dip0: 1.25,- dip1: 1.4,- pop0: 1.36,- pop1: 1.52,- content0: 2.45,- content1: 2.58,- tuck0: 2.58,- tuck1: 2.8,+ pop0: 1.3,+ pop1: 1.45,+ content0: 2.4,+ tuck0: 2.45,+ tuck1: 2.7,badge: 2.72,down0: 2.85,- down1: 3.2,- blink2: 3.8,+ down1: 3.45,+ blink2: 3.7,tint0: 3.85,tint1: 4.15,end: 4.6,@@ -31,18 +28,30 @@ const T = {export const GREETING_END = T.end;+/** The greeting's own sound, played from the start (greeting.wav, the Mac's file). */+const GREETING_SOUND = "greeting";+// ── Geometry (640×150) ────────────────────────────────────────────────────────+export const GREETING_W = 640;+export const GREETING_H = 150;const C0 = { x: 320, y: 90 };const HB = 58;-const ASP = 1.34;+export const ASP = 1.34;const EAR_X = 40;-const EAR_Y = 16;const EAR_HB = 17;const CARD = { x: 10, y: 36, w: 620, h: 104 };const CARD_R = 20;-const SMALL_W = COMPACT_W;-const SMALL_H = NOTCH_H;++/** IslandRestingLayout for the compact island the greeting lands in. */+const COMPACT = {+ width: COMPACT_W,+ height: NOTCH_H,+ botDiameter: Math.min(20, Math.max(0, NOTCH_H - 6)),+ botCenterY: NOTCH_H / 2,+ miniGridScale: Math.min(1, Math.max(0, NOTCH_H - 4) / 28),+ miniGridCenterX: COMPACT_W - 40,+};// ── Easing ────────────────────────────────────────────────────────────────────@@ -65,7 +74,7 @@ const seg = (t: number, a: number, b: number) => clamp((t - a) / (b - a), 0, 1);type EyeType = "dot" | "happy" | "content";-interface Pose {+export interface Pose {hb: number; x: number; y: number; sx: number; sy: number; tilt: number;eye: EyeType; open: number; eyeRoll: number;lookX: number; lookY: number;@@ -76,59 +85,100 @@ interface Pose {}function greetPose(t: number): Pose {+ // Island size — only the spread of the warp streaks uses it.const gx = seg(t, 0, 0.5);const g = Math.sin((Math.PI * gx) / 2) + 0.04 * Math.sin(Math.PI * gx) * gx;- const iw = lerp(NOTCH_W, 640, g);- const ih = lerp(NOTCH_H, 150, g);-- const gg = E.back(seg(t, 0.02, T.grow));- const hb = lerp(3, HB, gg);- let x = C0.x;- let y = lerp(16, C0.y, E.out(seg(t, 0.02, T.grow)));- let sx = 1;- let sy = 1;- let tilt = 0;-- if (t >= T.dip0 && t < T.pop1) {- const k = Math.sin(Math.PI * seg(t, T.dip0, T.pop1));- y += hb * 0.22 * k;- sy = 1 - 0.06 * k;- sx = 1 + 0.04 * k;- }- if (t >= T.pop1 && t < T.tuck1) {+ const iw = lerp(NOTCH_W, GREETING_W, g);+ const ih = lerp(COMPACT.height, GREETING_H, g);++ const cx = C0.x;+ const cy = C0.y;+ // Body height: invisible before 0.20, grows 0.15 → 1 with a back ease.+ const hb = t < 0.2 ? 0 : lerp(HB * 0.15, HB, E.back(seg(t, 0.2, 0.6)));++ // Landmarks, in multiples of the body height+ const landY = cy + 0.12 * HB;+ const peakY = cy - 0.15 * HB;+ const dipY = cy + 0.36 * HB;+ const springY = cy - 0.1 * HB;+ const sinkY = cy + 0.3 * HB;+ const drift1 = cx - 0.16 * HB;+ const drift2 = cx - 0.45 * HB;+ const drift3 = cx - 0.57 * HB;+ const drift4 = cx - 0.85 * HB;++ // Lateral travel: slides to the side, waves there, comes back.+ let x: number;+ if (t < 0.85) x = cx;+ else if (t < 1.2) x = lerp(cx, drift1, E.inOut(seg(t, 0.85, 1.2)));+ else if (t < 1.3) x = lerp(drift1, drift2, E.easeIn(seg(t, 1.2, 1.3)));+ else if (t < 1.45) x = lerp(drift2, drift3, E.inOut(seg(t, 1.3, 1.45)));+ else if (t < 2.4) x = lerp(drift3, drift4, E.inOut(seg(t, 1.45, 2.4)));+ else if (t < 2.85) x = drift4;+ else x = lerp(drift4, cx, E.inOut(seg(t, 2.85, 3.45)));++ // Vertical travel: drop in, bounce, plunge and spring for the wave, sink to tuck.+ let y: number;+ if (t < 0.2) y = COMPACT.botCenterY;+ else if (t < 0.6) y = lerp(COMPACT.botCenterY, landY, E.easeIn(seg(t, 0.2, 0.6)));+ else if (t < 0.73) y = lerp(landY, peakY, E.out(seg(t, 0.6, 0.73)));+ else if (t < 0.9) y = lerp(peakY, cy, E.inOut(seg(t, 0.73, 0.9)));+ else if (t < 1.2) y = cy;+ else if (t < 1.3) y = lerp(cy, dipY, E.easeIn(seg(t, 1.2, 1.3)));+ else if (t < 1.45) y = lerp(dipY, springY, E.out(seg(t, 1.3, 1.45)));+ else if (t < 1.6) y = lerp(springY, cy, E.inOut(seg(t, 1.45, 1.6)));+ else if (t < 2.4) y = cy;+ else if (t < 2.7) y = lerp(cy, sinkY, E.inOut(seg(t, 2.4, 2.7)));+ else if (t < 2.85) y = sinkY;+ else y = lerp(sinkY, cy, E.inOut(seg(t, 2.85, 3.45)));++ // Body bob in phase with the waving hand+ if (t >= T.pop1 && t < T.tuck0) {const w = t - T.pop1;- const fade = 1 - seg(t, T.tuck0, T.tuck1);- x += Math.sin(w * 2 * Math.PI * 0.9) * hb * ASP * 0.05 * fade;- tilt = Math.sin(w * 2 * Math.PI * 0.9 + 0.6) * 0.05 * fade;- y += Math.sin(w * 2 * Math.PI * 1.8) * 0.8 * fade;- }- if (t >= T.tuck0 && t < T.down1) {- y += hb * 0.12 * Math.sin(Math.PI * seg(t, T.tuck0, T.down1));+ y += Math.sin(w * 2 * Math.PI * 5) * 0.02 * HB * clamp(w / 0.08, 0, 1);}+ // Squash and stretch+ const landSqK = t >= 0.52 && t < 0.68 ? Math.sin(Math.PI * seg(t, 0.52, 0.68)) : 0;+ const bounceK = t >= 0.62 && t < 0.84 ? Math.sin(Math.PI * seg(t, 0.62, 0.84)) : 0;+ let sx = 1 + 0.14 * landSqK - 0.1 * bounceK;+ let sy = 1 - 0.14 * landSqK + 0.18 * bounceK;+ const plungeK = t >= 1.18 && t < 1.42 ? Math.sin(Math.PI * seg(t, 1.18, 1.42)) : 0;+ const springK = t >= 1.3 && t < 1.46 ? Math.sin(Math.PI * seg(t, 1.3, 1.46)) : 0;+ sx += 0.12 * plungeK - 0.18 * springK;+ sy -= 0.12 * plungeK - 0.25 * springK;+ let sinkK = 0;+ if (t >= 2.38 && t < 2.7) sinkK = E.inOut(seg(t, 2.38, 2.7));+ else if (t >= 2.7 && t < 2.85) sinkK = 1 - E.inOut(seg(t, 2.7, 2.85));+ sx += 0.18 * sinkK;+ sy -= 0.14 * sinkK;+ const microK = t >= 3.7 && t < 3.82 ? Math.sin(Math.PI * seg(t, 3.7, 3.82)) : 0;+ sx += 0.08 * microK;+ sy -= 0.07 * microK;++ // Eyeslet eye: EyeType = "dot";- if (t >= T.squint0 && t < T.squint1) eye = "happy";- if (t >= T.content0 && t < T.content1) eye = "content";- if (t >= T.down0 && t < T.down1) eye = "content";- let eyeRoll = 0;- if (t >= T.dip0 && t < T.pop1) eyeRoll = Math.sin(Math.PI * seg(t, T.dip0, T.pop1));+ if (t >= 0.55 && t < 0.8) eye = "happy";+ if (t >= T.content0 && t < T.tuck1) eye = "content";const blink = (tb: number) => {const k = seg(t, tb, tb + 0.12);return k > 0 && k < 1 ? 1 - Math.sin(Math.PI * k) * 0.94 : 1;};- const open = Math.min(blink(1.95), blink(T.blink2));+ const open = Math.min(blink(1.95), blink(3.05), blink(T.blink2));+ // Looklet lookX = 0;let lookY = 0;- if (t >= T.squint1 && t < T.dip0) lookY = -0.2;if (t >= T.pop1 && t < T.content0) { lookX = 0.55; lookY = -0.45; }- if (t >= T.content0 && t < T.down1) { lookX = -0.3; lookY = 0.6; }- if (t >= T.down1) {+ else if (t >= T.content0 && t < T.down0) { lookX = -0.3; lookY = 0.6; }+ else if (t >= T.down0 && t < T.down1) { lookX = 0.3; lookY = 0.6; }+ else if (t >= T.down1) {const k = E.inOut(seg(t, T.down1, T.down1 + 0.35));- lookX = lerp(-0.3, 0, k);+ lookX = lerp(0.3, 0, k);lookY = lerp(0.6, 0, k);}+ // Handsconst handL = t < T.tuck0? E.back(seg(t, T.pop0, T.pop0 + 0.14)): 1 - E.easeIn(seg(t, T.tuck0, T.tuck1 - 0.03));@@ -138,8 +188,8 @@ function greetPose(t: number): Pose {const wave = t >= T.pop1 && t < T.tuck0 ? t - T.pop1 : -1;return {- hb, x, y, sx, sy, tilt,- eye, open, eyeRoll,+ hb, x, y, sx, sy, tilt: 0,+ eye, open, eyeRoll: 0,lookX, lookY,handL, handR, wave,badge: E.back(seg(t, T.badge, T.badge + 0.28)),@@ -156,9 +206,9 @@ function greetPose(t: number): Pose {function smallPose(): Pose {return {- hb: EAR_HB,- x: 320 - SMALL_W / 2 + EAR_X,- y: EAR_Y,+ hb: (EAR_HB * COMPACT.botDiameter) / 20,+ x: GREETING_W / 2 - COMPACT.width / 2 + EAR_X,+ y: COMPACT.botCenterY,sx: 1, sy: 1, tilt: 0,eye: "dot", open: 1, eyeRoll: 0,lookX: 0, lookY: 0,@@ -166,15 +216,20 @@ function smallPose(): Pose {badge: 1, tint: 0.6, halo: 0.6, haloBlue: 1,minis: 1, fx: 1,header: 0, card: 0,- iw: SMALL_W, ih: SMALL_H,+ iw: COMPACT.width, ih: COMPACT.height,};}-function pose(t: number, tc: number): Pose {+/** Mochi's pose `t` seconds in; `tc` is when the collapse began (∞ if not yet). */+export function greetingPose(t: number, tc = Number.POSITIVE_INFINITY): Pose {if (t < tc) return greetPose(Math.min(t, T.end + 10));const a = greetPose(tc);const b = smallPose();- const e = E.inOut(seg(t, tc, tc + T.COLLAPSE));+ // Same curve and duration (340 ms) as the island shrinking around him: with+ // the Mac's inOut ease the island got ahead of Mochi and cut his body off+ // when the greeting was left early.+ const k = seg(t, tc, tc + T.COLLAPSE);+ const e = k >= 1 ? 1 : closeCurve(k);const p: Pose = { ...a };p.iw = lerp(a.iw, b.iw, e);p.ih = lerp(a.ih, b.ih, e);@@ -203,11 +258,74 @@ function pose(t: number, tc: number): Pose {return p;}-// ── Particles (seeded LCG, seed = 7, identical sequence to the Swift version) ──+/** Where the waving (left, round) hand is, in body space before the body's scale. */+function handLPos(hw: number, hh: number, p: Pose) {+ const k = p.handL;+ const hb = hh * 2;+ const r = hb * 0.15 * k;+ const x = lerp(-hw * 0.35, -hw - hb * 0.22, k);+ let y = lerp(hh * 0.85, hh * 0.62, k);+ if (p.wave >= 0) {+ // ramp in 0.08 s after pop1, ramp out over the tuck+ const w = p.wave;+ const rampIn = clamp(w / 0.08, 0, 1);+ const rampOut = 1 - clamp((w - (T.tuck0 - T.pop1)) / (T.tuck1 - T.tuck0), 0, 1);+ y += Math.sin(w * 2 * Math.PI * 5) * hb * 0.14 * rampIn * rampOut;+ }+ return { x, y, r };+}++/** The resting (right, capsule) hand. */+function handRPos(hw: number, hh: number, p: Pose) {+ const k = p.handR;+ const hb = hh * 2;+ return {+ x: lerp(hw * 0.35, hw + hb * 0.2, k),+ y: lerp(hh * 0.85, hh * 0.2, k),+ L: hb * 0.4 * k,+ T: hb * 0.22 * k,+ // breathing rotation ±0.04 rad at 2.5 Hz while the other hand waves+ ang: p.wave >= 0 ? -0.61 + Math.sin(p.wave * 2 * Math.PI * 2.5) * 0.04 : -0.61,+ };+}++/**+ * Bounding box of Mochi's body and hands in the 640×150 space — what must stay+ * inside the island so nothing of him is cut off.+ */+export function mochiBounds(p: Pose): { left: number; right: number; top: number; bottom: number } | null {+ const hh = p.hb / 2;+ const hw = hh * ASP;+ if (hh <= 0.4) return null;+ let left = -hw;+ let right = hw;+ let top = -hh;+ let bottom = hh;+ if (p.handL > 0.01) {+ const l = handLPos(hw, hh, p);+ left = Math.min(left, l.x - l.r);+ top = Math.min(top, l.y - l.r);+ bottom = Math.max(bottom, l.y + l.r);+ }+ if (p.handR > 0.01) {+ const r = handRPos(hw, hh, p);+ const ext = r.L / 2 + r.T / 2;+ right = Math.max(right, r.x + ext);+ top = Math.min(top, r.y - ext);+ bottom = Math.max(bottom, r.y + ext);+ }+ return {+ left: p.x + left * p.sx,+ right: p.x + right * p.sx,+ top: p.y + top * p.sy,+ bottom: p.y + bottom * p.sy,+ };+}++// ── Particles (seeded LCG, seed = 7, same sequence as the Swift version) ──────+interface WarpStreak { xNorm: number; speed: number; len: number; thick: number; alpha: number; t0: number }interface RingDot { a: number; j: number; s: number; al: number }-interface Ring { t0: number; dots: RingDot[] }-interface Streak { a: number; sp: number; len: number; t0: number; col: string }const PARTICLES = (() => {let seed = 7;@@ -215,24 +333,23 @@ const PARTICLES = (() => {seed = (Math.imul(seed, 1103515245) + 12345) & 0x7fffffff;return seed / 0x7fffffff;};- const rings: Ring[] = [0.1, 0.2, 0.3, 0.45, 0.6].map((t0) => ({- t0,- dots: Array.from({ length: 170 }, () => ({- a: rnd() * Math.PI * 2,- j: (rnd() - 0.5) * 0.22,- s: 0.7 + rnd() * 0.9,- al: 0.45 + rnd() * 0.55,- })),+ // ~70 white warp streaks for the fall-in (0 → 0.55 s)+ const warps: WarpStreak[] = Array.from({ length: 70 }, () => ({+ xNorm: rnd(),+ speed: 400 + rnd() * 300,+ len: 6 + rnd() * 16,+ thick: 1 + rnd() * 0.5,+ alpha: 0.25 + rnd() * 0.55,+ t0: rnd() * 0.35,}));- const cols = ["#3B9EFF", "#F29B38", "#FF5A4E", "#2EC4A0", "#A78BFA"];- const streaks: Streak[] = Array.from({ length: 16 }, (_, i) => ({- a: (i / 16) * Math.PI * 2 + (rnd() - 0.5) * 0.3,- sp: 230 + rnd() * 260,- len: 6 + rnd() * 9,- t0: 0.08 + rnd() * 0.14,- col: cols[i % 5],+ // one white burst ring at 0.45 s+ const ring: RingDot[] = Array.from({ length: 90 }, () => ({+ a: rnd() * Math.PI * 2,+ j: (rnd() - 0.5) * 0.22,+ s: 0.7 + rnd() * 0.9,+ al: 0.45 + rnd() * 0.55,}));- return { rings, streaks };+ return { warps, ring };})();// ── Drawing ───────────────────────────────────────────────────────────────────@@ -265,6 +382,7 @@ function mochiPath(hw: number, hh: number): Path2D {return p;}+/** White body gradient. A canvas gradient pads past its ends, so the corners are never left unpainted. */function whiteFill(x: CanvasRenderingContext2D, path: Path2D,x0: number, y0: number, x1: number, y1: number,@@ -272,22 +390,15 @@ function whiteFill(const g = x.createLinearGradient(x0, y0, x1, y1);g.addColorStop(0, "rgb(251,251,252)");g.addColorStop(1, "rgb(231,233,236)");- x.save();x.fillStyle = g;x.fill(path);- x.restore();}function drawHandL(x: CanvasRenderingContext2D, hw: number, hh: number, p: Pose) {- const k = p.handL;- if (k <= 0.01) return;- const hb = hh * 2;- const r = hb * 0.15 * k;- const rx = lerp(-hw * 0.35, -hw - hb * 0.22, k);- let ry = lerp(hh * 0.85, hh * 0.62, k);- if (p.wave >= 0) ry += Math.sin(p.wave * 6) * hb * 0.02;+ if (p.handL <= 0.01) return;+ const { x: hx, y: hy, r } = handLPos(hw, hh, p);x.save();- x.translate(rx, ry);+ x.translate(hx, hy);const circ = new Path2D();circ.ellipse(0, 0, r, r, 0, 0, Math.PI * 2);whiteFill(x, circ, r, -r, -r, r);@@ -298,27 +409,15 @@ function drawHandL(x: CanvasRenderingContext2D, hw: number, hh: number, p: Pose)}function drawHandR(x: CanvasRenderingContext2D, hw: number, hh: number, p: Pose) {- const k = p.handR;- if (k <= 0.01) return;- const hb = hh * 2;- const L = hb * 0.4 * k;- const T2 = hb * 0.22 * k;- let rx = lerp(hw * 0.35, hw + hb * 0.2, k);- let ry = lerp(hh * 0.85, hh * 0.2, k);- let ang = -0.61;- if (p.wave >= 0) {- const w = p.wave * 2 * Math.PI * 2.5;- ang += Math.sin(w) * 0.21;- ry += Math.sin(w + 0.8) * hb * 0.04;- rx += Math.cos(w) * hb * 0.015;- }+ if (p.handR <= 0.01) return;+ const h = handRPos(hw, hh, p);x.save();- x.translate(rx, ry);- x.rotate(ang);- const g = x.createLinearGradient(L / 2, -T2 / 2, -L / 2, T2 / 2);+ x.translate(h.x, h.y);+ x.rotate(h.ang);+ rr(x, -h.L / 2, -h.T / 2, h.L, h.T, h.T / 2);+ const g = x.createLinearGradient(h.L / 2, -h.T / 2, -h.L / 2, h.T / 2);g.addColorStop(0, "rgb(251,251,252)");g.addColorStop(1, "rgb(231,233,236)");- rr(x, -L / 2, -T2 / 2, L, T2, T2 / 2);x.fillStyle = g;x.fill();x.strokeStyle = "rgba(0,0,0,0.08)";@@ -364,11 +463,8 @@ function drawMochi(x: CanvasRenderingContext2D, p: Pose) {const g = x.createLinearGradient(0, hh, 0, -hh * 0.1);g.addColorStop(0, `rgba(127,180,234,${p.tint})`);g.addColorStop(1, "rgba(127,180,234,0)");- x.save();- x.clip(body);x.fillStyle = g;x.fill(body);- x.restore();}// Eyes@@ -433,45 +529,53 @@ function drawMochi(x: CanvasRenderingContext2D, p: Pose) {function drawParticles(x: CanvasRenderingContext2D, t: number, p: Pose) {if (!(p.card > 0 || p.fx < 1)) return;- for (const ring of PARTICLES.rings) {- const k = seg(t, ring.t0, ring.t0 + 1.35);- if (k <= 0 || k >= 1) continue;++ // Warp streaks: white vertical lines while Mochi falls in+ if (t < 0.55) {+ const fadeOut = 1 - seg(t, 0.4, 0.55);+ x.lineCap = "butt";+ for (const s of PARTICLES.warps) {+ if (t < s.t0) continue;+ const yBot = (t - s.t0) * s.speed;+ const yTop = yBot - s.len;+ if (yBot <= 0) continue;+ const sx = GREETING_W / 2 - p.iw / 2 + s.xNorm * p.iw;+ x.strokeStyle = `rgba(255,255,255,${s.alpha * p.fx * fadeOut})`;+ x.lineWidth = s.thick;+ x.beginPath();+ x.moveTo(sx, Math.max(0, yTop));+ x.lineTo(sx, Math.min(GREETING_H, yBot));+ x.stroke();+ }+ }++ // Ring: one white burst at 0.45 s+ const k = seg(t, 0.45, 0.45 + 1.35);+ if (k > 0 && k < 1) {const rx = lerp(14, 380, E.out(k));const ry = rx * 0.34;const fade = (1 - k) * (k < 0.08 ? k / 0.08 : 1) * p.fx * p.card;- for (const dot of ring.dots) {+ for (const dot of PARTICLES.ring) {const r = 1 + dot.j;x.fillStyle = `rgba(255,255,255,${dot.al * fade})`;x.fillRect(C0.x + Math.cos(dot.a) * rx * r, C0.y + Math.sin(dot.a) * ry * r, dot.s, dot.s);}}- for (const s of PARTICLES.streaks) {- const k = seg(t, s.t0, s.t0 + 0.6);- if (k <= 0 || k >= 1) continue;- const dist = s.sp * E.out(k) * 0.9 + 10;- const alpha = (1 - k) * p.fx;- x.strokeStyle = s.col + Math.round(alpha * 255).toString(16).padStart(2, "0");- x.lineWidth = 1.6;- x.lineCap = "round";- x.beginPath();- x.moveTo(C0.x + Math.cos(s.a) * (dist - s.len), C0.y + Math.sin(s.a) * (dist - s.len) * 0.42);- x.lineTo(C0.x + Math.cos(s.a) * dist, C0.y + Math.sin(s.a) * dist * 0.42);- x.stroke();- }}const MINI_COLORS = ["#E86A6A", "#3E86E0", "#EFAE5A", "#8C73F2"];function drawMinis(x: CanvasRenderingContext2D, alpha: number) {if (alpha <= 0.01) return;- const cx = 320 + SMALL_W / 2 - 27;- const cy = 16;- const sp = 6;+ const cx = GREETING_W / 2 - COMPACT.width / 2 + COMPACT.miniGridCenterX;+ const cy = COMPACT.botCenterY;+ const sp = 6 * COMPACT.miniGridScale;const offsets: [number, number][] = [[-sp, -sp], [sp, -sp], [-sp, sp], [sp, sp]];offsets.forEach(([dx, dy], i) => {x.save();x.translate(cx + dx, cy + dy);- x.scale(alpha, alpha);+ const scale = alpha * COMPACT.miniGridScale;+ x.scale(scale, scale);x.fillStyle = MINI_COLORS[i];x.fill(mochiPath(5.3, 4));x.restore();@@ -497,11 +601,10 @@ export class Greeting {this.tc = Number.POSITIVE_INFINITY;this.fired = false;this.cancelTimers();- this.timers.push(- window.setTimeout(() => Sound.play("greet"), T.pop0 * 1000),- window.setTimeout(() => Sound.play("blip"), T.badge * 1000),- window.setTimeout(() => this.fire(), (T.end + 0.05) * 1000),- );+ // The score plays from the start; it outlives greetComplete a little on+ // purpose and fades when the greeting view goes away (see leave()).+ Sound.play(GREETING_SOUND);+ this.timers.push(window.setTimeout(() => this.fire(), (T.end + 0.05) * 1000));}/** Mouse entered the island during the greeting — hold it open. */@@ -514,6 +617,13 @@ export class Greeting {const t = (performance.now() - this.startMs) / 1000;if (!Number.isFinite(this.tc) || this.tc > t) this.tc = t;this.cancelTimers();+ Sound.fadeOut(GREETING_SOUND, 0.25);+ }++ /** The greeting view is gone: let what is left of its sound fade away. */+ leave() {+ this.cancelTimers();+ Sound.fadeOut(GREETING_SOUND, 0.2);}get elapsed(): number {@@ -540,8 +650,8 @@ export class Greeting {const t = this.elapsed;if (!this.fired && t >= T.end && this.tc >= T.autoLeave) this.fire();- const p = pose(t, this.tc);- x.clearRect(0, 0, 640, 150);+ const p = greetingPose(t, this.tc);+ x.clearRect(0, 0, GREETING_W, GREETING_H);if (p.card > 0) {x.save();diff --git a/windows/tests/greeting.test.mjs b/windows/tests/greeting.test.mjsnew file mode 100644index 00000000..f26bb486--- /dev/null+++ b/windows/tests/greeting.test.mjs@@ -0,0 +1,72 @@+// The launch greeting (src/mochi/greeting.ts): Mochi must never be cut off by+// the island while it grows, while he bounces and waves, or while it shrinks+// back to the compact island.++import { test } from "node:test";+import assert from "node:assert/strict";+import { GREETING_END, GREETING_W, greetingPose, mochiBounds } from "../src/mochi/greeting.ts";+import { Tracked } from "../src/core/anim.ts";+import { COMPACT_W, NOTCH_H, NOTCH_W, VIEW_LAYOUTS } from "../src/core/layout.ts";++const FRAME = 1 / 60;+const SLACK = 0.5; // anti-aliasing++/** Mochi's box against the island's, which is centred in the 640 px greeting canvas. */+function assertInside(t, tc, w, h) {+ const b = mochiBounds(greetingPose(t, tc));+ if (!b) return;+ const left = GREETING_W / 2 - w / 2;+ const right = GREETING_W / 2 + w / 2;+ const at = `t=${t.toFixed(3)} tc=${tc}`;+ // No check on the top: he drops in from the edge of the screen, like out of+ // the notch on a Mac, so his head is meant to come out of it.+ assert.ok(b.bottom <= h + SLACK, `${at}: bottom ${b.bottom.toFixed(1)} below the island (${h.toFixed(1)})`);+ assert.ok(b.left >= left - SLACK, `${at}: left ${b.left.toFixed(1)} outside ${left.toFixed(1)}`);+ assert.ok(b.right <= right + SLACK, `${at}: right ${b.right.toFixed(1)} outside ${right.toFixed(1)}`);+}++/** Runs the island geometry the way Island does: spring open, then the 340 ms close curve. */+function run(tc) {+ const width = new Tracked(NOTCH_W);+ const height = new Tracked(0);+ width.springTo(GREETING_W);+ height.springTo(VIEW_LAYOUTS.greeting.height);+ let collapsed = false;+ const stop = Number.isFinite(tc) ? tc + 0.6 : GREETING_END + 0.5;+ for (let t = 0; t <= stop; t += FRAME) {+ const now = t * 1000;+ if (!collapsed && t >= tc) {+ collapsed = true;+ width.curveTowards(COMPACT_W, 340, now);+ height.curveTowards(NOTCH_H, 340, now);+ }+ width.step(FRAME, now);+ height.step(FRAME, now);+ assertInside(t, tc, width.value, height.value);+ }+}++test("Mochi stays inside the island for the whole greeting", () => {+ run(Number.POSITIVE_INFINITY);+});++test("Mochi stays inside the island when the greeting is cut short", () => {+ for (let tc = 0.3; tc < GREETING_END + 0.4; tc += 0.1) run(tc);+});++test("he slides to the side to wave, then comes back to the middle", () => {+ const atWave = greetingPose(2.0);+ assert.ok(atWave.x < 290, `waving at x=${atWave.x}`);+ assert.ok(atWave.handL > 0.9 && atWave.handR > 0.9, "both hands out");+ assert.ok(atWave.wave >= 0, "waving");+ const back = greetingPose(3.6);+ assert.equal(back.x, 320);+ assert.equal(back.handL, 0);+});++test("he lands where the compact island's Mochi sits", () => {+ const end = greetingPose(10, 5);+ assert.equal(end.y, NOTCH_H / 2);+ assert.equal(end.x, GREETING_W / 2 - COMPACT_W / 2 + 40);+ assert.equal(end.minis, 1);+});diff --git a/windows/vite.config.ts b/windows/vite.config.tsindex 1ff3b656..3cf942c5 100644--- a/windows/vite.config.ts+++ b/windows/vite.config.ts@@ -4,7 +4,7 @@ import { resolve, join, extname } from "node:path";// ───────────────────────────────────────────────────────────────────────────────// THE one and only place the shared sound folder is declared.-// The 28 WAVs live in the macOS app and are NOT duplicated in the repo; when they+// The 29 WAVs live in the macOS app and are NOT duplicated in the repo; when they// move to `shared/sounds/`, change this single line.export const SOUNDS_DIR = resolve(__dirname, "../NotchBuddy/Resources/sounds");// ───────────────────────────────────────────────────────────────────────────────