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
focus the manuscript editor on one issue with deep-linkable tabs
[._.]/ Adam Eivy5e1eed2fd03e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b4e912bbdc..d93c63f618 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -6,7 +6,7 @@- **Scheduled "Claim Issue" task** — a new built-in CoS schedule (CoS → Schedule → Claim Issue) that runs the `/claim --issues` flow on a cadence: it picks the next open GitHub issue, creates its own `claim/issue-<num>` worktree, implements the fix, opens a PR that closes the issue, runs the configured reviewers, merges, and cleans up. Configurable per app via an **Issue Author Filter** — claim only issues filed by the repository owner (default) or any open issue regardless of author. Off by default; enable and pick a provider/model per app like the other improvement tasks.- **Scheduled "Refresh local-LLM catalog" task** — a new built-in CoS schedule that periodically researches the current best local models per category and opens a PR refreshing PortOS's bundled suggested-models catalog (`server/lib/localLlmCatalog.js`) and the editorial model ranking, so the in-app install picker and recommendations don't go stale. It no-ops on any repo lacking the catalog file, so it only does work when enabled on the PortOS app itself. Off by default; weekly when enabled, and it only opens a PR when the catalog is actually out of date.- **Manuscript editorial review: "Start fresh" re-run mode** — re-running the editorial pass in the manuscript editor previously always *merged*, leaving every prior open note in place even when a later pass no longer flagged it. A new "Start fresh" checkbox next to "Run editorial review" reconciles the open list against the latest pass: open notes it still finds stay open, open notes it no longer finds are auto-dismissed, and genuinely-new findings are added. Your accepted and dismissed decisions are left untouched. Clearing is done by moving notes to dismissed (never by deleting them), so the change syncs correctly across federated machines instead of being resurrected by a peer. Merge stays the default.-- **Manuscript editor: editorial feedback is now shown in-context, not just in a sidebar** — instead of scrolling a disconnected list of notes, each editorial comment is highlighted directly on the text it points to. A header toggle switches between two modes: **Live** (Grammarly-style — the manuscript stays fully editable and each anchored note shows as a severity-toned underline; click the underlined text or its tag to pop the note's card right there with Generate-fix / Accept / Dismiss) and **Review** (a read-through where the prose is annotated and clicking a highlight expands the note inline, with a per-section Edit toggle to drop into free editing). The right sidebar becomes a filterable index (by severity, with open / accepted / dismissed groups and a "located in text" count) that scrolls to and opens any note. Suggested edits can now be reviewed as a **side-by-side before/after diff** (default) or the prior stacked inline diff, and a new **Impact preview** shows, per affected issue, how accepting the selected fixes changes the whole manuscript before you commit to them. Notes whose anchor text no longer matches the draft degrade gracefully — they stay listed in the sidebar with no in-text highlight rather than disappearing.+- **Manuscript editor: editorial feedback is now shown in-context, not just in a sidebar** — instead of scrolling a disconnected list of notes, each editorial comment is highlighted directly on the text it points to. A header toggle switches between two modes: **Live** (Grammarly-style — the manuscript stays fully editable and each anchored note shows as a severity-toned underline; click the underlined text or its tag to pop the note's card right there with Generate-fix / Accept / Dismiss) and **Review** (a read-through where the prose is annotated and clicking a highlight expands the note inline, with a per-section Edit toggle to drop into free editing). The right sidebar becomes a filterable index (by severity, with open / accepted / dismissed groups and a "located in text" count) that scrolls to and opens any note. The editor now focuses **one issue at a time** with a deep-linkable tab strip (`…/manuscript/<issueNumber>`, each tab badged with its open-note count) instead of one page-length scroll of every issue. Suggested edits can be reviewed as a **side-by-side before/after diff** (default) or the prior stacked inline diff, and a new **Impact preview** shows, per affected issue, how accepting the selected fixes changes the whole manuscript before you commit to them (a single fix can span multiple issues). Notes whose anchor text no longer matches the draft degrade gracefully — they stay listed in the sidebar with no in-text highlight rather than disappearing.## Changeddiff --git a/client/src/App.jsx b/client/src/App.jsxindex 35c0591192..58362bf896 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -299,7 +299,9 @@ export default function App() {<Route path="pipeline" element={<Pipeline />} /><Route path="pipeline/series/:seriesId" element={<PipelineSeries />} /><Route path="pipeline/series/:seriesId/roadmap" element={<PipelineSeriesRoadmap />} />- <Route path="pipeline/series/:seriesId/manuscript" element={<PipelineManuscriptEditor />} />+ {/* Splat (not a :param route) so navigating between issues reuses the+ same component instance instead of remounting + refetching. */}+ <Route path="pipeline/series/:seriesId/manuscript/*" element={<PipelineManuscriptEditor />} /><Route path="pipeline/series/:seriesId/sync" element={<SyncView kind="series" param="seriesId" backPath="/pipeline" />} /><Route path="pipeline/issues/:issueId" element={<Navigate to="idea" replace />} /><Route path="pipeline/issues/:issueId/:stage" element={<PipelineIssue />} />diff --git a/client/src/components/pipeline/manuscript/ManuscriptCommentIndex.jsx b/client/src/components/pipeline/manuscript/ManuscriptCommentIndex.jsxindex d687550001..246a66eeb4 100644--- a/client/src/components/pipeline/manuscript/ManuscriptCommentIndex.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptCommentIndex.jsx@@ -7,7 +7,7 @@import { useMemo, useState } from 'react';import { ChevronDown, ChevronRight, Check, X, MapPin } from 'lucide-react';-import { Badge } from './ManuscriptCommentCard';+import ManuscriptCommentCard, { Badge } from './ManuscriptCommentCard';const SEVERITIES = ['high', 'medium', 'low'];@@ -54,7 +54,7 @@ function ResolvedGroup({ label, icon: Icon, items, located, openCommentId, onRev);}-export default function ManuscriptCommentIndex({ comments, locatedCommentIds, openCommentId, onReveal }) {+export default function ManuscriptCommentIndex({ comments, locatedCommentIds, openCommentId, onReveal, commentCardProps }) {const [severityFilter, setSeverityFilter] = useState(null); // null = allconst grouped = useMemo(() => ({@@ -115,7 +115,25 @@ export default function ManuscriptCommentIndex({ comments, locatedCommentIds, op<div className="space-y-1.5">{openFiltered.map((c) => (- <CommentRow key={c.id} comment={c} located={locatedCommentIds.has(c.id)} active={c.id === openCommentId} onReveal={onReveal} />+ <div key={c.id} className="space-y-1.5">+ <CommentRow comment={c} located={locatedCommentIds.has(c.id)} active={c.id === openCommentId} onReveal={onReveal} />+ {/* Story-level notes (no issueNumber) have no issue tab to live on, so+ they expand and stay actionable right here in the index. */}+ {c.id === openCommentId && c.issueNumber == null && commentCardProps ? (+ <ManuscriptCommentCard+ comment={c}+ idScope={`index-${c.id}`}+ seriesId={commentCardProps.seriesId}+ providerOverride={commentCardProps.providerOverride}+ modelOverride={commentCardProps.modelOverride}+ onCommentChange={commentCardProps.onCommentChange}+ onAccepted={commentCardProps.onAccepted}+ draft={commentCardProps.fixDrafts[c.id]}+ onDraftChange={(entry) => commentCardProps.setCommentDraft(c.id, entry)}+ onJump={undefined}+ />+ ) : null}+ </div>))}</div>diff --git a/client/src/components/pipeline/manuscript/ManuscriptIssueTabs.jsx b/client/src/components/pipeline/manuscript/ManuscriptIssueTabs.jsxnew file mode 100644index 0000000000..170450d498--- /dev/null+++ b/client/src/components/pipeline/manuscript/ManuscriptIssueTabs.jsx@@ -0,0 +1,45 @@+/**+ * Issue tab strip for the Manuscript editor — one deep-linkable tab per issue+ * (`/pipeline/series/:id/manuscript/:issueNumber`), so the editor focuses one+ * issue at a time instead of one page-length scroll of every issue. Each tab+ * carries a badge with its count of open editorial notes anchored in the current+ * format, so where the feedback lives is visible at a glance.+ */++import { Link } from 'react-router-dom';++export default function ManuscriptIssueTabs({ seriesId, sections, activeNumber, openCountByNumber }) {+ if (sections.length === 0) return null;+ return (+ <nav+ aria-label="Issues"+ className="sticky top-0 z-20 -mx-1 flex gap-1 overflow-x-auto bg-port-bg/95 backdrop-blur py-1 px-1"+ >+ {sections.map((s) => {+ const active = s.number === activeNumber;+ const count = openCountByNumber.get(s.number) || 0;+ return (+ <Link+ key={s.issueId}+ to={`/pipeline/series/${seriesId}/manuscript/${s.number}`}+ aria-current={active ? 'page' : undefined}+ title={s.title ? `Issue ${s.number} — ${s.title}` : `Issue ${s.number}`}+ className={`shrink-0 inline-flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-medium border transition-colors ${+ active+ ? 'bg-port-accent text-white border-port-accent'+ : 'bg-port-card text-gray-300 border-port-border hover:text-white hover:border-port-accent/40'+ }`}+ >+ <span>Issue {s.number}</span>+ {s.title ? <span className="max-w-[10rem] truncate opacity-70">{s.title}</span> : null}+ {count > 0 ? (+ <span className={`ml-0.5 px-1 rounded-full text-[10px] ${active ? 'bg-white/20' : 'bg-port-accent/20 text-port-accent'}`}>+ {count}+ </span>+ ) : null}+ </Link>+ );+ })}+ </nav>+ );+}diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsxindex 97c41bba43..cb038b18ab 100644--- a/client/src/pages/PipelineManuscriptEditor.jsx+++ b/client/src/pages/PipelineManuscriptEditor.jsx@@ -35,6 +35,7 @@ import { locateAnchors } from '../lib/manuscriptAnchors';import ManuscriptLiveSection from '../components/pipeline/manuscript/ManuscriptLiveSection';import AnnotatedManuscriptSection from '../components/pipeline/manuscript/AnnotatedManuscriptSection';import ManuscriptCommentIndex from '../components/pipeline/manuscript/ManuscriptCommentIndex';+import ManuscriptIssueTabs from '../components/pipeline/manuscript/ManuscriptIssueTabs';import ManuscriptImpactPreview from '../components/pipeline/manuscript/ManuscriptImpactPreview';import { MANUSCRIPT_TYPES, STAGE_LABEL } from '../components/pipeline/manuscript/constants';import {@@ -54,8 +55,16 @@ const initialViewMode = () => {};export default function PipelineManuscriptEditor() {- const { seriesId } = useParams();+ const params = useParams();+ const { seriesId } = params;const navigate = useNavigate();+ // The issue (by number) the editor is focused on — one issue per view,+ // deep-linkable at /pipeline/series/:id/manuscript/:issueNumber. Read from the+ // route splat (a single splat route, not two :param routes, so issue→issue+ // navigation reuses this component instead of remounting). null on the bare+ // /manuscript URL; a reconcile effect canonicalizes it to the first issue.+ const issueParam = params['*'];+ const activeNumber = issueParam ? Number(issueParam) : null;const [series, setSeries] = useState(null);const [sections, setSections] = useState([]);const [viewType, setViewType] = useState(null); // format currently shown@@ -122,7 +131,10 @@ export default function PipelineManuscriptEditor() {}).finally(() => { if (!canceled) setLoading(false); });return () => { canceled = true; };- }, [seriesId, navigate]);+ // Keyed on seriesId only — `navigate`'s identity changes when the issue-tab+ // URL changes, and including it would re-run this initial load (clobbering a+ // format switch with a stale default-format refetch).+ }, [seriesId]); // eslint-disable-line react-hooks/exhaustive-depsuseEffect(() => {let canceled = false;@@ -246,18 +258,18 @@ export default function PipelineManuscriptEditor() {return result;};- // Reveal a comment in context: open its card and scroll its section into view.- // The section element is registered in every mode (Live + Review, editing or- // not), so this works regardless of which surface is showing. A comment with- // no issueNumber is genuinely unanchored — say so rather than scroll nowhere.+ // Reveal a comment in context: switch to its issue tab and open its card. An+ // issue-anchored note navigates to that issue (the section scrolls the card+ // into view on arrival); a story-level note with no issueNumber has no tab, so+ // it expands inline in the sidebar index instead.const revealComment = (comment) => {setOpenCommentId(comment.id);- if (comment.issueNumber == null) {- toast('This comment is not anchored to a specific issue');- return;+ if (comment.issueNumber == null) return; // unanchored — shown in the sidebar+ if (comment.issueNumber !== activeNumber) {+ navigate(`/pipeline/series/${seriesId}/manuscript/${comment.issueNumber}`);+ } else {+ sectionRefs.current.get(comment.issueNumber)?.scrollIntoView?.({ behavior: 'smooth', block: 'start' });}- const el = sectionRefs.current.get(comment.issueNumber);- el?.scrollIntoView?.({ behavior: 'smooth', block: 'start' });if (comment.stageId && viewType && comment.stageId !== viewType) {toast(`This note is on the ${STAGE_LABEL[comment.stageId] || comment.stageId} — switch formats to edit it in context`);}@@ -309,6 +321,24 @@ export default function PipelineManuscriptEditor() {return set;}, [sectionSpans]);+ // Open-note count per issue, for the tab badges.+ const openCountByNumber = useMemo(() => {+ const map = new Map();+ openCommentsByNumber.forEach((list, number) => map.set(number, list.length));+ return map;+ }, [openCommentsByNumber]);++ // The one issue the editor is focused on. On the bare /manuscript URL (or an+ // unknown issue) fall back to the first issue so there's no blank frame, and+ // canonicalize the URL to it so the tab highlights and deep links/back work.+ const matchedSection = sections.find((s) => s.number === activeNumber) || null;+ const activeSection = matchedSection || sections[0] || null;+ useEffect(() => {+ if (!activeSection) return;+ if (activeNumber === activeSection.number) return;+ navigate(`/pipeline/series/${seriesId}/manuscript/${activeSection.number}`, { replace: true });+ }, [activeSection, activeNumber, seriesId, navigate]);+// Plain object (not memoized): its handlers close over viewType/sections, so a// stale memo would apply accepts against the wrong format. Children read// individual fields rather than the object identity, so there's nothing to gain.@@ -419,33 +449,40 @@ export default function PipelineManuscriptEditor() {No drafted manuscript yet — write a comic script, prose, or teleplay on at least one issue, then run “Finish the draft” from the series arc.</p>) : (- sections.map((section) => {- const sectionComments = openCommentsByNumber.get(section.number) || EMPTY;- const common = {- key: section.issueId,- section,- comments: sectionComments,- spans: sectionSpans.get(section.issueId) || EMPTY,- saveState: saveState[section.issueId],- openCommentId,- onOpenComment: setOpenCommentId,- onCloseComment: () => setOpenCommentId(null),- onContentChange: (content) => setSectionContent(section.issueId, content),- onBlurSave: () => saveSection(section),- onRevert: (runId) => revertSection(section, runId),- registerRef: registerSectionRef(section.number),- commentCardProps,- };- return viewMode === 'live' ? (- <ManuscriptLiveSection {...common} />- ) : (- <AnnotatedManuscriptSection- {...common}- editing={editingIssueId === section.issueId}- onToggleEdit={() => setEditingIssueId((cur) => (cur === section.issueId ? null : section.issueId))}- />- );- })+ <>+ <ManuscriptIssueTabs+ seriesId={seriesId}+ sections={sections}+ activeNumber={activeNumber}+ openCountByNumber={openCountByNumber}+ />+ {activeSection ? (() => {+ const section = activeSection;+ const common = {+ section,+ comments: openCommentsByNumber.get(section.number) || EMPTY,+ spans: sectionSpans.get(section.issueId) || EMPTY,+ saveState: saveState[section.issueId],+ openCommentId,+ onOpenComment: setOpenCommentId,+ onCloseComment: () => setOpenCommentId(null),+ onContentChange: (content) => setSectionContent(section.issueId, content),+ onBlurSave: () => saveSection(section),+ onRevert: (runId) => revertSection(section, runId),+ registerRef: registerSectionRef(section.number),+ commentCardProps,+ };+ return viewMode === 'live' ? (+ <ManuscriptLiveSection {...common} />+ ) : (+ <AnnotatedManuscriptSection+ {...common}+ editing={editingIssueId === section.issueId}+ onToggleEdit={() => setEditingIssueId((cur) => (cur === section.issueId ? null : section.issueId))}+ />+ );+ })() : null}+ </>)}</section>@@ -535,6 +572,7 @@ export default function PipelineManuscriptEditor() {locatedCommentIds={locatedCommentIds}openCommentId={openCommentId}onReveal={revealComment}+ commentCardProps={commentCardProps}/></aside></div>diff --git a/client/src/pages/PipelineManuscriptEditor.test.jsx b/client/src/pages/PipelineManuscriptEditor.test.jsxindex 6b530e28e2..88d7f6ff4a 100644--- a/client/src/pages/PipelineManuscriptEditor.test.jsx+++ b/client/src/pages/PipelineManuscriptEditor.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi, beforeEach } from 'vitest';-import { render, screen, waitFor, fireEvent } from '@testing-library/react';+import { render, screen, waitFor, fireEvent, within } from '@testing-library/react';import { MemoryRouter, Routes, Route } from 'react-router-dom';const api = vi.hoisted(() => ({@@ -27,10 +27,10 @@ const comment = {status: 'open', fix: null, createdAt: 't', updatedAt: 't',};-const renderEditor = () => render(- <MemoryRouter initialEntries={['/pipeline/series/ser-1/manuscript']}>+const renderEditor = (path = '/pipeline/series/ser-1/manuscript') => render(+ <MemoryRouter initialEntries={[path]}><Routes>- <Route path="/pipeline/series/:seriesId/manuscript" element={<PipelineManuscriptEditor />} />+ <Route path="/pipeline/series/:seriesId/manuscript/*" element={<PipelineManuscriptEditor />} /><Route path="/pipeline/series/:seriesId" element={<div>series page</div>} /></Routes></MemoryRouter>,@@ -119,6 +119,52 @@ describe('PipelineManuscriptEditor', () => {});});+ it('shows issue tabs and focuses one issue; a deep link opens that issue', async () => {+ const twoIssues = {+ sections: [+ { issueId: 'iss-1', number: 1, title: 'One', stageId: 'prose', content: 'Issue one body.' },+ { issueId: 'iss-2', number: 2, title: 'Two', stageId: 'prose', content: 'Issue two body.' },+ ],+ viewType: 'prose', primaryStageId: 'prose', pinnedPrimary: 'prose', availableTypes: ['prose'],+ };+ api.getPipelineManuscript.mockResolvedValue(twoIssues);+ renderEditor('/pipeline/series/ser-1/manuscript/2');+ await screen.findByText('My Series');+ // Deep link focuses issue 2 only — issue 1's body is not rendered.+ expect(await screen.findByDisplayValue('Issue two body.')).toBeInTheDocument();+ expect(screen.queryByDisplayValue('Issue one body.')).not.toBeInTheDocument();+ // Both issues appear as tabs.+ const tabs = within(screen.getByRole('navigation', { name: 'Issues' })).getAllByRole('link');+ expect(tabs).toHaveLength(2);+ });++ it('redirects the bare /manuscript URL to the first issue', async () => {+ renderEditor('/pipeline/series/ser-1/manuscript');+ await screen.findByText('My Series');+ // The single issue (number 1) renders; the canonical issue tab is current.+ expect(await screen.findByDisplayValue('The hero walked in. She left.')).toBeInTheDocument();+ const tab = within(screen.getByRole('navigation', { name: 'Issues' })).getByRole('link');+ expect(tab).toHaveAttribute('aria-current', 'page');+ });++ it('switches issues via the tabs without refetching the manuscript', async () => {+ api.getPipelineManuscript.mockResolvedValue({+ sections: [+ { issueId: 'iss-1', number: 1, title: 'One', stageId: 'prose', content: 'Issue one body.' },+ { issueId: 'iss-2', number: 2, title: 'Two', stageId: 'prose', content: 'Issue two body.' },+ ],+ viewType: 'prose', primaryStageId: 'prose', pinnedPrimary: 'prose', availableTypes: ['prose'],+ });+ renderEditor('/pipeline/series/ser-1/manuscript/1');+ expect(await screen.findByDisplayValue('Issue one body.')).toBeInTheDocument();+ const callsBefore = api.getPipelineManuscript.mock.calls.length;++ fireEvent.click(within(screen.getByRole('navigation', { name: 'Issues' })).getByRole('link', { name: /Issue 2/ }));+ expect(await screen.findByDisplayValue('Issue two body.')).toBeInTheDocument();+ // Tab navigation is pure routing — no extra manuscript fetch.+ expect(api.getPipelineManuscript.mock.calls.length).toBe(callsBefore);+ });+it('switches manuscript format on demand', async () => {api.getPipelineManuscript.mockImplementation((_id, type) => {if (type === 'teleplay') return Promise.resolve({