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
fix: PR #223 review follow-ups + cd-evaluate prompt drift migration
[._.]/ Adam Eivy4c2e5348793f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex fd25272e57..e8f52819d5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -65,6 +65,12 @@## Fixed+- **Creative Director evaluator prompt — backfill `imageStrength` block on existing installs.** `data.sample/prompts/stages/cd-evaluate.md` gained a `{{#scene.hasImageStrength}}` / `{{^scene.hasImageStrength}}` block in the scene-context section (so the evaluator can see the current i2v strength) and a sentence in the retry-branch instructions documenting the `imageStrength` knob it can adjust on rewrite. New installs picked it up automatically (fresh `data/` clones from `data.sample/`), but existing installs were stuck with the old template because `setup-data.js` only seeds files that don't yet exist — three regression tests in `creativeDirectorPrompts.test.js` flagged the drift on every test run. New one-shot migration `data/migrations/002-cd-evaluate-image-strength.js` surgically patches both pieces in when the surrounding anchor text matches the pre-update template (so a hand-edited prompt is left alone with a `⚠️` notice). Idempotent — re-runs are a no-op.++- **Media chips/search now show LoRAs for snake_case-only sidecars.** `normalizeImage` / `normalizeVideo` were building `loraNames` from only the camelCase `loraFilenames` / `loraPaths` shapes, so a sidecar written by the Python pipeline (`lora_filenames` / `lora_paths`) showed no LoRA chips on the card and didn't surface in LoRA-name search — even though the requeue path through `getRenderConfigForItem` resolved them correctly via `pickLoraFilenames`. Both normalizers now reuse `pickLoraFilenames` so chips, search, and requeue agree across all four field shapes (`loraFilenames` / `lora_filenames` / `loraPaths` / `lora_paths`). Three new tests in `normalize.test.js` pin the snake_case coverage for both image and video. Picked up from PR #223 Copilot review.++- **Modal a11y — close-button labels.** `MemoryEditModal` and `ResumeAgentModal`'s header X buttons are icon-only and were rendering as unnamed controls; added `aria-label` ("Close edit memory" / "Close resume agent modal") and marked the inner `<X>` icon `aria-hidden` so the button has a single, screen-reader-friendly name. Aligns the new shared-`<Modal>` call sites with the rest of the app's overlay-close conventions. Picked up from PR #223 Copilot review.+- **Mobile MediaLightbox — tap-to-toggle-drawer removed.** Follow-up to the mobile lightbox overhaul: tapping the image in fullscreen on mobile was toggling a bottom-sheet settings drawer (`max-h-[55vh]`) that sat absolute-positioned over the bottom half of the image area. Because the image was centered in a `flex-1` container the drawer wasn't pushing it up, just covering it — visually the image "vanished" with no obvious way back. Removed the tap branch and the now-unreachable `drawerOpen` state (effect cleanups, Esc cascade step, chevron `drawer-open` branch, `SettingsPane` fullscreen aside-class branch, `fullScreen ? 'Hide settings' : 'Close'` aria-label, the `tap for settings` hint). In fullscreen on mobile the image is now the whole canvas — use the minimize pill (top-right) to exit fullscreen and reach settings. Swipe-to-navigate still works. Also collapsed `SettingsPane`'s `onClose` + `onPrimaryClose` into a single `onClose` prop, moved `cleaning` state into `SettingsPane` (its only consumer), and replaced the inline `document.body.style.overflow` stash with the shared `useScrollLock` hook so lightbox + refine-modal can stack without clobbering each other's saved overflow.- **Mobile MediaLightbox UX overhaul.** On a phone the lightbox was effectively unnavigable: prev/next chevrons rendered as faint `text-white/40` glyphs that disappeared on bright images, the swipe threshold was too strict for thumb arcs (`dx > dy×1.5`, 60 px), tapping in fullscreen opened a settings drawer that took the whole screen with no obvious dismiss, the chevrons sat at viewport `top-1/2` directly over landscape image content, and tapping the maximize/minimize button bubbled to the image div's tap handler — collapsing fullscreen AND toggling the drawer in the same gesture, leaving a `drawerOpen=true` state stranded under `fullScreen=false` that flashed the SettingsPane through the bottom-sheet layout on exit. Now: chevrons get a `bg-black/40 backdrop-blur` pill (visible on any image) and re-anchor to `bottom-4` in fullscreen so they sit in the letterbox bar for landscape renders; the fullscreen settings drawer is a bottom sheet (`max-h-[55vh]`) on mobile so the image + chevrons stay reachable above it (desktop keeps the side drawer); the swipe guard loosens to `dx > dy×1.2`, `SWIPE_MIN_PX=50`; touch handlers on the image area ignore events that originate inside a `<button>` via `e.target.closest('button')` so the max/min toggle no longer leaks into the tap-toggle; and a new `useEffect` clears `drawerOpen` whenever `fullScreen` falls back to false so the stale-state flash can't recur. The bottom-of-card hint also extends to `"tap for settings · swipe to navigate"` when prev/next exist.diff --git a/client/src/components/KeyboardHelp.jsx b/client/src/components/KeyboardHelp.jsxindex 1b61a303b1..f38e4e0071 100644--- a/client/src/components/KeyboardHelp.jsx+++ b/client/src/components/KeyboardHelp.jsx@@ -85,11 +85,13 @@ export default function KeyboardHelp() {<Modalopen={open}onClose={close}- // Modal's bubble-phase window Esc dispatcher closes us as the top-most- // layer. useKeyboardHelp listens on `document` (also bubble) — both- // fire on Esc, but they both ultimately call setOpen(false) so the- // double-handler is harmless. Modal's `stopImmediatePropagation` only- // blocks other window-level listeners, not document-level ones.+ // Modal installs bubble-phase keydown listeners on BOTH `document`+ // and `window`. Its document listener is registered at module load+ // (before useKeyboardHelp's mount-time effect), so it fires first as+ // the top-most-modal dispatch and calls our `close`. The+ // `stopImmediatePropagation` then blocks useKeyboardHelp's later-+ // registered document listener — but the result is identical+ // (`setOpen(false)`), so the redundancy is harmless.size="md"align="top"usePortaldiff --git a/client/src/components/cos/tabs/MemoryEditModal.jsx b/client/src/components/cos/tabs/MemoryEditModal.jsxindex 42c98128cf..641d3d2e66 100644--- a/client/src/components/cos/tabs/MemoryEditModal.jsx+++ b/client/src/components/cos/tabs/MemoryEditModal.jsx@@ -110,9 +110,10 @@ export default function MemoryEditModal({ memory, apps, onSave, onClose }) {<h2 id="memory-edit-title" className="text-lg sm:text-xl font-bold text-white">Edit Memory</h2><buttononClick={onClose}+ aria-label="Close edit memory"className="p-2 min-h-[40px] min-w-[40px] flex items-center justify-center text-gray-500 hover:text-white transition-colors rounded-lg">- <X size={22} />+ <X size={22} aria-hidden="true" /></button></div>diff --git a/client/src/components/cos/tabs/ResumeAgentModal.jsx b/client/src/components/cos/tabs/ResumeAgentModal.jsxindex f7cc005aef..665a07cc63 100644--- a/client/src/components/cos/tabs/ResumeAgentModal.jsx+++ b/client/src/components/cos/tabs/ResumeAgentModal.jsx@@ -99,9 +99,10 @@ export default function ResumeAgentModal({ agent, taskType = 'user', providers,</h2><buttononClick={onClose}+ aria-label="Close resume agent modal"className="text-gray-500 hover:text-white transition-colors">- <X size={20} />+ <X size={20} aria-hidden="true" /></button></div>diff --git a/client/src/components/media/normalize.js b/client/src/components/media/normalize.jsindex 3d20418ebd..8df478192d 100644--- a/client/src/components/media/normalize.js+++ b/client/src/components/media/normalize.js@@ -15,14 +15,7 @@ export function loraDisplayName(filename) {// Normalizes raw image-gallery / video-history records into a single shape// consumed by <MediaCard>. Lets the same card render in any history grid.export function normalizeImage(i) {- // Sidecar field shapes: new gen records use loraFilenames (basenames);- // legacy records pre-refactor used loraPaths (absolute paths). Reduce both- // to a list of basenames so the card can render the same chip regardless.- const fromFilenames = Array.isArray(i.loraFilenames) ? i.loraFilenames : [];- const fromPaths = Array.isArray(i.loraPaths)- ? i.loraPaths.map((p) => (typeof p === 'string' ? p.split(/[\\/]/).pop() : ''))- : [];- const loraNames = (fromFilenames.length ? fromFilenames : fromPaths).filter(Boolean);+ const loraNames = (pickLoraFilenames(i) || []).filter(Boolean);// modelId display falls back through several sidecar shapes:// 1. modelId — local-runner sidecars (mflux/flux2/z-image/ernie)// 2. model — codex sidecars (older path), and future Gemini etc.@@ -60,11 +53,7 @@ export function normalizeImage(i) {}export function normalizeVideo(v) {- const fromFilenames = Array.isArray(v.loraFilenames) ? v.loraFilenames : [];- const fromPaths = Array.isArray(v.loraPaths)- ? v.loraPaths.map((p) => (typeof p === 'string' ? p.split(/[\\/]/).pop() : ''))- : [];- const loraNames = (fromFilenames.length ? fromFilenames : fromPaths).filter(Boolean);+ const loraNames = (pickLoraFilenames(v) || []).filter(Boolean);return {kind: 'video',key: `video:${v.id}`,diff --git a/client/src/components/media/normalize.test.js b/client/src/components/media/normalize.test.jsindex 2e51e73f40..73bacccbdd 100644--- a/client/src/components/media/normalize.test.js+++ b/client/src/components/media/normalize.test.js@@ -115,6 +115,40 @@ describe('getRenderConfigForItem - image', () => {});});+describe('normalize loraNames - snake_case sidecar coverage', () => {+ // MediaCard chips/search read `item.loraNames`; these must surface for+ // sidecars written in any of the four supported field shapes so the UI+ // doesn't silently drop LoRA badges for legacy / Python-written records.++ it('image: surfaces snake_case lora_filenames in loraNames', () => {+ const image = normalizeImage({+ filename: 'a.png',+ prompt: '',+ lora_filenames: ['lora-snake.safetensors'],+ });+ expect(image.loraNames).toEqual(['lora-snake.safetensors']);+ });++ it('image: surfaces snake_case lora_paths in loraNames as basenames', () => {+ const image = normalizeImage({+ filename: 'b.png',+ prompt: '',+ lora_paths: ['/abs/path/oldStyle.safetensors'],+ });+ expect(image.loraNames).toEqual(['oldStyle.safetensors']);+ });++ it('video: surfaces snake_case lora_filenames in loraNames', () => {+ const video = normalizeVideo({+ id: 'v1',+ filename: 'a.mp4',+ prompt: '',+ lora_filenames: ['lora-cinematic.safetensors'],+ });+ expect(video.loraNames).toEqual(['lora-cinematic.safetensors']);+ });+});+describe('getRenderConfigForItem - video', () => {it('reads camelCase sidecar fields directly', () => {const video = normalizeVideo({diff --git a/data/migrations/002-cd-evaluate-image-strength.js b/data/migrations/002-cd-evaluate-image-strength.jsnew file mode 100644index 0000000000..089d5841cc--- /dev/null+++ b/data/migrations/002-cd-evaluate-image-strength.js@@ -0,0 +1,87 @@+/**+ * Backfill the `imageStrength` surfacing block in cd-evaluate.md for+ * pre-existing installs.+ *+ * The Creative Director evaluator template gained a two-line block in+ * `data.sample/prompts/stages/cd-evaluate.md` that surfaces the per-scene+ * `imageStrength` knob (and a sentence in the retry-branch instructions+ * documenting how to adjust it). `setup-data.js` only copies prompt files+ * that don't yet exist in `data/`, so installs created before that change+ * never received the new block. Three regression tests in+ * `creativeDirectorPrompts.test.js` fail until the local copy catches up.+ *+ * This migration surgically inserts the two missing pieces ONLY when the+ * surrounding anchor text matches the pre-update content exactly — so a+ * user who has hand-edited the template won't have their work clobbered.+ * If anchors don't match, the migration logs a notice and exits cleanly;+ * the user can either merge the change in by hand or accept that the+ * three CD-evaluator tests stay red on their machine.+ *+ * Idempotent — re-runs are a no-op once the block is present.+ */++import { readFile, writeFile } from 'fs/promises';+import { join } from 'path';++const TEMPLATE_REL_PATH = 'data/prompts/stages/cd-evaluate.md';++// Insertion 1: scene-context block. Anchors are the two existing lines that+// bracket the insertion point. Both must match verbatim or we skip.+const ANCHOR_BEFORE_BLOCK = '- Strategy: {{scene.strategy}}\n';+const ANCHOR_AFTER_BLOCK = '- Retry count: {{scene.retryCount}} (max 3)\n';+const NEW_BLOCK_LINES =+ '{{#scene.hasImageStrength}}- Image strength: {{scene.imageStrength}} (0–1; higher = stick closer to source image){{/scene.hasImageStrength}}\n' ++ '{{^scene.hasImageStrength}}- Image strength: default (continuation: 0.85; otherwise renderer default){{/scene.hasImageStrength}}\n';++// Insertion 2: extend the retry-branch instructions with the imageStrength+// knob guidance. The pre-update sentence is the full anchor; replace it+// with the post-update sentence (which is a strict superset).+const RETRY_OLD = '**If the render misses the mark and retries are still available** (`retryCount < 3`): tweak the prompt and request a re-render. The server will run the new render and then send you back here for another evaluation.';+const RETRY_NEW = '**If the render misses the mark and retries are still available** (`retryCount < 3`): tweak the prompt and request a re-render. The server will run the new render and then send you back here for another evaluation. You may also adjust `imageStrength` (0.0–1.0) on i2v scenes — drop it (e.g. 0.85 → 0.6) when the seed image is dominating and the prompt isn\'t expressed; raise it (e.g. → 0.95) when continuation drifted too far from the prior scene. Omit `imageStrength` from the PATCH to leave it unchanged.';++export default {+ async up({ rootDir }) {+ const templatePath = join(rootDir, TEMPLATE_REL_PATH);+ const original = await readFile(templatePath, 'utf-8').catch((err) => {+ if (err.code === 'ENOENT') return null;+ throw err;+ });+ if (original == null) {+ console.log(`📄 ${TEMPLATE_REL_PATH} not present — skipping (fresh install will copy from data.sample)`);+ return;+ }++ let next = original;+ let changed = false;++ // Insertion 1: scene-context imageStrength lines.+ const alreadyHasBlock = next.includes('{{#scene.hasImageStrength}}');+ if (!alreadyHasBlock) {+ const anchorPair = ANCHOR_BEFORE_BLOCK + ANCHOR_AFTER_BLOCK;+ if (next.includes(anchorPair)) {+ next = next.replace(anchorPair, ANCHOR_BEFORE_BLOCK + NEW_BLOCK_LINES + ANCHOR_AFTER_BLOCK);+ changed = true;+ } else {+ console.log(`⚠️ ${TEMPLATE_REL_PATH}: scene-context anchors don't match the pre-update template — skipping the imageStrength block insertion. Hand-merge from data.sample/ if needed.`);+ }+ }++ // Insertion 2: retry-branch sentence extension.+ const alreadyHasRetryGuidance = next.includes('adjust `imageStrength`');+ if (!alreadyHasRetryGuidance) {+ if (next.includes(RETRY_OLD)) {+ next = next.replace(RETRY_OLD, RETRY_NEW);+ changed = true;+ } else {+ console.log(`⚠️ ${TEMPLATE_REL_PATH}: retry-branch sentence doesn't match the pre-update template — skipping the imageStrength guidance extension. Hand-merge from data.sample/ if needed.`);+ }+ }++ if (changed) {+ await writeFile(templatePath, next);+ console.log(`📝 ${TEMPLATE_REL_PATH}: backfilled imageStrength surfacing`);+ } else {+ console.log(`✅ ${TEMPLATE_REL_PATH}: already up-to-date, no changes needed`);+ }+ },+};