Tighten GUI input and status layout
This commit is contained in:
parent
74da1dfa6a
commit
c5b5a70ad5
4 changed files with 51 additions and 96 deletions
|
|
@ -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<T extends HTMLElement>(id: string): T {
|
|||
const fileInput = byId<HTMLInputElement>("fileInput");
|
||||
const dropzone = byId<HTMLButtonElement>("dropzone");
|
||||
const dropzoneLabel = byId<HTMLSpanElement>("dropzoneLabel");
|
||||
const inputPreviewCanvas = byId<HTMLCanvasElement>("inputPreviewCanvas");
|
||||
const pickFileButton = byId<HTMLButtonElement>("pickFileButton");
|
||||
const runButton = byId<HTMLButtonElement>("runButton");
|
||||
const statusPanel = byId<HTMLDivElement>("statusPanel");
|
||||
|
|
@ -113,6 +111,7 @@ const statusMetrics = byId<HTMLDivElement>("statusMetrics");
|
|||
const inferenceSummary = byId<HTMLDivElement>("inferenceSummary");
|
||||
const candidateList = byId<HTMLDivElement>("candidateList");
|
||||
const eventLog = byId<HTMLDivElement>("eventLog");
|
||||
const scrubberPanel = byId<HTMLDivElement>("scrubberPanel");
|
||||
const stepSlider = byId<HTMLInputElement>("stepSlider");
|
||||
const stepValue = byId<HTMLSpanElement>("stepValue");
|
||||
const lossCanvas = byId<HTMLCanvasElement>("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<ImageAsset> {
|
|||
};
|
||||
}
|
||||
|
||||
async function renderInputPreview(): Promise<void> {
|
||||
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<void> {
|
|||
}
|
||||
|
||||
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<void> {
|
|||
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<void> {
|
|||
|
||||
async function acceptFile(file: File): Promise<void> {
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<h2 id="viewerTitle">Pipeline Stages</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div id="metricsPanel" class="metrics-panel stats-grid">
|
||||
<div id="metricsPanel" class="metrics-panel">
|
||||
<div id="statusPanel" class="metric-chip metric-status-block" data-job-state="idle">
|
||||
<div class="status-heading">
|
||||
<span id="statusBadge" class="status-badge">Idle</span>
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
</div>
|
||||
<div id="statusMetrics" class="status-metrics"></div>
|
||||
</div>
|
||||
<div class="metric-chip scrubber metric-scrubber">
|
||||
<div id="scrubberPanel" class="metric-chip scrubber metric-scrubber" hidden>
|
||||
<label for="stepSlider">Solver Step</label>
|
||||
<input id="stepSlider" type="range" min="0" max="0" step="1" value="0" disabled />
|
||||
<span id="stepValue" class="step-value">No frames yet</span>
|
||||
|
|
@ -143,10 +143,6 @@
|
|||
<strong>Drop image</strong>
|
||||
<span id="dropzoneLabel">PNG, sprite scrap, cursed logo. Whatever started this.</span>
|
||||
</button>
|
||||
<figure class="input-preview-card">
|
||||
<div class="viz-label">Selected Input</div>
|
||||
<canvas id="inputPreviewCanvas"></canvas>
|
||||
</figure>
|
||||
</section>
|
||||
|
||||
<section class="card section-block">
|
||||
|
|
|
|||
|
|
@ -599,12 +599,14 @@ p {
|
|||
}
|
||||
|
||||
.metrics-status-text {
|
||||
max-width: 32ch;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.status-heading {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 8px 16px;
|
||||
}
|
||||
|
||||
.status-stage {
|
||||
|
|
@ -641,7 +643,6 @@ p {
|
|||
gap: 10px;
|
||||
}
|
||||
|
||||
.input-preview-card,
|
||||
.viz-card {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
|
|
@ -658,7 +659,6 @@ p {
|
|||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.input-preview-card canvas,
|
||||
.viz-card canvas {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
|
@ -672,11 +672,6 @@ p {
|
|||
0 0 14px rgba(255, 216, 74, 0.06);
|
||||
}
|
||||
|
||||
.input-preview-card canvas {
|
||||
max-height: 280px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.metrics-panel {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
|
|
@ -684,13 +679,13 @@ p {
|
|||
|
||||
.metric-status-block {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
gap: 14px;
|
||||
align-content: start;
|
||||
align-self: stretch;
|
||||
justify-self: start;
|
||||
padding: 14px 16px;
|
||||
justify-self: stretch;
|
||||
padding: 16px 18px;
|
||||
width: 100%;
|
||||
max-width: min(100%, 34ch);
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.metric-scrubber {
|
||||
|
|
@ -698,8 +693,8 @@ p {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: fit-content(34ch) minmax(0, 1fr);
|
||||
.metric-scrubber[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.status-activity {
|
||||
|
|
@ -744,8 +739,8 @@ p {
|
|||
|
||||
.status-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.status-metric {
|
||||
|
|
|
|||
Loading…
Reference in a new issue