apps/desktop/docs/phase0-decisions.md
Phase 0 — spike results and decisions
The Phase 0 probe implementation and captured result files were retired in
Phase 6 after their decisions were incorporated. The media fixtures remain in
apps/desktop/e2e/fixtures/ for end-to-end coverage. Each row records the original
go/no-go decision for the Electron platform layer (Phase 1).
| # | Question | Result | Decision |
|---|---|---|---|
| a | Video decode via HTMLVideoElement | H.264 (mp4/mov), HEVC 8-bit (mp4/mov), HEVC-with-alpha (alpha survives), VP8, VP9, AV1 all decode with correct pixels. ProRes 422 and ProRes 4444 do not (DEMUXER_ERROR_NO_SUPPORTED_STREAMS / 0×0 track). AAC/Opus/MP3/FLAC/WAV decode. VideoDecoder/MediaSource report support for avc1, hvc1/hev1, vp8/vp9, av01. | Go. ProRes is the one regression vs WKWebView: import must detect-and-warn on the <video> error event ("ProRes needs transcoding"), not the extension allowlist. VP9/AV1 fixtures read [0,216,0] — a limited/full color-range tagging artifact in the fixtures, not a decode fault. |
| b | WebGPU | Adapter + device + copyExternalImageToTexture OK in ~7 ms, all launch modes. | Go. Drop the per-gesture adapter warm-up workaround (spatial.js:293-298) in Phase 3b, verify once. |
| c | WebCodecs encode | VP9 (vp09.00.31.08) and VP8 encoders OK (30×1080p frames in ~86 ms); Opus AudioEncoder OK and supplies decoderConfig.description. H.264 avc1 encoding unsupported. | Go. Export stays WebM (VP9+Opus) — now frame-exact with audio on every run (the MediaRecorder fallback becomes dead code). H.264/MP4 export is a post-parity feature (needs a muxer + platform encoder path). |
| d | Generated-script sandbox under CSP | Chromium inherits the parent CSP into about:srcdoc frames. With script-src 'self' 'unsafe-eval' (no 'unsafe-inline') the sandbox's inline bootstrap is blocked in both file and app modes. | Go (B2). Serve host/sandbox.html + host/sandbox.js from app:// with their own CSP header (script-src app://powermove/host/sandbox.js 'unsafe-eval'; worker-src blob:; connect-src 'none') inside <iframe sandbox="allow-scripts"> — verified: answer 42, opaque origin, fetch blocked, parent unreachable. 'self' also matches under the sandboxed origin. blob: frames and srcdoc inherit the parent policy and fail; a hash-allowlisted inline bootstrap works but couples the app CSP to the sandbox source, so it is rejected. Never add 'unsafe-inline'. |
| e | Fonts | queryLocalFonts() works without user activation under a granting permission handler: 284 families, fast. system_profiler takes ~9 s. | Renderer queryLocalFonts is the primary path (permission handler grants local-fonts to the app origin only); fonts:list main fallback is unnecessary for v1. Reverses the review assumption. |
| f | Window capture | webContents.capturePage() median 25 ms (2880×1736 PNG, ~42 KB). | Go. Keep the 700 ms renderer timeout as-is. |
| g | File System Access | showSaveFilePicker, showOpenFilePicker, showDirectoryPicker, OPFS all present in every mode. | Go for retained-handle ⌘S and PNG-sequence export. PENDING (human-in-the-loop): the 1 GiB createWritable() streaming run needs someone to accept a native Save dialog; scheduled for the Phase 1 gate. |
| h | Codex discovery | /opt/homebrew/bin/codex resolved in terminal, app, and open -n launches; login-shell probe (zsh -ilc) resolves it too. Neither Swift hardcoded npm path exists on this machine. CODEX_BINARY unset. | Runner discovery order: $CODEX_BINARY → user pref → login-shell command -v codex → known paths. The open -n mode inherited a Homebrew PATH, so it is not proof of a true Finder launch; the login-shell probe is the real safety net. |
| i | Panel re-parenting (appendChild ×50) | Input value, click handlers, WebGL context + pixels + uploaded texture, Resize/MutationObservers, CSS transitions, and <video> playback all survive. Focus is lost. | Go for the panel pool. portal.ts must restore activeElement (and selection range — B2 verifies) after each move. |
| j | app:// origin | location.origin = app://probe, isSecureContext = true, crypto.subtle present, IndexedDB opens, 200 KB boot snapshot round-trip 0.4 ms. | Go. Storage boot barrier is cheap. |
| k | Large IPC | 64 MiB 35 ms · 256 MiB 131 ms · 1 GiB 518 ms (works); main RSS ≈ 2.5 GiB during the 1 GiB transfer, renderer heap likewise. | file:save hard cap 256 MiB; anything larger streams through File System Access. |
Consequences folded into the plan
- Import: extension allowlist stays; add ProRes detection on decode error with a specific message. HEVC no longer a risk item.
- Export: WebM/VP9/Opus only; the Phase 1 gate's "export with audio bit-checked" now exercises a path WKWebView never ran.
- Fonts:
PM.Fonts.setSystemFamiliesis fed from rendererqueryLocalFonts()at boot (permission granted main-side); web fallback list retained. - Sandbox: served
host/sandbox.html(see row d); the legacyscripting.jsgets a branch that loads it whenwindow.powermoveexists. - Panel pool: focus restoration is part of the re-parent attachment contract.
- Scaffold review fixes applied by the integrator:
vitest.config.ts(legacytests/excluded), dev URL gated onapp.isPackaged,web-contents-created+will-frame-navigate+will-redirectguards, IPC sender derived from the event (BrowserWindow.fromWebContents+ frame URL check), MIME table (.mov .m4a .aac .flac .m4v .wasm .map), CJS output pinned for main/preload,app.setName('Powermove'),lib: ["ES2022"]for the node tsconfig.
Found while booting the legacy renderer under Electron
js/gl/compositor.js: shader and precomp layers rendered into a scratch FBO and never restored the caller's framebuffer, sodrawContentsampled the scratch texture while drawing into it (Chromium:GL_INVALID_OPERATION … Feedback loop). Fixed by tracking the bound FBO/texture units and restoring the target after nested rendering; pool/content texture creation now goes through the tracked binder. 0 GL errors after the fix.- Panel re-parenting loses focus and (occasionally) the selection range:
portal.tsmust snapshotactiveElement+selectionStart/End/Directionand restore them after every move (B2, probe i2).