推进 INI 面板 workflow overview helper

This commit is contained in:
2026-06-15 05:32:09 +08:00
parent df1f39974f
commit deb8b7cdd3
5 changed files with 247 additions and 4 deletions

View File

@@ -137,8 +137,10 @@ export function createMachineSessionStateReportExport(state = {}, options = {})
export function createMachineSessionWorkflowStatus(state = {}) {
const report = createMachineSessionStateReport(state);
const overview = createMachineSessionWorkflowOverview(report);
return {
readiness: report.readiness,
overview,
runReadiness: report.runReadiness,
lastAction: report.status.lastAction,
error: report.status.error,
@@ -147,12 +149,57 @@ export function createMachineSessionWorkflowStatus(state = {}) {
};
}
export function createMachineSessionWorkflowOverview(report = {}) {
const readiness = report.readiness ?? {};
const loaded = report.loaded ?? {};
const session = report.session ?? {};
const runReadiness = report.runReadiness ?? {};
const run = report.run ?? {};
const status = report.status ?? {};
const loadedIniWasmPath = loaded.iniWasmPath ?? runReadiness.iniWasmPath ?? null;
const missing = [];
if (!loadedIniWasmPath) {
missing.push("loaded-session");
}
if (!session.snapshotLabel) {
missing.push("session-snapshot");
}
if (!runReadiness.canRun) {
missing.push("run-readiness");
}
return {
phase: run.status ? "ran" : (missing.length === 0 ? "ready" : "waiting"),
missing,
readiness,
session: {
snapshotLabel: session.snapshotLabel ?? null,
workflow: session.workflow ?? null,
ini: session.ini ?? null,
gcode: session.gcode ?? null,
},
loaded,
runReadiness,
run: {
status: run.status ?? null,
canonicalEventCount: run.canonicalEventCount ?? 0,
motionSnapshotCount: run.motionSnapshotCount ?? 0,
iniWasmPath: run.iniWasmPath ?? null,
},
status: {
lastAction: status.lastAction ?? null,
error: status.error ?? null,
},
};
}
export function createMachineSessionStateBundle(state = {}, options = {}) {
const report = createMachineSessionStateReport(state);
const exportPayload = createMachineSessionStateReportExport(state, options);
const workflowStatus = createMachineSessionWorkflowStatus(state);
const overview = createMachineSessionWorkflowOverview(report);
return {
report,
overview,
export: exportPayload,
workflowStatus,
};
@@ -161,6 +208,7 @@ export function createMachineSessionStateBundle(state = {}, options = {}) {
export function createMachineSessionControlView(bundle = {}) {
const report = bundle.report ?? {};
const workflowStatus = bundle.workflowStatus ?? {};
const overview = bundle.overview ?? workflowStatus.overview ?? {};
const session = workflowStatus.session ?? report.session ?? {};
const runReadiness = workflowStatus.runReadiness ?? report.runReadiness ?? {};
const run = workflowStatus.run ?? report.run ?? {};
@@ -190,6 +238,16 @@ export function createMachineSessionControlView(bundle = {}) {
{ label: "G-code", value: session.gcode ?? null },
],
},
{
id: "workflow",
title: "Workflow",
rows: [
{ label: "Phase", value: overview.phase ?? null },
{ label: "Missing", value: overview.missing?.join(", ") || null },
{ label: "Last action", value: overview.status?.lastAction ?? null },
{ label: "Error", value: overview.status?.error ?? null },
],
},
{
id: "run",
title: "Run",