Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(shell): redesign mid-autumn egg animation flow
vastsaa5c73ffcf95f
diff --git a/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.css b/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.cssindex d2488c822..9762d8db5 100644--- a/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.css+++ b/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.css@@ -15,7 +15,7 @@padding: 0;overflow: hidden;isolation: isolate;- background: var(--ds-bg-under);+ background: #02040f;font-family:Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,"SF Pro Display", "PingFang SC", sans-serif;@@ -120,15 +120,18 @@/* Always-visible close affordance: high contrast, >= 32x32 hit area, focus ring. */.mid-autumn-egg-close {position: absolute;- top: 16px;- right: 16px;+ bottom: clamp(60px, 12vh, 120px);+ left: 50%;+ transform: translateX(-50%);z-index: 2;display: inline-flex;align-items: center;gap: 6px;min-width: 32px;min-height: 32px;- padding: 6px 12px;+ padding: 8px 20px;+ opacity: 0;+ animation: mid-autumn-egg-close-in 600ms ease-out 1.8s forwards;border: 1px solid rgba(255, 255, 255, 0.3);border-radius: var(--radius-full);background: rgba(12, 16, 28, 0.72);@@ -154,3 +157,14 @@outline: 2px solid var(--ds-focus);outline-offset: 2px;}++@keyframes mid-autumn-egg-close-in {+ from {+ opacity: 0;+ transform: translateX(-50%) translateY(8px);+ }+ to {+ opacity: 1;+ transform: translateX(-50%) translateY(0);+ }+}diff --git a/apps/desktop/src/features/mid-autumn-egg/scene.ts b/apps/desktop/src/features/mid-autumn-egg/scene.tsindex 6a779b46f..3321441a1 100644--- a/apps/desktop/src/features/mid-autumn-egg/scene.ts+++ b/apps/desktop/src/features/mid-autumn-egg/scene.ts@@ -133,6 +133,7 @@ type Cake = {controlX: number;controlY: number;delay: number;+ bornAt: number;};type Star = {@@ -495,38 +496,13 @@ export function createMidAutumnEggScene(* Mooncake rain* ------------------------------------------------------------------ */- function spawnCake(): void {- const pad = cakeRadius * CAKE_SPAWN_PAD_RATIO;- cakes.push({- x: pad + Math.random() * Math.max(1, width - pad * 2),- y: -cakeRadius * 2 - Math.random() * CAKE_SPAWN_ABOVE_RANGE,- vx: rand(-CAKE_SPAWN_VX, CAKE_SPAWN_VX),- vy: rand(CAKE_SPAWN_VY_MIN, CAKE_SPAWN_VY_MIN + CAKE_SPAWN_VY_RANGE),- rot: Math.random() * Math.PI * 2,- rot0: 0,- spin: rand(-CAKE_SPIN_RANGE, CAKE_SPIN_RANGE),- state: "falling",- targetX: 0,- targetY: 0,- originX: 0,- originY: 0,- controlX: 0,- controlY: 0,- delay: 0,- });- }-- /**- * Pair every mooncake with a sampled pixel of the target text.- *- * The sampler may return up to 15% more points than there are mooncakes; the- * points are sorted by x and thinned evenly, so the whole line stays covered- * instead of the surplus piling up on the right-hand glyph.- */- function buildTextTargets(): void {- const count = cakes.length;- if (!count) return;+ /** Pre-computed text target points, filled once by precomputeTextTargets(). */+ let textPoints: TextSamplePoint[] = [];+ let textRectX = 0;+ let textRectY = 0;+ function precomputeTextTargets(): void {+ const count = config.cakes;let rectWidth = Math.min(width * TEXT_RECT_WIDTH_RATIO, TEXT_RECT_MAX_WIDTH);let rectHeight = rectWidth / TEXT_RECT_ASPECT;const maxRectHeight = height * TEXT_RECT_MAX_HEIGHT_RATIO;@@ -534,46 +510,58 @@ export function createMidAutumnEggScene(rectHeight = maxRectHeight;rectWidth = rectHeight * TEXT_RECT_ASPECT;}- const rectX = (width - rectWidth) / 2;- const rectY = height * TEXT_RECT_CENTER_Y_RATIO - rectHeight * 0.5;+ textRectX = (width - rectWidth) / 2;+ textRectY = height * TEXT_RECT_CENTER_Y_RATIO - rectHeight * 0.5;+ textRect = { x: textRectX, y: textRectY, w: rectWidth, h: rectHeight };const raw = sampleTextPoints(config.text, count, rectWidth, rectHeight);if (!raw.length) return;- textRect = { x: rectX, y: rectY, w: rectWidth, h: rectHeight };-raw.sort((left, right) => left.x - right.x);- const points: TextSamplePoint[] = [];+if (raw.length > count) {const last = raw.length - 1;- for (let index = 0; index < count; index++) {- points.push(raw[Math.round((index * last) / Math.max(1, count - 1))]);+ for (let i = 0; i < count; i++) {+ textPoints.push(raw[Math.round((i * last) / Math.max(1, count - 1))]);}} else {- for (const point of raw) points.push(point);+ textPoints = raw.slice();}+ }- // Left cakes fly to the left points, which produces the sweeping stagger.- const ordered = cakes.slice().sort((left, right) => left.x - right.x);- const total = Math.max(1, points.length);-- for (let index = 0; index < ordered.length; index++) {- const cake = ordered[index];- const point = points[index % total];- const stacked = index >= total;- const jitter = cakeRadius * TEXT_STACK_JITTER_RATIO;- cake.targetX = rectX + point.x + (stacked ? rand(-jitter, jitter) : 0);- cake.targetY = rectY + point.y + (stacked ? rand(-jitter, jitter) : 0);- cake.originX = cake.x;- cake.originY = cake.y;- cake.controlX = (cake.originX + cake.targetX) * 0.5 + rand(-TEXT_CONTROL_SPREAD, TEXT_CONTROL_SPREAD);- cake.controlY =- Math.min(cake.originY, cake.targetY) - TEXT_ARC_LIFT - Math.random() * TEXT_ARC_LIFT_RANDOM;- cake.delay =- (cake.originX / Math.max(1, width)) * phases.flyStagger + Math.random() * TEXT_DELAY_RANDOM;- cake.rot0 = cake.rot;- }+ function spawnCake(): void {+ const pad = cakeRadius * CAKE_SPAWN_PAD_RATIO;+ const spawnX = pad + Math.random() * Math.max(1, width - pad * 2);+ const spawnY = -cakeRadius * 2 - Math.random() * CAKE_SPAWN_ABOVE_RANGE;+ const idx = cakes.length;+ const total = Math.max(1, textPoints.length);+ const point = textPoints[idx % total];+ const stacked = idx >= total;+ const jitter = cakeRadius * TEXT_STACK_JITTER_RATIO;+ const tx = textRectX + (point ? point.x : 0) + (stacked ? rand(-jitter, jitter) : 0);+ const ty = textRectY + (point ? point.y : 0) + (stacked ? rand(-jitter, jitter) : 0);++ cakes.push({+ x: spawnX,+ y: spawnY,+ vx: 0,+ vy: 0,+ rot: Math.random() * Math.PI * 2,+ rot0: Math.random() * Math.PI * 2,+ spin: 0,+ state: "falling",+ targetX: tx,+ targetY: ty,+ originX: spawnX,+ originY: spawnY,+ controlX: (spawnX + tx) * 0.5 + rand(-TEXT_CONTROL_SPREAD, TEXT_CONTROL_SPREAD),+ controlY: Math.min(spawnY, ty) - TEXT_ARC_LIFT - Math.random() * TEXT_ARC_LIFT_RANDOM,+ delay: 0,+ bornAt: elapsed,+ });}++/* ------------------------------------------------------------------ ** Poem layer* ------------------------------------------------------------------ */@@ -650,7 +638,13 @@ export function createMidAutumnEggScene(burst(moonPath.end.x, moonPath.end.y, MOON_SPARK_COUNT);}- /* Phase 2: the mooncake rain */+ /* Phase 2+3: spawn mooncakes and fly them directly to text targets */+ if (elapsed >= phases.rainStart && !textTargetsBuilt) {+ // Pre-compute text targets so each cake gets one on spawn.+ precomputeTextTargets();+ textTargetsBuilt = true;+ }+if (elapsed >= phases.rainStart && elapsed < phases.rainStart + phases.spawnDuration) {spawnAccumulator += dt * phases.rainRate;let guard = 0;@@ -660,45 +654,30 @@ export function createMidAutumnEggScene(}}- /* Phase 3: build text targets right after spawning ends and fly directly */- const flyRef = phases.rainStart + phases.spawnDuration;- if (elapsed >= flyRef && !textTargetsBuilt) {- for (const cake of cakes) {- if (cake.state === "falling") {- cake.state = "landed";- cake.vy = 0;- cake.rot0 = cake.rot;- }- }- buildTextTargets();- textTargetsBuilt = true;- }-- if (textTargetsBuilt) {- for (const cake of cakes) {- if (cake.state === "placed") continue;+ // Fly every spawned cake toward its target immediately.+ for (const cake of cakes) {+ if (cake.state === "placed") continue;- const local = elapsed - flyRef - cake.delay;- if (local <= 0) continue;+ const local = elapsed - cake.bornAt;+ if (local <= 0) continue;- const progress = Math.min(1, local / phases.flyDuration);- const eased = easeInOutCubic(progress);- const inverse = 1 - eased;+ const progress = Math.min(1, local / phases.flyDuration);+ const eased = easeInOutCubic(progress);+ const inverse = 1 - eased;- cake.x = inverse * inverse * cake.originX + 2 * inverse * eased * cake.controlX + eased * eased * cake.targetX;- cake.y = inverse * inverse * cake.originY + 2 * inverse * eased * cake.controlY + eased * eased * cake.targetY;- cake.rot = cake.rot0 * (1 - eased);+ cake.x = inverse * inverse * cake.originX + 2 * inverse * eased * cake.controlX + eased * eased * cake.targetX;+ cake.y = inverse * inverse * cake.originY + 2 * inverse * eased * cake.controlY + eased * eased * cake.targetY;+ cake.rot = cake.rot0 * (1 - eased);- if (progress >= 1) {- cake.state = "placed";- cake.x = cake.targetX;- cake.y = cake.targetY;- cake.rot = 0;- }+ if (progress >= 1) {+ cake.state = "placed";+ cake.x = cake.targetX;+ cake.y = cake.targetY;+ cake.rot = 0;}}- if (!textSparkDone && elapsed >= phases.done) {+ if (!textSparkDone && elapsed >= phases.rainStart + phases.spawnDuration + phases.flyDuration + 0.1) {textSparkDone = true;if (textRect) burst(textRect.x + textRect.w / 2, textRect.y + textRect.h / 2, TEXT_SPARK_COUNT);showCaption();diff --git a/apps/desktop/src/features/mid-autumn-egg/timeline.ts b/apps/desktop/src/features/mid-autumn-egg/timeline.tsindex 3430d728e..fb0a43636 100644--- a/apps/desktop/src/features/mid-autumn-egg/timeline.ts+++ b/apps/desktop/src/features/mid-autumn-egg/timeline.ts@@ -34,7 +34,7 @@ export type MidAutumnEggConfig = {/** The configuration the standalone animation was verified with. */export const DEFAULT_MID_AUTUMN_EGG_CONFIG: MidAutumnEggConfig = {- duration: 5.0,+ duration: 2.5,moonSpeed: 1.5,skyAlpha: 0.9,cakes: 520,@@ -98,11 +98,11 @@ export function createMidAutumnEggPhases(): MidAutumnEggPhases {const rise = config.duration * 0.21 * config.moonSpeed;const hold = 0.25;- const rainStart = rise + hold;- const spawnDuration = 1.2;+ const rainStart = 0;+ const spawnDuration = 0.8;const flyStart = rainStart + 2.2;const flyStagger = 0.5;- const flyDuration = 0.8;+ const flyDuration = 0.6;return {rise,hold,@@ -115,7 +115,7 @@ export function createMidAutumnEggPhases(done: flyStart + flyStagger + flyDuration,poemStart: rainStart + 3.15,poemFade: 0.75,- skyIn: 0.9,+ skyIn: 0.3,rainRate: config.cakes / spawnDuration,};}diff --git a/apps/desktop/test/mid-autumn-egg.test.mjs b/apps/desktop/test/mid-autumn-egg.test.mjsindex f159f1566..f1d8d492a 100644--- a/apps/desktop/test/mid-autumn-egg.test.mjs+++ b/apps/desktop/test/mid-autumn-egg.test.mjs@@ -47,8 +47,8 @@ test("a slow moon does not change the mooncake rain rhythm", () => {// The moon rise is the only phase that scales.assert.equal(slowed.rise, baseline.rise * DEFAULT_MID_AUTUMN_EGG_CONFIG.moonSpeed);- assert.equal(slowed.rise.toFixed(3), "1.575");- assert.equal(baseline.rise.toFixed(3), "1.050");+ assert.equal(slowed.rise.toFixed(3), "0.788");+ assert.equal(baseline.rise.toFixed(3), "0.525");assert.equal(slowed.spawnDuration, baseline.spawnDuration);assert.equal(slowed.flyStagger, baseline.flyStagger);@@ -59,26 +59,26 @@ test("a slow moon does not change the mooncake rain rhythm", () => {);assert.equal(slowed.flyDuration, baseline.flyDuration);assert.equal(slowed.poemFade, baseline.poemFade);+ // rainStart = 0 (fixed), so changing moonSpeed does not shift the rain start.assert.equal(- Number((slowed.rainStart - baseline.rainStart).toFixed(3)),- Number((slowed.rise - baseline.rise).toFixed(3)),+ slowed.rainStart - baseline.rainStart,+ 0,);});test("the phases keep the hand-tuned absolute timeline", () => {const phases = createMidAutumnEggPhases(DEFAULT_MID_AUTUMN_EGG_CONFIG);- assert.equal(phases.hold, 0.25);- assert.equal(phases.rainStart.toFixed(3), "1.825");- assert.equal(phases.spawnDuration.toFixed(3), "1.200");- assert.equal(phases.rainEnd.toFixed(3), "3.575");- assert.equal(phases.flyStart.toFixed(3), "4.025");- assert.equal(phases.done.toFixed(3), "5.325");- assert.equal(phases.poemStart.toFixed(3), "4.975");- assert.equal(phases.skyIn, 0.9);+ assert.equal(phases.rainStart.toFixed(3), "0.000");+ assert.equal(phases.spawnDuration.toFixed(3), "0.800");+ assert.equal(phases.rainEnd.toFixed(3), "1.750");+ assert.equal(phases.flyStart.toFixed(3), "2.200");+ assert.equal(phases.done.toFixed(3), "3.300");+ assert.equal(phases.poemStart.toFixed(3), "3.150");+ assert.equal(phases.skyIn, 0.3);// All 520 mooncakes are spawned inside the spawn window.- assert.equal(phases.rainRate.toFixed(3), (DEFAULT_MID_AUTUMN_EGG_CONFIG.cakes / 1.2).toFixed(3));+ assert.equal(phases.rainRate.toFixed(3), (DEFAULT_MID_AUTUMN_EGG_CONFIG.cakes / 0.8).toFixed(3));// The text is assembled after the rain has landed, and the poem follows it.assert.ok(phases.spawnDuration < phases.rainEnd - phases.rainStart);