Skip to content

Commit c492b64

Browse files
committed
simplify: dedup stage-content accessor + hoist the forward-source map
Two cleanups from the post-implementation review: - Export stageContentOf from textStages.js and reuse it in storyBuilder's collectIssueSourceText, which was re-inlining the same "edited input wins over raw output" precedence expression. - Move the client's DEFAULT_FORWARD_SOURCE into apiPipeline.js as PIPELINE_DEFAULT_FORWARD_SOURCE, next to PIPELINE_TEXT_STAGES / PIPELINE_STAGE_LABELS, matching the established client/server stage-constant mirror convention instead of a second private copy in TextStagePanel.
1 parent 3157cde commit c492b64

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

client/src/components/pipeline/stages/TextStagePanel.jsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,13 @@ import {
1212
generatePipelineStage, updatePipelineIssue,
1313
PIPELINE_STAGE_LABELS,
1414
PIPELINE_TEXT_STAGES,
15+
PIPELINE_DEFAULT_FORWARD_SOURCE as DEFAULT_FORWARD_SOURCE,
1516
PIPELINE_STAGE_STATUS_LABEL as STATUS_LABEL,
1617
PIPELINE_STAGE_STATUS_COLOR as STATUS_COLOR,
1718
} from '../../../services/api';
1819
import { useAsyncAction } from '../../../hooks/useAsyncAction';
1920
import StageHistoryModal from './StageHistoryModal';
2021

21-
// The stage that conventionally feeds each target — mirrors the server's
22-
// DEFAULT_FORWARD_SOURCE. Used to pre-check the source picker so the common
23-
// forward flow needs no clicks, while still allowing any populated stage to be
24-
// chosen as a backport source.
25-
const DEFAULT_FORWARD_SOURCE = {
26-
prose: ['idea'],
27-
comicScript: ['prose'],
28-
teleplay: ['prose'],
29-
};
30-
3122
const stageHasContent = (stage) => Boolean(stage?.input?.trim() || stage?.output?.trim());
3223

3324
export default function TextStagePanel({

client/src/services/apiPipeline.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ export const PIPELINE_STAGE_LABELS = Object.freeze({
3838
audio: 'Audio',
3939
});
4040

41+
// The stage that conventionally feeds each text-stage target — mirrors the
42+
// server's DEFAULT_FORWARD_SOURCE (server/services/pipeline/textStages.js).
43+
// The text-stage source picker pre-checks these so the common forward flow
44+
// needs no clicks, while still letting any populated stage be a backport source.
45+
export const PIPELINE_DEFAULT_FORWARD_SOURCE = Object.freeze({
46+
prose: ['idea'],
47+
comicScript: ['prose'],
48+
teleplay: ['prose'],
49+
});
50+
4151
export const PIPELINE_TARGET_FORMATS = Object.freeze(['comic', 'tv', 'comic+tv']);
4252

4353
export const PIPELINE_STAGE_STATUS_LABEL = Object.freeze({

server/services/storyBuilder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
generateArcOverview, generateArcFromSource, generateReaderMap, refineReaderMap, commitSeasonsWithRemap,
4141
} from './pipeline/arcPlanner.js';
4242
import { listIssues } from './pipeline/issues.js';
43+
import { stageContentOf } from './pipeline/textStages.js';
4344

4445
const TYPE_SCHEMA_VERSION = 1;
4546

@@ -440,7 +441,7 @@ async function collectIssueSourceText(seriesId) {
440441
for (const iss of ordered) {
441442
const st = iss.stages || {};
442443
const pick = ['comicScript', 'teleplay', 'prose', 'idea']
443-
.map((sid) => ({ sid, content: (st[sid]?.input?.trim() || st[sid]?.output?.trim() || '') }))
444+
.map((sid) => ({ sid, content: stageContentOf(st[sid]) }))
444445
.find((x) => x.content);
445446
if (!pick) continue;
446447
parts.push(`# Issue ${iss.number}${iss.title ? ` — ${iss.title}` : ''} (${pick.sid})\n\n${pick.content}`);

0 commit comments

Comments
 (0)