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

feat: scroll to and flash the flagged passage when opening an editorial finding (#1601)

[._.]/ Adam Eivy8316d6ca9e8f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 03d9460c9c..5cfb47bf41 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -57,6 +57,8 @@
## Editorial checks
+- **[issue-1601] Opening an editorial finding now scrolls the manuscript to the flagged passage and flashes it, instead of leaving you to hunt for the text.** A finding anchors to manuscript text by a verbatim quote, but opening it (from the findings triage deep-link, the sidebar index, a pin chip, or stepping prev/next through a triage pass) only ever scrolled the note *card* into view — the offending words themselves weren't called out, so on a long scene you still re-read paragraphs to find what the note was about. The editor now scrolls the anchored text to center and plays a brief tint **flash** over the exact words on open and on every prev/next step, in both view modes: **Review** mode reveals + flashes the highlighted span, and **Live** mode reveals + flashes the underlined text (and keeps it tinted while its card stays open). When the anchor quote isn't found verbatim in the current draft (the section was edited since the review), it falls back gracefully to the previous behavior of scrolling the note card into view — no jump, no flash. The scroll-and-flash is a small reusable hook (`useAnchorReveal`) and honors `prefers-reduced-motion`. (`client/src/hooks/useAnchorReveal.js`, `client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx`, `client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx`, `client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx`, `client/src/index.css`)
+
- **[issue-1600] The findings triage list now has filter, search, and sort controls so a large batch can be triaged strategically instead of scrolling a flat list.** Past ~50 findings the per-check list grew unwieldy with no way to focus on, say, just the high-severity open findings from one problematic check. A new toolbar above the list filters by **severity**, **status** (open / accepted / dismissed), **category** (check scope), **check**, and **issue**, plus a free-text **search** over each finding's problem/location and a **sort** order (scope & check, severity, issue, or status — sorting both the findings within each group and the groups themselves). The toolbar only ever offers facets that actually exist in the current findings (a single-value facet is hidden), each surviving group's open/total + severity counts are recomputed so the headers never lie about what's shown, and an empty result shows a clear-filters affordance. Every selection persists in the page URL query (`?fsev=`, `?fstatus=`, `?fscope=`, `?fcheck=`, `?fissue=`, `?fq=`, `?fsort=`), so a filtered view — "high-severity open findings on Issue 5, sorted by severity" — is deep-linkable per the repo's linkable-routes convention. The filter/sort logic lives in pure, unit-tested helpers (`deriveFindingFacets` / `applyFindingsView` in `editorialChecks.js`). (`client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`, `client/src/lib/editorialChecks.js`)
- **[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`)
diff --git a/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx b/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx
index a5d6bb5c78..f53c4f8b30 100644
--- a/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx
+++ b/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx
@@ -28,12 +28,14 @@ export default function AnnotatedManuscriptSection({
const located = openComment ? spans.some((s) => s.commentId === openComment.id) : false;
const cardRef = useRef(null);
- // Bring the open card (and with it the anchor text it sits under) into view —
- // on open, and again when stepping prev/next between notes. Only the section
- // that actually owns the open comment scrolls.
+ // Bring the open card into view when the note's anchor ISN'T located in the
+ // current draft (the card falls back to expanding beneath the prose). When the
+ // anchor IS located, ManuscriptHighlightedProse scrolls + flashes the
+ // highlighted text itself (#1601), so scrolling the card here too would fight
+ // that smooth scroll.
useEffect(() => {
- if (openComment) cardRef.current?.scrollIntoView?.({ behavior: 'smooth', block: 'center' });
- }, [openComment?.id]);
+ if (openComment && !located) cardRef.current?.scrollIntoView?.({ behavior: 'smooth', block: 'center' });
+ }, [openComment?.id, located]);
// Esc closes the open note — parity with the Live popover.
useEscapeKey(openComment, onCloseComment);
diff --git a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx
index f6f51653ed..b801ca1ccd 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx
@@ -8,14 +8,26 @@
* preserving whitespace.
*/
-import { useMemo } from 'react';
+import { useMemo, useRef } from 'react';
import { buildHighlightSegments } from '../../../lib/manuscriptAnchors';
+import useAnchorReveal from '../../../hooks/useAnchorReveal';
import { SEVERITY_TONE } from './constants';
export default function ManuscriptHighlightedProse({ content, spans, openCommentId, onOpenComment, inlineCard }) {
const text = content || '';
const segments = useMemo(() => buildHighlightSegments(text, spans), [text, spans]);
+ // Scroll the open finding's highlighted text into view and flash it on open /
+ // prev-next step (#1601). `activeRef` points at the first highlight segment
+ // carrying the open comment; it stays null when the anchor isn't located in
+ // the draft, so the reveal is a no-op and the parent's card fallback scrolls.
+ const activeRef = useRef(null);
+ const located = useMemo(
+ () => !!openCommentId && (spans || []).some((s) => s.commentId === openCommentId),
+ [openCommentId, spans],
+ );
+ useAnchorReveal(() => activeRef.current, located ? openCommentId : null);
+
// Character offset where the inline card splices into the prose: just past
// the newline ending the line that contains the open note's highlight (or the
// end of the text). -1 = no card to place. If the note's span isn't located
@@ -39,6 +51,7 @@ export default function ManuscriptHighlightedProse({ content, spans, openComment
return (
<button
key={key}
+ ref={active ? activeRef : undefined}
type="button"
onClick={() => onOpenComment(seg.commentIds[0])}
aria-expanded={active}
diff --git a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.test.jsx b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.test.jsx
index ba3548da91..e149a66fa8 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.test.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.test.jsx
@@ -55,4 +55,25 @@ describe('ManuscriptHighlightedProse', () => {
);
expect(screen.queryByTestId('card')).not.toBeInTheDocument();
});
+
+ it('scrolls to and flashes the open finding\'s highlight (#1601)', () => {
+ const scrollSpy = vi.fn();
+ window.HTMLElement.prototype.scrollIntoView = scrollSpy;
+ render(
+ <ManuscriptHighlightedProse content={CONTENT} spans={SPANS} openCommentId="c1" onOpenComment={() => {}} />,
+ );
+ const mark = screen.getByText('ANCHOR');
+ expect(mark.classList.contains('manuscript-anchor-flash')).toBe(true);
+ expect(scrollSpy).toHaveBeenCalledWith({ behavior: 'smooth', block: 'center' });
+ });
+
+ it('does not flash any highlight when the open note is not located', () => {
+ const scrollSpy = vi.fn();
+ window.HTMLElement.prototype.scrollIntoView = scrollSpy;
+ const { container } = render(
+ <ManuscriptHighlightedProse content={CONTENT} spans={SPANS} openCommentId="c-unlocated" onOpenComment={() => {}} />,
+ );
+ expect(container.querySelector('.manuscript-anchor-flash')).toBeNull();
+ expect(scrollSpy).not.toHaveBeenCalled();
+ });
});
diff --git a/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx b/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx
index c0e36cb458..8730ee4fec 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx
@@ -15,6 +15,7 @@
import { useLayoutEffect, useMemo, useRef, useState } from 'react';
import { X } from 'lucide-react';
import useEscapeKey from '../../../hooks/useEscapeKey';
+import useAnchorReveal from '../../../hooks/useAnchorReveal';
import { buildHighlightSegments } from '../../../lib/manuscriptAnchors';
import { CommentCardFromProps } from './ManuscriptCommentCard';
import ManuscriptSectionFrame from './ManuscriptSectionFrame';
@@ -68,6 +69,33 @@ export default function ManuscriptLiveSection({
};
useLayoutEffect(positionPopover, [openComment, content, segments]);
+ // The backdrop <mark> carrying the open comment's underline — the element to
+ // reveal/flash when a finding opens (#1601).
+ const openMark = () => {
+ const backdrop = backdropRef.current;
+ if (!backdrop || !openComment) return null;
+ return [...backdrop.querySelectorAll('mark[data-cids]')]
+ .find((m) => (m.dataset.cids || '').split(',').includes(openComment.id)) || null;
+ };
+
+ // Scroll the open finding's underlined text into view + flash it. A long
+ // section (rowsFor caps the textarea at 400 rows) scrolls INSIDE the textarea,
+ // whose internal scroll `scrollIntoView` on the decorative backdrop mark can't
+ // reach — so center it by setting `scrollTop` directly and re-pin the popover.
+ // Shorter sections grow to fit, so the page scroll moves the mark into view.
+ const revealMark = (mark) => {
+ const ta = taRef.current;
+ const backdrop = backdropRef.current;
+ if (ta && backdrop && ta.scrollHeight > ta.clientHeight + 1) {
+ ta.scrollTop = Math.max(0, mark.offsetTop - ta.clientHeight / 2 + mark.offsetHeight / 2);
+ backdrop.scrollTop = ta.scrollTop;
+ positionPopover();
+ } else if (typeof mark.scrollIntoView === 'function') {
+ mark.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ }
+ };
+ useAnchorReveal(openMark, openComment?.id, { reveal: revealMark });
+
// Esc closes the popover.
useEscapeKey(openComment, onCloseComment);
@@ -112,7 +140,10 @@ export default function ManuscriptLiveSection({
<mark
key={i}
data-cids={seg.commentIds.join(',')}
- className={`bg-transparent border-b-2 ${SEVERITY_UNDERLINE[seg.topSeverity] || SEVERITY_UNDERLINE.low}`}
+ // While its card is open, the offending words stay tinted (behind
+ // the textarea's transparent background) so the match stays
+ // visible after the open flash fades (#1601).
+ className={`border-b-2 ${seg.commentIds.includes(openCommentId) ? 'bg-port-accent/15' : 'bg-transparent'} ${SEVERITY_UNDERLINE[seg.topSeverity] || SEVERITY_UNDERLINE.low}`}
>
{seg.text}
</mark>
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index c7620ae2c8..33e8b32e34 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -76,6 +76,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| Hook | Purpose | Use when |
|---|---|---|
+| `useAnchorReveal` | `useAnchorReveal(getTarget, key, { reveal? })` — scroll a freshly-opened element into view + flash a tint over it; re-fires when `key` changes; no-op when `key` is falsy or `getTarget()` is null. | Reveal an editorial finding's anchored manuscript text on open / prev-next step (#1601). |
| `useArmedAction` | Two-click-arm `[armed, fire]` confirmation. | Destructive button needing a confirm tap. (Project memory: user finds this less discoverable — prefer inline confirm rows for new UI.) |
| `useAutoRefetch` | Poll-based refetch on an interval. `{ pollOnly: true }` skips internal data/loading state for side-effect-only callers (returns `{ refetch }` only). | Data needs periodic refresh (no socket / SSE available). |
| `useAutoSizeTextarea` | `[ref, resize]` — grows a `<textarea>` to fit its content (no scroll / hand-resize); recomputes before paint on value change. | A textarea that should auto-fit content. Prefer the `AutoSizeTextarea` UI component, which wraps this. |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index d39f5079db..2dd96371d8 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -8,6 +8,7 @@
// hook uses.
// === Default-exporting hooks (re-exported as named) ===
+export { default as useAnchorReveal } from './useAnchorReveal.js';
export { default as useCityAudio } from './useCityAudio.js';
export { default as useAutoSizeTextarea } from './useAutoSizeTextarea.js';
export { default as useClickOutside } from './useClickOutside.js';
diff --git a/client/src/hooks/useAnchorReveal.js b/client/src/hooks/useAnchorReveal.js
new file mode 100644
index 0000000000..6b9b6ecf5f
--- /dev/null
+++ b/client/src/hooks/useAnchorReveal.js
@@ -0,0 +1,48 @@
+import { useEffect } from 'react';
+
+// Class + duration must stay in sync with the `manuscript-anchor-flash`
+// keyframe in `client/src/index.css` (#1601).
+const FLASH_CLASS = 'manuscript-anchor-flash';
+const FLASH_MS = 1200;
+
+/**
+ * Reveal a freshly-opened editorial finding's anchored text: scroll it into
+ * view (centered) and flash a brief tint over it so the eye lands on the exact
+ * passage instead of hunting through a long scene (#1601).
+ *
+ * useAnchorReveal(getTarget, key, { reveal? })
+ *
+ * - `getTarget()` returns the DOM element to reveal (the located highlight /
+ * underline mark), or `null` when the anchor isn't present in the current
+ * draft — in which case this is a no-op and the caller's own fallback (e.g.
+ * scrolling the note card) handles it gracefully.
+ * - `key` re-fires the reveal whenever it changes (the open comment id), so
+ * stepping prev/next through a triage pass re-reveals each note. Falsy `key`
+ * (nothing open, or anchor not located) is a no-op — that's how callers
+ * disable the reveal (pass `null`).
+ * - `reveal(el)` optionally overrides the default `scrollIntoView` — used by the
+ * Live editor, whose anchor lives inside an internally-scrolling textarea.
+ *
+ * `getTarget`/`reveal` are intentionally excluded from the effect deps: the
+ * reveal should fire on open/step (the `key`), not on every render that hands a
+ * fresh closure.
+ */
+export default function useAnchorReveal(getTarget, key, { reveal } = {}) {
+ useEffect(() => {
+ if (!key) return undefined;
+ const target = getTarget();
+ if (!target) return undefined;
+ if (reveal) reveal(target);
+ else if (typeof target.scrollIntoView === 'function') {
+ target.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ }
+ target.classList?.add(FLASH_CLASS);
+ const timer = window.setTimeout(() => target.classList?.remove(FLASH_CLASS), FLASH_MS);
+ return () => {
+ window.clearTimeout(timer);
+ target.classList?.remove(FLASH_CLASS);
+ };
+ // `getTarget`/`reveal` excluded by design — fire on open/step (`key`), not
+ // on every render that hands a fresh closure.
+ }, [key]);
+}
diff --git a/client/src/hooks/useAnchorReveal.test.jsx b/client/src/hooks/useAnchorReveal.test.jsx
new file mode 100644
index 0000000000..30b3d66cbe
--- /dev/null
+++ b/client/src/hooks/useAnchorReveal.test.jsx
@@ -0,0 +1,67 @@
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+import { renderHook } from '@testing-library/react';
+import useAnchorReveal from './useAnchorReveal';
+
+// A stub anchor element exposing just what the hook touches.
+const makeEl = () => {
+ const classes = new Set();
+ return {
+ scrollIntoView: vi.fn(),
+ classList: { add: (c) => classes.add(c), remove: (c) => classes.delete(c) },
+ has: (c) => classes.has(c),
+ };
+};
+
+describe('useAnchorReveal', () => {
+ beforeEach(() => vi.useFakeTimers());
+ afterEach(() => vi.useRealTimers());
+
+ it('scrolls the target into view and flashes it, clearing the flash after the window', () => {
+ const el = makeEl();
+ renderHook(() => useAnchorReveal(() => el, 'c1'));
+ expect(el.scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth', block: 'center' });
+ expect(el.has('manuscript-anchor-flash')).toBe(true);
+ vi.advanceTimersByTime(1300);
+ expect(el.has('manuscript-anchor-flash')).toBe(false);
+ });
+
+ it('is a no-op when the key is falsy (nothing open)', () => {
+ const el = makeEl();
+ renderHook(() => useAnchorReveal(() => el, null));
+ expect(el.scrollIntoView).not.toHaveBeenCalled();
+ expect(el.has('manuscript-anchor-flash')).toBe(false);
+ });
+
+ it('is a no-op when the target is absent (anchor not located)', () => {
+ expect(() => renderHook(() => useAnchorReveal(() => null, 'c1'))).not.toThrow();
+ });
+
+ it('uses a custom reveal callback instead of scrollIntoView when provided', () => {
+ const el = makeEl();
+ const reveal = vi.fn();
+ renderHook(() => useAnchorReveal(() => el, 'c1', { reveal }));
+ expect(reveal).toHaveBeenCalledWith(el);
+ expect(el.scrollIntoView).not.toHaveBeenCalled();
+ expect(el.has('manuscript-anchor-flash')).toBe(true);
+ });
+
+ it('re-reveals when the key changes (prev/next step) but not on unrelated re-renders', () => {
+ const el = makeEl();
+ const { rerender } = renderHook(({ k }) => useAnchorReveal(() => el, k), {
+ initialProps: { k: 'c1' },
+ });
+ expect(el.scrollIntoView).toHaveBeenCalledTimes(1);
+ rerender({ k: 'c1' }); // same key — no refire
+ expect(el.scrollIntoView).toHaveBeenCalledTimes(1);
+ rerender({ k: 'c2' }); // stepped to next note — refire
+ expect(el.scrollIntoView).toHaveBeenCalledTimes(2);
+ });
+
+ it('clears the flash and pending timer on unmount', () => {
+ const el = makeEl();
+ const { unmount } = renderHook(() => useAnchorReveal(() => el, 'c1'));
+ expect(el.has('manuscript-anchor-flash')).toBe(true);
+ unmount();
+ expect(el.has('manuscript-anchor-flash')).toBe(false);
+ });
+});
diff --git a/client/src/index.css b/client/src/index.css
index a801c4528f..be0a06d32e 100644
--- a/client/src/index.css
+++ b/client/src/index.css
@@ -1047,6 +1047,20 @@ input[type="color"],
animation: pulse-soft 2s ease-in-out infinite;
}
+/* Manuscript editorial-finding anchor reveal (#1601): a brief tint pulse drawn
+ over the offending text when its finding opens, so the eye lands on the exact
+ passage after the scroll-to. Honors prefers-reduced-motion via the global
+ reduce block above (animation collapses to ~instant). Paired with
+ `useAnchorReveal` — keep the 1.2s duration in sync with FLASH_MS there. */
+@keyframes portos-anchor-flash {
+ 0% { background-color: rgba(59, 130, 246, 0.5); }
+ 100% { background-color: rgba(59, 130, 246, 0); }
+}
+.manuscript-anchor-flash {
+ animation: portos-anchor-flash 1.2s ease-out;
+ border-radius: 2px;
+}
+
/* Chief of Staff Character Animations */
.cos-character {
filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.3));