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: bulk accept/dismiss in editorial findings triage (#1599)
[._.]/ Adam Eivy188cc1049467
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d433f6475c..b90b480266 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -57,6 +57,8 @@## Editorial checks+- **[issue-1599] The findings triage list now does bulk accept / dismiss — select findings across checks and resolve the whole batch in one action.** The inline accept/dismiss flow (#1598) still resolved one finding at a time, so clearing a noisy run meant clicking through dozens of rows individually. Every open finding now carries a **checkbox**, each check group has a **select-all** header checkbox (with a tri-state "some selected" look), and once anything is selected a **sticky action bar** replaces the count line with **Accept N** / **Dismiss N** / **Clear**. *Accept* applies only the selected findings that carry an applicable fix (the count reflects that subset); *Dismiss* resolves the entire selection. The batch runs sequentially so the accept endpoint's manuscript-section writes don't race on the shared file, each result updates the list + health panel reactively per the repo's optimistic-UI convention, and resolved findings drop out of the selection automatically. A per-finding failure is counted and surfaced in one summary toast (open those in the editor) rather than aborting the rest of the batch. (`client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`)+- **[issue-1598] The findings triage list now previews, accepts, and dismisses a check finding inline — no deep-link into the manuscript editor per finding.** The Editorial Checks findings list only ever showed a finding's problem statement; to see (let alone apply) its suggested fix you had to open the manuscript editor one finding at a time, which made batch review impractical — 50 findings meant 50 context switches. Each open finding with a suggested fix now expands a **collapsed before/after diff** right in the triage row (reusing the manuscript card's `InlineDiff` and edit helpers, so the preview matches exactly what the editor would apply), with inline **Accept** and **Dismiss** buttons that apply or resolve the finding without leaving the page and update the list + health panel reactively. Heavier edits — rewriting the replacement text, cherry-picking individual edits within a multi-edit fix — still deep-link into the editor via an "Open in the editor" link. (`client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`, `client/src/pages/PipelineEditorialChecks.jsx`)- **[issue-1597] The editorial health panel now tracks each *check* over time, not just the overall score — a per-check finding-count sparkline that shows whether a given check is improving or regressing run-over-run.** The revision-trend ledger already snapshotted the open-finding counts by severity and category after every editorial-checks / completeness run, so the panel could draw an overall score sparkline and flag categories that regressed — but there was no way to see, say, whether the filter-word count is dropping draft-over-draft or whether name-similarity findings are creeping up as you add characters. Each trend snapshot now also records the open-finding count **per check**, and the Editorial Health panel renders an **Open by check** breakdown: every check with open findings, its current count, a magnitude sparkline of that check's count across the recorded revisions (normalized to its own peak), and a regression flag (`1→4`) when a check got worse since the previous revision. Check ids resolve to their human catalog labels (falling back to the raw id for a since-deleted custom check), and the list caps at the eight worst checks with a "+N more" note so a noisy run can't blow out the panel. Per-check counts are additive, install-local telemetry — snapshots recorded before this shipped simply start accumulating per-check history from the first run after upgrade. (`server/services/pipeline/editorialScore.js`, `client/src/lib/editorialHealth.js`, `client/src/components/pipeline/editorial/EditorialHealthPanel.jsx`, `client/src/pages/PipelineEditorialChecks.jsx`)diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsxindex 185e49fd3d..f51cde3758 100644--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx@@ -8,10 +8,15 @@* before/after diff (reusing the manuscript card's `InlineDiff` + edit helpers)* and applies or dismisses it without leaving the page. Heavier edits (editing* the replacement text, per-edit selection) still deep-link into the editor.+ *+ * For reviewing a large batch, open findings carry a checkbox (#1599): select+ * across checks (or a whole group via the header checkbox) and a sticky action+ * bar bulk-accepts the selected findings that have an applicable fix and/or+ * bulk-dismisses the selection — each result reactively updates local state.*/import { Link } from 'react-router-dom';import { ChevronDown, ChevronRight, ExternalLink, History, Check, X, Loader2, GitCompareArrows } from 'lucide-react';-import { useMemo, useState } from 'react';+import { useEffect, useMemo, useRef, useState } from 'react';import { groupFindingsByCheck, findingManuscriptLink, openFindingsTotal } from '../../../lib/editorialChecks';import { fixEditsOf, selectedEditsFor } from '../manuscript/ManuscriptCommentCard';import InlineDiff from '../../ui/InlineDiff';@@ -30,6 +35,18 @@ const STATUS_TONE = {dismissed: 'text-gray-600 line-through',};+// A fix is acceptable only when it carries usable replacement text — mirror the+// manuscript card so the inline/bulk Accept stays disabled for edge edits the+// editor must handle. Shared by the per-finding row and the bulk action bar.+const isAcceptableFix = (comment) =>+ !!comment.fix && fixEditsOf(comment).some((e) => (e.replace || '').trim());++// The edits payload the accept endpoint expects for a comment (drop the local+// `selected` flag). Shared by inline Accept and bulk Accept so both apply the+// same edits the editor would.+const acceptEditsOf = (comment) =>+ selectedEditsFor(comment, null).map(({ selected: _selected, ...edit }) => edit);+function CountPills({ counts }) {return (<span className="flex items-center gap-1.5">@@ -59,23 +76,39 @@ function StaleBadge({ count }) {);}-// One finding: deep-link header + (for open findings) an inline preview/accept/-// dismiss bar (#1598). The collapsed diff reuses the manuscript card's edit-// helpers + `InlineDiff` so the preview here matches what the editor applies.-function FindingRow({ seriesId, comment, onCommentChange }) {+// Checkbox that can render the tri-state "some selected" indeterminate look —+// the DOM `indeterminate` flag is set imperatively since React has no prop for it.+function SelectCheckbox({ checked, indeterminate = false, onChange, label, className = '' }) {+ const ref = useRef(null);+ useEffect(() => { if (ref.current) ref.current.indeterminate = indeterminate; }, [indeterminate]);+ return (+ <input+ ref={ref}+ type="checkbox"+ checked={checked}+ onChange={onChange}+ aria-label={label}+ className={`h-3.5 w-3.5 shrink-0 cursor-pointer accent-port-accent ${className}`}+ />+ );+}++// One finding: deep-link header + (for open findings) a selection checkbox and+// an inline preview/accept/dismiss bar (#1598). The collapsed diff reuses the+// manuscript card's edit helpers + `InlineDiff` so the preview here matches what+// the editor applies.+function FindingRow({ seriesId, comment, onCommentChange, selected, onToggleSelect }) {const [showFix, setShowFix] = useState(false);const hasFix = !!comment.fix;const isOpen = comment.status === 'open';const edits = useMemo(() => fixEditsOf(comment), [comment]);- // Mirror the manuscript card: a fix with no usable replacement text can't be- // applied, so the inline Accept stays disabled (the editor handles edge edits).- const acceptable = hasFix && edits.some((e) => (e.replace || '').trim());+ const acceptable = isAcceptableFix(comment);const [runAccept, accepting] = useAsyncAction(() => acceptPipelineManuscriptFix(seriesId,comment.id,- { edits: selectedEditsFor(comment, null).map(({ selected: _s, ...edit }) => edit) },+ { edits: acceptEditsOf(comment) },{ silent: true },),{ errorMessage: 'Failed to apply fix' },@@ -98,22 +131,32 @@ function FindingRow({ seriesId, comment, onCommentChange }) {return (<li className="p-2.5 space-y-2">- <Link- to={findingManuscriptLink(seriesId, comment)}- className="group flex items-start justify-between gap-2"- >- <span className="min-w-0 space-y-0.5">- <span className={`block text-xs ${STATUS_TONE[comment.status] || STATUS_TONE.open}`}>- <span className={`mr-1.5 inline-block h-2 w-2 rounded-full align-middle ${SEVERITY_DOT[comment.severity] || SEVERITY_DOT.low}`} />- {comment.problem}- </span>- <span className="flex items-center gap-2">- {comment.location ? <span className="block text-[11px] text-gray-500">{comment.location}</span> : null}- {isOpen && comment.stale ? <StaleBadge /> : null}+ <div className="flex items-start gap-2">+ {isOpen ? (+ <SelectCheckbox+ checked={selected}+ onChange={() => onToggleSelect?.(comment.id)}+ label={`Select finding: ${comment.problem}`}+ className="mt-1"+ />+ ) : null}+ <Link+ to={findingManuscriptLink(seriesId, comment)}+ className="group flex min-w-0 flex-1 items-start justify-between gap-2"+ >+ <span className="min-w-0 space-y-0.5">+ <span className={`block text-xs ${STATUS_TONE[comment.status] || STATUS_TONE.open}`}>+ <span className={`mr-1.5 inline-block h-2 w-2 rounded-full align-middle ${SEVERITY_DOT[comment.severity] || SEVERITY_DOT.low}`} />+ {comment.problem}+ </span>+ <span className="flex items-center gap-2">+ {comment.location ? <span className="block text-[11px] text-gray-500">{comment.location}</span> : null}+ {isOpen && comment.stale ? <StaleBadge /> : null}+ </span></span>- </span>- <ExternalLink size={13} className="mt-0.5 shrink-0 text-gray-600 group-hover:text-port-accent" />- </Link>+ <ExternalLink size={13} className="mt-0.5 shrink-0 text-gray-600 group-hover:text-port-accent" />+ </Link>+ </div>{isOpen ? (<div className="space-y-1.5">@@ -169,30 +212,53 @@ function FindingRow({ seriesId, comment, onCommentChange }) {);}-function CheckGroup({ seriesId, group, onCommentChange }) {+function CheckGroup({ seriesId, group, onCommentChange, selectedIds, onToggleSelect, onSelectMany }) {const [open, setOpen] = useState(group.open > 0);+ const openIds = useMemo(+ () => group.comments.filter((c) => c.status === 'open').map((c) => c.id),+ [group.comments],+ );+ const selectedCount = openIds.reduce((n, id) => n + (selectedIds.has(id) ? 1 : 0), 0);+ const allSelected = openIds.length > 0 && selectedCount === openIds.length;return (<div className="rounded-lg border border-port-border bg-port-card">- <button- type="button"- onClick={() => setOpen((v) => !v)}- className="flex w-full items-center justify-between gap-2 p-2.5 text-left"- aria-expanded={open}- >- <span className="flex items-center gap-1.5 min-w-0">- {open ? <ChevronDown size={14} className="shrink-0" /> : <ChevronRight size={14} className="shrink-0" />}- <span className="text-sm font-medium text-gray-100 truncate">{group.label}</span>- <span className="text-[10px] text-gray-500 shrink-0">{group.open} open · {group.total} total</span>- </span>- <span className="flex items-center gap-1.5 shrink-0">- {group.stale > 0 ? <StaleBadge count={group.stale} /> : null}- <CountPills counts={group.counts} />- </span>- </button>+ <div className="flex items-center gap-2 p-2.5">+ {openIds.length > 0 ? (+ <SelectCheckbox+ checked={allSelected}+ indeterminate={selectedCount > 0 && !allSelected}+ onChange={() => onSelectMany?.(openIds, !allSelected)}+ label={`Select all open findings in ${group.label}`}+ />+ ) : null}+ <button+ type="button"+ onClick={() => setOpen((v) => !v)}+ className="flex min-w-0 flex-1 items-center justify-between gap-2 text-left"+ aria-expanded={open}+ >+ <span className="flex items-center gap-1.5 min-w-0">+ {open ? <ChevronDown size={14} className="shrink-0" /> : <ChevronRight size={14} className="shrink-0" />}+ <span className="text-sm font-medium text-gray-100 truncate">{group.label}</span>+ <span className="text-[10px] text-gray-500 shrink-0">{group.open} open · {group.total} total</span>+ </span>+ <span className="flex items-center gap-1.5 shrink-0">+ {group.stale > 0 ? <StaleBadge count={group.stale} /> : null}+ <CountPills counts={group.counts} />+ </span>+ </button>+ </div>{open ? (<ul className="divide-y divide-port-border/60 border-t border-port-border/60">{group.comments.map((c) => (- <FindingRow key={c.id} seriesId={seriesId} comment={c} onCommentChange={onCommentChange} />+ <FindingRow+ key={c.id}+ seriesId={seriesId}+ comment={c}+ onCommentChange={onCommentChange}+ selected={selectedIds.has(c.id)}+ onToggleSelect={onToggleSelect}+ />))}</ul>) : null}@@ -200,8 +266,108 @@ function CheckGroup({ seriesId, group, onCommentChange }) {);}+// Sticky bar shown while findings are selected (#1599): bulk-accept those with an+// applicable fix, bulk-dismiss the whole selection. Actions run sequentially so+// the accept endpoint's section writes don't race on the shared manuscript file.+function BulkActionBar({ seriesId, selected, onCommentChange, onClear }) {+ const [busy, setBusy] = useState(false);+ const acceptable = useMemo(() => selected.filter(isAcceptableFix), [selected]);++ const runBulk = async (mode) => {+ const targets = mode === 'accept' ? acceptable : selected;+ if (!targets.length) return;+ setBusy(true);+ let ok = 0;+ let failed = 0;+ for (const comment of targets) {+ const result = mode === 'accept'+ ? await acceptPipelineManuscriptFix(seriesId, comment.id, { edits: acceptEditsOf(comment) }, { silent: true }).catch(() => null)+ : await patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed' }, { silent: true }).catch(() => null);+ if (result?.comment) {+ onCommentChange?.(result.comment);+ ok += 1;+ } else {+ failed += 1;+ }+ }+ setBusy(false);+ onClear?.();+ if (ok) toast.success(`${mode === 'accept' ? 'Applied' : 'Dismissed'} ${ok} finding${ok === 1 ? '' : 's'}`);+ if (failed) toast.error(`${failed} finding${failed === 1 ? '' : 's'} failed — open them in the editor`);+ };++ return (+ <div className="sticky top-0 z-10 flex flex-wrap items-center gap-2 rounded-lg border border-port-accent/40 bg-port-card p-2 shadow-lg">+ <span className="text-[11px] font-medium text-gray-200">{selected.length} selected</span>+ <div className="ml-auto flex items-center gap-1.5">+ <button+ type="button"+ onClick={() => runBulk('accept')}+ disabled={busy || !acceptable.length}+ title={acceptable.length ? undefined : 'No selected finding has an applicable fix'}+ className="inline-flex items-center gap-1 rounded border border-port-success/40 bg-port-success/20 px-2 py-1 text-[11px] text-port-success hover:bg-port-success/30 disabled:opacity-40"+ >+ {busy ? <Loader2 size={12} className="animate-spin" /> : <Check size={12} />}+ Accept {acceptable.length}+ </button>+ <button+ type="button"+ onClick={() => runBulk('dismiss')}+ disabled={busy || !selected.length}+ className="inline-flex items-center gap-1 rounded border border-port-border px-2 py-1 text-[11px] text-gray-300 hover:text-white hover:border-port-accent/40 disabled:opacity-40"+ >+ {busy ? <Loader2 size={12} className="animate-spin" /> : <X size={12} />}+ Dismiss {selected.length}+ </button>+ <button+ type="button"+ onClick={onClear}+ disabled={busy}+ className="rounded px-2 py-1 text-[11px] text-gray-500 hover:text-white disabled:opacity-40"+ >+ Clear+ </button>+ </div>+ </div>+ );+}+export default function EditorialFindingsTriage({ seriesId, comments = [], checksById = {}, onCommentChange }) {const groups = useMemo(() => groupFindingsByCheck(comments, checksById), [comments, checksById]);+ const [selectedIds, setSelectedIds] = useState(() => new Set());++ // Selection only ever holds open findings — once a finding is accepted/dismissed+ // (here or in the editor) drop it so the bar's counts never count resolved ones.+ const openIds = useMemo(+ () => new Set(comments.filter((c) => c.checkId && c.status === 'open').map((c) => c.id)),+ [comments],+ );+ useEffect(() => {+ setSelectedIds((prev) => {+ let changed = false;+ const next = new Set();+ prev.forEach((id) => { if (openIds.has(id)) next.add(id); else changed = true; });+ return changed ? next : prev;+ });+ }, [openIds]);++ const toggleSelect = (id) => setSelectedIds((prev) => {+ const next = new Set(prev);+ if (next.has(id)) next.delete(id); else next.add(id);+ return next;+ });+ const selectMany = (ids, on) => setSelectedIds((prev) => {+ const next = new Set(prev);+ ids.forEach((id) => (on ? next.add(id) : next.delete(id)));+ return next;+ });+ const clearSelection = () => setSelectedIds(new Set());++ const selectedComments = useMemo(+ () => comments.filter((c) => c.checkId && c.status === 'open' && selectedIds.has(c.id)),+ [comments, selectedIds],+ );+if (!groups.length) {return (<p className="rounded-lg border border-dashed border-port-border p-4 text-center text-xs text-gray-500">@@ -212,8 +378,27 @@ export default function EditorialFindingsTriage({ seriesId, comments = [], checkconst totalOpen = openFindingsTotal(groups);return (<div className="space-y-2">- <p className="text-[11px] text-gray-500">{totalOpen} open finding{totalOpen === 1 ? '' : 's'} across {groups.length} check{groups.length === 1 ? '' : 's'}</p>- {groups.map((g) => <CheckGroup key={g.checkId} seriesId={seriesId} group={g} onCommentChange={onCommentChange} />)}+ {selectedComments.length > 0 ? (+ <BulkActionBar+ seriesId={seriesId}+ selected={selectedComments}+ onCommentChange={onCommentChange}+ onClear={clearSelection}+ />+ ) : (+ <p className="text-[11px] text-gray-500">{totalOpen} open finding{totalOpen === 1 ? '' : 's'} across {groups.length} check{groups.length === 1 ? '' : 's'}</p>+ )}+ {groups.map((g) => (+ <CheckGroup+ key={g.checkId}+ seriesId={seriesId}+ group={g}+ onCommentChange={onCommentChange}+ selectedIds={selectedIds}+ onToggleSelect={toggleSelect}+ onSelectMany={selectMany}+ />+ ))}</div>);}diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsxindex af072c4339..c41bf39d20 100644--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx@@ -118,4 +118,74 @@ describe('EditorialFindingsTriage', () => {expect(screen.queryByRole('button', { name: /dismiss/i })).toBeNull();expect(screen.queryByRole('button', { name: /preview fix/i })).toBeNull();});++ it('only surfaces a selection checkbox for open findings (#1599)', () => {+ const comments = [+ { id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Open one' },+ { id: 'c2', checkId: 'naming.dissimilar-names', status: 'dismissed', severity: 'low', problem: 'Resolved one' },+ ];+ renderTriage({ comments });+ expect(screen.getByLabelText('Select finding: Open one')).toBeTruthy();+ expect(screen.queryByLabelText('Select finding: Resolved one')).toBeNull();+ });++ it('reveals the bulk action bar once a finding is selected and bulk-dismisses the selection (#1599)', async () => {+ const onCommentChange = vi.fn();+ patchPipelineManuscriptComment+ .mockResolvedValueOnce({ comment: { id: 'c1', checkId: 'naming.dissimilar-names', status: 'dismissed', severity: 'high', problem: 'A' } })+ .mockResolvedValueOnce({ comment: { id: 'c2', checkId: 'naming.dissimilar-names', status: 'dismissed', severity: 'low', problem: 'B' } });+ const comments = [+ { id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'A' },+ { id: 'c2', checkId: 'naming.dissimilar-names', status: 'open', severity: 'low', problem: 'B' },+ ];+ renderTriage({ comments, onCommentChange });++ // No selection → no bar.+ expect(screen.queryByText(/selected$/)).toBeNull();+ fireEvent.click(screen.getByLabelText('Select finding: A'));+ fireEvent.click(screen.getByLabelText('Select finding: B'));+ expect(screen.getByText('2 selected')).toBeTruthy();++ fireEvent.click(screen.getByRole('button', { name: /dismiss 2/i }));+ await waitFor(() => expect(patchPipelineManuscriptComment).toHaveBeenCalledTimes(2));+ expect(patchPipelineManuscriptComment).toHaveBeenCalledWith('ser-1', 'c1', { status: 'dismissed' }, { silent: true });+ expect(patchPipelineManuscriptComment).toHaveBeenCalledWith('ser-1', 'c2', { status: 'dismissed' }, { silent: true });+ await waitFor(() => expect(onCommentChange).toHaveBeenCalledTimes(2));+ });++ it('bulk-accepts only the selected findings that carry an applicable fix (#1599)', async () => {+ const onCommentChange = vi.fn();+ acceptPipelineManuscriptFix.mockResolvedValue({+ comment: { id: 'c1', checkId: 'naming.dissimilar-names', status: 'accepted', severity: 'high', problem: 'Fixable' },+ });+ const comments = [+ { id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Fixable', fix: { edits: [{ find: 'Adam', replace: 'Aaron' }] } },+ { id: 'c2', checkId: 'naming.dissimilar-names', status: 'open', severity: 'low', problem: 'No fix' },+ ];+ renderTriage({ comments, onCommentChange });++ fireEvent.click(screen.getByLabelText('Select finding: Fixable'));+ fireEvent.click(screen.getByLabelText('Select finding: No fix'));+ // Both selected, but only one has an applicable fix.+ expect(screen.getByRole('button', { name: /accept 1/i })).toBeTruthy();++ fireEvent.click(screen.getByRole('button', { name: /accept 1/i }));+ await waitFor(() => expect(acceptPipelineManuscriptFix).toHaveBeenCalledTimes(1));+ const [, commentId, payload, options] = acceptPipelineManuscriptFix.mock.calls[0];+ expect(commentId).toBe('c1');+ expect(payload.edits).toEqual([{ find: 'Adam', replace: 'Aaron' }]);+ expect(options).toEqual({ silent: true });+ });++ it('selects every open finding in a group via the group checkbox (#1599)', () => {+ const comments = [+ { id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'A' },+ { id: 'c2', checkId: 'naming.dissimilar-names', status: 'open', severity: 'low', problem: 'B' },+ { id: 'c3', checkId: 'naming.dissimilar-names', status: 'dismissed', severity: 'low', problem: 'C' },+ ];+ renderTriage({ comments });+ fireEvent.click(screen.getByLabelText(/Select all open findings in Character name dissimilarity/i));+ // Two open findings selected (the dismissed one is not selectable).+ expect(screen.getByText('2 selected')).toBeTruthy();+ });});