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): refine legacy-shaped page renders + keep Refine box visible mid-refine
[._.]/ Adam Eivy87aba8daccb9
diff --git a/client/src/components/pipeline/stages/ComicScriptStage.jsx b/client/src/components/pipeline/stages/ComicScriptStage.jsxindex b2e36c9134..8838e9dfce 100644--- a/client/src/components/pipeline/stages/ComicScriptStage.jsx+++ b/client/src/components/pipeline/stages/ComicScriptStage.jsx@@ -900,10 +900,13 @@ function PageRow({// A selected reference render uses the adjacent page (not this page's proof)// as its base, so it doesn't need a proof to exist — only proof-as-base does.const finalNeedsProof = useProofForFinal && !refPage && !proofSlot?.filename;- // The Refine control only makes sense once the page has a rendered image to- // correct (final preferred, else proof). Block it while a render is in flight- // so we don't i2i off a slot that's mid-write.- const hasRender = !!(finalSlot?.filename || proofSlot?.filename);+ // The Refine control only makes sense once the page has a render to correct+ // (final preferred, else proof). Gate on jobId OR filename — not filename+ // alone: refining a proof-only page replaces its slot with an in-flight+ // record whose filename is briefly null, and gating on filename alone would+ // make the Refine box vanish mid-refine and not return until reload. The+ // button's own in-flight gate (below) still blocks i2i off a mid-write slot.+ const hasRender = !!(finalSlot?.jobId || finalSlot?.filename || proofSlot?.jobId || proofSlot?.filename);const refineDisabled = refining || proofInFlight || finalInFlight || !refineText.trim();return (diff --git a/server/services/pipeline/visualStages.js b/server/services/pipeline/visualStages.jsindex 29f76ce67b..3a8b671dde 100644--- a/server/services/pipeline/visualStages.js+++ b/server/services/pipeline/visualStages.js@@ -973,13 +973,26 @@ export async function refineComicPageRender(issueId, options = {}) {});}+ // Mirror the client's getProofSlot: a legacy page (pre proof/final split)+ // stores its render at the record root (imageJobId/filename/prompt), and the+ // UI surfaces that as the proof slot — so it shows the Refine control. Resolve+ // the same legacy shape here, otherwise refining a page whose only render is+ // legacy would 400 with NO_RENDER even though the UI shows it as rendered. The+ // refined render lands on the proofImage slot, upgrading the record into the+ // new shape (same as a /render of a legacy page).+ const legacyProofSlot = (!page.proofImage?.filename && (page.imageJobId || page.filename))+ ? { filename: page.filename || null, prompt: page.prompt || null }+ : null;+// Resolve which rendered variant to refine: an explicit target wins; else// prefer the final render, falling back to the proof. The refined render// lands back on that SAME slot (the user is correcting that image).const variant = options.target? resolveVariant(options.target): (page.finalImage?.filename ? 'final' : 'proof');- const baseSlot = variant === 'final' ? page.finalImage : page.proofImage;+ const baseSlot = variant === 'final'+ ? page.finalImage+ : (page.proofImage?.filename ? page.proofImage : legacyProofSlot);const baseFilename = baseSlot?.filename;if (!baseFilename) {throw new ServerError(diff --git a/server/services/pipeline/visualStages.test.js b/server/services/pipeline/visualStages.test.jsindex f1e8ddaaf4..c7b1c48fc6 100644--- a/server/services/pipeline/visualStages.test.js+++ b/server/services/pipeline/visualStages.test.js@@ -703,6 +703,27 @@ describe('refineComicPageRender', () => {}));});+ it('refines a legacy-shaped page (root filename/prompt) by reading the legacy slot as the base', async () => {+ // Pre proof/final-split record: render lives at the page root, not in a+ // proofImage slot. The client surfaces this as the proof slot and shows+ // Refine, so the service must resolve it too (else NO_RENDER 400).+ getIssueMock.mockResolvedValueOnce(issueWithRenderedPage({+ imageJobId: 'legacy-job', filename: 'page0-legacy.png', prompt: 'legacy page prompt',+ }));++ const result = await refineComicPageRender('iss-test', { pageIndex: 0, instruction: 'tweak the sky' });++ expect(result.variant).toBe('proof');+ expect(runStagedLLMMock).toHaveBeenCalledWith(+ 'pipeline-comic-page-refine-render',+ expect.objectContaining({ currentPrompt: 'legacy page prompt' }),+ expect.anything(),+ );+ expect(enqueueJobMock).toHaveBeenCalledWith(expect.objectContaining({+ params: expect.objectContaining({ initImagePath: expect.stringContaining('page0-legacy.png') }),+ }));+ });+it('auto-prefers the final render as the refine base when both slots exist', async () => {getIssueMock.mockResolvedValueOnce(issueWithRenderedPage({proofImage: { jobId: 'j1', filename: 'page0-proof.png', prompt: 'proof prompt' },