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
cap character-arc editor inputs so one long field can't block every series save
[._.]/ Adam Eivycda0b2841e7a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex a990d04788..bf948d1fe2 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -38,6 +38,8 @@- **PortOS no longer boots to a blank white page when it can't reach the public internet.** The app shell pulled Inter and IBM Plex Mono from `fonts.googleapis.com` as a render-blocking `<link rel="stylesheet">`, so on any install with no route to Google — no WAN, a DNS sinkhole, an outbound firewall — the browser held the first paint until that request timed out. Measured on a live install: **~60 seconds of blank white page on every single navigation**, with no console error to explain it. The service worker made it durable rather than causing it: `public/sw.js` deliberately caches the font hosts, but `cacheFirst` can never populate that cache when the fetch never succeeds, so each navigation re-hung — the exact opposite of the offline app shell that service worker exists to provide, on a product whose documented deployment is a private Tailscale network. The stylesheet now loads non-blocking (`media="print"` flipped to `all` on load, with a `<noscript>` fallback), so first paint no longer waits on a third-party host. Nothing regresses when the fonts *are* reachable: only the `lumen-glass-day` theme puts them at the front of its stack, every stack in `themes/portosThemes.js` falls back to system fonts, and the sheet still applies the moment it arrives. A guard suite pins the shell so no future `<link>` can make boot depend on a cross-origin host again.+- **One over-long character-arc field no longer bricks every save on the Series settings page.** The arc editor's inputs — character name, want, need, start/end state, transition label, at-issue — carried no length caps, while the PATCH route enforces `CHARACTER_ARC_LIMITS` with Zod. Because `updateSeries` replaces `characterArcs` wholesale, Save re-sends the entire arc list every time, so a single field over its cap rejected the **whole** series PATCH — name, logline, premise, style guide and all — and kept rejecting it on every subsequent attempt, with only a raw validation path (`characterArcs.4.transitions.3.label`) to go on. (Seen repeating across hours of a live install's server log.) The inputs now cap at the server's limits, and a parity suite fails if the mirrored caps ever drift from `server/lib/seriesCharacterArc.js`.+- **Brain Memory and Media History no longer paint every record at once.** A live install with ~1.5k imported ChatGPT memories was mounting full Markdown trees for every card (~180k DOM nodes / multi-MB of text), and Media History mounted ~1.8k gallery cards with images in one grid — both tabs froze on open. Memory now shows a plain teaser for imported transcripts (full thread still opens in the conversation viewer) and both lists use a progressive "Show more" window so search still covers the full set while only a page of cards mounts. CoS 3D avatars also probe WebGL before creating a canvas, so headless/no-GPU displays degrade to a hint instead of unhandled `WebGLRenderer` rejections.- **The pre-episode arc-spine check now resolves at the altitude it judged at.** That checkpoint deliberately verifies the arc spine with the episode lineup hidden — no episodes have been planned in earnest yet, so it only asks whether the premise, principals, engine, and volume allocation are safe to expand. The auto-resolver behind it, though, was still handed the full episode lineup and the general "correct an episode synopsis when the contradiction originates there" instruction, so it answered spine findings by rewriting episode synopses the gate had never read. Those edits could not close what was flagged, the arc and volume text stayed unfixed, and the next spine verification came back with twice the blockers — a round that got reverted wholesale and paused the run. (Observed on a run that went in with 3 blocking findings, spent its round editing 3 episode synopses, and came back with 6.) Spine rounds now render the resolver the same episode-empty plan the verifier saw, tell it to fix the arc and volumes only, and discard any episode edits it returns anyway, so a customized or stale installed prompt can't re-open the blast radius. Nothing changes for the full arc gate that runs after episodes exist: it still verifies and repairs episode synopses, which is the only place an episode-scoped contradiction can converge. Sparse finding-keyed patches and the blocker-count rollback are untouched.diff --git a/client/src/pages/PipelineSeries.jsx b/client/src/pages/PipelineSeries.jsxindex b3f294c684..fb701e7ece 100644--- a/client/src/pages/PipelineSeries.jsx+++ b/client/src/pages/PipelineSeries.jsx@@ -785,6 +785,25 @@ function VoiceCandidateCard({ candidate, filedAs, onFileExemplar, onFileAntiExem);}+// Per-field caps for the character-arc editor — mirror CHARACTER_ARC_LIMITS in+// server/lib/seriesCharacterArc.js, which the PATCH route enforces with Zod.+//+// These are not cosmetic. `updateSeries` replaces `characterArcs` wholesale, so+// the Save button sends the entire arc list on every save; one over-long field+// fails Zod and the server rejects the WHOLE series PATCH — name, logline,+// premise, style guide and all — not just the offending arc. Without a+// `maxLength` the field that bricks every subsequent save is invisible in the+// UI, so cap at the input instead of discovering it in a rejected save.+const ARC_LIMITS = {+ CHARACTER_NAME_MAX: 200,+ WANT_MAX: 1000,+ NEED_MAX: 1000,+ START_STATE_MAX: 1000,+ END_STATE_MAX: 1000,+ TRANSITION_LABEL_MAX: 200,+ ISSUE_MAX: 9999,+};+// The change-beat kinds the arc.transitions editorial check recognizes — mirror// TRANSITION_KINDS in server/lib/seriesCharacterArc.js.const TRANSITION_KIND_OPTIONS = [@@ -902,6 +921,7 @@ function CharacterArcsSection({ series, patchSeries }) {value={arc.characterName || ''}onChange={(e) => setArc(i, { characterName: e.target.value })}placeholder="Character name"+ maxLength={ARC_LIMITS.CHARACTER_NAME_MAX}className={`${inputCls} font-medium`}/><button@@ -914,10 +934,10 @@ function CharacterArcsSection({ series, patchSeries }) {</button></div><div className="grid grid-cols-2 gap-2">- <input aria-label="Want" value={arc.want || ''} onChange={(e) => setArc(i, { want: e.target.value })} placeholder="Wants (external goal)" className={inputCls} />- <input aria-label="Need" value={arc.need || ''} onChange={(e) => setArc(i, { need: e.target.value })} placeholder="Needs (internal lesson)" className={inputCls} />- <input aria-label="Start state" value={arc.startState || ''} onChange={(e) => setArc(i, { startState: e.target.value })} placeholder="Starts as…" className={inputCls} />- <input aria-label="End state" value={arc.endState || ''} onChange={(e) => setArc(i, { endState: e.target.value })} placeholder="Ends as…" className={inputCls} />+ <input aria-label="Want" value={arc.want || ''} onChange={(e) => setArc(i, { want: e.target.value })} placeholder="Wants (external goal)" maxLength={ARC_LIMITS.WANT_MAX} className={inputCls} />+ <input aria-label="Need" value={arc.need || ''} onChange={(e) => setArc(i, { need: e.target.value })} placeholder="Needs (internal lesson)" maxLength={ARC_LIMITS.NEED_MAX} className={inputCls} />+ <input aria-label="Start state" value={arc.startState || ''} onChange={(e) => setArc(i, { startState: e.target.value })} placeholder="Starts as…" maxLength={ARC_LIMITS.START_STATE_MAX} className={inputCls} />+ <input aria-label="End state" value={arc.endState || ''} onChange={(e) => setArc(i, { endState: e.target.value })} placeholder="Ends as…" maxLength={ARC_LIMITS.END_STATE_MAX} className={inputCls} /></div><div className="mt-2">@@ -947,16 +967,26 @@ function CharacterArcsSection({ series, patchSeries }) {value={t.label || ''}onChange={(e) => setTransition(i, j, { label: e.target.value })}placeholder="What changes"+ maxLength={ARC_LIMITS.TRANSITION_LABEL_MAX}className="flex-1 px-2 py-1 bg-port-bg border border-port-border rounded text-white text-xs"/><inputaria-label="At issue"type="number"min={0}+ max={ARC_LIMITS.ISSUE_MAX}value={Number.isFinite(t.atIssue) ? t.atIssue : ''}onChange={(e) => {const n = parseInt(e.target.value, 10);- setTransition(i, j, { atIssue: Number.isFinite(n) ? n : null });+ // Clamp rather than lean on the `max` attribute — on a+ // number input `max` only fails constraint validation+ // on form submit, it does NOT stop typing or pasting a+ // larger value. This section has no <form>, so an+ // unclamped 99999 would sail through to the PATCH and+ // fail the ISSUE_MAX Zod cap, taking the whole series+ // save down with it.+ const clamped = Math.min(Math.max(n, 0), ARC_LIMITS.ISSUE_MAX);+ setTransition(i, j, { atIssue: Number.isFinite(n) ? clamped : null });}}placeholder="#"className="w-14 px-1.5 py-1 bg-port-bg border border-port-border rounded text-white text-xs"diff --git a/server/lib/seriesCharacterArc.mirror.test.js b/server/lib/seriesCharacterArc.mirror.test.jsnew file mode 100644index 0000000000..dd8fbe2db4--- /dev/null+++ b/server/lib/seriesCharacterArc.mirror.test.js@@ -0,0 +1,74 @@+/**+ * Parity guard: the character-arc editor's client-side input caps must match+ * the server's CHARACTER_ARC_LIMITS.+ *+ * `PipelineSeries.jsx` hard-codes an `ARC_LIMITS` object it feeds to the arc+ * inputs' `maxLength` / `max`. It can't import the server constant (browser+ * bundle), so the two are mirrored — and a mirror that drifts is worse than no+ * mirror here, because of how the write path fails: `updateSeries` replaces+ * `characterArcs` wholesale, so Save re-sends the entire arc list every time. A+ * single field over its Zod cap rejects the WHOLE series PATCH — name, logline,+ * premise, style guide and all — so a client cap that is larger than the+ * server's lets the user type a value that silently bricks every subsequent+ * save of the page.+ *+ * Reads the client file as TEXT rather than importing it: this suite runs in+ * the server (node) project, which has no React/lucide-react resolution.+ */++import { describe, it, expect } from 'vitest';+import { readFileSync } from 'fs';+import { join, dirname } from 'path';+import { fileURLToPath } from 'url';+import { CHARACTER_ARC_LIMITS } from './seriesCharacterArc.js';++const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');+const CLIENT_PAGE = join(REPO_ROOT, 'client', 'src', 'pages', 'PipelineSeries.jsx');++// The keys the editor actually renders an input for. A server limit with no+// input (e.g. TRANSITIONS_PER_ARC_MAX, enforced by the sanitizer dropping+// extras) is deliberately absent from the client mirror.+const MIRRORED_KEYS = [+ 'CHARACTER_NAME_MAX',+ 'WANT_MAX',+ 'NEED_MAX',+ 'START_STATE_MAX',+ 'END_STATE_MAX',+ 'TRANSITION_LABEL_MAX',+ 'ISSUE_MAX',+];++function clientArcLimits() {+ const src = readFileSync(CLIENT_PAGE, 'utf8');+ const block = src.match(/const ARC_LIMITS = \{([\s\S]*?)\};/);+ if (!block) return null;+ const out = {};+ for (const [, key, value] of block[1].matchAll(/(\w+):\s*(\d+)\s*,/g)) {+ out[key] = Number(value);+ }+ return out;+}++describe('PipelineSeries ARC_LIMITS ↔ server CHARACTER_ARC_LIMITS', () => {+ it('declares an ARC_LIMITS mirror in the client page', () => {+ expect(clientArcLimits()).not.toBeNull();+ });++ it('mirrors every cap the arc editor renders an input for', () => {+ const client = clientArcLimits();+ expect(Object.keys(client).sort()).toEqual([...MIRRORED_KEYS].sort());+ });++ it.each(MIRRORED_KEYS)('%s matches the server cap', (key) => {+ expect(clientArcLimits()[key]).toBe(CHARACTER_ARC_LIMITS[key]);+ });++ it('caps every arc input the editor renders', () => {+ const src = readFileSync(CLIENT_PAGE, 'utf8');+ // Each arc field's input must carry a maxLength (or max, for atIssue) drawn+ // from the mirror — not a bare uncapped input.+ for (const key of MIRRORED_KEYS) {+ expect(src).toContain(`ARC_LIMITS.${key}`);+ }+ });+});