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 (codex): run fallback model on direct /api/runs path; don't pin onto user-override provider
[._.]/ Adam Eivyc99d23840203
diff --git a/PLAN.md b/PLAN.mdindex c8e7044855..698b0e7865 100644--- a/PLAN.md+++ b/PLAN.md@@ -182,6 +182,7 @@ Surfaced while building the sync-hygiene feature. Consciously scoped out of v1.## Deferred+- [ ] [runs-route-fallback-model-tests] **Add a route-level test harness for `POST /api/runs` fallback-model execution.** `server/lib/aiToolkit/routes/runs.js` now derives `runModel` from `runData.usedFallback`/`fallbackModel` so an API/TUI/CLI fallback runs the fallback's model rather than leaking the primary's request model. There is currently no route-test harness anywhere in the repo (no supertest, no httpMocks), so this path is only covered transitively via the `createRun`/`getFallbackProvider` unit tests. Stand up a minimal route harness (fake `runnerService` with spied `createRun`/`executeApiRun`/`executeCliRun`/`executeTuiRun`) and assert: (a) non-fallback runs pass the request `model` unchanged for all three types; (b) a fallback swap with a configured `fallbackModel` runs that model on API (3rd arg), TUI (cloned `defaultModel`), and CLI (cloned `defaultModel`); (c) a fallback swap with no pin runs the fallback provider's own `defaultModel`, never the primary's model id. Skipped here to avoid building a route harness from scratch inside a bugfix PR.- [ ] [consolidate-client-url-normalize] **Consolidate client-side URL normalization.** Three components prepend `https://` to a bare URL with near-identical logic: `normalizeUrl` in `client/src/components/brain/tabs/LinksTab.jsx`, the inline block in `client/src/components/QuickBrainCapture.jsx` (~line 34, with `URL_PATTERN`/`DOMAIN_PATTERN` regexes), and `client/src/components/brain/tabs/FeedsTab.jsx` (~line 50, no `git@` handling). Extract one `normalizeUrl`/`isUrl` pair to a shared `client/src/utils/` helper and migrate all three. Must preserve each one's subtly different behavior (FeedsTab ignores `git@`; QuickBrainCapture splits detection from normalization).- [ ] [brain-bucket-chip-reorder] **Drag-to-reorder chips *within* a bucket.** The Brain → Links bucket board (`client/src/components/brain/links/BucketBoard.jsx` + `BucketCard.jsx`) supports dragging a chip *between* buckets and reordering buckets, but not repositioning a chip within its own bucket — `bucketOrder` is only ever appended (max+1) on assign. Add intra-bucket position-aware drop (compute target index from the drop location, renumber `bucketOrder`, persist via `updateBrainLink`).- [ ] [hidream-qwen-loras-runner-consumers] **Wire HIDREAM/QWEN through `client/src/pages/Loras.jsx`.** `imageGenResolutions.js` was extended on 2026-05-28 (`compatibilityKey` now returns HIDREAM/QWEN as their own keys). Still pending: `client/src/pages/Loras.jsx` `RUNNER_LABELS` / `RUNNER_BG_COLORS` / Top-LoRA section list omit HIDREAM/QWEN so the LoRA picker shows them as unlabeled / no badge color.diff --git a/server/lib/aiToolkit/routes/runs.js b/server/lib/aiToolkit/routes/runs.jsindex 7b8f425d33..0967645f35 100644--- a/server/lib/aiToolkit/routes/runs.js+++ b/server/lib/aiToolkit/routes/runs.js@@ -46,10 +46,28 @@ export function createRunsRoutes(runnerService, options = {}) {const { runId, provider, metadata, timeout: effectiveTimeout } = runData;console.log(`🚀 Run created: ${runId}, provider type: ${provider.type}`);+ // When createRun proactively swapped to a fallback (the requested provider+ // was benched), the request `model` was resolved against the now-benched+ // PRIMARY and almost never exists on the fallback — running it would leak+ // a bad model id onto the fallback (the same bug as the staged-LLM path).+ // Use the fallback's configured model (or its own default) instead; for+ // non-fallback runs keep honoring the request `model`.+ const runModel = runData.usedFallback+ ? (runData.fallbackModel || provider.defaultModel || null)+ : model;+ // executeCliRun reads `provider.defaultModel` for `--model` injection, so a+ // fallback pin must be threaded in via a clone (mirrors the TUI branch and+ // promptRunner's `providerForRun`). Only on the fallback path — non-fallback+ // CLI runs keep their existing behavior of using the provider's own default+ // (the request `model` has never been threaded into CLI runs here).+ const cliProvider = (runData.usedFallback && runModel && runModel !== provider.defaultModel)+ ? { ...provider, defaultModel: runModel }+ : provider;+if (provider.type === 'cli') {runnerService.executeCliRun(runId,- provider,+ cliProvider,prompt,workspacePath,(data) => {@@ -65,7 +83,7 @@ export function createRunsRoutes(runnerService, options = {}) {runnerService.executeApiRun(runId,provider,- model,+ runModel,prompt,workspacePath,screenshots,@@ -80,10 +98,11 @@ export function createRunsRoutes(runnerService, options = {}) {// Honor the user-picked model from the Runs UI — `executeTuiRun` reads// `provider.defaultModel` for its `--model` injection, so without the// clone every TUI run would silently fall back to the provider's saved- // default even when the user picked something else. Matches the API- // branch's `model` parameter being passed through.- const effectiveProvider = model- ? { ...provider, defaultModel: model }+ // default even when the user picked something else. Uses `runModel` so a+ // fallback swap runs the fallback's model rather than leaking the+ // primary's request model onto the fallback.+ const effectiveProvider = runModel+ ? { ...provider, defaultModel: runModel }: provider;runnerService.executeTuiRun(runId,diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.jsindex 8458e96269..4c2bea2bfa 100644--- a/server/services/agentLifecycle.js+++ b/server/services/agentLifecycle.js@@ -238,6 +238,10 @@ export async function spawnAgentForTask(task) {if (userProvider) {emitLog('info', `Using user-specified provider: ${userProviderId}`, { taskId: task.id });provider = userProvider;+ // The fallback pin belonged to the fallback provider we just replaced —+ // it must not carry onto the user's explicitly chosen provider, which+ // gets its own normal model selection.+ fallbackModelPin = null;} else {emitLog('warn', `User-specified provider "${userProviderId}" not found, using active provider`, { taskId: task.id });}