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
refactor([issue-2170]): simplify reader-panel staleness, dedup UI, label consensus findings
[._.]/ Adam Eivy3e094d5a8533
diff --git a/client/src/components/pipeline/ReaderPanelView.jsx b/client/src/components/pipeline/ReaderPanelView.jsxindex da02205278..d9ff6fd571 100644--- a/client/src/components/pipeline/ReaderPanelView.jsx+++ b/client/src/components/pipeline/ReaderPanelView.jsx@@ -82,53 +82,58 @@ function PersonaChips({ ids }) {);}+// consensus + attention are the same concern shape (differ only in tone) — one+// helper renders both; polarizing has its own loved/hated shape below.+function ConcernSection({ items, icon: Icon, title, headTone, itemClass, metaTone, labelClass }) {+ if (!items?.length) return null;+ return (+ <div>+ <h3 className={`text-[11px] uppercase tracking-wider ${headTone} mb-1.5 flex items-center gap-1.5`}>+ <Icon size={12} /> {title}+ </h3>+ <ul className="space-y-1.5">+ {items.map((c, i) => (+ <li key={`${c.questionId}-${c.issueNumber}-${i}`} className={`border rounded p-2 ${itemClass}`}>+ <div className="flex items-center gap-2 flex-wrap text-xs text-gray-300">+ <span className={`font-mono text-[10px] ${metaTone}`}>#{c.issueNumber}</span>+ <span className={labelClass}>{c.questionLabel}</span>+ <span className={`text-[10px] ${metaTone}`}>{c.count}/{c.totalPersonas}</span>+ <PersonaChips ids={c.personas} />+ </div>+ </li>+ ))}+ </ul>+ </div>+ );+}+function DisagreementList({ disagreements }) {const { consensus = [], attention = [], polarizing = [], totalPersonas = 0 } = disagreements || {};const nothing = !consensus.length && !attention.length && !polarizing.length;if (nothing) {return <p className="text-xs text-gray-500 italic">The panel found no notable disagreements — a rare and suspicious consensus.</p>;}+ const withTotal = (list) => list.map((c) => ({ ...c, totalPersonas }));return (<div className="space-y-4">- {consensus.length ? (- <div>- <h3 className="text-[11px] uppercase tracking-wider text-port-error/80 mb-1.5 flex items-center gap-1.5">- <AlertTriangle size={12} /> Consensus concerns — routed to editorial findings- </h3>- <ul className="space-y-1.5">- {consensus.map((c, i) => (- <li key={`${c.questionId}-${c.issueNumber}-${i}`} className="border border-port-error/30 bg-port-error/5 rounded p-2">- <div className="flex items-center gap-2 flex-wrap text-xs text-gray-200">- <span className="font-mono text-[10px] text-gray-400">#{c.issueNumber}</span>- <span className="font-medium">{c.questionLabel}</span>- <span className="text-[10px] text-gray-500">{c.count}/{totalPersonas}</span>- <PersonaChips ids={c.personas} />- </div>- </li>- ))}- </ul>- </div>- ) : null}-- {attention.length ? (- <div>- <h3 className="text-[11px] uppercase tracking-wider text-port-warning/80 mb-1.5 flex items-center gap-1.5">- <Scale size={12} /> Editorial attention — some flagged, some didn’t- </h3>- <ul className="space-y-1.5">- {attention.map((c, i) => (- <li key={`${c.questionId}-${c.issueNumber}-${i}`} className="border border-port-border rounded p-2 bg-port-bg/40">- <div className="flex items-center gap-2 flex-wrap text-xs text-gray-300">- <span className="font-mono text-[10px] text-gray-500">#{c.issueNumber}</span>- <span>{c.questionLabel}</span>- <span className="text-[10px] text-gray-600">{c.count}/{totalPersonas}</span>- <PersonaChips ids={c.personas} />- </div>- </li>- ))}- </ul>- </div>- ) : null}+ <ConcernSection+ items={withTotal(consensus)}+ icon={AlertTriangle}+ title="Consensus concerns — routed to editorial findings"+ headTone="text-port-error/80"+ itemClass="border-port-error/30 bg-port-error/5"+ metaTone="text-gray-400"+ labelClass="font-medium text-gray-200"+ />+ <ConcernSection+ items={withTotal(attention)}+ icon={Scale}+ title="Editorial attention — some flagged, some didn’t"+ headTone="text-port-warning/80"+ itemClass="border-port-border bg-port-bg/40"+ metaTone="text-gray-500"+ labelClass=""+ />{polarizing.length ? (<div>diff --git a/client/src/lib/editorialChecks.js b/client/src/lib/editorialChecks.jsindex 5c6a3bfefb..27c2864ec4 100644--- a/client/src/lib/editorialChecks.js+++ b/client/src/lib/editorialChecks.js@@ -16,6 +16,19 @@ export const CHECK_SCOPE_LABELS = Object.freeze({export const scopeLabel = (scope) =>CHECK_SCOPE_LABELS[scope] || (scope ? scope[0].toUpperCase() + scope.slice(1) : 'Other');+// Display metadata for findings seeded OUT OF BAND with a stable `checkId` that+// isn't a runnable registry check (so it never appears in the check catalog).+// Consulted by groupFindingsByCheck's label fallback so the triage section shows+// a human header instead of the raw slug. The reader panel (#2170) seeds+// ≥3-persona consensus concerns with `reader-panel.consensus`.+export const VIRTUAL_CHECK_META = Object.freeze({+ 'reader-panel.consensus': {+ label: 'Reader Panel — consensus concern',+ description: '3+ reader-panel personas independently flagged the same issue (#2170). Seeded from the Reader Panel, not a runnable editorial check.',+ scope: 'series',+ },+});+// A finding's editorial category (continuity / pacing / style / …) — distinct// from its check scope. Mirrors the server's normalization in editorialScore.js// so the triage facet and the health panel's "open by category" agree.@@ -107,11 +120,12 @@ export function groupFindingsByCheck(comments = [], rowsById = {}) {if (!c?.checkId) continue;if (!groups.has(c.checkId)) {const row = lookup.get(c.checkId) || null;+ const virtual = VIRTUAL_CHECK_META[c.checkId] || null;groups.set(c.checkId, {checkId: c.checkId,- label: row?.label || c.checkId,- description: row?.description || null,- scope: row?.scope || 'other',+ label: row?.label || virtual?.label || c.checkId,+ description: row?.description || virtual?.description || null,+ scope: row?.scope || virtual?.scope || 'other',kind: row?.kind || null,comments: [],open: 0,diff --git a/server/lib/editorial/panelDisagreement.js b/server/lib/editorial/panelDisagreement.jsindex 13b922dd5f..a3ba8ba2a6 100644--- a/server/lib/editorial/panelDisagreement.js+++ b/server/lib/editorial/panelDisagreement.js@@ -153,8 +153,7 @@ export function minePanelDisagreements(responses, { validIssueNumbers = null, coconst cites = citationsForQuestion(list, qid);for (const [issueNumber, personaSet] of cites) {if (validSet && !validSet.has(issueNumber)) continue;- const count = personaSet.size;- if (count < 1) continue;+ const count = personaSet.size; // ≥ 1 — citationsForQuestion only maps issues at least one persona citedconst entry = {questionId: qid,questionLabel: q.label,diff --git a/server/services/pipeline/readerPanel.js b/server/services/pipeline/readerPanel.jsindex b04d053dde..e591fcbf19 100644--- a/server/services/pipeline/readerPanel.js+++ b/server/services/pipeline/readerPanel.js@@ -22,13 +22,12 @@ import { join } from 'path';import { PATHS, atomicWrite, ensureDir, tryReadFile, safeJSONParse } from '../../lib/fileUtils.js';import { runStagedLLM } from '../../lib/stageRunner.js';import {- PANEL_PERSONAS,PANEL_PERSONA_IDS,minePanelDisagreements,consensusToFindings,sanitizePersonaResponse,} from '../../lib/editorial/panelDisagreement.js';-import { buildDigestForSeries, renderDigestText } from './readerPanelDigest.js';+import { computeSourceContentHash, renderDigestText } from './readerPanelDigest.js';import { seedReviewFromFindings } from './manuscriptReview.js';const CONSENSUS_CHECK_ID = 'reader-panel.consensus';@@ -99,9 +98,10 @@ export async function finalizePanel(seriesId, digest, responses, { runId = null});let seededFindings = 0;- if (findings.length || responses.length) {+ if (responses.length) {// Even with zero findings, run in 'fresh' mode so a re-run that resolved a- // prior consensus auto-dismisses that stale finding.+ // prior consensus auto-dismisses that stale finding. (`findings` derives from+ // `responses`, so a non-empty `findings` already implies a non-empty panel.)await seedReviewFromFindings(seriesId, findings, {runId,mode: 'fresh',@@ -130,13 +130,13 @@ export async function finalizePanel(seriesId, digest, responses, { runId = null}// Re-hash the current issue content to decide whether a stored panel is stale-// (the drafts moved since the digest was built). Cheap — issues + content only,-// no scene segmentation.+// (the drafts moved since the digest was built). Cheap — issue list + content+// only, no series record or scene segmentation (the hash ignores both).async function isPanelStale(snapshot, seriesId) {if (!snapshot || snapshot.status !== 'complete' || !snapshot.sourceContentHash) return false;- const digest = await buildDigestForSeries(seriesId).catch(() => null);- if (!digest) return false;- return digest.sourceContentHash !== snapshot.sourceContentHash;+ const hash = await computeSourceContentHash(seriesId).catch(() => null);+ if (hash === null) return false;+ return hash !== snapshot.sourceContentHash;}/**@@ -149,6 +149,3 @@ export async function getReaderPanel(seriesId) {if (!snapshot) return { seriesId, status: 'none', personas: [], disagreements: null };return { ...snapshot, stale: await isPanelStale(snapshot, seriesId) };}--export const PANEL_META = { personas: PANEL_PERSONAS, consensusCheckId: CONSENSUS_CHECK_ID };-export const __testing = { assertValidSeriesId, CONSENSUS_CHECK_ID };diff --git a/server/services/pipeline/readerPanelDigest.js b/server/services/pipeline/readerPanelDigest.jsindex 4ccd290a9c..ec9ce89e19 100644--- a/server/services/pipeline/readerPanelDigest.js+++ b/server/services/pipeline/readerPanelDigest.js@@ -125,6 +125,22 @@ const digestContentHash = (issues) =>.update(issues.map((i) => `${i.number}:${i.text || ''}`).sort().join('\n')).digest('hex');+/**+ * The digest's `sourceContentHash` depends ONLY on each issue's number + drafted+ * text (see `digestContentHash`), so the staleness check doesn't need the full+ * digest (series record, scene segmentation, excerpts). This lightweight variant+ * reads only the issue list + content — cheap enough for the panel read path.+ */+export async function computeSourceContentHash(seriesId, { issues: issuesArg } = {}) {+ const issues = Array.isArray(issuesArg) ? issuesArg : await listIssues({ seriesId });+ const withContent = [];+ for (const issue of issues) {+ const picked = pickAnalyzableContent(issue);+ if (picked) withContent.push({ number: issue.number, text: picked.text });+ }+ return digestContentHash(withContent);+}+/*** Build the full series digest the panel reads. Only issues with drafted* reader-facing content are included. Returns the structured digest plus a@@ -133,9 +149,13 @@ const digestContentHash = (issues) =>* for disagreement mining).*/export async function buildDigestForSeries(seriesId, { issues: issuesArg, series: seriesArg } = {}) {- const issues = Array.isArray(issuesArg) ? issuesArg : await listIssues({ seriesId });- const series = seriesArg !== undefined ? seriesArg : await getSeries(seriesId).catch(() => null);- const segmentation = await getSceneSegmentation(seriesId).catch(() => ({ scenes: [] }));+ // Three independent reads — one is a whole-manuscript stitch inside+ // getSceneSegmentation — so fan them out rather than awaiting serially.+ const [issues, series, segmentation] = await Promise.all([+ Array.isArray(issuesArg) ? issuesArg : listIssues({ seriesId }),+ seriesArg !== undefined ? seriesArg : getSeries(seriesId).catch(() => null),+ getSceneSegmentation(seriesId).catch(() => ({ scenes: [] })),+ ]);const scenesByNumber = new Map();for (const scene of segmentation.scenes || []) {const num = scene?.issueNumber;