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
fix: pin anchor reveal to the first active highlight fragment (#1601)
[._.]/ Adam Eivy6bc5e2b32600
diff --git a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsxindex b801ca1ccd..683b769f67 100644--- a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx@@ -42,16 +42,23 @@ export default function ManuscriptHighlightedProse({ content, spans, openCommentreturn nl === -1 ? text.length : nl + 1;}, [inlineCard, openCommentId, spans, text]);+ // The open comment can tile into several active segments (overlapping spans+ // split one highlight in two; the inline-card injection can split a segment).+ // Pin `activeRef` to the FIRST active fragment rendered so the reveal scrolls+ // to the start of the match, not a trailing piece. Reset per render.+ let activeRefTaken = false;const renderSegment = (seg, key, textOverride) => {const segText = textOverride ?? seg.text;if (!segText) return null;if (!seg.commentIds.length) return <span key={key}>{segText}</span>;const active = seg.commentIds.includes(openCommentId);+ const takeRef = active && !activeRefTaken;+ if (takeRef) activeRefTaken = true;const tone = SEVERITY_TONE[seg.topSeverity] || SEVERITY_TONE.low;return (<buttonkey={key}- ref={active ? activeRef : undefined}+ ref={takeRef ? 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.jsxindex e149a66fa8..2307d0b62a 100644--- a/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.test.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptHighlightedProse.test.jsx@@ -67,6 +67,23 @@ describe('ManuscriptHighlightedProse', () => {expect(scrollSpy).toHaveBeenCalledWith({ behavior: 'smooth', block: 'center' });});+ it('flashes the FIRST active fragment when an overlapping span splits the open highlight (#1601)', () => {+ window.HTMLElement.prototype.scrollIntoView = vi.fn();+ // c1 spans 'ABCDE'; c2 overlaps 'CDE', so buildHighlightSegments tiles c1+ // into two active-for-c1 fragments ('AB' then 'CDE'). The reveal must pin to+ // the first ('AB'), not the trailing piece.+ const content = 'ABCDE rest';+ const spans = [+ { commentId: 'c1', severity: 'high', start: 0, end: 5 },+ { commentId: 'c2', severity: 'low', start: 2, end: 5 },+ ];+ render(+ <ManuscriptHighlightedProse content={content} spans={spans} openCommentId="c1" onOpenComment={() => {}} />,+ );+ expect(screen.getByText('AB').classList.contains('manuscript-anchor-flash')).toBe(true);+ expect(screen.getByText('CDE').classList.contains('manuscript-anchor-flash')).toBe(false);+ });+it('does not flash any highlight when the open note is not located', () => {const scrollSpy = vi.fn();window.HTMLElement.prototype.scrollIntoView = scrollSpy;