Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: optional motion-blur subframes in HTML composition renderer (#8959)
[._.]/ Adam Eivy46a5d8b0afb7
diff --git a/server/lib/validation.js b/server/lib/validation.jsindex d0a24878ca..7089f092cd 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -2505,6 +2505,9 @@ export const htmlCompositionContractSchema = z.object({fps: z.number().int().min(12).max(60),width: z.number().int(),height: z.number().int(),+ // Subframes averaged per output frame to fake motion blur on fast moves;+ // 1 (default) keeps the existing single-sample-per-frame behavior.+ motionBlur: z.number().int().min(1).max(4).default(1),}).superRefine((value, ctx) => {if (!['1920x1080', '1080x1920', '1080x1080', '1280x720'].includes(`${value.width}x${value.height}`)) {ctx.addIssue({ code: 'custom', path: ['width'], message: 'width/height must be 1920x1080, 1080x1920, 1080x1080 or 1280x720' });diff --git a/server/services/htmlComposition/encode.js b/server/services/htmlComposition/encode.jsindex 7bc0d975bb..974ee6ca45 100644--- a/server/services/htmlComposition/encode.js+++ b/server/services/htmlComposition/encode.js@@ -11,12 +11,19 @@ export async function encodeComposition(page, contract, outputPath, { musicPath,if (!ffmpeg) throw new Error('ffmpeg not found on PATH');const tag = await bt709TagFilter();signal?.throwIfAborted();- const { fps, durationSec, width, height } = contract;+ const { fps, durationSec, width, height, motionBlur } = contract;const numFrames = Math.round(durationSec * fps);+ // motionBlur (1-4) captures that many subframes per output frame and lets+ // ffmpeg's tmix filter blend them; 1 (default) captures/encodes exactly as+ // before, byte for byte.+ const sub = motionBlur ?? 1;+ const motionBlurFilter = sub > 1+ ? `tmix=frames=${sub},select='eq(mod(n\\,${sub})\\,${sub - 1})',setpts=N/${fps}/TB`+ : null;await page.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: false });- const args = ['-hide_banner', '-loglevel', 'error', '-f', 'image2pipe', '-framerate', String(fps), '-vcodec', 'png', '-i', 'pipe:0'];+ const args = ['-hide_banner', '-loglevel', 'error', '-f', 'image2pipe', '-framerate', String(fps * sub), '-vcodec', 'png', '-i', 'pipe:0'];if (musicPath) args.push('-stream_loop', '-1', '-i', musicPath);- args.push('-map', '0:v', '-vf', ['scale=in_range=pc:out_range=tv:out_color_matrix=bt709', tag].filter(Boolean).join(','), ...H264_ENCODE_ARGS, ...BT709_CONTAINER_ARGS);+ args.push('-map', '0:v', '-vf', [motionBlurFilter, 'scale=in_range=pc:out_range=tv:out_color_matrix=bt709', tag].filter(Boolean).join(','), ...H264_ENCODE_ARGS, ...BT709_CONTAINER_ARGS);if (musicPath) args.push('-map', '1:a', '-af', `atrim=duration=${durationSec},asetpts=PTS-STARTPTS,afade=t=out:st=${durationSec - 0.5}:d=0.5`, ...AAC_ENCODE_ARGS);args.push('-frames:v', String(numFrames), '-t', String(durationSec), '-movflags', '+faststart', '-y', outputPath);const proc = spawn(ffmpeg, args, safeChildProcessOptions({ stdio: ['pipe', 'ignore', 'pipe'] }));@@ -40,16 +47,18 @@ export async function encodeComposition(page, contract, outputPath, { musicPath,signal?.addEventListener('abort', stop, { once: true });try {for (let n = 0; n < numFrames; n++) {- page.check();- // awaitPromise in evaluate is essential: each seek owns its paint.- await page.evaluate(`globalThis.portosComposition.seek(${n / fps})`);- page.check();- const { data } = await page.send('Page.captureScreenshot', { format: 'png', fromSurface: true, captureBeyondViewport: false });- page.check();- await Promise.race([- new Promise((resolve, reject) => proc.stdin.write(Buffer.from(data, 'base64'), error => error ? reject(error) : resolve())),- finished.then(() => { throw new Error('ffmpeg exited before capture completed'); }),- ]);+ for (let k = 0; k < sub; k++) {+ page.check();+ // awaitPromise in evaluate is essential: each seek owns its paint.+ await page.evaluate(`globalThis.portosComposition.seek(${n / fps + k / (fps * sub)})`);+ page.check();+ const { data } = await page.send('Page.captureScreenshot', { format: 'png', fromSurface: true, captureBeyondViewport: false });+ page.check();+ await Promise.race([+ new Promise((resolve, reject) => proc.stdin.write(Buffer.from(data, 'base64'), error => error ? reject(error) : resolve())),+ finished.then(() => { throw new Error('ffmpeg exited before capture completed'); }),+ ]);+ }onProgress?.((n + 1) / numFrames);}proc.stdin.end();diff --git a/server/services/htmlComposition/index.js b/server/services/htmlComposition/index.jsindex d9270fe27e..67d775b39d 100644--- a/server/services/htmlComposition/index.js+++ b/server/services/htmlComposition/index.js@@ -63,7 +63,7 @@ export async function renderComposition({ jobId, ...input }) {const metadata = await page.evaluate(`(() => {const c = globalThis.portosComposition;if (!c || typeof c.seek !== 'function') throw new Error('portosComposition.seek is required');- return { durationSec: c.durationSec, fps: c.fps, width: c.width, height: c.height };+ return { durationSec: c.durationSec, fps: c.fps, width: c.width, height: c.height, motionBlur: c.motionBlur };})()`);const parsed = htmlCompositionContractSchema.safeParse(metadata);if (!parsed.success) throw new Error(parsed.error.issues.map(issue => `${issue.path.join('.')}: ${issue.message}`).join('; '));diff --git a/server/services/htmlComposition/index.test.js b/server/services/htmlComposition/index.test.jsindex f75f300541..b34882e841 100644--- a/server/services/htmlComposition/index.test.js+++ b/server/services/htmlComposition/index.test.js@@ -99,6 +99,24 @@ describe.skipIf(!chrome || !ffmpeg)('HTML composition with real Chrome and ffmpeexpect((await readFile(join(PATHS.videoThumbnails, result.thumbnail))).length).toBeGreaterThan(0);}, 30000);+ it('renders motionBlur:1 byte-identical to the default, and motionBlur:4 blends subframes into a smoothed leading edge', async () => {+ const baseline = await renderComposition(await composition());+ const explicit = await renderComposition(await composition(fixture('', 'motionBlur:1')));+ expect(await readFile(join(PATHS.videos, explicit.filename))).toEqual(await readFile(join(PATHS.videos, baseline.filename)));++ const blurred = await renderComposition(await composition(fixture('', 'motionBlur:4')));+ const pixels = execFileSync(ffmpeg, ['-v', 'error', '-i', join(PATHS.videos, blurred.filename), '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-'], { maxBuffer: 40 * 1024 * 1024 });+ const frameBytes = 1280 * 720 * 3;+ expect(pixels.length / frameBytes).toBe(12); // frame count still durationSec * fps, unaffected by motionBlur+ // Frame six spans t=0.5..0.5625s across 4 subframes. The block's trailing+ // edge (px 345) is only inside the block on the later subframes, so the+ // blended average lands strictly between pure red and pure white.+ const at = x => pixels.subarray(6 * frameBytes + (110 * 1280 + x) * 3, 6 * frameBytes + (110 * 1280 + x) * 3 + 3);+ const blended = at(345);+ expect(blended[1]).toBeGreaterThan(30);+ expect(blended[1]).toBeLessThan(220);+ }, 60000);+it('renders a gated launch composition and uses its declared poster beat', async () => {const html = `<!doctype html><html><body><script>globalThis.portosComposition = { durationSec:15, fps:12, width:1280, height:720,@@ -213,6 +231,7 @@ describe.skipIf(!chrome || !ffmpeg)('HTML composition with real Chrome and ffmpeit.each([['durationSec', 'durationSec:0'], ['fps', 'fps:12.5'], ['width', 'width:123'],['durationSec', 'durationSec:1.01'], ['seek', 'seek:null'],+ ['motionBlur', 'motionBlur:0'], ['motionBlur', 'motionBlur:5'], ['motionBlur', 'motionBlur:2.5'],])('names the invalid %s before capture', async (field, contract) => {const input = await composition(fixture('', contract));await expect(renderComposition(input)).rejects.toThrow(field);diff --git a/server/services/taskPromptDefaults/appLaunchVideo.js b/server/services/taskPromptDefaults/appLaunchVideo.jsindex bd3c9bb213..6abf2a210f 100644--- a/server/services/taskPromptDefaults/appLaunchVideo.js+++ b/server/services/taskPromptDefaults/appLaunchVideo.js@@ -10,7 +10,7 @@ Every scene has durationSec; every visible text element has text, its exact whit- index.html and local assets: globalThis.portosComposition = {durationSec, fps:24, width, height, async seek(t){...}}. Use dimensions 1920x1080 (landscape), 1080x1920 (vertical), or 1080x1080 (square). Seek deterministically from t; await fonts and any asynchronous work. No wall-clock animations, external URLs, popups, workers or browser storage. Keep HTML/CSS/JS/SVG/JSON/Markdown/text UTF-8. No raster screenshots or footage.Direct it like a motion designer, not a slideshow. Banned defaults: a centered title on a gradient, everything fading in, corner labels, frame borders, crop marks or HUD chrome, glow on UI chrome, generic particle bursts and dead beats. Hook within the first two seconds and make something new happen every two to four seconds. Use one display face, one UI face and one accent color from the app's palette. Motion has mass: drive position, scale, radius and width with closed-form springs, not fixed easing curves, with a tiny overshoot on UI and none on type. All motion stays a pure function of t: seeded pseudo-randomness only, never Math.random or timers.The server pre-installed the PortOS motion kit at composition/portos-motion.js. Load it with <script src="portos-motion.js"></script> and use globalThis.PortosMotion: spring(t, stiffness, damping) and SPRINGS presets (snappy, default, heavy, playful); track(t, [[time, value], ...]) for any value with several targets (one spring per change, never restart one); indicator() for selection bars that stretch while they travel; swapAlpha() so content inside a morphing container enters after the morph starts and leaves before the next; rng(seed) for seeded noise; beats(bpm) for a beat grid; and renderCues, mixCues and toPcm for synthesized UI sound (click, tick, pop, thump, whoosh, riser). It is ordinary composition source: edit it or delete it if unused.-motionStyle picks the film's grammar. "walkthrough": a clear, paced product walkthrough of the recreated key flow, a cursor driving real actions, springs on every change. "showreel": a designer's showreel built around this product, not a slideshow of recreated screens. Cut on a steady beat (a new beat every one to two seconds, landing on bar boundaries when music is present) and give each beat a distinct technique: bold color-field swaps drawn from the app's palette, oversized kinetic typography (scale, mask and slide reveals; repeated-word patterns), spring contrasts (snappy against heavy against playful), generative geometry computed from t (tiling patterns, radial forms, wireframes), shape morphs, and a logo/name lockup endcard. Keep the recreated key flow as one or two punchy beats so the evidence-backed claim still lands. "ui-morph": one shape, never cut. A single container morphs size, radius and fill from state to state along this app's real flow (for example button, input being typed, loader, success check, dashboard card, chart drawing itself, command palette, toast, logo), its content swaps behind a short blur with swapAlpha, a cursor drives each change with real clicks, a state change lands on every beat at 120 BPM, and the last frame equals the first, cursor position included, so it loops. Write the state list on the beat grid in plan.md before any code. In every style, each word shown, including repeated kinetic words, is a storyboard line whose hold meets the reading-time gate.+motionStyle picks the film's grammar. "walkthrough": a clear, paced product walkthrough of the recreated key flow, a cursor driving real actions, springs on every change. "showreel": a designer's showreel built around this product, not a slideshow of recreated screens. Cut on a steady beat (a new beat every one to two seconds, landing on bar boundaries when music is present) and give each beat a distinct technique: bold color-field swaps drawn from the app's palette, oversized kinetic typography (scale, mask and slide reveals; repeated-word patterns), spring contrasts (snappy against heavy against playful), generative geometry computed from t (tiling patterns, radial forms, wireframes), shape morphs, and a logo/name lockup endcard. Keep the recreated key flow as one or two punchy beats so the evidence-backed claim still lands. "ui-morph": one shape, never cut. A single container morphs size, radius and fill from state to state along this app's real flow (for example button, input being typed, loader, success check, dashboard card, chart drawing itself, command palette, toast, logo), its content swaps behind a short blur with swapAlpha, a cursor drives each change with real clicks, a state change lands on every beat at 120 BPM, and the last frame equals the first, cursor position included, so it loops. Write the state list on the beat grid in plan.md before any code. In every style, each word shown, including repeated kinetic words, is a storyboard line whose hold meets the reading-time gate. For showreel and ui-morph, set motionBlur:4 on globalThis.portosComposition so the fast cuts and morphs render with blended motion blur instead of strobing.When generateMusic is true, the user explicitly requests original instrumental music. musicMethod chooses how: "agent" (the default) means compose and synthesize it yourself; "service" means use a configured PortOS music engine. Never require a music engine for the agent method.For the agent method, implement async globalThis.portosComposition.renderAudio({sampleRate, durationSec}) returning a plain array of exactly Math.round(sampleRate * durationSec) finite mono PCM samples in [-1, 1]. The renderer supplies sampleRate=24000 and the video duration, writes a temporary soundtrack and muxes it into the MP4. Compose a deliberate instrumental arrangement matching the storyboard, with melody, harmony, rhythm, dynamics and an ending; document tempo and musical direction in plan.md. Use native OfflineAudioContext, deterministic sample synthesis, or locally available Tone.js/Strudel code that can export this PCM contract. Use only procedural synthesis, no recordings or fetched samples. Keep all source in composition/ as inspectable UTF-8 JavaScript. No installs, CDN imports, network calls, live playback or binary audio assets. Do not assume Tone.js or Strudel is installed; native Web Audio or plain JavaScript synthesis requires no additional music runtime. Add synthesizeMusic:true to the render JSON; do not set musicTrack or call /api/music/engines or /api/music/generate. Audio played by the page is NOT captured: renderAudio is required. A failed audio render is a failed task, never silently omit requested music.When you compose the score, state its tempo and beat grid in plan.md, cut the picture on that grid, and layer UI sound effects on the actions they belong to: mix PortosMotion cues into the score buffer inside renderAudio (mixCues, then toPcm).diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.jsonindex b815c90d81..4afd16dc5a 100644--- a/server/services/taskPromptDefaults/integrity.snapshot.json+++ b/server/services/taskPromptDefaults/integrity.snapshot.json@@ -2,7 +2,7 @@"DEFAULT_TASK_PROMPTS": {"accessibility": "46f628a44a919bb788de8761e86ca0e1","api-contract": "d52e00ec53eb5618df1a769efccc08f3",- "app-launch-video": "c5f125ac04d41921030f7cd36a3ff3ee",+ "app-launch-video": "e355d37fb682c1f6c2ad4c031a7988a7","better-cognitive-load": "a1fe22f6ef936131456c55a6b0623204","better-complexity": "c99f67b43ff54a1c8cf0176c721d9c06","better-dependency-freedom": "8a79c8be829f926bbc7720ee29818d53",@@ -64,7 +64,7 @@"PROMPT_VERSIONS": {"accessibility": 5,"api-contract": 2,- "app-launch-video": 5,+ "app-launch-video": 6,"better-cognitive-load": 1,"better-complexity": 2,"better-dependency-freedom": 1,@@ -134,7 +134,8 @@"fa15ea11b4cf49f31ae17513ff780421","0247e82d4ae6e812dbd666d3bd75ad62","71962a1f6f902d93f2c8840e3281301b",- "f1aee8c3de778663a5ba44a4f3486ce5"+ "f1aee8c3de778663a5ba44a4f3486ce5",+ "c5f125ac04d41921030f7cd36a3ff3ee"],"better-complexity": ["c92b99080d0453d70bb26a412fb48ce9"diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.jsindex 83d002cb75..e36f54b7f9 100644--- a/server/services/taskPromptDefaults/versions.js+++ b/server/services/taskPromptDefaults/versions.js@@ -7,7 +7,7 @@// Prompt versions — bump when a default prompt changes so existing instances auto-upgrade.// Only non-customized prompts (promptCustomized !== true) are upgraded.export const PROMPT_VERSIONS = {- 'app-launch-video': 5,+ 'app-launch-video': 6, // v6: showreel and ui-morph runs set motionBlur:4 on portosComposition so fast cuts and morphs render with blended motion blur (#8959)'model-comparison-refresh': 4, // v4: installed inventory, sourced composite estimates and authenticated import// Current claim-flow bumps retire the Copilot fallback, drive local reviewers// fail closed, verify the remote merge state, and clean up without force-delete.