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
keep selected footage visible under authored document code
[._.]/ Adam Eivy0f9d1ad36925
diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.jsindex 04de4251d7..ba6c7b2f09 100644--- a/server/services/codeAnimation/prompt.js+++ b/server/services/codeAnimation/prompt.js@@ -463,7 +463,7 @@ export function buildMixedMediaDocumentPrompt({ title, song, palette, treatment,renderer === 'three' ? '' : CODE_VIDEO_RULES.replace('- Canvas 2D only. No external assets, fonts, or network.', '- Canvas 2D only. No network, remote URLs, filesystem paths or font loading. The host binds only the listed selected project assets; draw over footage/stills without obscuring them, and draw the entire authored world for card scenes, including characters, environments, camera staging, lighting and narrative actions. Local packaged fonts MV Mono, MV Cond and MV Stencil are available; authored titles are allowed, but do not duplicate host subtitles.'),MUSIC_VIDEO_DIRECTION,MUSIC_VIDEO_CHOREOGRAPHY,- renderer === 'three' ? 'The authored Three.js world receives no selected-media handles; all visual staging uses geometry and the host text overlay.' : 'env additionally has mediaKind (video, image or null) and visualLayer (footage, still, card or code — a code shot has no media and is drawn entirely by the section). The host has already drawn the selected media at its in/out time. Do not read DOM or load assets in a section function. Use seeded arithmetic from env.frame for visual motion. Keep repeated hooks related but deliberately vary their action.',+ renderer === 'three' ? 'The authored Three.js world receives no selected-media handles; all visual staging uses geometry and the host text overlay.' : 'env additionally has mediaKind (video, image or null) and visualLayer (footage, still, card or code — a code shot has no media and is drawn entirely by the section). The host has already drawn the selected media at its in/out time: when env.mediaKind is set, the section is an overlay, so never fill or clear the whole canvas (a full-frame fill is reduced to a faint wash) and keep the footage readable; paint full backgrounds only when env.mediaKind is null. Do not read DOM or load assets in a section function. Use seeded arithmetic from env.frame for visual motion. Keep repeated hooks related but deliberately vary their action.','NARRATIVE CLOCK: song.narrativeEvents are resolved absolute startFrame/endFrame bindings. env.events supplies active events with progress and counter value; env.reactiveGain is bounded by the section gain/maxGain and is zero during silence. The host freezes song time, media and graphics for silence, and draws exact event text/counters/motif labels after your function. Use the narrativeFunction, motif and mediumRationale to motivate your graphic actions; do not duplicate event text or infer new onsets. Prefer code/stills/selected media for exact text and graphics. Footage is for actions that need it and must already be selected.',`SHARED STYLE CONTRACT:\n${JSON.stringify(sharedStyle || { palette, treatment: { brief: treatment?.brief || null, motifs: treatment?.arc?.motifs || [], styleLook: treatment?.styleLook || null }, visualSpec, styleLines })}`,directionContext ? `APPROVED CAST & SETS DEFINITIONS AND RULES:\n${directionContext}` : '',diff --git a/server/services/musicVideo/documentTemplates/layered/engine.js b/server/services/musicVideo/documentTemplates/layered/engine.jsindex 4948ea3d6c..eb749b3fd0 100644--- a/server/services/musicVideo/documentTemplates/layered/engine.js+++ b/server/services/musicVideo/documentTemplates/layered/engine.js@@ -438,6 +438,32 @@}}+ // A view of ctx for authored code drawn over footage: a fill or clear covering most of the+ // canvas is limited to a translucent wash (clears are dropped), everything else passes+ // through. Authored functions are told to leave footage visible; this keeps it so when a+ // model paints a full-frame background anyway.+ const FOOTAGE_WASH_ALPHA = 0.25;+ function footageOverlayContext(target) {+ const covers = (w, h) => Math.abs(w * h) >= W * H * 0.9;+ return new Proxy(target, {+ get(obj, prop) {+ if (prop === 'fillRect') {+ return (x, y, w, h) => {+ if (!covers(w, h)) return obj.fillRect(x, y, w, h);+ const alpha = obj.globalAlpha;+ obj.globalAlpha = Math.min(alpha, FOOTAGE_WASH_ALPHA);+ obj.fillRect(x, y, w, h);+ obj.globalAlpha = alpha;+ };+ }+ if (prop === 'clearRect') return (x, y, w, h) => { if (!covers(w, h)) obj.clearRect(x, y, w, h); };+ const value = Reflect.get(obj, prop, obj);+ return typeof value === 'function' ? value.bind(obj) : value;+ },+ set(obj, prop, value) { return Reflect.set(obj, prop, value, obj); },+ });+ }+function render(t, scene, source, state) {ctx.fillStyle = C.ink; ctx.fillRect(0, 0, W, H);const authored = sectionFunction(t);@@ -456,7 +482,9 @@const inset = 0.1;ctx.save();try {- authored.fn(ctx, {+ // Over footage or a still, the authored code is an overlay: a full-canvas fill+ // becomes a translucent wash so the selected media stays visible.+ authored.fn(source ? footageOverlayContext(ctx) : ctx, {t, localT: t - authored.section.startSec, frame: frameOf(t), width: W, height: H,song: GENERATED.song, palette: GENERATED.palette, section: authored.section,safe: { x: W * inset, y: H * inset, w: W * (1 - 2 * inset), h: H * (1 - 2 * inset) },diff --git a/server/services/musicVideo/documentTemplates/layered/engine.overlay.test.js b/server/services/musicVideo/documentTemplates/layered/engine.overlay.test.jsnew file mode 100644index 0000000000..adf51616e4--- /dev/null+++ b/server/services/musicVideo/documentTemplates/layered/engine.overlay.test.js@@ -0,0 +1,42 @@+import { readFileSync } from 'node:fs';+import { describe, expect, it } from 'vitest';++// The layered engine is a browser template copied into each document, so the overlay+// guard is exercised by evaluating just that helper against a recording fake context.+const engine = readFileSync(new URL('./engine.js', import.meta.url), 'utf8');+const helper = engine.slice(engine.indexOf(' const FOOTAGE_WASH_ALPHA'), engine.indexOf(' function render(t, scene, source, state)'));+const W = 1920; const H = 1080;+const footageOverlayContext = new Function('W', 'H', `${helper}\nreturn footageOverlayContext;`)(W, H);++function fakeContext() {+ const calls = [];+ return {+ calls, globalAlpha: 1, fillStyle: '#000',+ fillRect(x, y, w, h) { calls.push(['fillRect', w, h, this.globalAlpha]); },+ clearRect(x, y, w, h) { calls.push(['clearRect', w, h]); },+ beginPath() { calls.push(['beginPath']); },+ };+}++describe('layered engine footage overlay guard', () => {+ it('turns a full-canvas fill over footage into a faint wash and drops a full clear', () => {+ const ctx = fakeContext();+ const view = footageOverlayContext(ctx);+ view.fillRect(0, 0, W, H);+ view.clearRect(0, 0, W, H);+ expect(ctx.calls).toEqual([['fillRect', W, H, 0.25]]);+ expect(ctx.globalAlpha).toBe(1);+ });++ it('passes partial fills, other methods and property writes through unchanged', () => {+ const ctx = fakeContext();+ const view = footageOverlayContext(ctx);+ view.globalAlpha = 0.6;+ view.fillStyle = '#fff';+ view.fillRect(10, 10, 200, 100);+ view.clearRect(0, 0, 50, 50);+ view.beginPath();+ expect(ctx.fillStyle).toBe('#fff');+ expect(ctx.calls).toEqual([['fillRect', 200, 100, 0.6], ['clearRect', 50, 50], ['beginPath']]);+ });+});