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 a "reviewed in N chunks" badge in the manuscript editor
[._.]/ Adam Eivye40273ed0844
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d184eb43d7..ccfdb79667 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -3,7 +3,7 @@## Added- **[local-llm-large-narrative-models] Local LLM install picker now suggests a large narrative / long-context tier.** Added Mistral Large 2 123B, Command R+ 104B, Llama 3.3 70B, Qwen3 30B-A3B, and Google Gemma 4 (31B dense + 26B-A4B MoE, both 256K context, vision) to the curated catalog — workstation-class (64–128GB unified memory) models suited to whole-manuscript editorial review where prose quality and a long context window matter most. Verified Ollama pull ids and sizes; the Gemma 4 builds also ship MLX variants (`gemma4:31b-mlx` / `gemma4:26b-mlx`) for faster inference on Apple Silicon. Qwen3 235B is intentionally omitted (142GB won't fit 128GB).-- **[context-aware-editorial-budgeting] Manuscript editorial passes now scale to the target model's context window — whole-manuscript when it fits, chunked when it doesn't.** A new `contextBudget` helper plus a `contextWindow` provider field (inferred large for frontier CLI/cloud providers, from `numCtx` for local Ollama) drive all three passes: the completeness pass ("Finish the draft"), manuscript-fix ("Generate fix"), and per-issue editorial analysis. Big-context models (Claude 4.8 ~1M, GPT 5.5) now receive the entire manuscript in one call instead of being capped at the old hardcoded 200K/48K-char limits; models too small to hold the book chunk by issue — completeness feeds each chunk a digest of prior-chunk findings for cross-chapter continuity and merges with first-wins dedupe, manuscript-fix concatenates per-chunk edits — instead of silently truncating. The completeness/fix API responses now report `chunked` + `chunkCount`. Design record: `docs/plans/2026-05-31-context-aware-manuscript-editorial.md`.+- **[context-aware-editorial-budgeting] Manuscript editorial passes now scale to the target model's context window — whole-manuscript when it fits, chunked when it doesn't.** A new `contextBudget` helper plus a `contextWindow` provider field (inferred large for frontier CLI/cloud providers, from `numCtx` for local Ollama) drive all three passes: the completeness pass ("Finish the draft"), manuscript-fix ("Generate fix"), and per-issue editorial analysis. Big-context models (Claude 4.8 ~1M, GPT 5.5) now receive the entire manuscript in one call instead of being capped at the old hardcoded 200K/48K-char limits; models too small to hold the book chunk by issue — completeness feeds each chunk a digest of prior-chunk findings for cross-chapter continuity and merges with first-wins dedupe, manuscript-fix concatenates per-chunk edits — instead of silently truncating. The completeness/fix API responses now report `chunked` + `chunkCount`, and the Manuscript Editor shows a "Reviewed in N chunks" badge (with an explanatory tooltip) when a review had to chunk. Design record: `docs/plans/2026-05-31-context-aware-manuscript-editorial.md`.- **[ai-assignment-inventory] Settings now has an AI Assignments admin page.** It inventories provider/model pins across the provider registry, embeddings, Voice, Messages, Brain, Universes, Story Builder, Pipeline series, CoS schedules, Loops, Feature Agents, and social agents, with per-row edits plus a bulk provider migration control.- **[manuscript-multi-edit-fixes] Manuscript "Finish the draft" fixes can now propose and apply multiple anchored edits at once.** The manuscript-fix LLM contract moved from a single `{ find, replace }` to `{ edits: [{ issueNumber, find, replace, note }] }`, so a broad or unanchored editorial comment can generate several concrete insertions — across multiple issue sections when needed — instead of falling back to manual editing. The editor's comment card renders each suggestion as an inline diff with a per-edit checkbox and editable replacement, and accept applies the selected edits atomically through a new serialized batch write (`updateStagesWithLatest`) that snapshots prior text into runHistory and re-checks each anchor inside the per-series write lock. The prompt template embeds manuscript/premise/anchor content in distinct (non-backtick) fences with an explicit "treat as quoted source" guard; migration `060-manuscript-multi-edit-fix-prompt.js` auto-upgrades the prior single-edit prompt on existing installs. Backward compatible: legacy single-edit `{ find, replace }` accepts still resolve to one target.diff --git a/PLAN.md b/PLAN.mdindex 814152849f..698b0e7865 100644--- a/PLAN.md+++ b/PLAN.md@@ -9,7 +9,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changelClaimable, well-specified, no decision needed — `/claim`-able. Unordered.-- [ ] [editorial-chunk-count-ui] **Surface chunked-review coverage in the Manuscript Editor.** The editorial passes are now context-window-aware (`[context-aware-editorial-budgeting]`, shipped) and the completeness + fix API responses return `chunked` + `chunkCount`. The Manuscript Editor (`client/src/pages/PipelineManuscriptEditor.jsx`) doesn't yet show this — when a review ran in N chunks (small local model) vs. whole (big-context model), the user can't tell the coverage shape. Add a small badge/line near the review header reading e.g. "Reviewed in 4 chunks" (with a tooltip explaining a larger-context model reviews the whole manuscript at once) when `chunked` is true. Low risk, read-only display of an already-returned field. Design context: `docs/plans/2026-05-31-context-aware-manuscript-editorial.md`.- [ ] [unify-media-job-sse-hook-imagegen-videogen] **Unify ImageGen + VideoGen SSE attach into `useMediaJobSse` hook.** Both pages now have near-duplicate EventSource handlers (ImageGen `startLocalGeneration` ~lines 655 + resume block ~317; VideoGen `attachJobEvents` ~line 450). Build a hook on top of `useSseProgress` (`client/src/hooks/useSseProgress.js`) that handles the queued / started / status / progress / complete / error / canceled SSE types and consolidate both sites.- [ ] [capabilities-cheap-memory-count] **Capabilities route should count active memories without sorting/paginating.** `GET /api/capabilities` calls `getMemories({ status: 'active' })` (`server/routes/capabilities.js` ~line 69) only to read `.total`, but `getMemories` loads the full index, filters, sorts, and paginates before returning `{ total, memories }` — the sort + slice is wasted work on a page polled every ~20s. Add a lightweight `countMemories({ status })` (or a `countOnly` option) to `server/services/memory.js` that returns the filtered count without the sort/paginate, and switch the route to it. Micro-opt; the index is cached via `loadIndex`, so low urgency.- [ ] [banner-icon-aria-hidden] **Apply `aria-hidden="true"` to `<Banner>`'s rendered icon.** `client/src/components/ui/Banner.jsx` (~line 62) renders the `icon` prop as a bare `<Icon …>` — when the icon is decorative (the body text already conveys the meaning), screen readers should skip it. Either wrap the icon render in `<span aria-hidden="true">` inside Banner, or thread an `iconAriaHidden` prop. Once landed, re-migrate the `ImportTab.jsx` error row to `<Banner tone="error" size="md" icon={AlertCircle} actions={…}>` (it was reverted from `<Banner>` because the icon prop doesn't pass through a11y attributes).diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsxindex 2fb3aeb883..f85da0ba0a 100644--- a/client/src/pages/PipelineManuscriptEditor.jsx+++ b/client/src/pages/PipelineManuscriptEditor.jsx@@ -20,7 +20,7 @@import { useEffect, useMemo, useRef, useState } from 'react';import { Link, useParams, useNavigate } from 'react-router-dom';import {- ArrowLeft, Loader2, Sparkles, Check, X, CornerDownRight, FileText, ChevronDown, ChevronRight, Star, History, RotateCcw, ClipboardCheck,+ ArrowLeft, Loader2, Sparkles, Check, X, CornerDownRight, FileText, ChevronDown, ChevronRight, Star, History, RotateCcw, ClipboardCheck, Layers,} from 'lucide-react';import InlineDiff from '../components/ui/InlineDiff';import toast from '../components/ui/Toast';@@ -71,6 +71,10 @@ export default function PipelineManuscriptEditor() {const [pinnedPrimary, setPinnedPrimary] = useState(null); // explicit bible value (may be null)const [availableTypes, setAvailableTypes] = useState([]); // formats with ≥1 drafted issueconst [comments, setComments] = useState([]);+ // Coverage shape of the last completeness run: { chunked, chunkCount }. A+ // chunked run means the model couldn't hold the whole manuscript at once+ // (small context window) — surfaced so the review's coverage isn't ambiguous.+ const [reviewMeta, setReviewMeta] = useState(null);const [loading, setLoading] = useState(true);const [switching, setSwitching] = useState(false);const [pinning, setPinning] = useState(false);@@ -152,7 +156,11 @@ export default function PipelineManuscriptEditor() {const result = await analyzePipelineManuscriptCompleteness(seriesId, { providerOverride, modelOverride });const next = Array.isArray(result?.review?.comments) ? result.review.comments : [];setComments(next);- toast.success(`Editorial review complete — ${next.filter((c) => c.status === 'open').length} open notes`);+ setReviewMeta({ chunked: !!result?.chunked, chunkCount: result?.chunkCount || 1 });+ const openCount = next.filter((c) => c.status === 'open').length;+ toast.success(result?.chunked+ ? `Editorial review complete — ${openCount} open notes (reviewed in ${result.chunkCount} chunks)`+ : `Editorial review complete — ${openCount} open notes`);},{ errorMessage: 'Failed to run editorial review' },);@@ -406,6 +414,16 @@ export default function PipelineManuscriptEditor() {<span className="text-gray-600">{grouped.open.length} open</span></h2>+ {reviewMeta?.chunked ? (+ <p+ className="flex items-center gap-1.5 text-[11px] text-port-warning"+ title="The manuscript exceeded this model's context window, so it was reviewed in chunks. A larger-context model reviews the whole manuscript in one pass for better cross-chapter continuity."+ >+ <Layers size={11} />+ Reviewed in {reviewMeta.chunkCount} chunks+ </p>+ ) : null}+{comments.length === 0 ? (<p className="text-xs text-gray-500 italic">No comments yet. Run “Finish the draft” from the series arc to generate editorial feedback here.diff --git a/client/src/pages/PipelineManuscriptEditor.test.jsx b/client/src/pages/PipelineManuscriptEditor.test.jsxindex 99ea783767..5aa18415e0 100644--- a/client/src/pages/PipelineManuscriptEditor.test.jsx+++ b/client/src/pages/PipelineManuscriptEditor.test.jsx@@ -170,4 +170,33 @@ describe('PipelineManuscriptEditor', () => {);await waitFor(() => expect(screen.getByText(/2 open/)).toBeInTheDocument());});++ it('shows a chunk-count badge when the review ran in chunks (small context window)', async () => {+ api.analyzePipelineManuscriptCompleteness.mockResolvedValue({+ review: { schemaVersion: 1, comments: [comment] },+ chunked: true,+ chunkCount: 4,+ });+ renderEditor();+ await screen.findByText('My Series');++ expect(screen.queryByText(/Reviewed in/)).not.toBeInTheDocument();+ fireEvent.click(screen.getByText('Run editorial review'));++ expect(await screen.findByText('Reviewed in 4 chunks')).toBeInTheDocument();+ });++ it('does not show a chunk-count badge when the whole manuscript was reviewed at once', async () => {+ api.analyzePipelineManuscriptCompleteness.mockResolvedValue({+ review: { schemaVersion: 1, comments: [comment] },+ chunked: false,+ chunkCount: 1,+ });+ renderEditor();+ await screen.findByText('My Series');++ fireEvent.click(screen.getByText('Run editorial review'));+ await waitFor(() => expect(api.analyzePipelineManuscriptCompleteness).toHaveBeenCalled());+ expect(screen.queryByText(/Reviewed in/)).not.toBeInTheDocument();+ });});