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
address review (claude): migration for stale reference-watch readOnly, privacy-respecting favicon, TOCTOU race in BYOV install SSE, skip empty story-builder updateSeries
[._.]/ Adam Eivydd55b0be16ff
diff --git a/client/src/components/brain/links/bucketColors.js b/client/src/components/brain/links/bucketColors.jsindex 9c46e213ee..3844509750 100644--- a/client/src/components/brain/links/bucketColors.js+++ b/client/src/components/brain/links/bucketColors.js@@ -35,8 +35,17 @@ export function hostnameOf(url) {}}-/** Google favicon service URL for a link (64px), or null if no hostname. */+/**+ * Favicon URL for a link — fetched from the link's own origin so we don't leak+ * the user's saved-link hostnames to a third party (e.g. Google's favicon+ * service) on every render. The `LinkChip` already has an `onError` fallback+ * to a generic icon when `/favicon.ico` is missing.+ */export function faviconUrl(url) {- const host = hostnameOf(url);- return host ? `https://www.google.com/s2/favicons?domain=${host}&sz=64` : null;+ try {+ const u = new URL(url);+ return `${u.protocol}//${u.host}/favicon.ico`;+ } catch {+ return null;+ }}diff --git a/scripts/migrations/046-reference-watch-readonly-false.js b/scripts/migrations/046-reference-watch-readonly-false.jsnew file mode 100644index 0000000000..848a3e0a76--- /dev/null+++ b/scripts/migrations/046-reference-watch-readonly-false.js@@ -0,0 +1,78 @@+/**+ * Flip the persisted `reference-watch` `taskMetadata.readOnly` from `true` to+ * `false` on existing installs.+ *+ * Background: prior versions of PortOS shipped `DEFAULT_TASK_INTERVALS['reference-watch']`+ * with `taskMetadata: { readOnly: true }`. That value got persisted into+ * `data/task-schedule.json` on every load through `loadSchedule`'s deep-merge+ * + `saveSchedule` path. The v2 reference-watch prompt+ * (`PROMPT_VERSIONS['reference-watch'] = 2`) instructs the agent to APPEND+ * slug-tagged `[ref-watch-…]` checklist items to PLAN.md and commit them — but+ * `readOnly: true` causes `agentPromptBuilder.js` to inject a "do not modify+ * or commit files" guard into the system prompt, so the agent (correctly)+ * refuses to write anything. The weekly cron silently no-oped.+ *+ * The default has been flipped to `readOnly: false` in this release, but+ * `loadSchedule`'s taskMetadata deep-merge (server/services/taskSchedule.js:2521)+ * spreads the STORED metadata *over* the new default — so any install that+ * previously persisted `readOnly: true` retains the broken stored value and+ * the cron stays no-op even after the default flip.+ *+ * This migration patches `data/task-schedule.json`: when+ * `tasks['reference-watch'].taskMetadata.readOnly === true`, flip it to+ * `false`. A user who deliberately set it to a different value (string,+ * object, etc.) is left alone — we only rewrite the exact stale boolean the+ * old default would have written. Fresh installs are unaffected (file absent+ * → migration no-ops).+ *+ * Idempotent: a second run sees `readOnly: false` (or no entry) and exits+ * without writing.+ */++import { readFile, writeFile } from 'fs/promises';+import { join } from 'path';++const REL_PATH = 'data/task-schedule.json';++export default {+ async up({ rootDir }) {+ const path = join(rootDir, REL_PATH);+ const raw = await readFile(path, 'utf-8').catch((err) => {+ if (err.code === 'ENOENT') return null;+ throw err;+ });+ if (raw == null) {+ console.log(`📄 ${REL_PATH} not present — skipping (fresh install)`);+ return;+ }++ let config;+ try {+ config = JSON.parse(raw);+ } catch (err) {+ console.log(`⚠️ ${REL_PATH}: invalid JSON, skipping (${err.message})`);+ return;+ }++ const task = config?.tasks?.['reference-watch'];+ if (!task || typeof task !== 'object') {+ console.log(`✅ ${REL_PATH}: no stored 'reference-watch' task — nothing to migrate`);+ return;+ }++ const meta = task.taskMetadata;+ if (!meta || typeof meta !== 'object') {+ console.log(`✅ ${REL_PATH}: 'reference-watch' has no stored taskMetadata — nothing to migrate`);+ return;+ }++ if (meta.readOnly !== true) {+ console.log(`✅ ${REL_PATH}: 'reference-watch' taskMetadata.readOnly already not-true, no changes`);+ return;+ }++ meta.readOnly = false;+ await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);+ console.log(`📝 ${REL_PATH}: flipped 'reference-watch' taskMetadata.readOnly true → false (v2 prompt needs write access to PLAN.md)`);+ },+};diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex 9b2113faba..8b1ad774e1 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -236,18 +236,26 @@ router.get('/setup/runtime-install', asyncHandler(async (req, res) => {send({ type: 'error', message: `Unknown runtime: ${runtime}` });return safeEnd();}+ // Claim the in-flight slot SYNCHRONOUSLY, before any await. Two near-+ // simultaneous SSE requests would otherwise both reach the readiness await+ // on line below, both observe `!ready`, and both spawn `setup-image-video.sh`+ // against the same target dir — racing two git clones / pip installs.+ // Placeholder (`null`) gets replaced with the real child handle once spawned;+ // every early-return path below releases the slot.+ if (runtimeInstallInFlight.has(info.id)) {+ send({ type: 'error', message: `Another ${info.label} install is already running. Wait for it to finish or restart PortOS.` });+ return safeEnd();+ }+ runtimeInstallInFlight.set(info.id, null);// Skip ONLY when both the binary AND the import probe pass. A venv with a// python binary but no torch is the partial-install case the user is// explicitly re-triggering us to fix — short-circuiting would strand them.if (isByovRuntimeInstalled(info.id) && await isByovRuntimeReady(info.id)) {+ runtimeInstallInFlight.delete(info.id);send({ type: 'log', message: `${info.label} already installed at ${info.venvPython}` });send({ type: 'complete', message: 'Already installed — nothing to do.' });return safeEnd();}- if (runtimeInstallInFlight.has(info.id)) {- send({ type: 'error', message: `Another ${info.label} install is already running. Wait for it to finish or restart PortOS.` });- return safeEnd();- }// The install may add/remove packages; drop any cached "ready" so the// post-install /runtime-status response reflects the new state instead of// a stale "true" from before a deliberate cleanup.@@ -255,6 +263,7 @@ router.get('/setup/runtime-install', asyncHandler(async (req, res) => {const scriptPath = join(PATHS.root, 'scripts', 'setup-image-video.sh');if (!existsSync(scriptPath)) {+ runtimeInstallInFlight.delete(info.id);send({ type: 'error', message: `Installer script not found at ${scriptPath}` });return safeEnd();}diff --git a/server/services/storyBuilder.js b/server/services/storyBuilder.jsindex 816eda3d97..96d5c1c78e 100644--- a/server/services/storyBuilder.js+++ b/server/services/storyBuilder.js@@ -461,7 +461,7 @@ export async function generateStep(id, stepId, options = {}) {if (logline && !universe?.locked?.logline) patch.logline = logline;await updateUniverse(session.universeId, patch);}- if (session.seriesId) {+ if (session.seriesId && (logline || expandedIdea)) {await updateSeries(session.seriesId, { ...(logline ? { logline } : {}), ...(expandedIdea ? { premise: expandedIdea } : {}) });}return { result: content, runId, providerId, model };