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: 4 Copilot findings on v1.54.0 PR (iter 4)
[._.]/ Adam Eivy080be04e7cb6
diff --git a/client/src/services/apiWorldBuilder.js b/client/src/services/apiWorldBuilder.jsindex b270251fb9..20564b8305 100644--- a/client/src/services/apiWorldBuilder.js+++ b/client/src/services/apiWorldBuilder.js@@ -112,19 +112,21 @@ export const isInfluenceLockField = (key) => WORLD_INFLUENCE_LOCK_FIELDS.include// Build a refined influences object that honors per-list locks. Locked lists// take their value from `fallback` (the user's current draft / originals);// unlocked lists take from `fresh` (the LLM output), falling back to-// `fallback` when the LLM omitted that list. Used by handleExpand merge AND-// the server-side refine merge (mirrored). The refine modal's apply path-// uses different semantics (no fallback-on-empty) and inlines its own build.+// `fallback` only when the LLM omitted that list (key absent). An explicit+// `[]` is applied so the user can intentionally clear an unlocked list.+// Mirrors the server-side mergeInfluencesWithLocks in worldBuilder.js.export const mergeInfluencesWithLocks = (locked, fresh, fallback) => {const freshSafe = ensureInfluences(fresh);const fallbackSafe = ensureInfluences(fallback);+ const freshHasEmbrace = Array.isArray(fresh?.embrace);+ const freshHasAvoid = Array.isArray(fresh?.avoid);return {embrace: locked?.influencesEmbrace? fallbackSafe.embrace- : (freshSafe.embrace.length ? freshSafe.embrace : fallbackSafe.embrace),+ : (freshHasEmbrace ? freshSafe.embrace : fallbackSafe.embrace),avoid: locked?.influencesAvoid? fallbackSafe.avoid- : (freshSafe.avoid.length ? freshSafe.avoid : fallbackSafe.avoid),+ : (freshHasAvoid ? freshSafe.avoid : fallbackSafe.avoid),};};diff --git a/server/index.js b/server/index.jsindex c90ef51e39..78e7921a1f 100644--- a/server/index.js+++ b/server/index.js@@ -217,11 +217,15 @@ setProvidersToolkit(aiToolkit);setRunnerToolkit(aiToolkit, { dataDir: DATA_DIR, hooks: aiToolkitHooks });setPromptsToolkit(aiToolkit);-// Warm the providers file at startup so the codex-sentinel migration lands-// before any inbound request can race a concurrent write.-aiToolkit.services.providers.getAllProviders().catch(err => {+// Warm the providers file at startup so the codex-sentinel migration runs+// before any inbound request can hit the providers cache. Awaited so the+// migration write completes deterministically before request handlers+// start consulting providers state.+try {+ await aiToolkit.services.providers.getAllProviders();+} catch (err) {console.error(`❌ Failed to load providers at startup: ${err.message}`);-});+}// Swap the toolkit's generic executeCliRun for PortOS's variant that adds// CLI-provider-specific args building (Codex `exec -`, Gemini stdin piping,@@ -230,7 +234,21 @@ aiToolkit.services.providers.getAllProviders().catch(err => {// invocation conventions, not for security.import { executeCliRun as executeCliRunFixed } from './services/runner.js';aiToolkit.services.runner.executeCliRun = executeCliRunFixed;-console.log('🔧 Patched aiToolkit runner.executeCliRun with PortOS CLI variants');+// Also patch stopRun so it can terminate child processes started by the+// PortOS variant — those are tracked in `_portosActiveRuns`, not the+// toolkit's internal `activeRuns` map, so the stock stopRun returns false+// for live CLI runs.+const originalStopRun = aiToolkit.services.runner.stopRun.bind(aiToolkit.services.runner);+aiToolkit.services.runner.stopRun = async (runId) => {+ const portosActive = aiToolkit.services.runner._portosActiveRuns?.get(runId);+ if (portosActive) {+ if (portosActive.kill) portosActive.kill('SIGTERM');+ aiToolkit.services.runner._portosActiveRuns.delete(runId);+ return true;+ }+ return originalStopRun(runId);+};+console.log('🔧 Patched aiToolkit runner.executeCliRun + stopRun with PortOS CLI variants');// Note: prompts service is initialized automatically by createAIToolkit()diff --git a/server/services/worldBuilderExpand.js b/server/services/worldBuilderExpand.jsindex 657362cfac..938ad15304 100644--- a/server/services/worldBuilderExpand.js+++ b/server/services/worldBuilderExpand.js@@ -367,14 +367,18 @@ export async function expandWorldTemplate({parsed.compositeSheets || [],);// sanitizeInfluences enforces the same per-entry cap, list cap, and- // case-insensitive dedupe used everywhere else; falls back to the input- // influences when the LLM omits them so the user's pinned references- // don't silently disappear on the first expansion that misses the field.- const llmInfluences = sanitizeInfluences(parsed.influences);- const influencesOut =- llmInfluences.embrace.length || llmInfluences.avoid.length- ? llmInfluences- : safeInfluences;+ // case-insensitive dedupe used everywhere else. Distinguish "LLM omitted+ // influences entirely" (preserve the user's pinned references) from "LLM+ // returned an explicit {embrace:[],avoid:[]}" (apply — user asked to clear+ // them) by checking the raw input shape before sanitization.+ const llmInfluencesRaw = parsed.influences;+ const llmInfluences = sanitizeInfluences(llmInfluencesRaw);+ const influencesOut = (llmInfluencesRaw && typeof llmInfluencesRaw === "object")+ ? {+ embrace: Array.isArray(llmInfluencesRaw.embrace) ? llmInfluences.embrace : safeInfluences.embrace,+ avoid: Array.isArray(llmInfluencesRaw.avoid) ? llmInfluences.avoid : safeInfluences.avoid,+ }+ : safeInfluences;const perCat = Object.keys(categories).map((k) => `${k}=${categories[k]?.variations?.length || 0}`).join(" ");