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

simplify: clean up state proxies, redundant sort, Set overhead, route literal

[._.]/ Adam Eivy40780466ec51
diff --git a/client/src/components/pipeline/stages/TextStagePanel.jsx b/client/src/components/pipeline/stages/TextStagePanel.jsx
index 04812d2497..906a54ade2 100644
--- a/client/src/components/pipeline/stages/TextStagePanel.jsx
+++ b/client/src/components/pipeline/stages/TextStagePanel.jsx
@@ -55,16 +55,11 @@ export default function TextStagePanel({
// Selected source stage ids. Defaults to the conventional forward source(s)
// that exist; recomputed whenever the candidate set changes (issue/stage swap).
- // `availableKey` is a stable string proxy for the availableSources array so
- // the effect re-runs on membership change without an array identity in deps.
- const availableKey = availableSources.join(',');
const [selectedSources, setSelectedSources] = useState([]);
useEffect(() => {
const preferred = (DEFAULT_FORWARD_SOURCE[stageId] || []).filter((id) => availableSources.includes(id));
setSelectedSources(preferred);
- // availableSources is captured via its `availableKey` string proxy.
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [issue.id, stageId, availableKey]);
+ }, [issue.id, stageId, availableSources]);
const toggleSource = (id) => setSelectedSources(
(prev) => (prev.includes(id) ? prev.filter((s) => s !== id) : [...prev, id]),
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.js
index 413626158d..ed923c90be 100644
--- a/server/routes/pipeline.js
+++ b/server/routes/pipeline.js
@@ -362,7 +362,7 @@ const generateSchema = z.object({
// Explicit source stages to feed the generation (backport support: generate
// any stage FROM any other populated stage). Omit for the conventional
// forward source. The service drops the target itself and empty stages.
- sourceStageIds: z.array(z.enum(['idea', 'prose', 'comicScript', 'teleplay'])).optional(),
+ sourceStageIds: z.array(z.enum(issuesSvc.TEXT_STAGE_IDS)).optional(),
});
const visualGenerateSchema = z.object({
diff --git a/server/services/pipeline/textStages.js b/server/services/pipeline/textStages.js
index d23125cf7f..e8fc82cb00 100644
--- a/server/services/pipeline/textStages.js
+++ b/server/services/pipeline/textStages.js
@@ -169,16 +169,13 @@ async function buildIdeaContextAugment(series, issue) {
* Returned in TEXT_STAGE_IDS order for stable prompt rendering.
*/
function resolveSourceStageIds({ issue, stageId, sourceStageIds }) {
- const requested = Array.isArray(sourceStageIds)
+ const requested = new Set(Array.isArray(sourceStageIds)
? sourceStageIds
- : DEFAULT_FORWARD_SOURCE[stageId] || [];
- const eligible = new Set(
- requested.filter((id) =>
- TEXT_STAGE_IDS.includes(id)
- && id !== stageId
- && stageContentOf(issue.stages?.[id])),
- );
- return TEXT_STAGE_IDS.filter((id) => eligible.has(id));
+ : DEFAULT_FORWARD_SOURCE[stageId] || []);
+ return TEXT_STAGE_IDS.filter((id) =>
+ requested.has(id)
+ && id !== stageId
+ && stageContentOf(issue.stages?.[id]));
}
/**
diff --git a/server/services/storyBuilder.js b/server/services/storyBuilder.js
index 80560ffe9b..e58bc9914c 100644
--- a/server/services/storyBuilder.js
+++ b/server/services/storyBuilder.js
@@ -436,9 +436,8 @@ const BACKFILL_SOURCE_MAX = 200_000;
async function collectIssueSourceText(seriesId) {
if (!seriesId) return '';
const issues = await listIssues({ seriesId }).catch(() => []);
- const ordered = [...issues].sort((a, b) => (a.number || 0) - (b.number || 0));
const parts = [];
- for (const iss of ordered) {
+ for (const iss of issues) {
const st = iss.stages || {};
const pick = ['comicScript', 'teleplay', 'prose', 'idea']
.map((sid) => ({ sid, content: stageContentOf(st[sid]) }))
@@ -523,7 +522,7 @@ export async function generateStep(id, stepId, options = {}) {
}
if (stepId === 'plotArc') {
if (!session.seriesId) throw makeErr('No series linked', ERR_VALIDATION);
- let arc; let seasons; let runId; let providerId; let model;
+ let arcGenResult;
if (options.fromDownstream) {
// Backfill: extract the arc + seasons from the issues that already exist
// (the user drafted scripts/prose first). Reuses the importer's
@@ -535,14 +534,15 @@ export async function generateStep(id, stepId, options = {}) {
ERR_VALIDATION,
);
}
- ({ arc, seasons, runId, providerId, model } = await generateArcFromSource(session.seriesId, {
+ arcGenResult = await generateArcFromSource(session.seriesId, {
sourceText, providerOverride: reqProviderId, modelOverride: reqModel,
- }));
+ });
} else {
- ({ arc, seasons, runId, providerId, model } = await generateArcOverview(session.seriesId, {
+ arcGenResult = await generateArcOverview(session.seriesId, {
providerOverride: reqProviderId, modelOverride: reqModel,
- }));
+ });
}
+ const { arc, seasons, runId, providerId, model } = arcGenResult;
// A null arc means the LLM returned nothing identifying — refuse rather
// than wiping a previously-generated arc with `updateSeries({ arc: null })`.
if (!arc) throw makeErr('LLM returned an empty arc — try regenerating', ERR_VALIDATION);