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
address review (codex): blank rounds fall back to default, persist-then-start, dry-run skip parity
[._.]/ Adam Eivy3b22ca7cc82d
diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxindex 0b28475dc6..576f8a746b 100644--- a/client/src/components/pipeline/AutopilotPanel.jsx+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -25,6 +25,10 @@ const ROUND_MAX = 20;const DEFAULT_ARC_ROUNDS = 3;const DEFAULT_EDITORIAL_ROUNDS = 2;const clampRound = (n, fallback) => {+ // A blank/cleared field falls back to the default — NOT 0. (Number('') === 0,+ // and 0 means "skip the gate", so without this a cleared input would silently+ // disable a verification gate.) An explicitly typed 0 is still honored.+ if (n === '' || n === null || n === undefined) return fallback;const v = Number(n);if (!Number.isFinite(v)) return fallback;return Math.max(ROUND_MIN, Math.min(ROUND_MAX, Math.round(v)));@@ -131,29 +135,43 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdateconst [fileGaps, setFileGaps] = useState(false);const [arcRounds, setArcRounds] = useState(DEFAULT_ARC_ROUNDS);const [editorialRounds, setEditorialRounds] = useState(DEFAULT_EDITORIAL_ROUNDS);+ // The round inputs only hold a *meaningful* value once settings have loaded OR+ // the user has edited them — before that they show display defaults we must NOT+ // persist or act on (doing so would clobber / ignore a higher saved setting).+ const [roundsReady, setRoundsReady] = useState(false);+ const roundsEditedRef = useRef(false);const [canon, setCanon] = useState(null);const [canonLoading, setCanonLoading] = useState(false);// Load the persisted convergence-round defaults so the Options inputs reflect- // the install's setting (the autopilot reads the same setting server-side when- // a run/resume doesn't carry a per-run override).+ // the install's setting. The autopilot reads the same setting server-side, so+ // we never send these as per-run overrides — we just keep the UI in sync and+ // persist edits back. Skip applying the load if the user already edited (a+ // fast edit must not be clobbered by a slow settings fetch).useEffect(() => {let canceled = false;getSettings({ silent: true }).then((s) => {- if (canceled) return;+ if (canceled || roundsEditedRef.current) return;const pec = s?.pipelineEditorialChecks || {};- if (Number.isInteger(pec.maxArcVerifyRounds)) setArcRounds(pec.maxArcVerifyRounds);- if (Number.isInteger(pec.maxEditorialRounds)) setEditorialRounds(pec.maxEditorialRounds);+ setArcRounds(Number.isInteger(pec.maxArcVerifyRounds) ? pec.maxArcVerifyRounds : DEFAULT_ARC_ROUNDS);+ setEditorialRounds(Number.isInteger(pec.maxEditorialRounds) ? pec.maxEditorialRounds : DEFAULT_EDITORIAL_ROUNDS);+ setRoundsReady(true);})- .catch(() => null);+ .catch(() => null); // load failed → roundsReady stays false → server uses the on-disk settingreturn () => { canceled = true; };}, []);// Persist a round setting (clamped) so a later Resume picks it up server-side.- const persistRounds = useCallback((patch) => {- patchSettingsSlice('pipelineEditorialChecks', patch, { silent: true }).catch(() => null);- }, []);+ // Returns the promise so start() can await it (close the persist→read race).+ const persistRounds = useCallback((patch) => (+ patchSettingsSlice('pipelineEditorialChecks', patch, { silent: true }).catch(() => null)+ ), []);++ // User edited an input — mark the values as real so a late settings load can't+ // overwrite them and so start() knows they're worth persisting.+ const editArcRounds = useCallback((v) => { roundsEditedRef.current = true; setRoundsReady(true); setArcRounds(v); }, []);+ const editEditorialRounds = useCallback((v) => { roundsEditedRef.current = true; setRoundsReady(true); setEditorialRounds(v); }, []);const { latest, frames } = usePipelineProgress(pipelineAutopilotSseUrl, [seriesId], { enabled: active });@@ -210,12 +228,18 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdateconst start = useCallback(async () => {setStarting(true);setPlan(null);- const res = await startPipelineAutopilot(seriesId, {- includeVisual,- fileGaps,- maxArcVerifyRounds: clampRound(arcRounds, DEFAULT_ARC_ROUNDS),- maxEditorialRounds: clampRound(editorialRounds, DEFAULT_EDITORIAL_ROUNDS),- }, { silent: true })+ // Persist the chosen rounds FIRST (only when they reflect a real value), then+ // start with no per-run round overrides — the server resolves the run from+ // the freshly-saved setting. Awaiting the persist closes the persist→read+ // race; sending the inputs as overrides instead would mask a saved default+ // whenever the settings load hadn't resolved yet.+ if (roundsReady) {+ await persistRounds({+ maxArcVerifyRounds: clampRound(arcRounds, DEFAULT_ARC_ROUNDS),+ maxEditorialRounds: clampRound(editorialRounds, DEFAULT_EDITORIAL_ROUNDS),+ });+ }+ const res = await startPipelineAutopilot(seriesId, { includeVisual, fileGaps }, { silent: true }).catch((err) => { toast.error(err.message || 'Could not start autopilot'); return null; });setStarting(false);if (!res) return;@@ -225,7 +249,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate// effect can reject a stale terminal frame from the previous run.activeRunIdRef.current = res.runId || null;setActive(true);- }, [seriesId, includeVisual, fileGaps, arcRounds, editorialRounds]);+ }, [seriesId, includeVisual, fileGaps, arcRounds, editorialRounds, roundsReady, persistRounds]);const cancel = useCallback(async () => {await cancelPipelineAutopilot(seriesId).catch(() => null);@@ -304,7 +328,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdatelabel="Arc verify rounds"settingKey="maxArcVerifyRounds"value={arcRounds}- setValue={setArcRounds}+ setValue={editArcRounds}defaultValue={DEFAULT_ARC_ROUNDS}persist={persistRounds}/>@@ -313,7 +337,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdatelabel="Editorial rounds"settingKey="maxEditorialRounds"value={editorialRounds}- setValue={setEditorialRounds}+ setValue={editEditorialRounds}defaultValue={DEFAULT_EDITORIAL_ROUNDS}persist={persistRounds}/>diff --git a/client/src/components/pipeline/AutopilotPanel.test.jsx b/client/src/components/pipeline/AutopilotPanel.test.jsxindex ddc7ad026d..89a0dd53e0 100644--- a/client/src/components/pipeline/AutopilotPanel.test.jsx+++ b/client/src/components/pipeline/AutopilotPanel.test.jsx@@ -54,10 +54,10 @@ describe('AutopilotPanel', () => {renderPanel({ id: 's1', targetFormat: 'comic' });await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());fireEvent.click(screen.getByRole('button', { name: /run autopilot/i }));+ // Rounds are NOT sent as per-run overrides — the server resolves them from+ // the persisted setting (which start() saves first when loaded).await waitFor(() => expect(startPipelineAutopilot).toHaveBeenCalledWith(- 's1',- { includeVisual: true, fileGaps: false, maxArcVerifyRounds: 3, maxEditorialRounds: 2 },- { silent: true },+ 's1', { includeVisual: true, fileGaps: false }, { silent: true },));});@@ -71,10 +71,40 @@ describe('AutopilotPanel', () => {fireEvent.click(checks[1]); // fileGaps -> truefireEvent.click(screen.getByRole('button', { name: /run autopilot/i }));await waitFor(() => expect(startPipelineAutopilot).toHaveBeenCalledWith(- 's1',- { includeVisual: false, fileGaps: true, maxArcVerifyRounds: 3, maxEditorialRounds: 2 },+ 's1', { includeVisual: false, fileGaps: true }, { silent: true },+ ));+ });++ it('persists edited rounds before starting and never sends them as overrides', async () => {+ getSettings.mockResolvedValue({ pipelineEditorialChecks: { maxArcVerifyRounds: 6, maxEditorialRounds: 4 } });+ renderPanel({ id: 's1', targetFormat: 'comic' });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ fireEvent.click(screen.getByRole('button', { name: /options/i }));+ // Wait for the persisted setting to populate the input, then edit it.+ await waitFor(() => expect(screen.getByLabelText('Arc verify rounds')).toHaveValue(6));+ fireEvent.change(screen.getByLabelText('Arc verify rounds'), { target: { value: '9' } });+ fireEvent.blur(screen.getByLabelText('Arc verify rounds'));+ fireEvent.click(screen.getByRole('button', { name: /run autopilot/i }));+ // The edited value is persisted (clamped) and the start payload omits rounds.+ await waitFor(() => expect(patchSettingsSlice).toHaveBeenCalledWith(+ 'pipelineEditorialChecks',+ expect.objectContaining({ maxArcVerifyRounds: 9 }),{ silent: true },));+ expect(startPipelineAutopilot).toHaveBeenCalledWith(+ 's1', { includeVisual: true, fileGaps: false }, { silent: true },+ );+ });++ it('clears to the default (not 0) when a round input is emptied', async () => {+ renderPanel({ id: 's1', targetFormat: 'comic' });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ fireEvent.click(screen.getByRole('button', { name: /options/i }));+ const input = screen.getByLabelText('Arc verify rounds');+ fireEvent.change(input, { target: { value: '' } });+ fireEvent.blur(input);+ // Number('') === 0 would skip the gate — clearing must fall back to the default.+ await waitFor(() => expect(input).toHaveValue(3));});it('shows a paused banner with residual findings and a Resume action', async () => {diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.jsindex c8cc97f765..d2cda7aaec 100644--- a/server/services/pipeline/seriesAutopilot.js+++ b/server/services/pipeline/seriesAutopilot.js@@ -995,8 +995,14 @@ function buildDryRunPlan(series, issues, options) {if (isComicTarget(series)) plan.push({ kind: 'scriptVerify', count: ordered.length });const edRounds = Number.isInteger(options?.maxEditorialRounds) ? options.maxEditorialRounds : MAX_EDITORIAL_ROUNDS;plan.push({ kind: 'editorialReview', count: 1, note: roundsNote(edRounds) });- plan.push({ kind: 'editorialChecks', count: 1, note: 'enabled editorial checks (#1284)' });- plan.push({ kind: 'editorialHealthGate', count: 1, note: 'editorial health readiness gate (#1316)' });+ // maxEditorialRounds === 0 skips the whole editorial gate in execute mode+ // (runEditorial marks editorialReviewed + editorialChecksReviewed ++ // editorialHealthReady), so the plan must not advertise the registry checks or+ // the health gate that won't run.+ if (edRounds !== 0) {+ plan.push({ kind: 'editorialChecks', count: 1, note: 'enabled editorial checks (#1284)' });+ plan.push({ kind: 'editorialHealthGate', count: 1, note: 'editorial health readiness gate (#1316)' });+ }if (VISUAL_DRAFT_ENABLED && wantsVisual(options) && isComicTarget(series)) {plan.push({ kind: 'canonVerify', count: 1, note: 'descriptive integrity of drawn nouns' });const visualNeeded = ordered.filter((i) => !visualReady(i)).length;diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex d1c57626e9..20effadaaf 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -211,6 +211,19 @@ describe('resolveNextStep (pure)', () => {expect(plan[0].kind).toBe('generateArc');});+ it('dry-run plan omits editorialChecks + editorialHealthGate when editorial rounds are 0', () => {+ const series = { targetFormat: 'comic', arc: { logline: 'L', summary: 'S' }, seasons: [{ id: 'se1', number: 1 }] };+ const issues = [{ id: 'i1', seasonId: 'se1', number: 1, arcPosition: 1, stages: {} }];+ const kinds = (opts) => autopilot.__testing.buildDryRunPlan(series, issues, opts).map((p) => p.kind);+ // With editorial enabled (default), both registry checks + health gate appear.+ expect(kinds({})).toEqual(expect.arrayContaining(['editorialReview', 'editorialChecks', 'editorialHealthGate']));+ // With maxEditorialRounds:0, execute mode skips all three — the plan must too.+ const skipped = kinds({ maxEditorialRounds: 0 });+ expect(skipped).toContain('editorialReview'); // shown as "skipped (0 rounds)"+ expect(skipped).not.toContain('editorialChecks');+ expect(skipped).not.toContain('editorialHealthGate');+ });+it('asks to generate episodes for a season with no issues', () => {const step = resolveNextStep(comic, []);expect(step).toMatchObject({ kind: 'generateEpisodes', seasonId: 'se1' });