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
Persist media job progress snapshots
[._.]/ Adam Eivy05d971018f38
diff --git a/.changelog/v2.13.0.md b/.changelog/v2.13.0.mdindex a14865d4b7..d03ff68650 100644--- a/.changelog/v2.13.0.md+++ b/.changelog/v2.13.0.md@@ -4,6 +4,8 @@ Released: 2026-05-30## Changed+- **[media-job-store-progress-on-job-record] Render queue rows now hydrate live progress from the job record.** The media job queue now stores `progress` and `statusMsg` on the running job whenever image/video runners emit progress or status events, exposes those fields through `GET /api/media-jobs/:id` and list responses, and preserves them in persisted queue snapshots. The Image / Video render queue uses that snapshot to show a compact progress bar during polling, so non-SSE consumers no longer reset in-flight jobs to 0% until the next live event arrives.+- **[claude-default-opus-4-8] Default Claude CLI/TUI providers now use `claude-opus-4-8`.** The seeded `claude-code` and `claude-code-tui` providers ship the new opus tier (`claude-haiku-4-5` / `claude-sonnet-4-6` / `claude-opus-4-8`) with `claude-opus-4-8` as the default and heavy model, and the Anthropic model-refresh dropdown lists it first. Migration 058 bumps existing installs from the opus-4-7 trio to the opus-4-8 trio — rewriting the models list and swapping any tier pointer still on `claude-opus-4-7`, while leaving customized model lists and still-current pins (sonnet-4-6, haiku-4-5) untouched. Bedrock providers (separate model ids) are not affected.- **[comic-structure-editorial-review] "Finish the draft" editorial review now flags malformed comic-script pages.** Comic scripts can accumulate pages where all scene content — action, dialogue, transitions — is in the page-level description instead of panel definitions; those pages can't be rendered by the image generator because no discrete panels exist. The review pass now detects these as a new `comic-structure` category finding (always `high` severity) and generates a full panel-by-panel rewrite as the suggestion, so accepting the fix restructures the page in place. A legitimate page description is 1–3 lines of layout intent; anything longer that reads as story content is flagged. Migration 057 updates the `pipeline-manuscript-completeness` prompt on existing installs (customized prompts are skipped with a warning).diff --git a/PLAN.md b/PLAN.mdindex 195343cae5..8df92f8db7 100644--- a/PLAN.md+++ b/PLAN.md@@ -5,11 +5,10 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel## Next Up1. **[ltx2-fflf-skips-last-image-resize-when-both-frames-set]** **ltx2 FFLF skips last-image resize when both start and end frames are provided — CONFIRMED bug (verified 2026-05-30 this replan).** `server/services/videoGen/local.js:573` gates `lastImageWillBeUsed` on `mode === 'fflf' && !sourceImagePath`, so the ltx2 true-FFLF flow (both `sourceImagePath` AND `lastImagePath` set, passed via `--image` + `--last-image` at `buildLtx2Args` ~line 328) skips the `resizeImage` ffmpeg pass for the end frame; `scripts/generate_ltx2.py` `_resolve_keyframes` (~line 313) then passes both paths straight through with no resize/letterbox/pad. The end-frame image reaches `KeyframeInterpolationPipeline.generate_and_save()` at its ORIGINAL dimensions → dimension mismatch / degraded output (the multi-keyframe path already resizes each keyframe at `local.js` ~line 606; the two-keyframe legacy path was missed). Fix: resize the last image in the ltx2 two-keyframe FFLF path the same way multi-keyframes are resized, and correct the stale comment at `local.js` ~line 560 that wrongly assumes only mlx_video/Windows consume `--last-image`. (Was filed UNVERIFIED under blocked; verification this replan confirmed it real and moved it up.)-2. **[media-job-store-progress-on-job-record]** **mediaJobQueue: persist progress/statusMsg on the job record.** `runJob`'s progress handler in `server/services/mediaJobQueue/index.js` (~line 575) only broadcasts to SSE (`broadcastSse`) — it doesn't mutate the job object. So `GET /api/media-jobs/:id` (used by `MediaJobsQueue.jsx` and any other non-SSE consumer) always reports 0 progress for in-flight jobs. SSE-attached pages don't see this (lastPayload replay), but list-view hydration does. Add `job.progress` + `job.statusMsg` updates inside the dispatcher's `progress` handler. Cross-cutting across image/video/codex paths.-3. **[shared-bounded-concurrency-mapper]** **Extract a generic `mapWithConcurrency(items, n, fn)` to `server/lib/` and reuse it.** The worker-pool idiom (cursor + N workers draining a shared array, order-preserving result) is now hand-rolled in THREE places (verified 2026-05-30): `embedBatch` in `server/services/embeddings.js` (~line 158), the mapper in `server/services/catalogExtraction.js` (~line 317), and another in `server/routes/imageVideoModels.js`. A pure `server/lib/` helper would collapse all three onto one tested mechanism (barrel + README row per the maintenance rule).-4. **[video-resume-restore-keyframes]** **VideoGen resume: restore keyframes from the active job.** `ACTIVE_JOB_PARAM_FIELDS` in `server/routes/videoGen.js` (~line 739) intentionally omits `keyframes` (gallery filename + frame-index pairs for multi-keyframe FFLF) because the v1 resume effect doesn't repopulate the picker UI for them. A user who reloads mid-render on a keyframe job loses the keyframe-picker state even though every other form field is restored. Whitelist `keyframes` in the route AND wire a `setKeyframes()`-style setter in `client/src/pages/VideoGen.jsx`'s resume effect (~line 507). Independent of the SSE re-attach.-5. **[chrome-canary-followups]** **Hardening for the custom-Chrome-binary feature — remaining low/medium items.** _High-severity (a)–(f) are now DONE (verified 2026-05-30): (a) `browser/server.js` (~line 46) derives `macAppBundle` from `chromePath` on macOS; (b) both `spawn()` calls (~lines 221, 236) have `.on('error', …)` listeners; (d) both `loadConfig`s try/catch `JSON.parse`; (e) `setup-browser.js#loadConfig` warns + returns null and `applyCanaryToConfig` skips the save on unreadable config; (f) top-level `runCanarySetup()` is `.catch()`-wrapped. (c) headless-flag flip is tracked in `[setup-browser-canary-headless]` (now in Backlog with a decision)._ **Remaining low/medium:** (g) idempotency guard only checks `chromePath` — decliners + `macAppBundle`-only users get re-prompted every update; (h) `PORTOS_USE_CANARY` only matches literal `0/false/1/true` — `no/off/yes/on/True` fall through both branches; (i) `spawnSync(install.cmd, …, { stdio: 'inherit' })` for brew/winget can hang on a sudo prompt under non-TTY + `PORTOS_USE_CANARY=1`; (j) `cachedConfig` in `browserService.js` is stale relative to setup-browser's direct write (GET /api/browser/config returns pre-update values until process restart); (k) `saveConfig` uses bare `writeFileSync` — switch to the canonical `atomicWrite` (`server/lib/fileUtils.js`); (l) `spawnSync` status check treats `status: null` (spawn-failure/signal) like a non-zero exit and never logs `result.error`; (m) `optionalPath` Zod schema has no `.app`/`.exe` sanity check; (n) `launchBrowser`'s reuse-existing-Chrome early-return fires BEFORE `headlessMode` is set (wrong /health mode after a PM2 restart that reuses Chrome); (o) `detectCanary` on macOS only checks `/Applications/...` and misses per-user `~/Applications` installs.-6. **[ref-watch-phosphene-teacache-extend-a2v-denoise]** **TeaCache through Extend + A2V Stage-1 denoise loops.** From `reference-watch` review of phosphene (commits `ea98aad8` + `17be2a79`, 2026-05-28). PortOS's `scripts/generate_ltx2.py` invokes `ExtendPipeline.extend_from_video(...)` (~line 378) and `AudioToVideoPipeline.generate_and_save(...)` (~line 417) directly without passing a TeaCache controller, so the slowest two modes in the panel run full denoise. Phosphene reuses the existing Stage-1 calibration (`ti2vid_two_stages._build_teacache_controller(n_steps, thresh=0.5)`) by monkey-patching `guided_denoise_loop` on the `ltx_pipelines_mlx.retake` and `ltx_pipelines_mlx.a2vid_two_stage` modules, gating activation on a per-call module-level config dict, set before the pipeline call and cleared in `finally`. Predicted ~1.2× on extend at default threshold (up to ~3× at 1.5); similar for A2V Stage 1. Fix: install both monkey-patches at the top of `generate_ltx2.py`, wire `_EXTEND_TC_CONFIG` / `_A2V_TC_CONFIG` from the helper's `run_extend`/`run_a2v` paths, and add a `--no-teacache` CLI flag (default-on). **Decision (resolved 2026-05-30): land independently** against today's pin — the calibration helper `_build_teacache_controller` already exists at the current pin, so there's no need to couple this to the risky rename in `[ref-watch-phosphene-bump-ltx2-pin-v0148]`. Scope: small/medium.+2. **[shared-bounded-concurrency-mapper]** **Extract a generic `mapWithConcurrency(items, n, fn)` to `server/lib/` and reuse it.** The worker-pool idiom (cursor + N workers draining a shared array, order-preserving result) is now hand-rolled in THREE places (verified 2026-05-30): `embedBatch` in `server/services/embeddings.js` (~line 158), the mapper in `server/services/catalogExtraction.js` (~line 317), and another in `server/routes/imageVideoModels.js`. A pure `server/lib/` helper would collapse all three onto one tested mechanism (barrel + README row per the maintenance rule).+3. **[video-resume-restore-keyframes]** **VideoGen resume: restore keyframes from the active job.** `ACTIVE_JOB_PARAM_FIELDS` in `server/routes/videoGen.js` (~line 739) intentionally omits `keyframes` (gallery filename + frame-index pairs for multi-keyframe FFLF) because the v1 resume effect doesn't repopulate the picker UI for them. A user who reloads mid-render on a keyframe job loses the keyframe-picker state even though every other form field is restored. Whitelist `keyframes` in the route AND wire a `setKeyframes()`-style setter in `client/src/pages/VideoGen.jsx`'s resume effect (~line 507). Independent of the SSE re-attach.+4. **[chrome-canary-followups]** **Hardening for the custom-Chrome-binary feature — remaining low/medium items.** _High-severity (a)–(f) are now DONE (verified 2026-05-30): (a) `browser/server.js` (~line 46) derives `macAppBundle` from `chromePath` on macOS; (b) both `spawn()` calls (~lines 221, 236) have `.on('error', …)` listeners; (d) both `loadConfig`s try/catch `JSON.parse`; (e) `setup-browser.js#loadConfig` warns + returns null and `applyCanaryToConfig` skips the save on unreadable config; (f) top-level `runCanarySetup()` is `.catch()`-wrapped. (c) headless-flag flip is tracked in `[setup-browser-canary-headless]` (now in Backlog with a decision)._ **Remaining low/medium:** (g) idempotency guard only checks `chromePath` — decliners + `macAppBundle`-only users get re-prompted every update; (h) `PORTOS_USE_CANARY` only matches literal `0/false/1/true` — `no/off/yes/on/True` fall through both branches; (i) `spawnSync(install.cmd, …, { stdio: 'inherit' })` for brew/winget can hang on a sudo prompt under non-TTY + `PORTOS_USE_CANARY=1`; (j) `cachedConfig` in `browserService.js` is stale relative to setup-browser's direct write (GET /api/browser/config returns pre-update values until process restart); (k) `saveConfig` uses bare `writeFileSync` — switch to the canonical `atomicWrite` (`server/lib/fileUtils.js`); (l) `spawnSync` status check treats `status: null` (spawn-failure/signal) like a non-zero exit and never logs `result.error`; (m) `optionalPath` Zod schema has no `.app`/`.exe` sanity check; (n) `launchBrowser`'s reuse-existing-Chrome early-return fires BEFORE `headlessMode` is set (wrong /health mode after a PM2 restart that reuses Chrome); (o) `detectCanary` on macOS only checks `/Applications/...` and misses per-user `~/Applications` installs.+5. **[ref-watch-phosphene-teacache-extend-a2v-denoise]** **TeaCache through Extend + A2V Stage-1 denoise loops.** From `reference-watch` review of phosphene (commits `ea98aad8` + `17be2a79`, 2026-05-28). PortOS's `scripts/generate_ltx2.py` invokes `ExtendPipeline.extend_from_video(...)` (~line 378) and `AudioToVideoPipeline.generate_and_save(...)` (~line 417) directly without passing a TeaCache controller, so the slowest two modes in the panel run full denoise. Phosphene reuses the existing Stage-1 calibration (`ti2vid_two_stages._build_teacache_controller(n_steps, thresh=0.5)`) by monkey-patching `guided_denoise_loop` on the `ltx_pipelines_mlx.retake` and `ltx_pipelines_mlx.a2vid_two_stage` modules, gating activation on a per-call module-level config dict, set before the pipeline call and cleared in `finally`. Predicted ~1.2× on extend at default threshold (up to ~3× at 1.5); similar for A2V Stage 1. Fix: install both monkey-patches at the top of `generate_ltx2.py`, wire `_EXTEND_TC_CONFIG` / `_A2V_TC_CONFIG` from the helper's `run_extend`/`run_a2v` paths, and add a `--no-teacache` CLI flag (default-on). **Decision (resolved 2026-05-30): land independently** against today's pin — the calibration helper `_build_teacache_controller` already exists at the current pin, so there's no need to couple this to the risky rename in `[ref-watch-phosphene-bump-ltx2-pin-v0148]`. Scope: small/medium.## Backlogdiff --git a/client/src/components/media/MediaJobsQueue.jsx b/client/src/components/media/MediaJobsQueue.jsxindex a6dfb0dc48..8dc971d62f 100644--- a/client/src/components/media/MediaJobsQueue.jsx+++ b/client/src/components/media/MediaJobsQueue.jsx@@ -191,6 +191,9 @@ function JobRow({ job, onCancel, onRetry, onRunNow, onDelete }) {// Run-now is codex-only — GPU jobs serialize on the single MLX runtime.const isQueuedCodex = job.status === 'queued' && job.kind === 'image' && job.params?.mode === IMAGE_GEN_MODE.CODEX;const canRunNow = isQueuedCodex && typeof onRunNow === 'function';+ const progressPct = typeof job.progress === 'number'+ ? Math.max(0, Math.min(100, Math.round(job.progress * 100)))+ : 0;// Inline edit form for retry-with-overrides.const [editing, setEditing] = useState(false);const canEdit = canRetry;@@ -277,6 +280,17 @@ function JobRow({ job, onCancel, onRetry, onRunNow, onDelete }) {{job.status === 'failed' && job.error && (<div className="text-xs text-port-error mt-2 truncate" title={job.error}>{job.error}</div>)}+ {job.status === 'running' && (+ <div className="mt-2 space-y-1">+ <div className="flex items-center justify-between gap-2 text-xs text-port-text-muted">+ <span className="truncate" title={job.statusMsg || undefined}>{job.statusMsg || 'Running'}</span>+ <span className="font-mono shrink-0">{progressPct}%</span>+ </div>+ <div className="h-1.5 bg-port-border rounded overflow-hidden">+ <div className="h-full bg-port-accent transition-all" style={{ width: `${progressPct}%` }} />+ </div>+ </div>+ )}<div className="text-xs text-port-text-muted mt-1">{job.queuedAt && `queued ${new Date(job.queuedAt).toLocaleTimeString()}`}{job.startedAt && ` · started ${new Date(job.startedAt).toLocaleTimeString()}`}diff --git a/client/src/hooks/useMediaJobProgress.js b/client/src/hooks/useMediaJobProgress.jsindex 28275beee1..87516bd058 100644--- a/client/src/hooks/useMediaJobProgress.js+++ b/client/src/hooks/useMediaJobProgress.js@@ -12,7 +12,7 @@ import { usePreviousSync } from './usePrevious.js';* Returns:* {* status: 'unknown' | 'queued' | 'running' | 'completed' | 'failed' | 'canceled',- * progress, step, totalSteps, currentImage,+ * progress, statusMsg, step, totalSteps, currentImage,* filename, path, error,* }*@@ -23,6 +23,7 @@ import { usePreviousSync } from './usePrevious.js';const INITIAL_STATE = Object.freeze({status: 'unknown',progress: 0,+ statusMsg: null,step: 0,totalSteps: null,currentImage: null,@@ -69,6 +70,8 @@ export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {setState((prev) => ({...prev,status: job.status || 'unknown',+ progress: typeof job.progress === 'number' ? job.progress : prev.progress,+ statusMsg: job.statusMsg || prev.statusMsg,filename: job.result?.filename || prev.filename,path: job.result?.path || prev.path,error: job.error || prev.error,@@ -99,6 +102,7 @@ export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {...prev,status: 'running',progress: data.progress ?? prev.progress,+ statusMsg: data.message ?? prev.statusMsg,step: data.step ?? prev.step,totalSteps: data.totalSteps ?? prev.totalSteps,currentImage: data.currentImage ?? prev.currentImage,@@ -106,6 +110,7 @@ export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {if (next.status === prev.status&& next.progress === prev.progress+ && next.statusMsg === prev.statusMsg&& next.step === prev.step&& next.totalSteps === prev.totalSteps&& next.currentImage === prev.currentImage@@ -118,6 +123,8 @@ export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {setState((prev) => ({...prev,status: 'completed',+ progress: 1,+ statusMsg: 'Completed',filename: data.filename ?? prev.filename,path: data.path ?? prev.path,}));diff --git a/server/routes/mediaJobs.js b/server/routes/mediaJobs.jsindex 9455b7e850..93f5292dac 100644--- a/server/routes/mediaJobs.js+++ b/server/routes/mediaJobs.js@@ -91,6 +91,8 @@ function sanitizeJob(job) {startedAt: job.startedAt,completedAt: job.completedAt,position: job.position,+ progress: job.progress,+ statusMsg: job.statusMsg,error: job.error,result: job.result,params: safeParams,diff --git a/server/routes/mediaJobs.test.js b/server/routes/mediaJobs.test.jsindex 49d2eda9a2..4afd2b974a 100644--- a/server/routes/mediaJobs.test.js+++ b/server/routes/mediaJobs.test.js@@ -42,6 +42,37 @@ describe('mediaJobs routes', () => {vi.clearAllMocks();});+ it('GET /:id exposes progress and statusMsg while sanitizing params', async () => {+ jobStore.set('j-progress', {+ id: 'j-progress',+ kind: 'video',+ owner: null,+ status: 'running',+ queuedAt: '2026-05-30T10:00:00.000Z',+ startedAt: '2026-05-30T10:00:01.000Z',+ position: 1,+ progress: 0.37,+ statusMsg: 'Rendering step 37/100',+ params: {+ prompt: 'visible prompt',+ pythonPath: '/private/python',+ uploadedTempPath: '/private/upload.png',+ },+ });++ const r = await request(makeApp()).get('/api/media-jobs/j-progress');+ expect(r.status).toBe(200);+ expect(r.body).toMatchObject({+ id: 'j-progress',+ status: 'running',+ progress: 0.37,+ statusMsg: 'Rendering step 37/100',+ params: { prompt: 'visible prompt' },+ });+ expect(r.body.params.pythonPath).toBeUndefined();+ expect(r.body.params.uploadedTempPath).toBeUndefined();+ });+it('POST /:id/retry 404s for unknown id', async () => {const r = await request(makeApp()).post('/api/media-jobs/nope/retry').send({});expect(r.status).toBe(404);diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.jsindex 5ff03bec40..972b8a045a 100644--- a/server/services/mediaJobQueue/index.js+++ b/server/services/mediaJobQueue/index.js@@ -228,8 +228,8 @@ async function persistImpl() {...archive,];// Strip non-serializable bits.- const serializable = live.map(({ id, kind, owner, status, queuedAt, startedAt, completedAt, params, result, error, position }) =>- ({ id, kind, owner, status, queuedAt, startedAt, completedAt, params, result, error, position }),+ const serializable = live.map(({ id, kind, owner, status, queuedAt, startedAt, completedAt, params, result, error, position, progress, statusMsg }) =>+ ({ id, kind, owner, status, queuedAt, startedAt, completedAt, params, result, error, position, progress, statusMsg }),);await atomicWrite(JOBS_FILE, { jobs: serializable });}@@ -344,6 +344,8 @@ function startLaneJob(job, { isCodex }) {job.status = 'running';job.startedAt = new Date().toISOString();job.position = 1;+ job.progress = typeof job.progress === 'number' && Number.isFinite(job.progress) ? job.progress : 0;+ job.statusMsg = job.statusMsg || 'Starting';if (isCodex) {codexRunning.push(job);} else {@@ -558,6 +560,10 @@ async function runJob(job) {emitter.off?.('progress', onActivity);apply(job);job.status = state;+ if (state === 'completed') {+ job.progress = 1;+ job.statusMsg = 'Completed';+ }job.completedAt = new Date().toISOString();const logPrefix = state === 'completed' ? '✅' : state === 'canceled' ? '🛑' : '❌';const logSuffix = state === 'failed' ? `: ${job.error}` : state === 'canceled' ? ' (was running)' : '';@@ -573,6 +579,12 @@ async function runJob(job) {const handlers = {progress: (payload) => {+ if (payload.type === 'progress' && typeof payload.progress === 'number' && Number.isFinite(payload.progress)) {+ job.progress = Math.max(0, Math.min(1, payload.progress));+ }+ if (typeof payload.message === 'string' && payload.message.length > 0) {+ job.statusMsg = payload.message;+ }broadcastSse(sseEntry, payload);},completed: (payload) => {diff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.jsindex d2088b5870..ed318c0f7f 100644--- a/server/services/mediaJobQueue/index.test.js+++ b/server/services/mediaJobQueue/index.test.js@@ -218,6 +218,38 @@ describe('mediaJobQueue', () => {expect(finished.result?.path).toBe(`/data/videos/${job.jobId}.mp4`);});+ it('progress/status events update the live job record for non-SSE readers', async () => {+ const file = join(tempDataDir, 'media-jobs.json');+ const job = mediaJobQueue.enqueueJob({ kind: 'video', params: { prompt: 'progress please' } });+ await waitFor(() => stubs.generateVideo.mock.calls.length === 1);++ videoGenEvents.emit('status', { generationId: job.jobId, message: 'Loading pipeline' });+ await waitFor(() => mediaJobQueue.getJob(job.jobId)?.statusMsg === 'Loading pipeline');+ expect(mediaJobQueue.getJob(job.jobId).progress).toBe(0);++ videoGenEvents.emit('progress', {+ generationId: job.jobId,+ progress: 0.42,+ step: 21,+ totalSteps: 50,+ message: 'Rendering step 21/50',+ });+ await waitFor(() => mediaJobQueue.getJob(job.jobId)?.progress === 0.42);+ const running = mediaJobQueue.getJob(job.jobId);+ expect(running.status).toBe('running');+ expect(running.statusMsg).toBe('Rendering step 21/50');++ videoGenEvents.emit('completed', { generationId: job.jobId, filename: `${job.jobId}.mp4` });+ await waitFor(() => {+ const data = JSON.parse(readFileSync(file, 'utf-8'));+ const persisted = data.jobs.find((j) => j.id === job.jobId);+ return persisted?.status === 'completed';+ });+ const persisted = JSON.parse(readFileSync(file, 'utf-8')).jobs.find((j) => j.id === job.jobId);+ expect(persisted.progress).toBe(1);+ expect(persisted.statusMsg).toBe('Completed');+ });+it('boot recovery: persisted "running" jobs are reclassified as failed', async () => {const interruptedId = '00000000-0000-4000-8000-000000000001';const persisted = {