From c5b5a70ad5f311079c3544581bab5ff94c92a6b7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 24 Apr 2026 18:35:18 +0100 Subject: [PATCH] Tighten GUI input and status layout --- frontend/src/app.ts | 55 +++++++++------------------ src/repixelizer/gui_static/app.js | 53 +++++++++----------------- src/repixelizer/gui_static/index.html | 8 +--- src/repixelizer/gui_static/styles.css | 31 +++++++-------- 4 files changed, 51 insertions(+), 96 deletions(-) diff --git a/frontend/src/app.ts b/frontend/src/app.ts index c8b1584..6cd8489 100644 --- a/frontend/src/app.ts +++ b/frontend/src/app.ts @@ -61,7 +61,6 @@ type AppState = { stageKey: string; stageLabel: string; statusText: string; - inputPreviewImage: ImageAsset | null; sourceImage: ImageAsset | null; preprocessedImage: ImageAsset | null; latticeImage: ImageAsset | null; @@ -102,7 +101,6 @@ function byId(id: string): T { const fileInput = byId("fileInput"); const dropzone = byId("dropzone"); const dropzoneLabel = byId("dropzoneLabel"); -const inputPreviewCanvas = byId("inputPreviewCanvas"); const pickFileButton = byId("pickFileButton"); const runButton = byId("runButton"); const statusPanel = byId("statusPanel"); @@ -113,6 +111,7 @@ const statusMetrics = byId("statusMetrics"); const inferenceSummary = byId("inferenceSummary"); const candidateList = byId("candidateList"); const eventLog = byId("eventLog"); +const scrubberPanel = byId("scrubberPanel"); const stepSlider = byId("stepSlider"); const stepValue = byId("stepValue"); const lossCanvas = byId("lossCanvas"); @@ -177,7 +176,6 @@ const state: AppState = { stageKey: "idle", stageLabel: "Waiting for input", statusText: "Choose a file, then run the machine.", - inputPreviewImage: null, sourceImage: null, preprocessedImage: null, latticeImage: null, @@ -276,9 +274,12 @@ function setStage(stageKey: string, label: string, detail: string): void { statusText.textContent = detail; } -function resetRunArtifacts(): void { +function resetRunArtifacts(options: { preserveSourceImage?: boolean } = {}): void { + const preserveSourceImage = options.preserveSourceImage ?? false; state.jobId = null; - state.sourceImage = null; + if (!preserveSourceImage) { + state.sourceImage = null; + } state.preprocessedImage = null; state.latticeImage = null; state.guidanceImage = null; @@ -374,31 +375,6 @@ async function fileToImageAsset(file: File): Promise { }; } -async function renderInputPreview(): Promise { - const context = inputPreviewCanvas.getContext("2d"); - if (!context) { - return; - } - const asset = state.inputPreviewImage; - if (!asset) { - inputPreviewCanvas.width = 320; - inputPreviewCanvas.height = 180; - context.clearRect(0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); - context.fillStyle = "#081012"; - context.fillRect(0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); - context.fillStyle = "rgba(255,255,255,0.2)"; - context.font = "16px sans-serif"; - context.fillText("No input loaded yet", 20, 32); - return; - } - const image = await loadImage(asset); - inputPreviewCanvas.width = image.naturalWidth || asset.width; - inputPreviewCanvas.height = image.naturalHeight || asset.height; - context.imageSmoothingEnabled = false; - context.clearRect(0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); - context.drawImage(image, 0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); -} - function readNestedNumber(root: JsonRecord | null, path: string[]): number | null { let current: unknown = root; for (const key of path) { @@ -552,6 +528,7 @@ async function renderViewer(): Promise { } function renderSlider(): void { + scrubberPanel.hidden = state.frames.length === 0; if (state.frames.length === 0) { stepSlider.disabled = true; stepSlider.max = "0"; @@ -1038,7 +1015,7 @@ async function startRun(): Promise { setStage("idle", "Waiting for input", "Pick a file first. The machine is not clairvoyant."); return; } - resetRunArtifacts(); + resetRunArtifacts({ preserveSourceImage: true }); renderEventLog(); runButton.disabled = true; setJobState("queued"); @@ -1066,24 +1043,29 @@ async function startRun(): Promise { async function acceptFile(file: File): Promise { state.file = file; + resetRunArtifacts(); dropzoneLabel.textContent = file.name; - setJobState("idle"); - setStage("ready", "Ready to run", `${file.name} is loaded. Hit run when you want the machine to start sweating.`); + setJobState("waiting"); + setStage("loading_input", "Loading input", `Reading ${file.name} so the panels stop sitting around empty.`); + renderEventLog(); + await renderEverything(); try { const previewImage = await fileToImageAsset(file); if (state.file !== file) { return; } - state.inputPreviewImage = previewImage; + state.sourceImage = previewImage; + setJobState("idle"); + setStage("ready", "Ready to run", `${file.name} is loaded. Hit run when you want the machine to start sweating.`); } catch (error) { if (state.file !== file) { return; } - state.inputPreviewImage = null; + state.sourceImage = null; setJobState("failed"); setStage("failed", "Preview failed", error instanceof Error ? error.message : "Failed to load image preview."); } - await renderInputPreview(); + await renderEverything(); } dropzone.addEventListener("click", () => fileInput.click()); @@ -1264,5 +1246,4 @@ setPaintColor(state.paintColor); syncEditorCursorState(); zoomValue.textContent = `${state.zoom}x`; renderEventLog(); -void renderInputPreview(); void renderEverything(); diff --git a/src/repixelizer/gui_static/app.js b/src/repixelizer/gui_static/app.js index c42498e..d6e4e9e 100644 --- a/src/repixelizer/gui_static/app.js +++ b/src/repixelizer/gui_static/app.js @@ -9,7 +9,6 @@ function byId(id) { const fileInput = byId("fileInput"); const dropzone = byId("dropzone"); const dropzoneLabel = byId("dropzoneLabel"); -const inputPreviewCanvas = byId("inputPreviewCanvas"); const pickFileButton = byId("pickFileButton"); const runButton = byId("runButton"); const statusPanel = byId("statusPanel"); @@ -20,6 +19,7 @@ const statusMetrics = byId("statusMetrics"); const inferenceSummary = byId("inferenceSummary"); const candidateList = byId("candidateList"); const eventLog = byId("eventLog"); +const scrubberPanel = byId("scrubberPanel"); const stepSlider = byId("stepSlider"); const stepValue = byId("stepValue"); const lossCanvas = byId("lossCanvas"); @@ -80,7 +80,6 @@ const state = { stageKey: "idle", stageLabel: "Waiting for input", statusText: "Choose a file, then run the machine.", - inputPreviewImage: null, sourceImage: null, preprocessedImage: null, latticeImage: null, @@ -168,9 +167,12 @@ function setStage(stageKey, label, detail) { statusStage.textContent = label; statusText.textContent = detail; } -function resetRunArtifacts() { +function resetRunArtifacts(options = {}) { + const preserveSourceImage = options.preserveSourceImage ?? false; state.jobId = null; - state.sourceImage = null; + if (!preserveSourceImage) { + state.sourceImage = null; + } state.preprocessedImage = null; state.latticeImage = null; state.guidanceImage = null; @@ -260,30 +262,6 @@ async function fileToImageAsset(file) { height: image.naturalHeight || 1, }; } -async function renderInputPreview() { - const context = inputPreviewCanvas.getContext("2d"); - if (!context) { - return; - } - const asset = state.inputPreviewImage; - if (!asset) { - inputPreviewCanvas.width = 320; - inputPreviewCanvas.height = 180; - context.clearRect(0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); - context.fillStyle = "#081012"; - context.fillRect(0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); - context.fillStyle = "rgba(255,255,255,0.2)"; - context.font = "16px sans-serif"; - context.fillText("No input loaded yet", 20, 32); - return; - } - const image = await loadImage(asset); - inputPreviewCanvas.width = image.naturalWidth || asset.width; - inputPreviewCanvas.height = image.naturalHeight || asset.height; - context.imageSmoothingEnabled = false; - context.clearRect(0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); - context.drawImage(image, 0, 0, inputPreviewCanvas.width, inputPreviewCanvas.height); -} function readNestedNumber(root, path) { let current = root; for (const key of path) { @@ -431,6 +409,7 @@ async function renderViewer() { await Promise.all([drawAsset(leftCanvas, leftAsset), drawAsset(rightCanvas, rightAsset)]); } function renderSlider() { + scrubberPanel.hidden = state.frames.length === 0; if (state.frames.length === 0) { stepSlider.disabled = true; stepSlider.max = "0"; @@ -873,7 +852,7 @@ async function startRun() { setStage("idle", "Waiting for input", "Pick a file first. The machine is not clairvoyant."); return; } - resetRunArtifacts(); + resetRunArtifacts({ preserveSourceImage: true }); renderEventLog(); runButton.disabled = true; setJobState("queued"); @@ -901,25 +880,30 @@ async function startRun() { } async function acceptFile(file) { state.file = file; + resetRunArtifacts(); dropzoneLabel.textContent = file.name; - setJobState("idle"); - setStage("ready", "Ready to run", `${file.name} is loaded. Hit run when you want the machine to start sweating.`); + setJobState("waiting"); + setStage("loading_input", "Loading input", `Reading ${file.name} so the panels stop sitting around empty.`); + renderEventLog(); + await renderEverything(); try { const previewImage = await fileToImageAsset(file); if (state.file !== file) { return; } - state.inputPreviewImage = previewImage; + state.sourceImage = previewImage; + setJobState("idle"); + setStage("ready", "Ready to run", `${file.name} is loaded. Hit run when you want the machine to start sweating.`); } catch (error) { if (state.file !== file) { return; } - state.inputPreviewImage = null; + state.sourceImage = null; setJobState("failed"); setStage("failed", "Preview failed", error instanceof Error ? error.message : "Failed to load image preview."); } - await renderInputPreview(); + await renderEverything(); } dropzone.addEventListener("click", () => fileInput.click()); pickFileButton.addEventListener("click", () => fileInput.click()); @@ -1072,5 +1056,4 @@ setPaintColor(state.paintColor); syncEditorCursorState(); zoomValue.textContent = `${state.zoom}x`; renderEventLog(); -void renderInputPreview(); void renderEverything(); diff --git a/src/repixelizer/gui_static/index.html b/src/repixelizer/gui_static/index.html index db5a6cb..acaeed0 100644 --- a/src/repixelizer/gui_static/index.html +++ b/src/repixelizer/gui_static/index.html @@ -37,7 +37,7 @@

Pipeline Stages

-
+
Idle @@ -49,7 +49,7 @@
-
+