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
feat: deep-link an editorial finding by its comment id alone (#1608)
[._.]/ Adam Eivy7bf009ea59da
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex aac61bbec4..f97491e457 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -59,6 +59,8 @@- **[issue-1606] The editorial health panel's category and check breakdowns are now clickable — tap one to filter the findings list to it.** The "Open by category" and "Open by check" rows (and their regression flags) showed you *where* the problems were but weren't navigable: spotting a regressed category meant manually re-scanning the list for its findings. Each row whose findings you can triage is now a button that deep-links the triage filter to that category or check and scrolls the findings list into view; clicking the active row again clears the filter, and the row shows a highlighted state while it's the active filter. (Rows that only count findings the triage doesn't list — e.g. the "completeness" bucket — stay as plain text rather than linking to an empty list.) Because the filter writes the same URL query the toolbar uses, the resulting view stays deep-linkable. This also adds a proper **Category** filter to the triage toolbar — distinct from the existing scope filter, which is now correctly labeled **Scope** (its Noun/Scene/Issue/Series values were mislabeled "Category"). (`client/src/components/pipeline/editorial/EditorialHealthPanel.jsx`, `client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`, `client/src/lib/editorialChecks.js`)+- **[issue-1608] Editorial findings are now deep-linkable by their comment id alone.** There was no direct URL to a single finding: to act on a `comment-…` id referenced elsewhere (a note, a chat, an agent hand-off) you had to open Editorial Checks, pick the right series, wait for it to load, then hunt the list. A new route — **`/pipeline/findings/:commentId`** — resolves the owning series for you and redirects straight to that finding in the manuscript editor, focused and ready to accept/dismiss/fix, reusing the exact deep-link the triage already produces (`findingManuscriptLink`). A new server endpoint (`GET /api/pipeline/findings/:commentId/locate`) scans every series' review for the id (comment ids are UUID-based, so the match is unambiguous) and returns `{ seriesId, comment }`, or 404 when no series owns it; the client `locatePipelineFinding` wrapper maps that 404 to a tidy "Finding not found" page with a path back to Editorial Checks (it may have been dismissed-and-cleared, or the link is stale). The resolver is a redirect, not a navigable destination (the target depends on the id), so it is intentionally left out of `NAV_COMMANDS` — the navigable surface stays the Editorial Checks page, which already carries the `findings` keyword for ⌘K/voice. (`server/services/pipeline/manuscriptReview.js`, `server/routes/pipeline/manuscript.js`, `client/src/services/apiPipeline.js`, `client/src/pages/PipelineFindingRedirect.jsx`, `client/src/App.jsx`)+- **[issue-1607] Preview a custom check against a series before saving it.** Custom checks are authored as free-text prompts, and the only way to know whether one was noisy or mis-scoped used to be to save it, run the whole series, see the findings, then edit and re-run — a slow loop that left a half-baked check (and its seeded findings) in the catalog. The custom-check form now has a **Preview on this series** button: pick a series, fill in the name + prompt, and PortOS runs the *draft* against the live manuscript and shows sample findings inline — **without persisting the check, seeding the review, or recording a health-trend snapshot**. The dry-run uses the exact same provider-sized manuscript chunking and source resolution a real run would (so the sample reflects production behavior), respects the per-run findings cap, and surfaces the gate-skip case ("this series has no manuscript yet") and the clean case ("flagged nothing") distinctly. The button is disabled with a hint until a series is selected. Internally, the runner's shared context construction was extracted into a reusable `buildEditorialContext` helper so the preview and a real run can never drift apart. (`server/services/pipeline/editorial/checkRunner.js`, `server/routes/pipeline/editorial.js`, `server/lib/validation.js`, `client/src/services/apiPipeline.js`, `client/src/components/pipeline/editorial/EditorialCustomCheckForm.jsx`, `client/src/pages/PipelineEditorialChecks.jsx`)- **[issue-1596] Override any editorial check's severity to match a series' house style — without touching code.** Every check ships a fixed default severity (e.g. `prose.adverb-density` defaults to `low`), but a literary-fiction series may want adverb density flagged `high` while an action series wants it `low`. Each check in the catalog now has a **Severity** selector: leave it on **Default** to use the registry value, or pin it to `high` / `medium` / `low`. A pin is **authoritative** — every finding that check raises is stamped with the chosen level, consistently across deterministic *and* LLM checks (a pin overrides both a check's escalation-from-default and an LLM's own per-finding severity, so "pin this check to low" actually means low everywhere). On the next run the pin also re-grades the check's *existing* open findings — even ones a sampled LLM pass doesn't re-surface — so the editorial-health score and any severity-based autopilot gating reflect the pinned level immediately rather than lagging on stale severities. Leaving a check on **Default** preserves its native per-finding nuance untouched. The override is backward-compatible and additive (absent → the check's `severityDefault`), and the catalog badge shows the effective level with a `*` marker when it's been overridden. (`server/lib/editorial/checkRegistry.js`, `server/routes/pipeline/editorial.js`, `server/services/pipeline/editorial/checkRunner.js`, `server/lib/validation.js`, `client/src/components/pipeline/editorial/EditorialCheckCard.jsx`, `client/src/pages/PipelineEditorialChecks.jsx`)diff --git a/client/src/App.jsx b/client/src/App.jsxindex f8aa4e94c1..4a71b39786 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -97,6 +97,7 @@ const StoryBuilder = lazyWithReload(() => import('./pages/StoryBuilder'));const PipelineSeries = lazyWithReload(() => import('./pages/PipelineSeries'));const PipelineSeriesRoadmap = lazyWithReload(() => import('./pages/PipelineSeriesRoadmap'));const PipelineEditorialChecks = lazyWithReload(() => import('./pages/PipelineEditorialChecks'));+const PipelineFindingRedirect = lazyWithReload(() => import('./pages/PipelineFindingRedirect'));const PipelineReverseOutline = lazyWithReload(() => import('./pages/PipelineReverseOutline'));const PipelineContinuityBible = lazyWithReload(() => import('./pages/PipelineContinuityBible'));const PipelineManuscriptEditor = lazyWithReload(() => import('./pages/PipelineManuscriptEditor'));@@ -325,6 +326,7 @@ export default function App() {<Route path="music/:tab" element={<Music />} /><Route path="pipeline" element={<Pipeline />} /><Route path="pipeline/editorial-checks" element={<PipelineEditorialChecks />} />+ <Route path="pipeline/findings/:commentId" element={<PipelineFindingRedirect />} /><Route path="pipeline/series/:seriesId" element={<PipelineSeries />} /><Route path="pipeline/series/:seriesId/roadmap" element={<PipelineSeriesRoadmap />} /><Route path="pipeline/series/:seriesId/reverse-outline" element={<PipelineReverseOutline />} />diff --git a/client/src/pages/PipelineFindingRedirect.jsx b/client/src/pages/PipelineFindingRedirect.jsxnew file mode 100644index 0000000000..efdef4c17b--- /dev/null+++ b/client/src/pages/PipelineFindingRedirect.jsx@@ -0,0 +1,64 @@+/**+ * Pipeline — finding deep-link resolver (#1608).+ *+ * Findings (editorial-check comments) live per-series, so a link that carries+ * only a `commentId` — shared from elsewhere, pasted into a note, surfaced by an+ * agent — can't open the editor directly: it first has to discover which series+ * owns the comment. This route does exactly that. It resolves the owning series+ * server-side, then redirects (replace) to the canonical manuscript-editor deep+ * link the triage already uses (`findingManuscriptLink`), so all the existing+ * comment-focus plumbing is reused rather than duplicated.+ *+ * Reachable at /pipeline/findings/:commentId. It is a redirect resolver, not a+ * navigable page (the destination depends on the id), so it is intentionally NOT+ * registered in NAV_COMMANDS — the navigable surface is the Editorial Checks+ * triage page, which already carries the `findings` keyword.+ */+import { useEffect, useState } from 'react';+import { Link, Navigate, useParams } from 'react-router-dom';+import { AlertTriangle } from 'lucide-react';+import BrailleSpinner from '../components/BrailleSpinner';+import { locatePipelineFinding } from '../services/api';+import { findingManuscriptLink } from '../lib/editorialChecks';++export default function PipelineFindingRedirect() {+ const { commentId } = useParams();+ // `located`: undefined while resolving, then the lookup result — `{ seriesId,+ // comment }` when a series owns the id, or `null` when none does / it failed.+ // The api wrapper resolves null (never rejects), so absent + failed collapse+ // into the same "not found" fallback below.+ const [located, setLocated] = useState(undefined);++ useEffect(() => {+ let active = true;+ setLocated(undefined);+ locatePipelineFinding(commentId).then((res) => { if (active) setLocated(res); });+ return () => { active = false; };+ }, [commentId]);++ if (located === undefined) {+ return (+ <div className="flex items-center justify-center py-16 text-sm">+ <BrailleSpinner text="Resolving finding…" />+ </div>+ );+ }++ if (located?.seriesId) {+ return <Navigate to={findingManuscriptLink(located.seriesId, located.comment)} replace />;+ }++ return (+ <div className="flex flex-col items-center justify-center gap-3 py-16 text-center">+ <AlertTriangle className="h-8 w-8 text-port-warning" />+ <h1 className="text-lg font-semibold">Finding not found</h1>+ <p className="max-w-md text-sm text-gray-400">+ No series review contains finding <code className="text-gray-300">{commentId}</code>.+ It may have been dismissed and cleared, or the link is stale.+ </p>+ <Link to="/pipeline/editorial-checks" className="text-sm text-port-accent hover:underline">+ Go to Editorial Checks+ </Link>+ </div>+ );+}diff --git a/client/src/pages/PipelineFindingRedirect.test.jsx b/client/src/pages/PipelineFindingRedirect.test.jsxnew file mode 100644index 0000000000..7fc97ed369--- /dev/null+++ b/client/src/pages/PipelineFindingRedirect.test.jsx@@ -0,0 +1,56 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { act, render, screen, waitFor } from '@testing-library/react';+import { MemoryRouter, Routes, Route, useParams, useSearchParams } from 'react-router-dom';+import PipelineFindingRedirect from './PipelineFindingRedirect';+import { locatePipelineFinding } from '../services/api';++vi.mock('../services/api', () => ({+ locatePipelineFinding: vi.fn(),+}));++// Destination stand-in that echoes where the resolver landed (#1608) so we can+// assert it redirected to the right series + comment without the real editor.+function EditorLanding() {+ const { seriesId } = useParams();+ const [params] = useSearchParams();+ return <div>editor series={seriesId} comment={params.get('comment')}</div>;+}++const renderAt = (commentId) => render(+ <MemoryRouter initialEntries={[`/pipeline/findings/${commentId}`]}>+ <Routes>+ <Route path="/pipeline/findings/:commentId" element={<PipelineFindingRedirect />} />+ <Route path="/pipeline/series/:seriesId/manuscript/*" element={<EditorLanding />} />+ <Route path="/pipeline/editorial-checks" element={<div>editorial checks page</div>} />+ </Routes>+ </MemoryRouter>,+);++describe('PipelineFindingRedirect', () => {+ beforeEach(() => locatePipelineFinding.mockReset());++ it('shows a resolving state while the lookup is in flight', async () => {+ let resolve;+ locatePipelineFinding.mockReturnValue(new Promise((r) => { resolve = r; }));+ renderAt('c-1');+ expect(screen.getByText(/resolving finding/i)).toBeInTheDocument();+ // Settle so the pending effect promise doesn't dangle into the next test.+ await act(async () => { resolve(null); });+ });++ it('redirects to the manuscript editor with the resolved series + comment focused', async () => {+ locatePipelineFinding.mockResolvedValue({ seriesId: 'ser-9', comment: { id: 'c-1', issueNumber: 4 } });+ renderAt('c-1');+ await waitFor(() => expect(screen.getByText(/editor series=ser-9/)).toBeInTheDocument());+ expect(screen.getByText(/comment=c-1/)).toBeInTheDocument();+ expect(locatePipelineFinding).toHaveBeenCalledWith('c-1');+ });++ it('shows a not-found state with a path back to Editorial Checks when no series owns the id', async () => {+ locatePipelineFinding.mockResolvedValue(null);+ renderAt('gone');+ await waitFor(() => expect(screen.getByText(/finding not found/i)).toBeInTheDocument());+ const link = screen.getByRole('link', { name: /editorial checks/i });+ expect(link).toHaveAttribute('href', '/pipeline/editorial-checks');+ });+});diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.jsindex 6f2c9e8e4d..299938a466 100644--- a/client/src/services/apiPipeline.js+++ b/client/src/services/apiPipeline.js@@ -509,6 +509,15 @@ export const getPipelineManuscript = (seriesId, type) =>export const getPipelineManuscriptReview = (seriesId) =>request(`/pipeline/series/${encodeURIComponent(seriesId)}/manuscript/review`);+// Resolve a finding by its comment id alone (series-agnostic deep-link, #1608).+// Finder semantics: resolves `{ seriesId, comment }` when a series owns the id,+// or `null` when it doesn't (the route 404s) or the lookup fails — the deep-link+// page renders the same "not found" fallback either way, so it owns the error UI+// and we stay silent.+export const locatePipelineFinding = (commentId) =>+ request(`/pipeline/findings/${encodeURIComponent(commentId)}/locate`, { silent: true })+ .catch(() => null);+// Patch one comment: { status } flip and/or { fix } attach/clear. Returns { comment }.export const patchPipelineManuscriptComment = (seriesId, commentId, patch, options = {}) =>request(`/pipeline/series/${encodeURIComponent(seriesId)}/manuscript/review/comments/${encodeURIComponent(commentId)}`, {diff --git a/server/routes/pipeline/manuscript.js b/server/routes/pipeline/manuscript.jsindex ad4796c85b..01a54fe5b3 100644--- a/server/routes/pipeline/manuscript.js+++ b/server/routes/pipeline/manuscript.js@@ -172,6 +172,17 @@ router.get('/series/:id/manuscript/review', asyncHandler(async (req, res) => {res.json(await getReviewWithStaleness(req.params.id));}));+// Resolve a finding by its (series-agnostic) comment id alone → the owning+// series + comment, so a deep-link carrying only a commentId can open the+// editor without the user first picking a series (#1608). 404 when no series+// review contains the id (e.g. the finding was dismissed-then-GC'd or the link+// is stale).+router.get('/findings/:commentId/locate', asyncHandler(async (req, res) => {+ const located = await manuscriptReview.locateComment(req.params.commentId);+ if (!located) throw new ServerError('Finding not found', { status: 404, code: 'PIPELINE_FINDING_NOT_FOUND' });+ res.json(located);+}));+router.patch('/series/:id/manuscript/review/comments/:commentId', asyncHandler(async (req, res) => {await seriesSvc.getSeries(req.params.id).catch((err) => { throw mapServiceError(err); });const body = validateRequest(manuscriptCommentPatchSchema, req.body ?? {});diff --git a/server/routes/pipeline/manuscript.locate.test.js b/server/routes/pipeline/manuscript.locate.test.jsnew file mode 100644index 0000000000..daf58565f3--- /dev/null+++ b/server/routes/pipeline/manuscript.locate.test.js@@ -0,0 +1,36 @@+import { describe, it, expect, vi } from 'vitest';+import express from 'express';+import { request } from '../../lib/testHelper.js';+import { errorMiddleware } from '../../lib/errorHandler.js';++// Only the finding-locate route is under test here, so stub the resolver and let+// every other manuscript dependency pass through.+const locateComment = vi.fn();+vi.mock('../../services/pipeline/manuscriptReview.js', async (importOriginal) => ({+ ...(await importOriginal()),+ locateComment: (...a) => locateComment(...a),+}));++const manuscriptRoutes = (await import('./manuscript.js')).default;++const app = express();+app.use(express.json());+app.use('/api/pipeline', manuscriptRoutes);+app.use(errorMiddleware);++describe('GET /pipeline/findings/:commentId/locate (#1608)', () => {+ it('returns the owning series + comment when the id resolves', async () => {+ locateComment.mockResolvedValueOnce({ seriesId: 'ser-7', comment: { id: 'c-1', issueNumber: 3 } });+ const res = await request(app).get('/api/pipeline/findings/c-1/locate');+ expect(res.status).toBe(200);+ expect(res.body).toEqual({ seriesId: 'ser-7', comment: { id: 'c-1', issueNumber: 3 } });+ expect(locateComment).toHaveBeenCalledWith('c-1');+ });++ it('404s with a PIPELINE_FINDING_NOT_FOUND code when no series owns the id', async () => {+ locateComment.mockResolvedValueOnce(null);+ const res = await request(app).get('/api/pipeline/findings/missing/locate');+ expect(res.status).toBe(404);+ expect(res.body.error?.code || res.body.code).toBe('PIPELINE_FINDING_NOT_FOUND');+ });+});diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.jsindex dc92e8addb..853b0eb8eb 100644--- a/server/services/pipeline/manuscriptReview.js+++ b/server/services/pipeline/manuscriptReview.js@@ -19,7 +19,7 @@ import { join } from 'path';import { randomUUID } from 'crypto';import { atomicWrite, readJSONFile } from '../../lib/fileUtils.js';import { createFileWriteQueue } from '../../lib/fileWriteQueue.js';-import { seriesStore } from './series.js';+import { seriesStore, listSeries } from './series.js';import { collectManuscriptSections, REPLACEMENT_STRATEGIES, replacementStrategyForCategory } from './arcPlanner.js';import { shapeAnchoredEdit, fixFromEdits } from './manuscriptFix.js';import { emitRecordUpdated } from '../sharing/recordEvents.js';@@ -439,3 +439,22 @@ export async function getComment(seriesId, commentId) {const review = await readReview(seriesId);return review.comments.find((c) => c.id === commentId) || null;}++/**+ * Locate a finding/comment across ALL series by its (globally-unique) comment+ * id. Findings live per-series in each series' manuscript-review.json, so a+ * deep-link that carries only a commentId (e.g. one shared from elsewhere) has+ * to resolve the owning series before the editor can open it (#1608). Returns+ * `{ seriesId, comment }` for the first series whose review contains the id, or+ * `null` when no series owns it. Comment ids are UUID-based (`randomUUID`) so a+ * match is unambiguous; deleted series are skipped (listSeries default).+ */+export async function locateComment(commentId) {+ if (typeof commentId !== 'string' || !commentId) return null;+ const series = await listSeries();+ for (const s of series) {+ const comment = await getComment(s.id, commentId);+ if (comment) return { seriesId: s.id, comment };+ }+ return null;+}diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.jsindex 1bb7ba8711..2ddc9a5b5d 100644--- a/server/services/pipeline/manuscriptReview.test.js+++ b/server/services/pipeline/manuscriptReview.test.js@@ -7,9 +7,19 @@ vi.mock('../../lib/fileUtils.js', () => ({readJSONFile: vi.fn(async (path, fallback) => (fileStore.has(path) ? fileStore.get(path) : fallback)),}));-// seriesStore().recordDir(id) → a stable per-series path key.+// seriesStore().recordDir(id) → a stable per-series path key. `listSeries`+// derives the seeded series ids straight from the in-memory file store so+// locateComment's cross-series scan stays consistent with whatever was seeded.vi.mock('./series.js', () => ({seriesStore: () => ({ recordDir: (id) => `/mock/series/${id}` }),+ listSeries: async () => {+ const ids = [];+ for (const key of fileStore.keys()) {+ const id = /^\/mock\/series\/([^/]+)\//.exec(key)?.[1];+ if (id && !ids.includes(id)) ids.push(id);+ }+ return ids.map((id) => ({ id }));+ },}));// No manuscript sections needed for most tests (seed resolves issueId/stageId@@ -25,7 +35,7 @@ vi.mock('./arcPlanner.js', () => ({import { recordEvents } from '../sharing/recordEvents.js';import { collectManuscriptSections } from './arcPlanner.js';-import { seedReviewFromFindings, updateComment, mergeReviewFromSync, getReview, DISMISS_REASONS } from './manuscriptReview.js';+import { seedReviewFromFindings, updateComment, mergeReviewFromSync, getReview, locateComment, DISMISS_REASONS } from './manuscriptReview.js';describe('manuscriptReview — record-event emission on write', () => {let updates;@@ -494,3 +504,29 @@ describe('manuscriptReview — false-positive dismissal reason (#1605)', () => {expect(byId.fp2.dismissReason).toBeNull(); // not dismissed → reason dropped});});++describe('manuscriptReview — locateComment (cross-series deep-link resolver, #1608)', () => {+ beforeEach(() => { fileStore.clear(); });++ it('resolves the owning series + comment for a known id', async () => {+ await seedReviewFromFindings('loc-a', [{ problem: 'Act I drags', anchorQuote: 'q1' }]);+ const seededB = await seedReviewFromFindings('loc-b', [{ problem: 'POV slips', anchorQuote: 'q2' }]);+ const targetId = seededB.comments[0].id;++ const located = await locateComment(targetId);+ expect(located).toMatchObject({ seriesId: 'loc-b' });+ expect(located.comment.id).toBe(targetId);+ expect(located.comment.problem).toBe('POV slips');+ });++ it('returns null when no series review owns the id', async () => {+ await seedReviewFromFindings('loc-a', [{ problem: 'P', anchorQuote: 'q' }]);+ expect(await locateComment('comment-does-not-exist')).toBeNull();+ });++ it('returns null for a blank/non-string id without scanning', async () => {+ expect(await locateComment('')).toBeNull();+ expect(await locateComment(null)).toBeNull();+ expect(await locateComment(undefined)).toBeNull();+ });+});