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 manuscript note reveal: scroll-anchor every mode, drop false 'not anchored'

[._.]/ Adam Eivyf3c8816515f5
diff --git a/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx b/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx
index 7edc64f8b5..3a4bf3a51a 100644
--- a/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx
+++ b/client/src/components/pipeline/manuscript/AnnotatedManuscriptSection.jsx
@@ -6,8 +6,8 @@
* the new text. The open comment's card expands inline beneath the prose.
*/
-import { useMemo } from 'react';
-import { Pencil, Check } from 'lucide-react';
+import { useEffect, useMemo, useRef } from 'react';
+import { Pencil, Check, X } from 'lucide-react';
import ManuscriptHighlightedProse from './ManuscriptHighlightedProse';
import ManuscriptCommentCard from './ManuscriptCommentCard';
import ManuscriptSectionFrame from './ManuscriptSectionFrame';
@@ -15,12 +15,20 @@ import { rowsFor } from './constants';
export default function AnnotatedManuscriptSection({
section, comments, spans, saveState, editing, onToggleEdit,
- openCommentId, onOpenComment,
+ openCommentId, onOpenComment, onCloseComment,
onContentChange, onBlurSave, onRevert, registerRef, commentCardProps,
}) {
const content = section.content || '';
const byId = useMemo(() => new Map(comments.map((c) => [c.id, c])), [comments]);
const openComment = openCommentId && byId.get(openCommentId)?.status === 'open' ? byId.get(openCommentId) : null;
+ const cardRef = useRef(null);
+
+ // The card expands beneath the (often long) prose, so bring it into view when
+ // it opens — otherwise clicking a highlight mid-section looks like nothing
+ // happened. Only the section that actually owns the open comment scrolls.
+ useEffect(() => {
+ if (openComment) cardRef.current?.scrollIntoView?.({ behavior: 'smooth', block: 'center' });
+ }, [openComment?.id]); // eslint-disable-line react-hooks/exhaustive-deps
const editToggle = (
<button
@@ -34,10 +42,9 @@ export default function AnnotatedManuscriptSection({
);
return (
- <ManuscriptSectionFrame section={section} saveState={saveState} onRevert={onRevert} headerExtra={editToggle}>
+ <ManuscriptSectionFrame section={section} saveState={saveState} onRevert={onRevert} headerExtra={editToggle} registerRef={registerRef}>
{editing ? (
<textarea
- ref={registerRef}
value={content}
onChange={(e) => onContentChange(e.target.value)}
onBlur={onBlurSave}
@@ -56,7 +63,16 @@ export default function AnnotatedManuscriptSection({
)}
{!editing && openComment ? (
- <div className="border-l-2 border-port-accent/50 pl-2">
+ <div ref={cardRef} className="relative border-l-2 border-port-accent/50 pl-2">
+ <button
+ type="button"
+ onClick={onCloseComment}
+ className="absolute right-1 top-1 z-10 text-gray-500 hover:text-white"
+ aria-label="Close note"
+ title="Close note"
+ >
+ <X size={14} />
+ </button>
<ManuscriptCommentCard
comment={openComment}
idScope={`review-${openComment.id}`}
diff --git a/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx b/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx
index 814d83ce65..582464d355 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptLiveSection.jsx
@@ -70,7 +70,7 @@ export default function ManuscriptLiveSection({
}, [openComment, onCloseComment]);
return (
- <ManuscriptSectionFrame section={section} saveState={saveState} onRevert={onRevert}>
+ <ManuscriptSectionFrame section={section} saveState={saveState} onRevert={onRevert} registerRef={registerRef}>
{/* Pin chips: a touch-friendly, count-bearing way into each anchored note. */}
{anchoredComments.length > 0 || unlocatedCount > 0 ? (
<div className="flex flex-wrap items-center gap-1">
@@ -123,7 +123,7 @@ export default function ManuscriptLiveSection({
</div>
<textarea
- ref={(el) => { taRef.current = el; registerRef(el); }}
+ ref={(el) => { taRef.current = el; }}
value={content}
onChange={(e) => onContentChange(e.target.value)}
onBlur={onBlurSave}
diff --git a/client/src/components/pipeline/manuscript/ManuscriptSectionFrame.jsx b/client/src/components/pipeline/manuscript/ManuscriptSectionFrame.jsx
index 0e664bc6c1..a4ca104548 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptSectionFrame.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptSectionFrame.jsx
@@ -17,7 +17,7 @@ function SaveBadge({ state }) {
return null;
}
-export default function ManuscriptSectionFrame({ section, saveState, onRevert, headerExtra, children }) {
+export default function ManuscriptSectionFrame({ section, saveState, onRevert, headerExtra, registerRef, children }) {
const [showVersions, setShowVersions] = useState(false);
const [revertingId, setRevertingId] = useState(null);
const versions = section.versions || [];
@@ -29,7 +29,7 @@ export default function ManuscriptSectionFrame({ section, saveState, onRevert, h
};
return (
- <article className="space-y-1.5">
+ <article ref={registerRef} className="space-y-1.5">
<div className="flex items-center justify-between gap-2 sticky top-0 bg-port-bg/95 backdrop-blur py-1 z-10">
<h2 className="text-sm font-semibold text-gray-200">
Issue {section.number}{section.title ? ` — ${section.title}` : ''}
diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsx
index 8bcade2bf3..97c41bba43 100644
--- a/client/src/pages/PipelineManuscriptEditor.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.jsx
@@ -246,20 +246,20 @@ export default function PipelineManuscriptEditor() {
return result;
};
- // Reveal a comment in context: open its card and scroll its section into view
- // (focusing the textarea if that section is being edited).
+ // Reveal a comment in context: open its card and scroll its section into view.
+ // The section element is registered in every mode (Live + Review, editing or
+ // not), so this works regardless of which surface is showing. A comment with
+ // no issueNumber is genuinely unanchored — say so rather than scroll nowhere.
const revealComment = (comment) => {
setOpenCommentId(comment.id);
- const ta = comment.issueNumber != null ? sectionRefs.current.get(comment.issueNumber) : null;
- if (!ta) {
+ if (comment.issueNumber == null) {
toast('This comment is not anchored to a specific issue');
return;
}
- ta.scrollIntoView?.({ behavior: 'smooth', block: 'start' });
- if (document.activeElement === ta || editingIssueId) {
- const quote = comment.anchorQuote || '';
- const idx = quote ? ta.value.indexOf(quote) : -1;
- if (idx !== -1) { ta.focus(); ta.setSelectionRange(idx, idx + quote.length); }
+ const el = sectionRefs.current.get(comment.issueNumber);
+ el?.scrollIntoView?.({ behavior: 'smooth', block: 'start' });
+ if (comment.stageId && viewType && comment.stageId !== viewType) {
+ toast(`This note is on the ${STAGE_LABEL[comment.stageId] || comment.stageId} — switch formats to edit it in context`);
}
};
diff --git a/client/src/pages/PipelineManuscriptEditor.test.jsx b/client/src/pages/PipelineManuscriptEditor.test.jsx
index 5f41d8de3e..6b530e28e2 100644
--- a/client/src/pages/PipelineManuscriptEditor.test.jsx
+++ b/client/src/pages/PipelineManuscriptEditor.test.jsx
@@ -172,6 +172,24 @@ describe('PipelineManuscriptEditor', () => {
expect(await screen.findByDisplayValue('The hero walked in. She left.')).toBeInTheDocument();
});
+ it('Review mode: revealing an anchored comment from the sidebar opens it in-context (no "not anchored")', async () => {
+ const toast = (await import('../components/ui/Toast')).default;
+ renderEditor();
+ await screen.findByText('My Series');
+ fireEvent.click(screen.getByRole('button', { name: /Review/ }));
+ await waitFor(() => expect(screen.queryByDisplayValue('The hero walked in. She left.')).not.toBeInTheDocument());
+
+ revealFromIndex('The ending is abrupt');
+ // The inline card appears (problem now shown in both the index row and card)…
+ await waitFor(() => expect(screen.getAllByText('The ending is abrupt')).toHaveLength(2));
+ // …and the bogus "not anchored" toast is NOT fired for an anchored comment.
+ expect(toast).not.toHaveBeenCalledWith('This comment is not anchored to a specific issue');
+
+ // The card's close control collapses it back to index-only.
+ fireEvent.click(screen.getByLabelText('Close note'));
+ await waitFor(() => expect(screen.getAllByText('The ending is abrupt')).toHaveLength(1));
+ });
+
it('opens the whole-manuscript impact preview modal', async () => {
renderEditor();
await screen.findByText('My Series');