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: bind manuscript action results to their series and format (#9953)
[._.]/ Adam Eivy39b14a12a352
diff --git a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsxindex a78f9469c2..fd66c99f2f 100644--- a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx@@ -114,7 +114,10 @@ export default function ManuscriptImpactPreview({ open, onClose, seriesId, sectiif (!mountedRef.current) return;if (result) {applied += 1;- onAccepted(result, snapshot);+ if (onAccepted(result, snapshot) === false) {+ setAcceptState(null);+ return;+ }}setAcceptState((s) => (s ? { ...s, done: s.done + 1 } : s));}diff --git a/client/src/pages/PipelineManuscriptEditor.jsx b/client/src/pages/PipelineManuscriptEditor.jsxindex 42d5bb2d93..a29a6a9d10 100644--- a/client/src/pages/PipelineManuscriptEditor.jsx+++ b/client/src/pages/PipelineManuscriptEditor.jsx@@ -42,6 +42,7 @@ import useUnsavedChangesGuard from '../hooks/useUnsavedChangesGuard';import { filterGenerationModels, mergeModelLists, localBackendForProvider, modelOptionLabel } from '../utils/providers';import ProviderModelSelector from '../components/ProviderModelSelector';import useLocalModels from '../hooks/useLocalModels';+import useMounted from '../hooks/useMounted';import { locateAnchors } from '../lib/manuscriptAnchors';import { safeReadStorage, safeWriteStorage } from '../lib/safeStorage';import ManuscriptLiveSection from '../components/pipeline/manuscript/ManuscriptLiveSection';@@ -81,6 +82,12 @@ const isSectionDirty = (baselines, section) => {};export default function PipelineManuscriptEditor() {+ const { seriesId } = useParams();+ // Series changes dispose every draft and callback; issue tabs keep this owner.+ return <SeriesManuscriptEditor key={seriesId} />;+}++function SeriesManuscriptEditor() {const params = useParams();const { seriesId } = params;const navigate = useNavigate();@@ -95,6 +102,13 @@ export default function PipelineManuscriptEditor() {const [series, setSeries] = useState(null);const [sections, setSections] = useState([]);const [viewType, setViewType] = useState(null); // format currently shown+ const mountedRef = useMounted();+ // Each format activation owns its callbacks, even if we later return to the+ // same format. An old card/Undo toast must not apply into a replacement view.+ const viewOwnerRef = useRef({ stageId: viewType });+ if (viewOwnerRef.current.stageId !== viewType) viewOwnerRef.current = { stageId: viewType };+ const viewOwner = viewOwnerRef.current;+ const ownsView = () => mountedRef.current && viewOwnerRef.current === viewOwner;const [pinnedPrimary, setPinnedPrimary] = useState(null);const [availableTypes, setAvailableTypes] = useState([]);const [comments, setComments] = useState([]);@@ -126,8 +140,9 @@ export default function PipelineManuscriptEditor() {// Per-comment fix-edit drafts, keyed by comment id and shared across every// place the card renders (sidebar reveal, in-context card, impact preview).const [fixDrafts, setFixDrafts] = useState({});- const setCommentDraft = (commentId, entry) =>- setFixDrafts((prev) => ({ ...prev, [commentId]: entry }));+ const setCommentDraft = (commentId, entry) => {+ if (ownsView()) setFixDrafts((prev) => ({ ...prev, [commentId]: entry }));+ };// textarea elements keyed by issue number, for reveal-to-section scroll/focus.const sectionRefs = useRef(new Map());// Last server-confirmed content per section, as STATE so the issue tabs can@@ -150,15 +165,19 @@ export default function PipelineManuscriptEditor() {commitBaselines(next);};- const patchSection = (issueId, fields) =>- setSections((prev) => prev.map((s) => (s.issueId === issueId ? { ...s, ...fields } : s)));+ const patchSection = (section, fields) => {+ if (!ownsView()) return;+ setSections((prev) => prev.map((s) => (+ s.issueId === section.issueId && s.stageId === section.stageId ? { ...s, ...fields } : s+ )));+ };// Live mirror of `sections` so async handlers (e.g. the slow AI reformat) can// read the CURRENT content at resolution time and detect a mid-call edit// instead of clobbering it via a stale closure.const liveSectionsRef = useRef([]);liveSectionsRef.current = sections;- const liveContentFor = (issueId) => liveSectionsRef.current.find((s) => s.issueId === issueId)?.content ?? '';+ const liveContentFor = (section) => liveSectionsRef.current.find((s) => s.issueId === section.issueId && s.stageId === section.stageId)?.content ?? '';// Issue numbers holding an unsaved edit, for the tab dirty dots. Sections save// onBlur, so tabbing away from a pending edit leaves it unsaved with no cue@@ -289,6 +308,7 @@ export default function PipelineManuscriptEditor() {const [runEditorialReview, reviewing] = useAsyncAction(async (mode = 'merge') => {const result = await analyzePipelineManuscriptCompleteness(seriesId, { providerOverride, modelOverride, mode }, { silent: true });+ if (!ownsView()) return;const next = Array.isArray(result?.review?.comments) ? result.review.comments : [];setComments(next);setReviewMeta({ chunked: !!result?.chunked, chunkCount: result?.chunkCount || 1 });@@ -325,6 +345,7 @@ export default function PipelineManuscriptEditor() {const reloadReviewAfterRun = (meta = null, { recovered = false } = {}) =>getPipelineManuscriptReview(seriesId, { silent: true }).then((review) => {+ if (!ownsView()) return;const next = Array.isArray(review?.comments) ? review.comments : [];setComments(next);if (meta) setReviewMeta({ chunked: !!meta.chunked, chunkCount: meta.chunkCount || 1 });@@ -337,7 +358,7 @@ export default function PipelineManuscriptEditor() {? `Editorial review complete — ${openCount} open notes with drafted edits (reviewed in ${meta.chunkCount} chunks)`: `Editorial review complete — ${openCount} open notes with drafted edits`);})- .catch((err) => toast.error(err.message || 'Failed to load review'));+ .catch((err) => { if (ownsView()) toast.error(err.message || 'Failed to load review'); });// Terminal-frame handler for the streamed run: refresh comments + toast, then// tear the subscription down. Per-chunk frames only drive the button label.@@ -377,7 +398,9 @@ export default function PipelineManuscriptEditor() {toast.error(err.message || 'Failed to start editorial review');return null;});+ if (!mountedRef.current) return;setReviewStarting(false);+ if (!ownsView()) return;if (!result) return;setReviewActive(true);};@@ -421,7 +444,9 @@ export default function PipelineManuscriptEditor() {const changeView = async (type) => {if (type === viewType || switching) return;setSwitching(true);- if (!(await flushPendingSectionSaves())) {+ const flushed = await flushPendingSectionSaves();+ if (!ownsView()) return;+ if (!flushed) {setSwitching(false);toast('Kept this format open — your unsaved edit could not be saved');return;@@ -430,6 +455,7 @@ export default function PipelineManuscriptEditor() {toast.error(err.message || 'Failed to load that format');return null;});+ if (!ownsView()) return;setSwitching(false);if (!manuscript) return;// Editing remains available during the GET. Recheck the live owners before@@ -453,13 +479,15 @@ export default function PipelineManuscriptEditor() {setPinning(true);const updated = await updatePipelineSeries(seriesId, { primaryManuscriptType: viewType }, { silent: true }).catch((err) => { toast.error(err.message || 'Failed to set primary format'); return null; });+ if (!mountedRef.current) return;setPinning(false);+ if (!ownsView()) return;if (!updated) return;setPinnedPrimary(updated.primaryManuscriptType || viewType);toast.success(`${STAGE_LABEL[viewType] || viewType} set as the primary manuscript`);};- const setSectionContent = (issueId, content) => patchSection(issueId, { content });+ const setSectionContent = (section, content) => patchSection(section, { content });// Tail of each section's save chain, keyed by section. Two paths can target// the same section at once — the onBlur save and the flush below (clicking the@@ -470,7 +498,7 @@ export default function PipelineManuscriptEditor() {const persistSection = async (section, key, content) => {// Re-checked HERE, not before queueing: by the time this link runs, the save// ahead of it may have already persisted this exact text.- if (baselineRef.current.get(key) === content) return;+ if (!ownsView() || baselineRef.current.get(key) === content) return;setSaveState((prev) => ({ ...prev, [section.issueId]: 'saving' }));const result = await savePipelineManuscriptSection(seriesId,@@ -481,9 +509,10 @@ export default function PipelineManuscriptEditor() {toast.error(err.message || 'Failed to save manuscript edit');return null;});+ if (!ownsView()) return result;if (result?.section) {setBaseline(key, result.section.content);- patchSection(section.issueId, { versions: result.section.versions });+ patchSection(section, { versions: result.section.versions });}setSaveState((prev) => ({ ...prev, [section.issueId]: result ? 'saved' : undefined }));return result;@@ -541,7 +570,7 @@ export default function PipelineManuscriptEditor() {toast('Already well-formatted — nothing to clean up');return;}- setSectionContent(section.issueId, formatted);+ setSectionContent(section, formatted);// Only claim success once the save lands — saveSectionContent swallows its// own error (toasts "Failed to save…") and resolves null, so an// unconditional success toast would stack a green toast on the red one.@@ -570,8 +599,8 @@ export default function PipelineManuscriptEditor() {toast.error(err.message || 'AI reformat failed');return null;});- if (!result || typeof result.text !== 'string') return;- if (liveContentFor(section.issueId) !== sent) {+ if (!ownsView() || !result || typeof result.text !== 'string') return;+ if (liveContentFor(section) !== sent) {toast('Section changed while reformatting — discarded the AI result');return;}@@ -579,7 +608,7 @@ export default function PipelineManuscriptEditor() {toast('Already well-formatted — nothing to clean up');return;}- setSectionContent(section.issueId, result.text);+ setSectionContent(section, result.text);const saved = await saveSectionContent(section, result.text);if (saved) toast.success('Reformatted with AI');};@@ -598,6 +627,7 @@ export default function PipelineManuscriptEditor() {// with it, because settling it first would save it over that change.const retainedDrafts = useRef(new Set());const beginSectionMutation = async (keys = null) => {+ if (!ownsView()) return null;for (const key of [...retainedDrafts.current]) {const live = liveSectionsRef.current.find((s) => baselineKey(s) === key);if (!live || !isSectionDirty(baselineRef.current, live)) retainedDrafts.current.delete(key);@@ -606,7 +636,9 @@ export default function PipelineManuscriptEditor() {return null;}}- if (!(await flushPendingSectionSaves(keys))) {+ const flushed = await flushPendingSectionSaves(keys);+ if (!ownsView()) return null;+ if (!flushed) {toast('Not applied — your unsaved edit could not be saved first');return null;}@@ -615,6 +647,7 @@ export default function PipelineManuscriptEditor() {// Returns true when a newer local draft was retained instead of replaced.const adoptSectionResult = ({ issueId, stageId, content, versions }, snapshot) => {+ if (!ownsView()) return false;const key = `${issueId}:${stageId}`;const live = liveSectionsRef.current.find((s) => baselineKey(s) === key);const retain = !!live && (isSectionDirty(baselineRef.current, live)@@ -622,11 +655,11 @@ export default function PipelineManuscriptEditor() {setBaseline(key, content);if (retain) {retainedDrafts.current.add(key);- patchSection(issueId, { versions });+ patchSection({ issueId, stageId }, { versions });return true;}retainedDrafts.current.delete(key);- patchSection(issueId, { content, versions });+ patchSection({ issueId, stageId }, { content, versions });setSaveState((prev) => ({ ...prev, [issueId]: 'saved' }));return false;};@@ -638,7 +671,7 @@ export default function PipelineManuscriptEditor() {if (!snapshot) return null;const result = await restorePipelineStageVersion(section.issueId, section.stageId, runId, { silent: true }).catch((err) => { toast.error(err.message || 'Failed to revert'); return null; });- if (!result?.stage) return null;+ if (!ownsView() || !result?.stage) return null;const versions = (result.stage.runHistory || []).map((h) => ({ runId: h.runId, createdAt: h.createdAt }));const retained = adoptSectionResult({ issueId: section.issueId, stageId: section.stageId, content: result.stage.output || '', versions },@@ -655,6 +688,7 @@ export default function PipelineManuscriptEditor() {// a cross-issue jump, or immediately when it's the active issue. A story-level// note with no issueNumber has no tab, so it expands inline in the sidebar.const advanceTo = (comment) => {+ if (!ownsView()) return;setOpenCommentId(comment.id);setEditingIssueId(null); // make sure it's the card showing, not the editorif (comment.issueNumber == null) return; // unanchored — expands in the sidebar@@ -679,6 +713,7 @@ export default function PipelineManuscriptEditor() {// is one action per note with no scroll-back in between. `openOrder` is// declared below; by the time these handlers run it's populated.const updateCommentLocal = (next) => {+ if (!ownsView()) return;setComments((prev) => prev.map((c) => (c.id === next.id ? next : c)));if (next.id !== openCommentId || next.status === 'open') return;const idx = openOrder.findIndex((c) => c.id === next.id);@@ -688,14 +723,16 @@ export default function PipelineManuscriptEditor() {};const applyAccepted = (result, snapshot) => {+ if (!ownsView()) return false;let retained = false;acceptedSectionsOf(result).forEach((changed) => {- if (changed?.issueId && changed.stageId === viewType) {+ if (changed?.issueId && changed.stageId === viewOwnerRef.current.stageId) {retained = adoptSectionResult(changed, snapshot) || retained;}});if (retained) toast(RETAINED_MESSAGE);if (result.comment) updateCommentLocal(result.comment);+ return true;};// Open editorial comments anchorable to the on-screen format, grouped by issue@@ -950,7 +987,7 @@ export default function PipelineManuscriptEditor() {openCommentId,onOpenComment: setOpenCommentId,onCloseComment: () => setOpenCommentId(null),- onContentChange: (content) => setSectionContent(section.issueId, content),+ onContentChange: (content) => setSectionContent(section, content),onBlurSave: () => saveSection(section),onFormat: () => formatSection(section),onReformat: () => reformatSection(section),@@ -958,13 +995,13 @@ export default function PipelineManuscriptEditor() {registerRef: registerSectionRef(section.number),commentCardProps,};- // Key on issueId so switching issues mounts a fresh section —+ // Key on issue + stage so a replacement section owns its controls —// the card-scroll-into-view effect then fires on arrival.return viewMode === 'live' ? (- <ManuscriptLiveSection key={section.issueId} {...common} />+ <ManuscriptLiveSection key={baselineKey(section)} {...common} />) : (<AnnotatedManuscriptSection- key={section.issueId}+ key={baselineKey(section)}{...common}editing={editingIssueId === section.issueId}onToggleEdit={() => setEditingIssueId((cur) => (cur === section.issueId ? null : section.issueId))}@@ -1099,6 +1136,7 @@ export default function PipelineManuscriptEditor() {/><ManuscriptReadAloud+ key={activeSection ? baselineKey(activeSection) : 'empty'}open={showReadAloud}onClose={() => setShowReadAloud(false)}section={activeSection}diff --git a/client/src/pages/PipelineManuscriptEditor.test.jsx b/client/src/pages/PipelineManuscriptEditor.test.jsxindex 5e92070b4f..76b1440154 100644--- a/client/src/pages/PipelineManuscriptEditor.test.jsx+++ b/client/src/pages/PipelineManuscriptEditor.test.jsx@@ -26,7 +26,7 @@ vi.mock('../services/apiLocalLlm', async (importOriginal) => ({...await importOriginal(),getLocalLlmStatus: vi.fn().mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } }),}));-vi.mock('../components/ui/Toast', () => ({ default: Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() }) }));+vi.mock('../components/ui/Toast', () => ({ default: Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), dismiss: vi.fn() }) }));import PipelineManuscriptEditor from './PipelineManuscriptEditor';@@ -278,6 +278,179 @@ describe('PipelineManuscriptEditor', () => {? { sections: [{ issueId: 'iss-1', number: 1, title: 'One', stageId: 'teleplay', content: 'INT. ROOM - DAY' }], viewType: 'teleplay', availableTypes: ['prose', 'teleplay'] }: { sections: [{ issueId: 'iss-1', number: 1, title: 'One', stageId: 'prose', content: 'The hero walked in. She left.' }], viewType: 'prose', pinnedPrimary: 'prose', availableTypes: ['prose', 'teleplay'] }));+ const deferred = () => {+ let resolve;+ const promise = new Promise((done) => { resolve = done; });+ return { promise, resolve };+ };+ const acceptedProse = {+ comment: { ...comment, status: 'accepted' },+ section: { issueId: 'iss-1', number: 1, stageId: 'prose', content: 'Accepted prose.', versions: [] },+ };+ const expectTeleplayUnchanged = () => {+ const textarea = screen.getByDisplayValue('INT. ROOM - DAY');+ expect(screen.queryByText('saved')).not.toBeInTheDocument();+ fireEvent.blur(textarea);+ expect(api.savePipelineManuscriptSection).not.toHaveBeenCalled();+ };++ it('disposes a delayed format read when the route changes to another series (#9953)', async () => {+ mockBothFormats();+ const load = api.getPipelineManuscript.getMockImplementation();+ const pending = deferred();+ api.getPipelineManuscript.mockImplementation((id, type) => id === 'ser-1' && type === 'teleplay'+ ? pending.promise+ : id === 'ser-2'+ ? Promise.resolve({ sections: [{ issueId: 'other-1', number: 1, stageId: 'prose', content: 'Other series draft.' }], viewType: 'prose', availableTypes: ['prose'] })+ : load(id, type));+ api.getPipelineSeries.mockImplementation((id) => Promise.resolve({ id, name: id === 'ser-2' ? 'Other Series' : 'My Series' }));+ const { router } = renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ fireEvent.click(screen.getByRole('button', { name: 'Teleplay' }));+ await waitFor(() => expect(api.getPipelineManuscript).toHaveBeenCalledWith('ser-1', 'teleplay', { silent: true }));+ await act(async () => { await router.navigate('/pipeline/series/ser-2/manuscript/1'); });+ await screen.findByDisplayValue('Other series draft.');+ await act(async () => { pending.resolve(await load('ser-1', 'teleplay')); });+ expect(screen.getByDisplayValue('Other series draft.')).toBeInTheDocument();+ expect(screen.getByRole('heading', { name: 'Other Series' })).toBeInTheDocument();+ expect(router.state.location.pathname).toBe('/pipeline/series/ser-2/manuscript/1');+ fireEvent.blur(screen.getByDisplayValue('Other series draft.'));+ expect(api.savePipelineManuscriptSection).not.toHaveBeenCalled();+ });++ it.each(['Accept', 'Manual edit'])('drops a delayed %s from the prior format before it can enter a save (#9953)', async (action) => {+ mockBothFormats();+ api.getPipelineManuscriptReview.mockResolvedValue({ comments: [{ ...comment, fix: { find: 'She left.', replace: 'Accepted prose.' } }] });+ const pending = deferred();+ api.acceptPipelineManuscriptFix.mockReturnValue(pending.promise);+ renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ revealFromIndex(comment.problem);+ if (action === 'Manual edit') {+ fireEvent.click(await screen.findByRole('button', { name: 'Manual edit' }));+ fireEvent.change(screen.getByDisplayValue('She left.'), { target: { value: 'Accepted prose.' } });+ fireEvent.click(screen.getByRole('button', { name: 'Apply edit' }));+ } else fireEvent.click(await screen.findByRole('button', { name: 'Accept' }));+ await waitFor(() => expect(api.acceptPipelineManuscriptFix).toHaveBeenCalledTimes(1));+ fireEvent.click(screen.getByRole('button', { name: 'Teleplay' }));+ await screen.findByText('INT. ROOM - DAY');+ fireEvent.click(screen.getByRole('button', { name: /Live/ }));+ await act(async () => { pending.resolve(acceptedProse); });+ expectTeleplayUnchanged();+ expect(screen.getByText(/1 open/)).toBeInTheDocument();+ });++ it('drops a prior-format version restore without changing the new baseline or save state (#9953)', async () => {+ mockBothFormats();+ const load = api.getPipelineManuscript.getMockImplementation();+ api.getPipelineManuscript.mockImplementation(async (id, type) => {+ const data = await load(id, type);+ if (!type) data.sections[0].versions = [{ runId: 'v1' }];+ return data;+ });+ const pending = deferred();+ api.restorePipelineStageVersion.mockReturnValue(pending.promise);+ renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ fireEvent.click(screen.getByTitle('Show prior saved versions'));+ fireEvent.click(screen.getByRole('button', { name: 'Revert' }));+ fireEvent.click(screen.getByRole('button', { name: 'Teleplay' }));+ await screen.findByDisplayValue('INT. ROOM - DAY');+ await act(async () => { pending.resolve({ stage: { output: 'Restored prose.', runHistory: [] } }); });+ expectTeleplayUnchanged();+ expect(api.restorePipelineStageVersion).toHaveBeenCalledWith('iss-1', 'prose', 'v1', { silent: true });+ });++ it('keeps the Undo toast bound to the format that accepted the fix (#9953)', async () => {+ mockBothFormats();+ api.getPipelineManuscriptReview.mockResolvedValue({ comments: [{ ...comment, fix: { find: 'She left.', replace: 'Accepted prose.' } }] });+ api.acceptPipelineManuscriptFix.mockResolvedValue(acceptedProse);+ const pending = deferred();+ api.undoPipelineManuscriptFix.mockReturnValue(pending.promise);+ const toast = (await import('../components/ui/Toast')).default;+ renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ revealFromIndex(comment.problem);+ fireEvent.click(await screen.findByRole('button', { name: 'Accept' }));+ await screen.findByText('Accepted prose.');+ const renderToast = toast.mock.calls.find(([value]) => typeof value === 'function')[0];+ render(renderToast({ id: 'test-toast' }));+ fireEvent.click(screen.getByRole('button', { name: 'Undo' }));+ fireEvent.click(screen.getByRole('button', { name: 'Teleplay' }));+ await screen.findByText('INT. ROOM - DAY');+ fireEvent.click(screen.getByRole('button', { name: /Live/ }));+ await act(async () => { pending.resolve({ ...acceptedProse, comment, section: { ...acceptedProse.section, content: 'Original prose.' } }); });+ expectTeleplayUnchanged();+ expect(api.undoPipelineManuscriptFix).toHaveBeenCalledWith('ser-1', comment.id, { silent: true });+ });++ it('stops a delayed accept-all batch when another format replaces its owner (#9953)', async () => {+ mockBothFormats();+ const second = { ...comment, id: 'mrc-2', anchorQuote: 'The hero walked in.', fix: { find: 'The hero walked in.', replace: 'A visitor arrived.' } };+ api.getPipelineManuscriptReview.mockResolvedValue({ comments: [{ ...comment, fix: { find: 'She left.', replace: 'Accepted prose.' } }, second] });+ const pending = deferred();+ api.acceptPipelineManuscriptFix.mockReturnValue(pending.promise);+ renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ fireEvent.click(screen.getByRole('button', { name: 'Impact preview' }));+ fireEvent.click(await screen.findByRole('button', { name: 'Accept all 2 edits' }));+ fireEvent.click(screen.getByRole('button', { name: 'Teleplay' }));+ await screen.findByDisplayValue('INT. ROOM - DAY');+ await act(async () => { pending.resolve(acceptedProse); });+ expectTeleplayUnchanged();+ expect(api.acceptPipelineManuscriptFix).toHaveBeenCalledTimes(1);+ expect(screen.getByRole('dialog', { name: 'Manuscript impact preview' })).toBeInTheDocument();+ });++ it('keeps an old card response from changing another series text, comments or selection (#9953)', async () => {+ api.getPipelineManuscriptReview.mockResolvedValue({ comments: [{ ...comment, fix: { find: 'She left.', replace: 'Accepted prose.' } }] });+ const pending = deferred();+ api.acceptPipelineManuscriptFix.mockReturnValue(pending.promise);+ const { router } = renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ revealFromIndex(comment.problem);+ fireEvent.click(await screen.findByRole('button', { name: 'Accept' }));+ await act(async () => { await router.navigate('/pipeline/series/ser-2/manuscript/1'); });+ await screen.findByText(comment.problem);+ fireEvent.click(screen.getByRole('button', { name: /Live/ }));+ await act(async () => { pending.resolve(acceptedProse); });+ expect(screen.getByDisplayValue('The hero walked in. She left.')).toBeInTheDocument();+ expect(screen.getByText(/1 open/)).toBeInTheDocument();+ expect(router.state.location.pathname).toBe('/pipeline/series/ser-2/manuscript/1');+ });++ it('retains an unblurred draft across issue tabs in the same series (#9953)', async () => {+ api.getPipelineManuscript.mockResolvedValue({+ sections: [+ { issueId: 'iss-1', number: 1, stageId: 'prose', content: 'First issue draft.' },+ { issueId: 'iss-2', number: 2, stageId: 'prose', content: 'Second issue draft.' },+ ], viewType: 'prose', availableTypes: ['prose'],+ });+ renderEditor('/pipeline/series/ser-1/manuscript/1');+ fireEvent.change(await screen.findByDisplayValue('First issue draft.'), { target: { value: 'Unblurred edit.' } });+ const tabs = within(screen.getByRole('navigation', { name: 'Issues' }));+ fireEvent.click(tabs.getByRole('link', { name: /Issue 2/ }));+ await screen.findByDisplayValue('Second issue draft.');+ fireEvent.click(tabs.getByRole('link', { name: /Issue 1/ }));+ expect(await screen.findByDisplayValue('Unblurred edit.')).toBeInTheDocument();+ expect(screen.getByLabelText('Issue 1 has unsaved edits')).toBeInTheDocument();+ expect(api.getPipelineManuscript).toHaveBeenCalledTimes(1);+ });++ it('disposes old review responses without replacing another series comments or route (#9953)', async () => {+ const pending = deferred();+ api.analyzePipelineManuscriptCompleteness.mockReturnValue(pending.promise);+ api.getPipelineSeries.mockImplementation((id) => Promise.resolve({ id, name: id === 'ser-2' ? 'Other Series' : 'My Series' }));+ const { router } = renderEditor();+ await screen.findByDisplayValue('The hero walked in. She left.');+ fireEvent.click(screen.getByRole('button', { name: 'Run editorial review' }));+ await act(async () => { await router.navigate('/pipeline/series/ser-2/manuscript/1'); });+ await screen.findByRole('heading', { name: 'Other Series' });+ await act(async () => { pending.resolve({ review: { comments: [] } }); });+ expect(screen.getByText(comment.problem)).toBeInTheDocument();+ expect(router.state.location.pathname).toBe('/pipeline/series/ser-2/manuscript/1');+ });+const savedProse = {section: { issueId: 'iss-1', number: 1, title: 'One', stageId: 'prose', content: 'The hero walked in. She stayed.', versions: [] },};