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
show page and chapter targets per form on Writers Room Guide (#492)
[._.]/ Adam Eivy0570dc303165
diff --git a/PLAN.md b/PLAN.mdindex e4db49e3da..3deeb2c349 100644--- a/PLAN.md+++ b/PLAN.md@@ -13,6 +13,7 @@ _Batch-cleared 2026-05-25: 23 Next Up items shipped together via parallel sub-ag- [ ] [mediacard-use-mediaimage-for-syncing-assets] **`MediaCard.jsx` grid thumbnails still use a raw `<img src={previewUrl}>`.** Same peer-sync placeholder/live-swap gap that `[peer-sync-medialightbox-use-mediaimage-for-syncing-assets]` fixed for the lightbox — `client/src/components/media/MediaCard.jsx` (~line 42) doesn't get the "Syncing" placeholder or the `peerSync:asset-arrived` atomic swap. Swap the raw `<img>` for `MediaImage`. Surfaced by that item's cross-check during the batch-clear (2026-05-25); was outside its stated scope.- [ ] [chrome-canary-followups] **Hardening for the custom-Chrome-binary feature (xhigh code-review 2026-05-25).** **High-severity:** (a) On macOS headed mode (the default), `browser/server.js:208` uses `macAppBundle` only and silently ignores `chromePath` — a UI user who fills in `chromePath` for Canary/Chromium/Brave but leaves `macAppBundle` empty gets stock Chrome and the log misreports the binary; couple the two fields in the UI (or auto-derive `macAppBundle` from `chromePath` when the latter is inside a `.app`). (b) Neither `spawn(chromePath, …)` (line 216) nor `spawn('/usr/bin/open', …)` (line 208) has an `.on('error', …)` listener — a typo in `chromePath` emits 'error' with no listener → `uncaughtException` → portos-browser PM2 child crashes and restart-loops. (c) `scripts/setup-browser.js#applyCanaryToConfig` writes `chromePath` + `macAppBundle` but doesn't flip `headless: false`; combined with the seed default of `headless: true` (`data.reference/browser-config.json`), a fresh install accepting Canary runs Canary invisibly. (d) `browser/server.js#loadConfig` does bare `JSON.parse(raw)` with no try/catch — combined with setup-browser's non-atomic `writeFileSync` and the `cachedConfig` race, a partial-file write crashes the supervisor on next start (PM2 restart-loop forever). **Medium-severity:** (e) `setup-browser.js#loadConfig` silently catches all JSON parse errors and returns `{}`, then `applyCanaryToConfig` saves `{chromePath, macAppBundle}` only — wiping every other user-customized key. (f) Top-level `await runCanarySetup()` has no try/catch — any EACCES on data/browser-config.json aborts `npm run setup` / `update.sh` at what was previously a no-op step. (g) Idempotency guard only checks `chromePath`: users who decline get re-prompted on every update, and users who set only `macAppBundle` keep getting re-prompted. (h) `PORTOS_USE_CANARY` only matches literal `'0'`/`'false'` (opt-out) or `'1'`/`'true'` (opt-in) — `'no'`/`'off'`/`'yes'`/`'on'`/`'True'` fall through both branches. (i) `spawnSync(install.cmd, …, { stdio: 'inherit' })` for brew/winget can hang on a sudo password prompt under non-TTY + `PORTOS_USE_CANARY=1` (update.sh stalls). (j) `cachedConfig` in `browserService.js` is stale relative to setup-browser's direct write — GET /api/browser/config returns pre-update values until process restart. (k) `saveConfig` uses bare `writeFileSync` — switch to the canonical `atomicWrite` pattern (`server/lib/fileUtils.js`). **Low-severity:** (l) `spawnSync` failure-status check `result.status !== 0` treats `status: null` (spawn-failure / signal kill) identically to a non-zero exit and never logs `result.error` — masks ENOENT/EPERM/SIGKILL. (m) `optionalPath` Zod schema accepts any string up to 1024 chars; no `.app`/`.exe` sanity check — user pastes the bundle into `chromePath` → spawn() EISDIR. (n) `launchBrowser`'s reuse-existing-Chrome early-return (line 167) fires BEFORE `headlessMode = config.headless === true` (line 170), leaving the module-level default `false` after a PM2 restart that reuses Chrome — /health reports wrong mode (pre-existing, but in a function touched by this change). (o) `detectCanary` on macOS only checks `/Applications/...`; misses per-user `~/Applications/Google Chrome Canary.app` installs (corporate Macs, `HOMEBREW_CASK_OPTS=--appdir=$HOME/Applications`).- [ ] [voice-tool-edge-hardening] **Edge-case hardening for the new voice tools (all low-severity, from the xhigh code-review 2026-05-25).** (c) `timer_set` is a bare in-memory `setTimeout` with no persistence (lost silently on restart) and no dedup across tool-loop iterations (LLM re-issue → double notification). Also minor: `dataSync.js` per-`(category,forPeerId)` `checksumCache` keys are never evicted (unbounded for cycling peer ids; negligible for a home federation). _(Fixed in the v2.9.0 release review: (a) the `calendar_today` DST-offset bug — `anchorLocalMidnightUtc` now samples the offset at the target midnight; (b) `calendar_next` now matches calendarSync's `endTime >= now` range so in-progress and all-day-today events surface; and `resolveExcludeSet` is now deferred to the `getChecksum` cache-miss path.)_+- [ ] [shared-pill-chip-component] **Extract a shared `<Pill>` (or `<Chip>`) component for inline label badges.** The pattern `<span className="text-xs … rounded px-2 py-0.5">{label}</span>` is hand-rolled across the client: `client/src/pages/WritersRoomGuide.jsx` (multiple call sites — the local `Pill` helper added 2026-05-25 for length-target cards is a candidate seed), `client/src/pages/Instances.jsx:695,874`, and `client/src/components/goals/GoalDetailPanel.jsx:857,868`. Promote to `client/src/components/ui/Pill.jsx` with `tone="accent|muted|note|context"` variants and migrate the call sites. Surfaced by the simplify-agent reuse review during the Writers Room Guide length-targets change. Skip until another touch into one of those files justifies the sweep.## Deferred Architecture (human-led planning)diff --git a/client/src/lib/writingGuide.js b/client/src/lib/writingGuide.jsindex fca13c02d4..309d460d7f 100644--- a/client/src/lib/writingGuide.js+++ b/client/src/lib/writingGuide.js@@ -8,11 +8,23 @@// per word (≈5 letters + 1 space). Min chars use 5×words, max chars use 6×words;// the literary-category rows below preserve the exact figures from the editorial// brief and the book table preserves its 5.5–6× page-based estimate.+//+// Page counts assume the conventional ~250–300 words per printed page: min+// pages use 300 wpp (denser, fewer pages), max pages use 250 wpp (looser, more+// pages), each ceil-rounded to a whole page. Chapter ranges derive from the+// conventional ~3,000–5,000 words per chapter: min chapters use 5,000 wpc+// (longer chapters, fewer of them), max chapters use 3,000 wpc (shorter+// chapters, more of them), each ceil-rounded to a whole chapter. Forms read in+// one sitting (microfiction, flash, short story) carry `min`/`max` of `null`+// on `chapters` along with a "single sitting" label so consumers render a+// single uniform shape without a special-case branch.-// Literary length ladder — microfiction through novel. `words`/`chars` carry-// `{ min, max }` in absolute counts (null `min`/`max` = open-ended bound) plus a-// human `label` for display. `core` marks the four categories from the original-// brief; novella/novel complete the ladder for context.+// Literary length ladder — microfiction through novel. `words`/`chars`/`pages`/+// `chapters` all carry `{ min, max, label }` with a human label for display;+// `min`/`max` may be `null` to express open-ended or not-applicable bounds (an+// open-ended top band, a single-sitting form with no chapter target). `core`+// marks the four categories from the original brief; novella/novel complete the+// ladder for context.export const WRITING_LENGTH_TARGETS = [{id: 'microfiction',@@ -20,6 +32,8 @@ export const WRITING_LENGTH_TARGETS = [core: true,words: { min: null, max: 500, label: '≤500 words' },chars: { min: null, max: 3000, label: '≤2,500–3,000 chars' },+ pages: { min: null, max: 2, label: '≤2 pages' },+ chapters: { min: null, max: null, label: 'Single sitting · no chapters' },note: 'A single sharp image or turn. Every word load-bearing; no room for sub-plots.',},{@@ -28,6 +42,8 @@ export const WRITING_LENGTH_TARGETS = [core: true,words: { min: 750, max: 1000, label: '750–1,000 words' },chars: { min: 3750, max: 6000, label: '3,750–6,000 chars' },+ pages: { min: 3, max: 4, label: '3–4 pages' },+ chapters: { min: null, max: null, label: 'Single sitting · no chapters' },note: 'One scene, one decisive moment. Implies the world rather than building it.',},{@@ -36,6 +52,8 @@ export const WRITING_LENGTH_TARGETS = [core: true,words: { min: 1500, max: 7500, label: '1,500–7,500 words' },chars: { min: 7500, max: 45000, label: '7,500–45,000 chars' },+ pages: { min: 5, max: 30, label: '5–30 pages' },+ chapters: { min: null, max: null, label: 'Single sitting · no chapters' },note: 'Room for a complete arc with a small cast. The default short-form target.',},{@@ -44,6 +62,8 @@ export const WRITING_LENGTH_TARGETS = [core: true,words: { min: 7500, max: 17500, label: '7,500–17,500 words' },chars: { min: 37500, max: 105000, label: '37,500–105,000 chars' },+ pages: { min: 25, max: 70, label: '25–70 pages' },+ chapters: { min: 2, max: 6, label: '2–6 chapters' },note: 'Subplots and a fuller secondary cast become viable. Longer than most magazines buy.',},{@@ -52,6 +72,8 @@ export const WRITING_LENGTH_TARGETS = [core: false,words: { min: 17500, max: 40000, label: '17,500–40,000 words' },chars: { min: 87500, max: 240000, label: '87,500–240,000 chars' },+ pages: { min: 59, max: 160, label: '59–160 pages' },+ chapters: { min: 4, max: 14, label: '4–14 chapters' },note: 'A single dominant throughline with depth — too long for a magazine, too short for a typical print novel.',},{@@ -60,6 +82,8 @@ export const WRITING_LENGTH_TARGETS = [core: false,words: { min: 40000, max: 120000, label: '40,000–120,000 words' },chars: { min: 200000, max: 720000, label: '200,000–720,000 chars' },+ pages: { min: 134, max: 480, label: '134–480 pages' },+ chapters: { min: 8, max: 40, label: '8–40 chapters' },note: 'Multiple arcs and a full cast. Genre sets the sweet spot (≈70k YA, ≈100k+ epic fantasy).',},];diff --git a/client/src/lib/writingGuide.test.js b/client/src/lib/writingGuide.test.jsindex 13bfb82843..2cb0e807f9 100644--- a/client/src/lib/writingGuide.test.js+++ b/client/src/lib/writingGuide.test.js@@ -8,17 +8,36 @@ import {} from './writingGuide.js';describe('writingGuide data shape', () => {- it('every length target carries id, label, and word/char bands with labels', () => {+ it('every length target carries id, label, and word/char/page/chapter bands with labels', () => {for (const t of WRITING_LENGTH_TARGETS) {expect(typeof t.id).toBe('string');expect(t.id.length).toBeGreaterThan(0);expect(typeof t.label).toBe('string');expect(typeof t.words.label).toBe('string');expect(typeof t.chars.label).toBe('string');+ expect(typeof t.pages.label).toBe('string');+ expect(typeof t.chapters.label).toBe('string');expect(typeof t.core).toBe('boolean');}});+ it('marks single-sitting forms with null chapter bounds and chapter-bearing forms with numeric ones', () => {+ const chapters = Object.fromEntries(+ WRITING_LENGTH_TARGETS.map((t) => [t.id, t.chapters]),+ );+ // Forms typically read in one sitting carry null min/max bounds; the label+ // still renders so the card has a uniform shape.+ for (const id of ['microfiction', 'flash-fiction', 'short-story']) {+ expect(chapters[id].min).toBeNull();+ expect(chapters[id].max).toBeNull();+ }+ // Longer forms have numeric bounds.+ for (const id of ['novelette', 'novella', 'novel']) {+ expect(typeof chapters[id].min).toBe('number');+ expect(typeof chapters[id].max).toBe('number');+ }+ });+it('preserves the four core categories from the brief', () => {const core = WRITING_LENGTH_TARGETS.filter((t) => t.core).map((t) => t.id);expect(core).toEqual(['microfiction', 'flash-fiction', 'short-story', 'novelette']);diff --git a/client/src/pages/WritersRoomGuide.jsx b/client/src/pages/WritersRoomGuide.jsxindex bb70e86c40..f9bbdd9300 100644--- a/client/src/pages/WritersRoomGuide.jsx+++ b/client/src/pages/WritersRoomGuide.jsx@@ -13,7 +13,26 @@ import {// <main> is full-width/overflow-hidden (see Layout.jsx isFullWidth), so this// page owns its own vertical scroll.+const PILL_TONES = {+ accent: 'text-port-accent bg-port-accent/10 border-port-accent/20',+ muted: 'text-gray-300 bg-port-bg border-port-border',+ note: 'text-gray-500 bg-port-bg border-port-border italic',+};++function Pill({ tone = 'muted', children }) {+ return (+ <span className={`text-xs border rounded px-2 py-0.5 ${PILL_TONES[tone]}`}>+ {children}+ </span>+ );+}+function LengthCard({ target }) {+ // A chapter band with null bounds means the form is read in one sitting; render+ // it muted/italic to keep it visually distinct from real numeric targets.+ const chapterTone = target.chapters.min == null && target.chapters.max == null+ ? 'note'+ : 'muted';return (<div className="bg-port-card border border-port-border rounded-lg p-4 flex flex-col gap-2"><div className="flex items-center justify-between gap-2">@@ -25,12 +44,10 @@ function LengthCard({ target }) {)}</div><div className="flex flex-wrap gap-1.5">- <span className="text-xs text-port-accent bg-port-accent/10 border border-port-accent/20 rounded px-2 py-0.5">- {target.words.label}- </span>- <span className="text-xs text-gray-300 bg-port-bg border border-port-border rounded px-2 py-0.5">- {target.chars.label}- </span>+ <Pill tone="accent">{target.words.label}</Pill>+ <Pill>{target.chars.label}</Pill>+ <Pill>{target.pages.label}</Pill>+ <Pill tone={chapterTone}>{target.chapters.label}</Pill></div><p className="text-xs text-gray-400 leading-relaxed">{target.note}</p></div>@@ -90,8 +107,11 @@ export default function WritersRoomGuide() {</div><p className="text-xs text-gray-500 max-w-3xl">Word counts are the primary signal; character counts assume the conventional English- estimate of ~5–6 characters per word (≈5 letters + a space). Bands have small gaps- between named forms — a draft that lands in a gap rounds up to the next form.+ estimate of ~5–6 characters per word (≈5 letters + a space). Page counts assume the+ conventional ~250–300 words per printed page, and chapter counts assume ~3,000–5,000+ words per chapter (forms read in one sitting list no chapter target). Bands have+ small gaps between named forms — a draft that lands in a gap rounds up to the next+ form.</p><div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">{WRITING_LENGTH_TARGETS.map((target) => (