Skip to content

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

refactor: make the runtime manage-page one source of truth, not three copies

[._.]/ Adam Eivyf3efc272e9aa
diff --git a/client/src/components/cos/ReviewerPicker.jsx b/client/src/components/cos/ReviewerPicker.jsx
index 9fc7f44ac5..aafd5fb08c 100644
--- a/client/src/components/cos/ReviewerPicker.jsx
+++ b/client/src/components/cos/ReviewerPicker.jsx
@@ -19,18 +19,19 @@ import ProviderModelSelector from '../ProviderModelSelector';
import { selectableModelsForProvider, effortLevelsForProvider, effectiveModelFor } from '../../utils/providers';
import { isProviderReviewer, normalizeReviewerSlug } from '../../lib/reviewerPins';
import { getNavPageForPath } from '../../../../server/lib/navManifest.js';
+// The SAME map the readiness cards link by (`LOCAL_RUNTIMES[*].manageUrl` reads
+// from it), taken from the server leaf rather than mirrored — the mirror is what
+// #7414 had to chase. Imported here because these hints must name the page that
+// actually manages each backend: Ollama and LM Studio are pulled and started
+// from the Model Library, while MTPLX's server and checkpoints are a Runtimes
+// card.
+import { LOCAL_RUNTIME_MANAGE_URLS } from '../../../../server/lib/modelPinMembership.js';
-// Where each local-LLM reviewer's backend is actually managed. #7414 split the
-// model SERVERS (Models → Runtimes) from the weights catalog (Models → LLMs),
-// and these three land on either side of it: Ollama and LM Studio are pulled
-// and started from the Model Library, while MTPLX's server and its checkpoints
-// are a Runtimes card. The empty-state hints below name the page by resolving
-// the route, so a future move re-words them instead of stranding a breadcrumb.
-const LOCAL_BACKEND_MANAGE_PATHS = {
- ollama: '/models/llms',
- lmstudio: '/models/llms',
- mtplx: '/models/llms-runtimes',
-};
+// Resolved once at module load, not per render: the routes are constants, and
+// only the (usually absent) empty-state hint reads the result.
+const LOCAL_BACKEND_MANAGE_PAGES = Object.fromEntries(
+ Object.entries(LOCAL_RUNTIME_MANAGE_URLS).map(([id, path]) => [id, getNavPageForPath(path)?.breadcrumb]),
+);
const normalizeReviewerValue = (value) => normalizeReviewerSlug(value);
@@ -556,7 +557,7 @@ export default function ReviewerPicker({
// doesn't accuse a healthy backend of being empty.
const renderModelCell = (token) => {
if (!MODEL_SELECTABLE_REVIEWERS.includes(token) && !isProviderReviewer(token)) return renderNoPinCell(`${labelFor(token)} takes no model`);
- const backendPage = getNavPageForPath(LOCAL_BACKEND_MANAGE_PATHS[token])?.breadcrumb;
+ const backendPage = LOCAL_BACKEND_MANAGE_PAGES[token];
const subject = labelFor(token);
const pinnedValue = models.get(token);
const value = pinnedValue ?? '';
diff --git a/client/src/components/settings/LocalLlmRuntimesView.jsx b/client/src/components/settings/LocalLlmRuntimesView.jsx
index d663e0b5ac..14963aecc0 100644
--- a/client/src/components/settings/LocalLlmRuntimesView.jsx
+++ b/client/src/components/settings/LocalLlmRuntimesView.jsx
@@ -26,9 +26,6 @@ import { LOCAL_LLM_BACKENDS as BACKENDS, localLlmBackendLabel as labelFor } from
// is already on disk, and how to fetch it. A client-side copy would inevitably
// list a path the Download button had no source for.
const DEFAULT_SPEC_PRESET_ID = 'qwen3.8-27b-dspark';
-// Exported so a test can assert the panel's `aria-labelledby` resolves to a real
-// element rather than re-typing the literal on both sides of the assertion.
-export const RUNTIMES_HEADING_ID = 'llm-runtimes-heading';
const downloadKey = (presetId, role) => `${presetId}:${role}`;
// Each entry carries its own `role`, so the rows come straight off the preset
// rather than from a second copy of the role list.
@@ -67,8 +64,8 @@ function summarizeMigrate(r) {
}
// Install, start, stop and configure the local servers that run language models.
-// Mounted only while the Runtimes pill is selected, so every socket subscription
-// and poll below belongs to a visible surface.
+// Its own Models tab since #7414 (`/models/llms-runtimes`), so every socket
+// subscription and poll below belongs to a page the user is actually looking at.
export default function LocalLlmRuntimesView() {
const [llamaStatus, setLlamaStatus] = useState(null);
const [mtplxStatus, setMtplxStatus] = useState(null);
@@ -649,14 +646,14 @@ export default function LocalLlmRuntimesView() {
};
return (
- <section id="llm-runtimes-panel" role="tabpanel" aria-labelledby={RUNTIMES_HEADING_ID} className="space-y-4">
+ <section id="llm-runtimes-panel" role="tabpanel" aria-labelledby="llm-runtimes-heading" className="space-y-4">
{/* The panel names itself. It used to borrow `tab-runtimes` from the LLMs
pill bar, but #7414 made Runtimes a section tab, and `RouteTabsHeader`
passes no `controlsIdPrefix` — so that id stopped existing and the
labelledby dangled, leaving the panel unnamed. A heading of its own
survives whatever tab bar happens to be above it. Visually hidden
because the section header already shows "Models → Runtimes". */}
- <h2 id={RUNTIMES_HEADING_ID} className="sr-only">Runtimes</h2>
+ <h2 id="llm-runtimes-heading" className="sr-only">Runtimes</h2>
{/* One start/stop/install surface for every local server PortOS can run */}
<RuntimeServersCard
status={status}
diff --git a/client/src/components/settings/LocalLlmRuntimesView.test.jsx b/client/src/components/settings/LocalLlmRuntimesView.test.jsx
index 248c72383b..3d95fa2696 100644
--- a/client/src/components/settings/LocalLlmRuntimesView.test.jsx
+++ b/client/src/components/settings/LocalLlmRuntimesView.test.jsx
@@ -66,7 +66,7 @@ import {
} from '../../services/api';
import socket from '../../services/socket';
import { clickStartDownload } from '../../test/downloadPreflightConfirm.js';
-import LocalLlmRuntimesView, { RUNTIMES_HEADING_ID } from './LocalLlmRuntimesView.jsx';
+import LocalLlmRuntimesView from './LocalLlmRuntimesView.jsx';
import {
appleGpuBudgetGib,
hardwareLlmRecommendation,
@@ -141,7 +141,6 @@ describe('LocalLlmRuntimesView information architecture', () => {
await renderRuntimes();
const panel = screen.getByRole('tabpanel');
- expect(panel).toHaveAttribute('aria-labelledby', RUNTIMES_HEADING_ID);
const label = document.getElementById(panel.getAttribute('aria-labelledby'));
expect(label).not.toBeNull();
expect(label.tagName).toBe('H2');
diff --git a/client/src/components/settings/LocalLlmTab.test.jsx b/client/src/components/settings/LocalLlmTab.test.jsx
index e6ae2857b1..26eb070226 100644
--- a/client/src/components/settings/LocalLlmTab.test.jsx
+++ b/client/src/components/settings/LocalLlmTab.test.jsx
@@ -61,7 +61,6 @@ describe('LocalLlmTab view dispatch', () => {
it('no longer advertises Runtimes as one of its pills', () => {
renderTab();
- expect(screen.queryByRole('tab', { name: 'Runtimes' })).not.toBeInTheDocument();
expect(screen.getAllByRole('tab').map((t) => t.textContent)).toEqual(['Model Library', 'Abuse Guard']);
});
diff --git a/client/src/components/settings/LocalPersistentMindSetupCard.jsx b/client/src/components/settings/LocalPersistentMindSetupCard.jsx
index c3d388eced..61219a169b 100644
--- a/client/src/components/settings/LocalPersistentMindSetupCard.jsx
+++ b/client/src/components/settings/LocalPersistentMindSetupCard.jsx
@@ -20,6 +20,8 @@ import {
Sparkles,
Wand2,
} from 'lucide-react';
+import { LOCAL_RUNTIME_MANAGE_URLS } from '../../../../server/lib/modelPinMembership.js';
+import { getNavPageForPath } from '../../../../server/lib/navManifest.js';
import Banner from '../ui/Banner';
import BrailleSpinner from '../BrailleSpinner';
import toast from '../ui/Toast';
@@ -38,6 +40,14 @@ const STEP_ICON = {
skipped: CheckCircle2,
};
+// The Ollama weights catalog, named by its own route rather than by a typed
+// breadcrumb — this card sits on Models → Runtimes now, so the two pages have
+// to stay distinguishable, and #7414 is the proof that a literal drifts.
+const CATALOG_PAGE = {
+ to: LOCAL_RUNTIME_MANAGE_URLS.ollama,
+ label: getNavPageForPath(LOCAL_RUNTIME_MANAGE_URLS.ollama)?.breadcrumb || 'Model catalog',
+};
+
export default function LocalPersistentMindSetupCard({
className = '',
compact = false,
@@ -263,7 +273,7 @@ export default function LocalPersistentMindSetupCard({
: <span className="text-gray-500">Complete install / start / pull, then enable the provider.</span>}
<Link to="/ai" className="text-port-accent hover:underline">AI Providers</Link>
<Link to="/cos/mind" className="text-port-accent hover:underline">Persistent Mind</Link>
- <Link to="/models/llms" className="text-port-accent hover:underline">Models → LLMs → Model Library</Link>
+ <Link to={CATALOG_PAGE.to} className="text-port-accent hover:underline">{CATALOG_PAGE.label}</Link>
</div>
</section>
);
diff --git a/client/src/pages/Models.test.jsx b/client/src/pages/Models.test.jsx
index 988d9767a0..a1d4a6f9f4 100644
--- a/client/src/pages/Models.test.jsx
+++ b/client/src/pages/Models.test.jsx
@@ -14,7 +14,7 @@ import { TABS } from '../components/models/ModelsTabsHeader';
vi.mock('../components/settings/LocalModelAssessments.jsx', () => ({ default: () => <div>assessments panel</div> }));
vi.mock('../components/settings/LocalLlmTab', () => ({
- LocalLlmTab: ({ view }) => <div data-testid="llms-view" data-view={view || 'library'}>llms panel</div>,
+ LocalLlmTab: ({ view }) => <div data-testid="llms-view" data-view={view || 'none'}>llms panel</div>,
}));
vi.mock('../components/settings/LocalLlmRuntimesView.jsx', () => ({ default: () => <div>runtimes panel</div> }));
vi.mock('../components/settings/EmbeddingsTab', () => ({ default: () => <div>embeddings panel</div> }));
@@ -141,14 +141,10 @@ describe('Models', () => {
});
describe('Models — tab drill-downs', () => {
- // #7414 moved Runtimes out of the pill bar. The bare LLMs route now lands on
- // Model Library — the runtimes default would otherwise render a view the tab
- // no longer serves — and Runtimes has its own tab, not a sub-route.
- it('defaults the bare LLMs route to Model Library, not the departed runtimes view', async () => {
- renderAt('/models/llms');
- expect(await screen.findByTestId('llms-view')).toHaveAttribute('data-view', 'library');
- });
-
+ // #7414 moved Runtimes out of the pill bar and onto its own tab. Which view
+ // the bare `/models/llms` route falls back to is LocalLlmTab's contract and is
+ // asserted there; what this page owes is that Runtimes no longer routes
+ // THROUGH the LLMs dispatcher at all.
it('serves Runtimes as its own tab rather than an LLMs sub-view', async () => {
renderAt('/models/llms-runtimes');
expect(await screen.findByText('runtimes panel')).toBeInTheDocument();
diff --git a/server/lib/README.md b/server/lib/README.md
index e277c1b566..1eba26b983 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -210,7 +210,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `providerVendors.js` | `PROVIDER_VENDORS` — one row per coding-agent CLI/TUI vendor (claude/codex/antigravity/opencode/grok/kimi/cursor, plus a deliberately-incomplete legacy `gemini-cli` row), consumed by every dispatch site that used to hand-roll its own vendor if-chain across ~8 branches in 5 files (#3618): `applyCommandDefaults`/`prepareCliPrompt` (re-exported from `tuiHandshake.js`/`cliProviderArgs.js`), `buildVendorCliArgs`/`buildVendorSpawnConfig` (consumed by `cliProviderArgs.js#buildCliArgs` / `agentCliSpawning.js#buildCliSpawnConfig`), `inferTuiCommand` (re-exported from `tuiHandshake.js`), and `injectTuiModelAndEffort` — the shared antigravity-validates-the-pair-vs-everyone-else `--model`/`--effort` injection used by both `tuiHandshake.js#buildTuiInvocation` and `agentTuiSpawning.js#buildTuiSpawnConfig`, replacing a second copy of that split that had already drifted once before this file existed. Doesn't rewrite any vendor's argv-building logic — that stays in `antigravity.js`/`grok.js`/`kimi.js`/`cursor.js`/`codex.js`. Dependency-light on purpose, mirroring those files. |
| `publicReviewSpawnGate.js` | The ordered spawn-time preconditions a public-content review stage must clear before `runAgentSpawn` starts an agent for it — `checkPublicReviewSpawnPreconditions` returns the FIRST failing gate as `{ reason, category, emit }` (or null), running them in the order that is the contract: `publicReviewScanBlock` (the model-abuse scan cleared at least one PR), `publicReviewEligibilityBlock` (a complete eligibility verdict COVERING every PR the issue watcher saw — a partial gate is not a pass), `publicReviewProviderBlock` from `providerVendors.js` (the vendor row declares a maintained recipe for the requested posture; it owns the ordinary-task `null` posture, the re-derivation #5866 got wrong), then the model itself. `emit` tells the caller how to announce it: `warn-log` for the two fail-closed CONTENT gates, whose block must not raise an investigator that could retry the same unvalidated input, `agent:error` for a provider/model misconfiguration that should. `validateModel` is injected rather than imported — it is the one gate that probes a live runtime, so taking it as a parameter keeps this leaf out of the local-LLM graph and makes the gate ORDER testable with a stub. |
| `modelCapabilityTests.js` | Catalog + scoring for the CAPABILITY tests on `/models/performance` (run by `services/modelCapabilityTests.js`): `CAPABILITY_TESTS` (sandbox repair / image analysis / story outline / fiction scene / rhetoric evaluator, each gated on the capability badges the install catalog already shows), `applicabilityFor` + `applicableTests` (`applicable` / `not-applicable` / `unknown` — an UNCLAIMED capability is never a failure, and `null` capabilities mean the runtime reported none, which is distinct from `[]`), `scoreKeywords` + `VISION_FIXTURE_KEYWORDS` (required vs bonus terms, word-boundary matched with a negation guard so "no dog" doesn't score a dog), `scoreStoryBeats` + `HEROS_JOURNEY_BEATS` (coverage AND ordering, judged only over the beats present), `scoreSandboxRepair` (verdict from observed disk facts — editing the test instead of the module fails outright), `formatAgentEvent` (one agent stream frame → a transcript line), `rollUpVerdict`, and the verbatim `CAPABILITY_TEST_PROMPTS` / `SANDBOX_TASK_PROMPT` the consent gate shows. Pure, so any stored transcript can be re-scored with no provider call. |
-| `modelPinMembership.js` | THE model-pin membership rule, and the local-daemon classification it rests on — `modelPinIsOffered(provider, model)` (may this provider be handed this model? a configured-default sentinel, an empty catalog and a local daemon's cached snapshot are all pass-throughs, so a freshly pulled Ollama model is never rejected as "not offered"; beyond those the match is exact, with two same-model-spelled-differently tolerances: agy compares on BASE ids, since `--effort` carries the tier and the spawner splits a suffixed pin into exactly that, and OpenCode's `namespace/model` form matches a bare pin, since pins are stored bare and namespaced at spawn), plus `localRuntimeKind(provider)` (the `*Backed` markers first, then the endpoint/name classifier; `orcarouter` excluded as a remote API) and `localBackendForProvider`. Split out of `localProviderRuntime.js` — which re-exports all three, so existing importers are untouched — because the browser needs this rule for a picker and must not pull that module's endpoint graph (`opencodeConfig.js` → `zod`, not a client dependency) to get it. Consumed by `cliProviderRun.js`, `routes/brainSettings.js`, `services/agentProviderResolution.js`, `modelPinReconcile.js` and `client/src/utils/providerModels.js` — one answer for all five (#7327). |
+| `modelPinMembership.js` | THE model-pin membership rule, and the local-daemon classification it rests on — `modelPinIsOffered(provider, model)` (may this provider be handed this model? a configured-default sentinel, an empty catalog and a local daemon's cached snapshot are all pass-throughs, so a freshly pulled Ollama model is never rejected as "not offered"; beyond those the match is exact, with two same-model-spelled-differently tolerances: agy compares on BASE ids, since `--effort` carries the tier and the spawner splits a suffixed pin into exactly that, and OpenCode's `namespace/model` form matches a bare pin, since pins are stored bare and namespaced at spawn), plus `localRuntimeKind(provider)` (the `*Backed` markers first, then the endpoint/name classifier; `orcarouter` excluded as a remote API) and `localBackendForProvider`. Split out of `localProviderRuntime.js` — which re-exports all three, so existing importers are untouched — because the browser needs this rule for a picker and must not pull that module's endpoint graph (`opencodeConfig.js` → `zod`, not a client dependency) to get it. Carries `LOCAL_RUNTIME_MANAGE_URLS` for the same reason (#7414): the route that manages each local runtime — Models → Runtimes for the servers, Models → LLMs for the weights catalog, `null` for the operator-owned compose projects — read by `LOCAL_RUNTIMES[*].manageUrl` and by the client surfaces that must name the same page. Consumed by `cliProviderRun.js`, `routes/brainSettings.js`, `services/agentProviderResolution.js`, `modelPinReconcile.js` and `client/src/utils/providerModels.js` — one answer for all five (#7327). |
| `modelPinReconcile.js` | Retired-model-pin AUDIT over the shared membership rule (#7315) — `providerCatalogListsModel(provider, modelId)` (is a stored pin still served? `modelPinIsOffered` from `modelPinMembership.js` verbatim, plus the one case a retirement check answers differently from a spawn-time one: nothing is pinned at all. The agy base-id and OpenCode namespace tolerances used to be layered HERE above a stricter rule, which made the audit and the three spawn-time callers disagree about the same pin; they moved down into the rule in #7327), `catalogOfferings` (the listed ids with sentinels dropped, agy collapsed to base ids for a picker), `reconcileModelPins(pins, providers)` — which pin descriptors name a model their provider no longer lists — and, since #7339, the two helpers that make a pin's provider field singular-or-plural-agnostic: `pinProviderIds(pin)` (THE coercion from `providerId` / `providerIds` to a trimmed id list, called by the audit's descriptor builder too so the two layers cannot drift) and `pinProviderNames(pin, providers)` (how a surface names those records — shared by the warnings panel and the notification card so they cannot describe one pin differently). A reviewer pin names a BINARY several records front, so it is stale only when EVERY named record stops listing the model. Every UNKNOWN case (no pin, empty catalog, unresolved provider) answers "still listed": a false "your pin is gone" tells the user to change a setting that works. Derived on read, never persisted — see `services/modelPinAudit.js`. |
| `reviewerProviderMatchers.js` | Which PROVIDER RECORDS front each model-taking reviewer's binary — `REVIEWER_PROVIDER_MATCHERS` (slug → record predicates, in preference order), `providersForReviewer(reviewer, providers)` (every match, de-duped, preference-ordered so `[0]` is the record whose default a picker shows) and `reviewerProviderIds`. A reviewer slug names a BINARY and PortOS ships more than one record per binary (`claude` spans `claude-code` + `claude-code-tui`, `grok` spans `grok-cli` + its TUI), so both the picker's option list and the retired-pin audit union every match: sourcing from one record makes the answer hostage to that record's staleness, and judging a pin against one produces a false retirement for a model the other still lists. Deliberately excludes Bedrock/Vertex and the `opencode-<backend>` presets (ids that resolve only under another record's environment). Imported directly by `client/src/hooks/useReviewerModelOptions.js` — one table, no mirror to drift (#7339). |
| `modelPricing.js` | Per-model API billing rates for the /devtools/usage cost estimates — `resolveModelRates(providerId, model)` (exact → family regex → provider default → blended fallback, with a `matched` tier; also derives `cacheReadPer1M`/`cacheWritePer1M` from the input rate via per-family multipliers), `isFreeProvider` (ollama/lmstudio/`ollamaBacked`/localhost = free), `estimateCostUsd(tokensIn, tokensOut, rates, cache?)` — `tokensIn` is UNCACHED input; cache tiers are priced separately via the optional 4th arg — and `PRICING_AS_OF`. Informational only (PortOS runs on subscriptions); still excludes batch/long-context tiers. |
@@ -490,7 +490,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `migrationMarker.js` | Shared marker-file helpers for one-time migration/repair/reconcile scripts — `markerExists(filename)` (boolean gate), `readMarker(filename)` (parsed payload or null), `writeMarker(filename, payload)` (atomic write). All anchor `filename` under `PATHS.data` and use `tryReadFile`/`atomicWrite` so a crash can't leave a truncated marker. |
| `goalFeatureMap.js` | Deterministic goal `category` → PortOS feature-area map (deep-links sourced from `NAV_COMMANDS`). `getGoalFeatureAreas(goal)` honors the per-goal `featureAreas` override, else the category default. Mirrored byte-for-byte to `client/src/lib/`. |
| `goalFidelity.js` | Goal-fidelity review contract (#5994) — the value half of "does this diff deliver what was asked?", the question the quality-review chain structurally cannot answer because it never sees the request. `GOAL_FIDELITY_VERDICTS` (`ship` / `fix-first` / `rethink`, only `rethink` gating a run via `goalFidelityHoldsRun`), `taskObjective(task)` (the trusted operator-authored objective — the TASK's description + prompt block, never the agent's transcript, since a reviewer handed the transcript inherits the assumptions that produced the drift), `resolveGoalFidelityConfig(codeReview, chain)` (enabled/backend/model/effort, restricted to the local-LLM reviewers PortOS can call server-side and falling back to the quality chain's own local reviewer + its `<backend>Model`/`Effort` scalars), `normalizeGoalFidelityVerdict(parsed)` (`null` = nothing judged the run, never collapsed into a `ship` pass or a `rethink` hold) and `formatGoalFidelitySummary(review)`. `MAX_OBJECTIVE_CHARS` / `MAX_FIDELITY_DIFF_CHARS` bound what crosses into a fixed-window local model. Pure. |
-| `navManifest.js` | Single source of truth for nav (`⌘K` palette + voice). Add an entry when you add a page. |
+| `navManifest.js` | Single source of truth for nav (`⌘K` palette + voice). Add an entry when you add a page. Also `getNavPageForPath(pathname)` → `{ label, section, breadcrumb }` for the most specific command that owns a route (`null` for one nothing declares) — how user-facing copy NAMES a page it links to, instead of typing "Models → LLMs" beside the link and stranding it on the next move (#7414). |
| `noReplaceMove.js` | `moveWithoutReplace(from, to)` — publish a staged file into its final name WITHOUT ever clobbering an existing one. `fs.rename` silently replaces its destination, which is the wrong default for a derived artifact; this uses `link(2)` + `unlink(2)`, so an existing destination fails atomically with `MOVE_DEST_EXISTS` and both files survive. Refuses rather than degrading when the filesystem cannot express it (`MOVE_CROSS_DEVICE`, `MOVE_NO_REPLACE_UNSUPPORTED`) — a `stat`-then-`rename` fallback would be a race. Used by the rigging publication contract (`services/rigging/autoSkin.js`). |
| `personaTraitBlend.js` | Digital-twin persona trait-blending (M34 P7). Blends a persona's `traitAdjustments` against the base twin's communication profile + Big-Five into a "Communication Calibration" directive. A pure leaf — `client/src/lib/personaTraitBlend.js` re-exports it for the Personas UI preview. |
| `textUtils.js` | Pure dependency-free prose helpers. `isStr(v)` and `isNonBlankStr(v)` are the ONLY string predicates under `server/` (#6837) — the bare type check, and type check plus a non-empty `trim()` for ids, keys, hosts, model names and prose fields where whitespace-only is already invalid; the "no private string predicate or bounder" guard in `textUtils.test.js` fails the suite when a copy of either, or a `trimTo`-shaped bounder, is re-declared in any non-test source under `server/` or any source under `client/src/` (`client/src/lib/textUtils.js` re-exports both for the browser bundle). `countWords(text)` is the canonical whitespace-token count (`\S+`) and the only one — every server word count (Writers Room, lettering density, rapid reader, autobiography, script-video beats) and the client's (`client/src/lib/textUtils.js` re-exports it) resolve here, and the "no private countWords" guard in `textUtils.test.js` fails the suite when a re-spelled count (the whitespace-token match, a split-and-filter, or a helper under either conventional name) reappears in any non-test source under `server/` or any source under `client/src/`; the editorial prose-analysis checks deliberately count LETTER words instead, through `editorial/proseTics.js#tokenizeWords`, which owns that tokenizer the same way; `trimTo(value, max)` trims and bounds strings without coercing non-strings, and is safe for shared modules consumed by the browser; `escapeRegExp(value)` is the one to import instead of re-inlining the escape (the sibling guard in `textUtils.test.js` fails the suite when a copy reappears in any non-test source under `server/`, or in ANY source under `client/src/`, tests and `.jsx` included — `client/src/lib/textUtils.js` re-exports this module for the browser bundle); `trimToClause(v, max)` is its boundary-aware twin for PROSE fields — it backs off to the last sentence terminator, then the last clause boundary, then the last whole word, so a capped field never ends mid-thought (it lives here rather than in `storyBible.js`, which re-exports it, so the pure story-model leaves the browser bundle shares can cap prose without pulling `crypto` / `fileUtils`); `kebabCase(text)` is the canonical ASCII slug transform (PLAN.md `[slug]` ids and `planner:<model>` labels); `clampToCharLimit(text, max)` is `trimTo`'s reader-facing twin — it cuts on a sentence end (when one sits 60%+ into the allowance) or a word boundary rather than mid-word and returns `{ text, truncated }` so the caller can say the text was cut, which is what bounds an AI-enhanced render prompt to a backend's hard cap (reactor.inc fast-h3 rejects an over-length prompt outright). |
diff --git a/server/lib/localProviderRuntime.js b/server/lib/localProviderRuntime.js
index 743b9f8362..bb7fd3eaa4 100644
--- a/server/lib/localProviderRuntime.js
+++ b/server/lib/localProviderRuntime.js
@@ -33,7 +33,7 @@
import { isOpencodeCommand, parseOpencodeConfigContent } from './providerModels.js';
import { opencodeLocalBaseUrl } from './opencodeConfig.js';
-import { localRuntimeKind } from './modelPinMembership.js';
+import { localRuntimeKind, LOCAL_RUNTIME_MANAGE_URLS } from './modelPinMembership.js';
import { PORTS } from './ports.js';
import { isLocalInstanceEndpoint } from './localEndpoint.js';
@@ -42,7 +42,7 @@ export { isLocalInstanceHost, isLocalInstanceEndpoint, localEndpointPort } from
// browser-safe leaf `modelPinMembership.js` so a picker can share them without
// pulling this module's endpoint graph (`opencodeConfig.js` → `zod`, not a
// client dependency). Re-exported so every existing importer is untouched.
-export { localBackendForProvider, localRuntimeKind, modelPinIsOffered } from './modelPinMembership.js';
+export { localBackendForProvider, localRuntimeKind, modelPinIsOffered, LOCAL_RUNTIME_MANAGE_URLS } from './modelPinMembership.js';
/**
* One row per local runtime PortOS knows how to check for.
@@ -56,11 +56,17 @@ export { localBackendForProvider, localRuntimeKind, modelPinIsOffered } from './
* requirement links there rather than duplicating the install UI on the
* Providers page. It is NOT one page: since #7414, server lifecycle lives on
* Models → Runtimes and the weights catalog on Models → LLMs, and a runtime
- * points at whichever of the two actually manages it. Readiness copy names the
- * page by resolving this route through `navManifest.getNavPageForPath` rather
- * than repeating a breadcrumb, so a future move re-words every hint at once.
- * `null` means PortOS has no page for it — the readiness card's own setup
- * controls (or the vendor docs) are the whole story.
+ * points at whichever of the two actually manages it. Read from
+ * `LOCAL_RUNTIME_MANAGE_URLS` (`modelPinMembership.js`) rather than typed here,
+ * because the client needs the same answer and must not import this module's
+ * endpoint graph to get it. `null` means PortOS has no page for that runtime.
+ *
+ * `modelsHint` and `standbyDetail` are read by a user, so they name that page —
+ * but they write it as the `{page}` token, which `providerReadiness.js` expands
+ * through `navManifest.getNavPageForPath`. A literal breadcrumb here is what
+ * #7414 had to hand-edit across a dozen files; a token re-words itself on the
+ * next move. Runtimes whose `manageUrl` is `null` must not use the token —
+ * there is no page to name.
*/
export const LOCAL_RUNTIMES = Object.freeze({
llama: Object.freeze({
@@ -70,7 +76,7 @@ export const LOCAL_RUNTIMES = Object.freeze({
// `llamaServerManager` resolves and starts.
command: 'llama-server',
defaultBaseUrl: opencodeLocalBaseUrl('llama'),
- manageUrl: '/models/llms-runtimes',
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.llama,
docsUrl: 'https://github.com/ggml-org/llama.cpp',
// Named so an unmet check can say what the user still has to fetch. GGUF
// weights are a separate download from the binary — the single most common
@@ -95,23 +101,23 @@ export const LOCAL_RUNTIMES = Object.freeze({
// standby without turning every enabled llama-backed provider into a setup
// failure on the capability map.
standbyWhenStopped: true,
- standbyDetail: 'No model server is running, which is a valid idle state. Choose a GGUF preset in Models → Runtimes when you want to start one; with idle release configured, llama.cpp unloads it in place and reloads it on the next request.',
+ standbyDetail: 'No model server is running, which is a valid idle state. Choose a GGUF preset on {page} when you want to start one; with idle release configured, llama.cpp unloads it in place and reloads it on the next request.',
}),
ollama: Object.freeze({
id: 'ollama',
label: 'Ollama',
command: 'ollama',
defaultBaseUrl: opencodeLocalBaseUrl('ollama'),
- manageUrl: '/models/llms',
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.ollama,
docsUrl: 'https://ollama.com/download',
- modelsHint: 'Pull a model from Models → LLMs before an agent can use this provider.',
+ modelsHint: 'Pull a model from {page} before an agent can use this provider.',
}),
lmstudio: Object.freeze({
id: 'lmstudio',
label: 'LM Studio',
command: 'lms',
defaultBaseUrl: opencodeLocalBaseUrl('lmstudio'),
- manageUrl: '/models/llms',
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.lmstudio,
docsUrl: 'https://lmstudio.ai/download',
modelsHint: 'Download a model in LM Studio and start its local server.',
// No pre-spawn context preparation, unlike Ollama's
@@ -135,7 +141,7 @@ export const LOCAL_RUNTIMES = Object.freeze({
// No Models page at all — the weights and the compose project are an
// operator-owned ~20 GB prepare step, not something PortOS downloads, so
// the readiness checklist is the whole surface.
- manageUrl: null,
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.vllm,
docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/features/qwen38-rtx3090.md',
modelsHint: 'Clone syv-ai/qwen38-27b-rtx3090 and run its prepare step once — or let the checklist do it, which is the only path that spends the ~30 GB.',
// What each local-setup state MEANS for this runtime, overriding
@@ -161,7 +167,7 @@ export const LOCAL_RUNTIMES = Object.freeze({
defaultBaseUrl: opencodeLocalBaseUrl('sglang'),
// No Models page at all — the weights are an operator-owned ~20 GB
// download, not something PortOS fetches.
- manageUrl: null,
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.sglang,
docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/features/sglang-qwen38.md',
modelsHint: 'Save the compose file from docs/features/sglang-qwen38.md and download the weights once — PortOS never pulls the image or the ~20 GB of weights.',
// One container, one checkpoint; the recipe picks the quantized repo from
@@ -174,12 +180,12 @@ export const LOCAL_RUNTIMES = Object.freeze({
command: 'slotstream',
// Dedicated loopback port — never 11434, which is a PortOS-managed Ollama.
defaultBaseUrl: `http://127.0.0.1:${PORTS.SLOTSTREAM}/v1`,
- manageUrl: '/models/llms-runtimes',
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.slotstream,
docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/features/slotstream.md',
- modelsHint: 'A start never fetches weights — add a checkpoint on Models → Runtimes, then start Slotstream there.',
+ modelsHint: 'A start never fetches weights — add a checkpoint on {page}, then start Slotstream there.',
servesOneModel: true,
standbyWhenStopped: true,
- standbyDetail: 'No streaming runtime is running, which is a valid idle state. Start it from Models → Runtimes when you want a model larger than this machine\'s RAM; with idle release configured, PortOS stops it and starts it again on the next request.',
+ standbyDetail: 'No streaming runtime is running, which is a valid idle state. Start it from {page} when you want a model larger than this machine\'s RAM; with idle release configured, PortOS stops it and starts it again on the next request.',
}),
mtplx: Object.freeze({
id: 'mtplx',
@@ -192,7 +198,7 @@ export const LOCAL_RUNTIMES = Object.freeze({
// that is where a readiness card should send someone (#7414). The one-click
// setup on the checklist itself (`services/localRuntimeSetup.js`) remains
// the shortest path and still runs in place.
- manageUrl: '/models/llms-runtimes',
+ manageUrl: LOCAL_RUNTIME_MANAGE_URLS.mtplx,
docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/features/mtplx.md',
modelsHint: 'Point the server at the Qwen MTP checkpoint you want, or let the checklist fetch MTPLX\'s default one when nothing is cached.',
// One process, one checkpoint — MTPLX names it after the checkpoint it
diff --git a/server/lib/localProviderRuntime.test.js b/server/lib/localProviderRuntime.test.js
index a8c8206a89..2a764b78f9 100644
--- a/server/lib/localProviderRuntime.test.js
+++ b/server/lib/localProviderRuntime.test.js
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, afterEach } from 'vitest';
import {
LOCAL_RUNTIMES,
+ LOCAL_RUNTIME_MANAGE_URLS,
isLocalInstanceEndpoint,
localRuntimeForProvider,
normalizeOpenAiBaseUrl,
@@ -180,3 +181,49 @@ describe('localRuntimeForProvider', () => {
expect(runtime.endpoint).toBe('http://127.0.0.1:8000/v1');
});
});
+
+// #7414 split the runtimes off the LLMs page, and the hand-sweep that followed
+// is what these guards exist to prevent repeating: a breadcrumb typed into a
+// runtime row goes stale the next time a page moves, and nothing fails.
+describe('LOCAL_RUNTIMES — user-facing copy names its page by route, never by literal', () => {
+ const COPY_FIELDS = ['modelsHint', 'standbyDetail'];
+ const rows = Object.entries(LOCAL_RUNTIMES);
+
+ it('writes no breadcrumb into a runtime row', () => {
+ const offenders = rows.flatMap(([id, runtime]) => COPY_FIELDS
+ .filter((field) => typeof runtime[field] === 'string' && runtime[field].includes('→'))
+ .map((field) => `${id}.${field}`));
+ expect(offenders).toEqual([]);
+ });
+
+ // The token only expands for a runtime that HAS a page; on one with
+ // `manageUrl: null` it would ship as a literal `{page}` or as filler prose.
+ it('uses the {page} token only where a manage route can name a page', () => {
+ const offenders = rows.flatMap(([id, runtime]) => COPY_FIELDS
+ .filter((field) => typeof runtime[field] === 'string' && runtime[field].includes('{page}') && !runtime.manageUrl)
+ .map((field) => `${id}.${field}`));
+ expect(offenders).toEqual([]);
+ });
+
+ it('takes every manageUrl from the shared map the client reads', () => {
+ expect(Object.fromEntries(rows.map(([id, runtime]) => [id, runtime.manageUrl])))
+ .toEqual(LOCAL_RUNTIME_MANAGE_URLS);
+ });
+
+ it('points each runtime at the surface that actually manages it', () => {
+ // Server lifecycle is Models → Runtimes; the weights catalog is Models →
+ // LLMs. Pinned per runtime because getting ONE of these wrong is the whole
+ // bug — a checklist that links llama.cpp at the catalog is a dead end.
+ expect(LOCAL_RUNTIME_MANAGE_URLS).toEqual({
+ llama: '/models/llms-runtimes',
+ slotstream: '/models/llms-runtimes',
+ mtplx: '/models/llms-runtimes',
+ ollama: '/models/llms',
+ lmstudio: '/models/llms',
+ // Operator-owned compose projects: the readiness checklist is the only
+ // PortOS surface, so there is no page to link.
+ vllm: null,
+ sglang: null,
+ });
+ });
+});
diff --git a/server/lib/modelPinMembership.js b/server/lib/modelPinMembership.js
index bdfda363c6..284ef3d877 100644
--- a/server/lib/modelPinMembership.js
+++ b/server/lib/modelPinMembership.js
@@ -19,6 +19,35 @@ import { localRuntimeNamespace, isAntigravityProvider, isOpencodeProvider, antig
import { PORTS } from './ports.js';
import { isLocalInstanceHost, localEndpointPort } from './localEndpoint.js';
+/**
+ * Which PortOS page manages each local runtime — the single source for
+ * `LOCAL_RUNTIMES[*].manageUrl`, which reads from here.
+ *
+ * It lives in this leaf rather than in `localProviderRuntime.js` because the
+ * CLIENT needs it too: a reviewer picker that says "start it from …" has to
+ * name the same page the readiness card links to, and it cannot import the
+ * endpoint half (`opencodeConfig.js` → `zod`) to get one static string. Before
+ * #7414 every runtime shared one page, so a second copy was invisible; splitting
+ * Models → Runtimes off Models → LLMs made a stale copy name the wrong sibling.
+ *
+ * Server LIFECYCLE (install, start, stop, checkpoints) is Models → Runtimes;
+ * the Ollama / LM Studio WEIGHTS catalog is Models → LLMs. `null` means PortOS
+ * has no page for that runtime — vLLM and SGLang are operator-owned compose
+ * projects whose only PortOS surface is the readiness checklist.
+ *
+ * Callers turn a route into prose with `navManifest.getNavPageForPath`; never
+ * write the breadcrumb out by hand beside one of these.
+ */
+export const LOCAL_RUNTIME_MANAGE_URLS = Object.freeze({
+ llama: '/models/llms-runtimes',
+ ollama: '/models/llms',
+ lmstudio: '/models/llms',
+ vllm: null,
+ sglang: null,
+ slotstream: '/models/llms-runtimes',
+ mtplx: '/models/llms-runtimes',
+});
+
// Default OpenAI-compatible ports for the two local backends PortOS manages. An
// endpoint-only provider (no id/name) pointed at one of these on the local
// instance maps to that backend.
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index 8ee19418fd..b5956437bb 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -427,19 +427,33 @@ const pathContainsNavRoute = (pathname, routePath) => (
pathname === routePath || pathname.startsWith(`${routePath}/`)
);
-// Find the section whose tab owns a routed page. Longest-match keeps nested
-// views (for example `/models/llms/abuse`) on their parent tab, and intentionally
-// ignores workflow commands such as `/ai/fleet` that do not carry a `tabId`.
-export const getNavSectionForPath = (pathname) => {
+// Every command with its path pre-normalized, longest path first — so a route
+// lookup is one `.find()` down a fixed list instead of a normalize-filter-sort
+// of the whole manifest per call. `NAV_COMMANDS` is frozen at module load and
+// never mutated, so this cannot go stale.
+//
+// Longest-first IS the match rule: it keeps a drill-down (`/models/llms/abuse`)
+// on itself rather than on the parent whose prefix it also shares.
+const NAV_COMMANDS_BY_SPECIFICITY = NAV_COMMANDS
+ .map((command) => ({ command, routePath: normalizedNavPath(command.path) }))
+ .sort((a, b) => b.routePath.length - a.routePath.length);
+
+// The most specific command that OWNS a routed path, or `undefined`. `predicate`
+// narrows the candidate set; both exports below are this walk plus a projection,
+// so the ranking rule lives in exactly one place.
+const navCommandForPath = (pathname, predicate) => {
const normalizedPath = normalizedNavPath(pathname);
- return NAV_COMMANDS
- .filter((command) => command.tabId && !command.tabGroup && pathContainsNavRoute(
- normalizedPath,
- normalizedNavPath(command.path),
- ))
- .sort((a, b) => normalizedNavPath(b.path).length - normalizedNavPath(a.path).length)[0]?.section || null;
+ return NAV_COMMANDS_BY_SPECIFICITY
+ .find(({ command, routePath }) => predicate(command) && pathContainsNavRoute(normalizedPath, routePath))
+ ?.command;
};
+// Find the section whose tab owns a routed page, intentionally ignoring workflow
+// commands such as `/ai/fleet` that do not carry a `tabId`.
+export const getNavSectionForPath = (pathname) => (
+ navCommandForPath(pathname, (command) => command.tabId && !command.tabGroup)?.section || null
+);
+
// The page a route belongs to, as a user reads it in the UI: `label` is the tab
// name ("Runtimes"), `breadcrumb` is how the sidebar path to it is spoken and
// written ("Models → Runtimes").
@@ -451,15 +465,12 @@ export const getNavSectionForPath = (pathname) => {
// that links to `manageUrl` now NAMES whatever page that route resolves to, so
// the next move re-words all of them.
//
-// Longest-match, so a drill-down (`/models/llms/abuse`) reports its own page
-// rather than its parent's. Returns `null` for a path no command declares —
-// callers fall back to route-free wording rather than inventing a page name.
+// Unlike the section lookup this considers drill-downs too, so a nested view
+// reports its own page. Returns `null` for a blank path or one no command
+// declares — callers drop the clause rather than inventing a page name.
export const getNavPageForPath = (pathname) => {
- const normalizedPath = normalizedNavPath(pathname);
- if (normalizedPath === '/') return null;
- const command = NAV_COMMANDS
- .filter((c) => pathContainsNavRoute(normalizedPath, normalizedNavPath(c.path)))
- .sort((a, b) => normalizedNavPath(b.path).length - normalizedNavPath(a.path).length)[0];
+ if (normalizedNavPath(pathname) === '/') return null;
+ const command = navCommandForPath(pathname, () => true);
if (!command) return null;
return { label: command.label, section: command.section, breadcrumb: `${command.section} → ${command.label}` };
};
diff --git a/server/services/providerReadiness.js b/server/services/providerReadiness.js
index 7fe58d70fc..9c54b304fe 100644
--- a/server/services/providerReadiness.js
+++ b/server/services/providerReadiness.js
@@ -268,8 +268,21 @@ function weightsDetail(runtime, weights) {
* `null` for a runtime with no page (vLLM, SGLang) — callers drop the clause
* rather than inventing a destination.
*/
-const managePage = (runtime) => (
- runtime.manageUrl ? getNavPageForPath(runtime.manageUrl)?.breadcrumb || null : null
+const managePage = (runtime) => getNavPageForPath(runtime.manageUrl)?.breadcrumb ?? null;
+
+/**
+ * Expand the `{page}` token a runtime's user-facing copy writes instead of a
+ * breadcrumb (`localProviderRuntime.js`). Same reason as `managePage`: the
+ * sentence and the link it describes must name one page, decided by the route.
+ *
+ * A runtime with no page never uses the token, but fall back rather than ship a
+ * literal `{page}` if one ever slips in — `localProviderRuntime.test.js` is the
+ * guard that keeps that from happening quietly.
+ */
+const expandPageToken = (text, runtime) => (
+ typeof text === 'string' && text.includes('{page}')
+ ? text.replaceAll('{page}', managePage(runtime) || 'its management page')
+ : text
);
/** The `runtime` check — is the daemon's software here at all? */
@@ -299,9 +312,10 @@ function serverCheck(runtime, { installed, result, setup, weights = 'unknown' })
}
const page = managePage(runtime);
const start = `Start ${runtime.label}${page ? ` from ${page}` : ''}.`;
+ const modelsHint = expandPageToken(runtime.modelsHint, runtime);
const fallback = installed
- ? `${start} ${runtime.modelsHint}`
- : `Install ${runtime.label} first, then start it. ${runtime.modelsHint}`;
+ ? `${start} ${modelsHint}`
+ : `Install ${runtime.label} first, then start it. ${modelsHint}`;
// Name the blocker in the SAME line that says nothing answered. Otherwise the
// checklist reads "installed ✓ / not responding — just press Start", and
// Start is the thing that cannot work until the weights land.
@@ -421,6 +435,7 @@ function catalogCheck(runtime, offered, served, probeError = null, { weights = '
// either — otherwise the provider still runs, and only a stage that pinned one
// of these ids dies.
const nothingDispatchable = unserved.length === offered.length && !(pinned && served.includes(pinned));
+ const page = managePage(runtime);
const detail = nothingDispatchable
? `${runtime.label} serves none of them (${listed}${more}), so every run dispatched onto this provider fails before producing output.`
: `${runtime.label} does not serve ${listed}${more}, so a task or stage pinned to one of those fails at spawn.`;
@@ -429,7 +444,7 @@ function catalogCheck(runtime, offered, served, probeError = null, { weights = '
label,
ok: false,
detail,
- fixHint: `Refresh this provider's models so it only offers ids the server serves${managePage(runtime) ? `, or pull the missing ones from ${managePage(runtime)}.` : `. ${runtime.modelsHint}`}`,
+ fixHint: `Refresh this provider's models so it only offers ids the server serves${page ? `, or pull the missing ones from ${page}.` : `. ${expandPageToken(runtime.modelsHint, runtime)}`}`,
unservedModels: unserved,
};
}
@@ -507,7 +522,7 @@ export async function getProviderReadiness(provider, deps = {}) {
// available, but an installed model-selecting runtime is not missing setup
// merely because no model was chosen to occupy resources right now.
standby,
- standbyDetail: standby ? runtime.standbyDetail : null,
+ standbyDetail: standby ? expandPageToken(runtime.standbyDetail, runtime) : null,
checks,
// What a one-click "set this up for me" button can do about the unmet
// checks, or `null` when nothing here is auto-fixable (see
diff --git a/server/services/providerReadiness.test.js b/server/services/providerReadiness.test.js
index 44d26f86db..ce5d2404a5 100644
--- a/server/services/providerReadiness.test.js
+++ b/server/services/providerReadiness.test.js
@@ -87,6 +87,10 @@ describe('getProviderReadiness', () => {
expect(stopped.ready).toBe(false);
expect(stopped.standby).toBe(true);
expect(stopped.standbyDetail).toMatch(/valid idle state/);
+ // The runtime row writes "{page}"; the page name is resolved from its own
+ // manageUrl here, so a page move re-words this without touching the row.
+ expect(stopped.standbyDetail).toMatch(/Models → Runtimes/);
+ expect(stopped.standbyDetail).not.toMatch(/\{page\}/);
const missingWeights = await getProviderReadiness(llamaProvider(), {
findCommand: () => '/opt/homebrew/bin/llama-server',
@@ -163,6 +167,19 @@ describe('getProviderReadiness', () => {
expect(model.fixHint).toMatch(/only accepts/);
});
+ // The whole point of deriving the page: two runtimes managed on two different
+ // pages must not be handed the same breadcrumb. llama.cpp resolves to
+ // Runtimes above; Ollama's catalog stayed on LLMs.
+ it('names a different page for a runtime whose catalog did not move', async () => {
+ const readiness = await getProviderReadiness(
+ { id: 'ollama', type: 'api', endpoint: 'http://127.0.0.1:11434/v1', defaultModel: 'qwen3:8b' },
+ { findCommand: () => '/opt/homebrew/bin/ollama', probe: reachable([]) },
+ );
+ const model = checkById(readiness, 'model');
+ expect(model.fixHint).toMatch(/Models → LLMs/);
+ expect(model.fixHint).not.toMatch(/Models → Runtimes/);
+ });
+
it('calls out a running server with nothing loaded', async () => {
const readiness = await getProviderReadiness(llamaProvider(), {
findCommand: () => '/opt/homebrew/bin/llama-server',