Skip to content

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

fix: health-panel deep-links honor the triage's session-local check mute (#1697)

[._.]/ Adam Eivyb43758de0f81
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 1143fdb24c..74b16a8035 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,4 +2,5 @@
## Editorial checks
+- **[issue-1697] Health-panel deep-links now honor the triage's session-local check mute.** Muting a check from the Editorial Findings triage (#1602) hid its findings group but the health panel kept advertising that check/category row as clickable — clicking it scrolled to an empty filtered view. The session mute state (`hiddenCheckIds`) was lifted from `EditorialFindingsTriage` up to `PipelineEditorialChecks`, which now subtracts muted checks from the filterable sets the health panel receives; a category stays clickable only while a non-muted check still contributes an open finding to it. (`client/src/pages/PipelineEditorialChecks.jsx`, `client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`)
- **[issue-1667] Final-part editorial verdicts no longer lose their carried setup context on a packed last chunk.** The cross-chunk "setup so far" digest normally yields to manuscript coverage — but two whole-story checks (`arc.climax-agency`, `emotion.reaction-proportionality`) gate their verdict to the final part and anchor it on a snippet carried in that digest (the climax candidate / the unprocessed event). When the final chunk packed to within a few hundred chars of the provider window, the digest was silently dropped and the final-only finding was missed. These checks now opt into a `reserveSetupDigest` guarantee that trims the final chunk's manuscript tail to make room for the digest (the inverse of the usual yield), scoped to the final chunk and opt-in checks only — every other chunk and every non-reserving check keeps full manuscript coverage. (`server/lib/editorial/checkRegistry.js`)
diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
index 0be78f2008..0b164c937f 100644
--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
@@ -57,6 +57,11 @@ const STATUS_FILTER_ORDER = ['open', 'accepted', 'dismissed'];
const parseSet = (raw) => new Set((raw || '').split(',').map((s) => s.trim()).filter(Boolean));
const serializeSet = (set) => [...set].join(',');
+// Stable empty default for the `hiddenCheckIds` prop so callers that don't pass it
+// (tests, read-only embeds) don't bust the `visibleView` memo with a fresh Set
+// identity each render.
+const EMPTY_HIDDEN = new Set();
+
// A check-sourced finding that's still open — the only findings that are
// selectable / bulk-actionable. Named once so the predicate lives in one place.
const isOpenFinding = (c) => !!c.checkId && c.status === 'open';
@@ -678,56 +683,14 @@ function NextStepsCTA({ seriesId, allCleared, onRunChecks, runDisabled = false }
);
}
-export default function EditorialFindingsTriage({ seriesId, comments = [], checksById = {}, onCommentChange, onToggleCheckEnabled, onRunChecks, runDisabled = false }) {
+export default function EditorialFindingsTriage({ seriesId, comments = [], checksById = {}, onCommentChange, hiddenCheckIds = EMPTY_HIDDEN, onDisableCheck, onRunChecks, runDisabled = false }) {
const groups = useMemo(() => groupFindingsByCheck(comments, checksById), [comments, checksById]);
const [selectedIds, setSelectedIds] = useState(() => new Set());
- // Checks the user muted from this view this session (#1602). Disabling a check
- // doesn't delete its persisted findings, so the group is hidden locally until an
- // undo (or a fresh findings load) brings it back. Keyed by checkId.
- const [hiddenCheckIds, setHiddenCheckIds] = useState(() => new Set());
- const unhideCheck = (checkId) => setHiddenCheckIds((s) => {
- if (!s.has(checkId)) return s;
- const next = new Set(s);
- next.delete(checkId);
- return next;
- });
- const disableCheck = (checkId, label) => {
- setHiddenCheckIds((s) => new Set(s).add(checkId));
- const toastId = toast((t) => (
- <span className="flex items-center gap-3 text-xs">
- <span className="text-gray-200">Disabled <span className="font-medium text-white">{label}</span> — findings hidden</span>
- <button
- type="button"
- onClick={() => { unhideCheck(checkId); onToggleCheckEnabled?.(checkId, true); toast.dismiss(t.id); }}
- className="inline-flex shrink-0 items-center gap-1 rounded border border-port-border px-2 py-0.5 text-[11px] text-port-accent hover:border-port-accent/40 hover:text-white"
- >
- <Undo2 size={12} /> Undo
- </button>
- </span>
- ), { duration: 8000 });
- // Optimistic hide above; reconcile if the persist fails (onToggleCheckEnabled
- // resolves false on error and has already reverted + toasted) so a failed
- // disable doesn't leave the group stuck hidden behind a dead undo toast.
- Promise.resolve(onToggleCheckEnabled?.(checkId, false)).then((ok) => {
- if (ok === false) { unhideCheck(checkId); toast.dismiss(toastId); }
- });
- };
- // Keep the muted set honest against the live enabled-state: if a muted check is
- // re-enabled elsewhere (the catalog toggle on this same page, or a findings
- // reload carrying fresh catalog rows), un-hide its group so visibility always
- // follows the check's actual enabled state — never stranding a group the empty
- // state tells the user to restore from the catalog. Re-enabling through the
- // undo path goes here too (its onToggleCheckEnabled flips enabled back to true).
- useEffect(() => {
- setHiddenCheckIds((s) => {
- if (!s.size) return s;
- let changed = false;
- const next = new Set();
- s.forEach((id) => { if (checksById[id]?.enabled === false) next.add(id); else changed = true; });
- return changed ? next : s;
- });
- }, [checksById]);
+ // The set of checks muted this session (#1602) is owned by the parent page
+ // (#1697) so the health panel's filterable sets can subtract them; this view
+ // just reads `hiddenCheckIds` to hide their groups and calls `onDisableCheck`
+ // (which records the mute, persists the disable, and shows the undo toast).
// ---- Filter / search / sort, persisted in the URL so a view is deep-linkable
// (#1600). Facets are derived from the full (unfiltered) groups so options never
@@ -868,8 +831,8 @@ export default function EditorialFindingsTriage({ seriesId, comments = [], check
seriesId={seriesId}
group={g}
onCommentChange={onCommentChange}
- canDisable={!!onToggleCheckEnabled && checksById[g.checkId]?.enabled === true}
- onDisableCheck={disableCheck}
+ canDisable={!!onDisableCheck && checksById[g.checkId]?.enabled === true}
+ onDisableCheck={onDisableCheck}
selectedIds={selectedIds}
onToggleSelect={toggleSelect}
onSelectMany={selectMany}
diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx
index e15f7e3517..debfa4cb18 100644
--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx
+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import EditorialFindingsTriage from './EditorialFindingsTriage';
-import { Toaster, toast } from '../../ui/Toast';
+import { toast } from '../../ui/Toast';
import { findingManuscriptLink } from '../../../lib/editorialChecks';
import { acceptPipelineManuscriptFix, patchPipelineManuscriptComment, undoPipelineManuscriptFix } from '../../../services/api';
@@ -366,18 +366,19 @@ describe('EditorialFindingsTriage', () => {
expect(screen.getByText('1 selected')).toBeTruthy();
});
- // ---- Disable a noisy check in-situ (#1602) ----
+ // ---- Disable a noisy check in-situ (#1602). The mute state + persist + undo
+ // toast were lifted to the parent page (#1697); this view now just renders the
+ // affordance, fires `onDisableCheck`, and hides groups named in `hiddenCheckIds`.
const enabledChecksById = {
'naming.dissimilar-names': { label: 'Character name dissimilarity', scope: 'series', kind: 'deterministic', enabled: true },
};
const renderDisable = (props) => render(
<MemoryRouter>
<EditorialFindingsTriage seriesId="ser-1" checksById={enabledChecksById} {...props} />
- <Toaster />
</MemoryRouter>,
);
- it('offers a Disable action only when onToggleCheckEnabled is wired and the check is enabled (#1602)', () => {
+ it('offers a Disable action only when onDisableCheck is wired and the check is enabled (#1602)', () => {
const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Noisy' }];
// No handler → no disable affordance (read-only triage).
renderTriage({ comments });
@@ -389,75 +390,28 @@ describe('EditorialFindingsTriage', () => {
renderDisable({
comments,
checksById: { 'naming.dissimilar-names': { label: 'Character name dissimilarity', scope: 'series', enabled: false } },
- onToggleCheckEnabled: vi.fn(),
+ onDisableCheck: vi.fn(),
});
expect(screen.queryByRole('button', { name: /Disable check:/i })).toBeNull();
});
- it('disables a check in-situ, hides its findings group, and disables it server-side (#1602)', () => {
- const onToggleCheckEnabled = vi.fn().mockResolvedValue(true);
+ it('fires onDisableCheck with the checkId + label when the Disable button is clicked (#1697)', () => {
+ const onDisableCheck = vi.fn();
const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Noisy finding' }];
- renderDisable({ comments, onToggleCheckEnabled });
+ renderDisable({ comments, onDisableCheck });
- expect(screen.getByText('Noisy finding')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: /Disable check: Character name dissimilarity/i }));
-
- // PATCHes the check off + the group's findings vanish from the view.
- expect(onToggleCheckEnabled).toHaveBeenCalledWith('naming.dissimilar-names', false);
- expect(screen.queryByText('Noisy finding')).toBeNull();
- // Empty-state copy points the user back to the catalog to re-enable.
- expect(screen.getByText(/Every check with findings is disabled/i)).toBeTruthy();
- });
-
- it('restores the hidden group and re-enables the check via the undo toast (#1602)', async () => {
- const onToggleCheckEnabled = vi.fn().mockResolvedValue(true);
- const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Noisy finding' }];
- renderDisable({ comments, onToggleCheckEnabled });
-
- fireEvent.click(screen.getByRole('button', { name: /Disable check: Character name dissimilarity/i }));
- expect(screen.queryByText('Noisy finding')).toBeNull();
-
- // The undo toast re-enables the check and brings the group back.
- fireEvent.click(await screen.findByRole('button', { name: /undo/i }));
- expect(onToggleCheckEnabled).toHaveBeenCalledWith('naming.dissimilar-names', true);
- expect(screen.getByText('Noisy finding')).toBeTruthy();
+ expect(onDisableCheck).toHaveBeenCalledWith('naming.dissimilar-names', 'Character name dissimilarity');
});
- it('un-hides a muted group once its check is re-enabled elsewhere, e.g. the catalog toggle (#1602)', () => {
- const onToggleCheckEnabled = vi.fn().mockResolvedValue(true);
+ it('hides a check group whose id is in hiddenCheckIds and shows the catalog hint (#1697)', () => {
+ const onDisableCheck = vi.fn();
const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Noisy finding' }];
- const enabledRow = { label: 'Character name dissimilarity', scope: 'series', enabled: true };
- const disabledRow = { ...enabledRow, enabled: false };
- const tree = (checksById) => (
- <MemoryRouter>
- <EditorialFindingsTriage seriesId="ser-1" checksById={checksById} comments={comments} onToggleCheckEnabled={onToggleCheckEnabled} />
- <Toaster />
- </MemoryRouter>
- );
- const { rerender } = render(tree({ 'naming.dissimilar-names': enabledRow }));
+ // Parent-owned mute set: the group is hidden purely off this prop now.
+ renderDisable({ comments, onDisableCheck, hiddenCheckIds: new Set(['naming.dissimilar-names']) });
- fireEvent.click(screen.getByRole('button', { name: /Disable check: Character name dissimilarity/i }));
- expect(screen.queryByText('Noisy finding')).toBeNull();
-
- // The page's optimistic disable flips the catalog row off — group stays hidden.
- rerender(tree({ 'naming.dissimilar-names': disabledRow }));
expect(screen.queryByText('Noisy finding')).toBeNull();
-
- // Re-enabling from the catalog (a fresh enabled row) restores the group even
- // though the undo toast was never clicked.
- rerender(tree({ 'naming.dissimilar-names': enabledRow }));
- expect(screen.getByText('Noisy finding')).toBeTruthy();
- });
-
- it('un-hides the group when the disable PATCH fails (#1602)', async () => {
- // onToggleCheckEnabled resolves false on failure (the page reverts + toasts).
- const onToggleCheckEnabled = vi.fn().mockResolvedValue(false);
- const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Noisy finding' }];
- renderDisable({ comments, onToggleCheckEnabled });
-
- fireEvent.click(screen.getByRole('button', { name: /Disable check: Character name dissimilarity/i }));
- // Optimistically hidden, then reconciled back once the PATCH rejects.
- await waitFor(() => expect(screen.getByText('Noisy finding')).toBeTruthy());
+ expect(screen.getByText(/Every check with findings is disabled/i)).toBeTruthy();
});
});
diff --git a/client/src/pages/PipelineEditorialChecks.jsx b/client/src/pages/PipelineEditorialChecks.jsx
index 26c6be9a28..f05e583821 100644
--- a/client/src/pages/PipelineEditorialChecks.jsx
+++ b/client/src/pages/PipelineEditorialChecks.jsx
@@ -13,7 +13,7 @@
*/
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Link, useSearchParams } from 'react-router-dom';
-import { ArrowLeft, ListChecks, Loader2, Play, Plus, Square } from 'lucide-react';
+import { ArrowLeft, ListChecks, Loader2, Play, Plus, Square, Undo2 } from 'lucide-react';
import toast from '../components/ui/Toast';
import EditorialCheckCard from '../components/pipeline/editorial/EditorialCheckCard';
import EditorialCustomCheckForm from '../components/pipeline/editorial/EditorialCustomCheckForm';
@@ -46,6 +46,13 @@ export default function PipelineEditorialChecks() {
const [loadingCatalog, setLoadingCatalog] = useState(true);
const [savingIds, setSavingIds] = useState(() => new Set());
const [selectedIds, setSelectedIds] = useState(() => new Set());
+ // Checks the user muted from the triage this session (#1602, lifted here for
+ // #1697). Disabling a check doesn't delete its persisted findings, so its triage
+ // group is hidden locally (keyed by checkId) until an undo, a fresh findings
+ // load, or a catalog re-enable brings it back. Owned here — not in the triage —
+ // so the health panel's filterable sets can subtract muted checks (the mute
+ // state and the filterable-set derivation must share one source of truth).
+ const [hiddenCheckIds, setHiddenCheckIds] = useState(() => new Set());
// Below `lg` the catalog + findings columns stack into one; this segmented
// switch picks which one is visible. Default to triage since that's the
// page's primary mobile task (#1611). No URL param — it's a breakpoint-only
@@ -102,13 +109,22 @@ export default function PipelineEditorialChecks() {
() => comments.filter((c) => c?.checkId && c.status === 'open'),
[comments],
);
+ // Subtract checks the user muted this session (#1697): the triage hides their
+ // groups, so the health panel must not advertise a check/category whose only
+ // open findings are hidden — clicking such a row would deep-link to a triage
+ // view with nothing in it. A category stays filterable as long as ANY non-muted
+ // check still contributes an open finding to it.
+ const visibleOpenCheckSourced = useMemo(
+ () => (hiddenCheckIds.size ? openCheckSourced.filter((c) => !hiddenCheckIds.has(c.checkId)) : openCheckSourced),
+ [openCheckSourced, hiddenCheckIds],
+ );
const triageFilterableCheckIds = useMemo(
- () => new Set(openCheckSourced.map((c) => c.checkId)),
- [openCheckSourced],
+ () => new Set(visibleOpenCheckSourced.map((c) => c.checkId)),
+ [visibleOpenCheckSourced],
);
const triageFilterableCategories = useMemo(
- () => new Set(openCheckSourced.map((c) => normCategory(c))),
- [openCheckSourced],
+ () => new Set(visibleOpenCheckSourced.map((c) => normCategory(c))),
+ [visibleOpenCheckSourced],
);
// Config saves read server settings, so a run that fires before a save lands
// would use stale config — gate the run buttons while any save is in flight.
@@ -258,6 +274,51 @@ export default function PipelineEditorialChecks() {
return result;
}, []);
+ // ---- Session-local check mute (#1602), lifted from the triage (#1697). Hiding
+ // a check's triage group AND keeping the health panel's filterable sets honest
+ // both read `hiddenCheckIds`, so the state lives here and the action does too. ----
+ const unhideCheck = useCallback((checkId) => setHiddenCheckIds((s) => {
+ if (!s.has(checkId)) return s;
+ const next = new Set(s);
+ next.delete(checkId);
+ return next;
+ }), []);
+ const disableCheck = useCallback((checkId, label) => {
+ setHiddenCheckIds((s) => new Set(s).add(checkId));
+ const toastId = toast((t) => (
+ <span className="flex items-center gap-3 text-xs">
+ <span className="text-gray-200">Disabled <span className="font-medium text-white">{label}</span> — findings hidden</span>
+ <button
+ type="button"
+ onClick={() => { unhideCheck(checkId); handleToggle(checkId, true); toast.dismiss(t.id); }}
+ className="inline-flex shrink-0 items-center gap-1 rounded border border-port-border px-2 py-0.5 text-[11px] text-port-accent hover:border-port-accent/40 hover:text-white"
+ >
+ <Undo2 size={12} /> Undo
+ </button>
+ </span>
+ ), { duration: 8000 });
+ // Optimistic hide above; reconcile if the persist fails (handleToggle resolves
+ // false on error and has already reverted + toasted) so a failed disable doesn't
+ // leave the group stuck hidden behind a dead undo toast.
+ Promise.resolve(handleToggle(checkId, false)).then((ok) => {
+ if (ok === false) { unhideCheck(checkId); toast.dismiss(toastId); }
+ });
+ }, [unhideCheck, handleToggle]);
+ // Keep the muted set honest against the live enabled-state: if a muted check is
+ // re-enabled elsewhere (the catalog toggle on this page, or a findings reload
+ // carrying fresh catalog rows), un-hide its group so visibility always follows
+ // the check's actual enabled state — never stranding a group the triage's empty
+ // state tells the user to restore from the catalog.
+ useEffect(() => {
+ setHiddenCheckIds((s) => {
+ if (!s.size) return s;
+ let changed = false;
+ const next = new Set();
+ s.forEach((id) => { if (checksById[id]?.enabled === false) next.add(id); else changed = true; });
+ return changed ? next : s;
+ });
+ }, [checksById]);
+
const handleConfigSave = useCallback((checkId, nextConfig) => {
setSavingIds((s) => new Set(s).add(checkId));
patchEditorialCheck(checkId, { config: nextConfig }, { silent: true })
@@ -631,7 +692,7 @@ export default function PipelineEditorialChecks() {
{loadingFindings ? (
<p className="flex items-center gap-2 text-sm text-gray-400"><Loader2 size={16} className="animate-spin" /> Loading findings…</p>
) : (
- <EditorialFindingsTriage seriesId={seriesId} comments={comments} checksById={checksById} onCommentChange={handleCommentChange} onToggleCheckEnabled={handleToggle} onRunChecks={() => runChecks(null)} runDisabled={runDisabled || enabledCount === 0} />
+ <EditorialFindingsTriage seriesId={seriesId} comments={comments} checksById={checksById} onCommentChange={handleCommentChange} hiddenCheckIds={hiddenCheckIds} onDisableCheck={disableCheck} onRunChecks={() => runChecks(null)} runDisabled={runDisabled || enabledCount === 0} />
)}
</>
)}
diff --git a/client/src/pages/PipelineEditorialChecks.muteFilter.test.jsx b/client/src/pages/PipelineEditorialChecks.muteFilter.test.jsx
new file mode 100644
index 0000000000..e5fcd19a14
--- /dev/null
+++ b/client/src/pages/PipelineEditorialChecks.muteFilter.test.jsx
@@ -0,0 +1,143 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import PipelineEditorialChecks from './PipelineEditorialChecks';
+import { Toaster, toast } from '../components/ui/Toast';
+
+// #1697 — the triage's session-local check mute must flow into the health panel's
+// filterable sets so a muted check's deep-link row stops advertising itself as
+// clickable (clicking it would scroll to an empty filtered triage view). The mute
+// state was lifted to this page, so this suite renders the REAL triage + health
+// panel together and exercises the cross-component handshake.
+
+const listPipelineSeries = vi.fn();
+const getEditorialChecks = vi.fn();
+const getPipelineManuscriptReview = vi.fn();
+const getEditorialHealth = vi.fn();
+const getEditorialChecksRunStatus = vi.fn();
+const patchEditorialCheck = vi.fn();
+
+vi.mock('../services/api', () => ({
+ listPipelineSeries: (...a) => listPipelineSeries(...a),
+ updatePipelineSeries: vi.fn(),
+ getEditorialChecks: (...a) => getEditorialChecks(...a),
+ patchEditorialCheck: (...a) => patchEditorialCheck(...a),
+ createEditorialCustomCheck: vi.fn(),
+ updateEditorialCustomCheck: vi.fn(),
+ deleteEditorialCustomCheck: vi.fn(),
+ previewEditorialCustomCheck: vi.fn(),
+ startEditorialChecksRun: vi.fn(),
+ cancelEditorialChecksRun: vi.fn(),
+ getEditorialChecksRunStatus: (...a) => getEditorialChecksRunStatus(...a),
+ editorialChecksRunSseUrl: () => '',
+ getPipelineManuscriptReview: (...a) => getPipelineManuscriptReview(...a),
+ getEditorialHealth: (...a) => getEditorialHealth(...a),
+ setEditorialReadinessGate: vi.fn(),
+ // Touched transitively by the triage → ManuscriptCommentCard tree.
+ acceptPipelineManuscriptFix: vi.fn(),
+ patchPipelineManuscriptComment: vi.fn(),
+ undoPipelineManuscriptFix: vi.fn(),
+ generatePipelineManuscriptFix: vi.fn(),
+}));
+
+vi.mock('../hooks/usePipelineProgress', () => ({
+ usePipelineProgress: () => ({ latest: null, closed: true }),
+}));
+vi.mock('../hooks/useProviderModels', () => ({
+ default: () => ({
+ providers: [], selectedProviderId: '', selectedModel: '', availableModels: [],
+ setSelectedProviderId: vi.fn(), setSelectedModel: vi.fn(),
+ }),
+}));
+
+// Keep the catalog cards + provider selector out of the way; the triage and health
+// panel are the surfaces under test, so they stay REAL.
+vi.mock('../components/pipeline/editorial/EditorialCheckCard', () => ({ default: () => <div>check-card</div> }));
+vi.mock('../components/pipeline/editorial/EditorialCustomCheckForm', () => ({ default: () => <div>custom-form</div> }));
+vi.mock('../components/ProviderModelSelector', () => ({ default: () => <div>provider-selector</div> }));
+
+const CHECK_ID = 'naming.dissimilar-names';
+const CHECK_LABEL = 'Character name dissimilarity';
+const CHECK = { id: CHECK_ID, label: CHECK_LABEL, scope: 'series', kind: 'deterministic', enabled: true };
+
+function renderPage() {
+ return render(
+ <MemoryRouter initialEntries={[`/pipeline/editorial-checks?series=ser-1`]}>
+ <PipelineEditorialChecks />
+ <Toaster />
+ </MemoryRouter>,
+ );
+}
+
+describe('PipelineEditorialChecks — muted checks drop out of the health-panel filterable sets (#1697)', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ toast.dismiss();
+ listPipelineSeries.mockResolvedValue([{ id: 'ser-1', title: 'My Series' }]);
+ getEditorialChecks.mockResolvedValue({ checks: [CHECK] });
+ getPipelineManuscriptReview.mockResolvedValue({
+ comments: [{ id: 'c1', checkId: CHECK_ID, status: 'open', severity: 'high', problem: 'Noisy finding', category: 'naming' }],
+ });
+ getEditorialHealth.mockResolvedValue({
+ score: 50, gate: 'noOpenHigh', ready: false,
+ openBySeverity: { high: 1, medium: 0, low: 0 },
+ openByCategory: { naming: 1 },
+ openByCheck: { [CHECK_ID]: 1 },
+ perIssue: [],
+ trend: { points: [], regressions: [], checkRegressions: [] },
+ });
+ getEditorialChecksRunStatus.mockResolvedValue({ active: false });
+ patchEditorialCheck.mockImplementation((id, body) => Promise.resolve({ ...CHECK, ...body }));
+ });
+
+ it('makes the health-panel check + category rows non-interactive after the check is muted in the triage', async () => {
+ renderPage();
+
+ // Before muting: both the check row and its category row deep-link the triage.
+ expect(await screen.findByTitle(`Filter findings to ${CHECK_LABEL}`)).toBeTruthy();
+ expect(screen.getByTitle('Filter findings to naming')).toBeTruthy();
+
+ // Mute the check from the triage's in-situ Disable affordance.
+ fireEvent.click(screen.getByRole('button', { name: new RegExp(`Disable check: ${CHECK_LABEL}`, 'i') }));
+
+ // The deep-link rows survive (the findings still exist) but stop advertising as
+ // clickable — the only finding behind each is now hidden in the triage.
+ await screen.findByTitle(`${CHECK_LABEL} findings aren't in the triage filter`);
+ expect(screen.queryByTitle(`Filter findings to ${CHECK_LABEL}`)).toBeNull();
+ expect(screen.getByTitle("naming findings aren't in the triage filter")).toBeTruthy();
+ expect(screen.queryByTitle('Filter findings to naming')).toBeNull();
+
+ // It also persisted the disable server-side.
+ expect(patchEditorialCheck).toHaveBeenCalledWith(CHECK_ID, { enabled: false }, { silent: true });
+ });
+
+ it('re-arms the health-panel rows when the mute is undone', async () => {
+ renderPage();
+ await screen.findByTitle(`Filter findings to ${CHECK_LABEL}`);
+
+ fireEvent.click(screen.getByRole('button', { name: new RegExp(`Disable check: ${CHECK_LABEL}`, 'i') }));
+ await screen.findByTitle(`${CHECK_LABEL} findings aren't in the triage filter`);
+
+ // The undo toast re-enables the check and restores the deep-link.
+ fireEvent.click(await screen.findByRole('button', { name: /undo/i }));
+ // handleToggle chains the PATCH onto a per-check tail (a microtask), so the
+ // re-enable call lands asynchronously after the click.
+ await waitFor(() => expect(patchEditorialCheck).toHaveBeenCalledWith(CHECK_ID, { enabled: true }, { silent: true }));
+ await screen.findByTitle(`Filter findings to ${CHECK_LABEL}`);
+ });
+
+ it('reconciles the health-panel rows back when the disable PATCH fails', async () => {
+ patchEditorialCheck.mockImplementation((id, body) => (
+ body.enabled === false ? Promise.reject(new Error('nope')) : Promise.resolve({ ...CHECK, ...body })
+ ));
+ renderPage();
+ await screen.findByTitle(`Filter findings to ${CHECK_LABEL}`);
+
+ fireEvent.click(screen.getByRole('button', { name: new RegExp(`Disable check: ${CHECK_LABEL}`, 'i') }));
+
+ // Optimistically hidden, then un-hidden once the PATCH rejects — the deep-link
+ // comes back rather than stranding the row as permanently non-clickable.
+ await waitFor(() => expect(screen.queryByTitle(`${CHECK_LABEL} findings aren't in the triage filter`)).toBeNull());
+ expect(screen.getByTitle(`Filter findings to ${CHECK_LABEL}`)).toBeTruthy();
+ });
+});