推进 INI 面板 control view helper

This commit is contained in:
2026-06-14 22:40:47 +08:00
parent e6f55d775f
commit 4133d202f0
6 changed files with 237 additions and 2 deletions

View File

@@ -369,6 +369,7 @@ TOOL_TABLE = browser-tool.tbl
);
const uiApi = uiDocument.defaultView.linuxCncIniPanelApi;
if (
!uiApi?.getMachineSessionControlView ||
!uiApi?.getMachineSessionStateBundle ||
!uiApi?.getMachineSessionStateReport ||
!uiApi?.getMachineSessionStateReportExport ||
@@ -830,6 +831,32 @@ TOOL_TABLE = browser-tool.tbl
machineSessionStateBundle.workflowStatus.lastAction,
"UI legacy machine session state bundle getter matches API namespace",
);
const machineSessionControlView = uiApi.getMachineSessionControlView();
assertEqual(
machineSessionControlView.status.runStatus,
"ok",
"UI machine session control view run status",
);
assertEqual(
machineSessionControlView.sections[0].id,
"readiness",
"UI machine session control view readiness section",
);
assertEqual(
machineSessionControlView.sections[1].rows[1].value,
"save-session-snapshot",
"UI machine session control view session workflow row",
);
assertEqual(
machineSessionControlView.sections[2].rows[1].value,
2,
"UI machine session control view canonical event row",
);
assertEqual(
uiDocument.defaultView.getMachineSessionControlView().status.lastAction,
machineSessionControlView.status.lastAction,
"UI legacy machine session control view getter matches API namespace",
);
assertEqual(
uiDocument.defaultView.getMachineSessionStateReport().status.lastAction,
machineSessionStateReport.status.lastAction,

View File

@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
import {
createIniPanelStateSummary,
createMachineSessionControlView,
createMachineSessionStateSnapshot,
createMachineSessionStateBundle,
createMachineSessionStateReport,
@@ -473,17 +474,92 @@ assert.deepEqual(
);
assert.deepEqual(
createMachineSessionControlView({
report: expectedBundleReport,
export: {
filename: "machine-session-state-report.json",
mediaType: "application/json",
report: expectedBundleReport,
text: `${JSON.stringify(expectedBundleReport, null, 2)}\n`,
},
workflowStatus: {
readiness: {
ini: "INI WASM: ready",
interp: "Interpreter WASM: ready",
opfs: "OPFS: ready",
},
lastAction: "run-gcode",
error: null,
session: {
snapshotLabel: "ui-machine-session/ui-machine-session.json",
workflow: "save-session-snapshot",
ini: "/work/session-machine.ini",
parameters: null,
toolTable: null,
gcode: "linuxcnc/gcode/ui-session.ngc",
},
run: {
status: "ok",
canonicalEventCount: 2,
motionSnapshotCount: 2,
iniWasmPath: null,
},
},
}),
{
status: {
lastAction: "run-gcode",
error: null,
runStatus: "ok",
},
sections: [
{
id: "readiness",
title: "Readiness",
rows: [
{ label: "INI", value: "INI WASM: ready" },
{ label: "Interpreter", value: "Interpreter WASM: ready" },
{ label: "OPFS", value: "OPFS: ready" },
],
},
{
id: "session",
title: "Session",
rows: [
{ label: "Snapshot", value: "ui-machine-session/ui-machine-session.json" },
{ label: "Workflow", value: "save-session-snapshot" },
{ label: "INI", value: "/work/session-machine.ini" },
{ label: "G-code", value: "linuxcnc/gcode/ui-session.ngc" },
],
},
{
id: "run",
title: "Run",
rows: [
{ label: "Status", value: "ok" },
{ label: "Canonical events", value: 2 },
{ label: "Motion snapshots", value: 2 },
{ label: "INI WASM", value: null },
],
},
],
},
);
assert.deepEqual(
{
getMachineSessionControlView: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionControlView,
getMachineSessionStateBundle: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionStateBundle,
getMachineSessionStateReport: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionStateReport,
getMachineSessionStateReportExport: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionStateReportExport,
getMachineSessionWorkflowStatus: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionWorkflowStatus,
getMachineSessionStateBundle: typeof globalThis.window?.linuxCncIniPanelApi?.getMachineSessionStateBundle,
},
{
getMachineSessionControlView: "undefined",
getMachineSessionStateBundle: "undefined",
getMachineSessionStateReport: "undefined",
getMachineSessionStateReportExport: "undefined",
getMachineSessionWorkflowStatus: "undefined",
getMachineSessionStateBundle: "undefined",
},
);