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

address review: clear stale candidates on reindex + flush blur-save before generate (#904)

Adam Eivyb2a3c8ae4487
diff --git a/client/src/components/pipeline/stages/ComicPagesStage.jsx b/client/src/components/pipeline/stages/ComicPagesStage.jsx
index b12af98c6a..89ff3187b8 100644
--- a/client/src/components/pipeline/stages/ComicPagesStage.jsx
+++ b/client/src/components/pipeline/stages/ComicPagesStage.jsx
@@ -63,8 +63,14 @@ export default function ComicPagesStage({ issue, onStageUpdate, actionsGated = f
const next = pages.map((p, i) => i === pi ? { ...p, panels: [...(p.panels || []), { description: '', imageJobId: null }] } : p);
persist(next);
};
- const removePage = (pi) => persist(pages.filter((_, i) => i !== pi));
+ // Removing a page or panel reindexes the `${pi}:${ni}`-keyed candidates after
+ // it, so any open candidate list would point at the wrong panel — drop them.
+ const removePage = (pi) => {
+ setPanelCandidates({});
+ persist(pages.filter((_, i) => i !== pi));
+ };
const removePanel = (pi, ni) => {
+ setPanelCandidates({});
const next = pages.map((p, i) => i === pi
? { ...p, panels: (p.panels || []).filter((_, j) => j !== ni) }
: p);
@@ -93,6 +99,9 @@ export default function ComicPagesStage({ issue, onStageUpdate, actionsGated = f
setExtracting(false);
if (!result) return;
setPages(result.stage?.pages || []);
+ // Extraction replaces the whole page/panel tree — stale candidates would
+ // now belong to different panels.
+ setPanelCandidates({});
onStageUpdate?.('comicPages', result.stage, result.issue);
toast.success(`Extracted ${result.pageCount} page${result.pageCount === 1 ? '' : 's'} / ${result.panelCount} panel${result.panelCount === 1 ? '' : 's'}`);
};
@@ -171,6 +180,10 @@ export default function ComicPagesStage({ issue, onStageUpdate, actionsGated = f
}
const key = `${pi}:${ni}`;
setPromptingKey(key);
+ // Flush any pending textarea edit before the server reads the panel
+ // description (it builds the prompt from the persisted text). pagesRef
+ // holds the latest keystroke that onBlur may not have committed yet.
+ await persist(pagesRef.current);
const result = await generatePipelineComicPanelImagePrompts(
issue.id, pi, ni, { count: promptCount, ...genConfigToRefineOptions(genConfig) },
).catch((err) => {
diff --git a/client/src/components/pipeline/stages/StoryboardsStage.jsx b/client/src/components/pipeline/stages/StoryboardsStage.jsx
index 64444982d2..f7d51d8f60 100644
--- a/client/src/components/pipeline/stages/StoryboardsStage.jsx
+++ b/client/src/components/pipeline/stages/StoryboardsStage.jsx
@@ -91,7 +91,12 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
};
const addScene = () => persist([...scenes, { slugline: '', description: '', imageJobId: null }]);
- const removeScene = (i) => persist(scenes.filter((_, j) => j !== i));
+ const removeScene = (i) => {
+ // Removing a scene reindexes everything after it, so any index-keyed
+ // candidate state would now point at the wrong scene — drop it all.
+ setSceneCandidates({});
+ persist(scenes.filter((_, j) => j !== i));
+ };
const updateScene = (i, patch) => {
const next = scenes.map((s, j) => j === i ? { ...s, ...patch } : s);
setScenes(next);
@@ -197,6 +202,9 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
if (!result) return;
const next = result.stage?.scenes || [];
setScenes(next);
+ // Extraction replaces the whole scene list — stale index-keyed candidates
+ // would now belong to different scenes.
+ setSceneCandidates({});
onStageUpdate?.('storyboards', result.stage, result.issue);
toast.success(`Extracted ${result.sceneCount} scene${result.sceneCount === 1 ? '' : 's'}`);
};
@@ -262,6 +270,10 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions
return;
}
setPromptingIdx(i);
+ // Flush any pending textarea edit before the server reads scene.description
+ // (the server builds the prompt from the persisted text). Same guard the
+ // shot-render path uses against the blur-save race.
+ await persist(scenes);
const result = await generatePipelineSceneImagePrompts(
issue.id, i, { count: promptCount, ...genConfigToRefineOptions(genConfig) },
).catch((err) => {