推进 INI 面板 readonly status API

This commit is contained in:
2026-06-15 05:40:41 +08:00
parent deb8b7cdd3
commit 3280f3a53e
11 changed files with 302 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
export function createMachineSessionReadonlyStatus({
stateBundle = null,
workflowStatus = null,
controlView = null,
} = {}) {
const overview = stateBundle?.overview ?? workflowStatus?.overview ?? null;
return {
stateBundle,
workflowStatus,
overview,
controlView,
report: stateBundle?.report ?? null,
runReadiness: workflowStatus?.runReadiness ?? stateBundle?.report?.runReadiness ?? null,
run: workflowStatus?.run ?? stateBundle?.report?.run ?? null,
session: workflowStatus?.session ?? stateBundle?.report?.session ?? null,
status: {
lastAction: workflowStatus?.lastAction ?? overview?.status?.lastAction ?? null,
error: workflowStatus?.error ?? overview?.status?.error ?? null,
runStatus: workflowStatus?.run?.status ?? stateBundle?.report?.run?.status ?? null,
},
};
}
export function readMachineSessionReadonlyStatus({ getPanelApi, getControlView } = {}) {
if (typeof getPanelApi !== "function") {
throw new Error("A panel API getter is required.");
}
if (typeof getControlView !== "function") {
throw new Error("A control view getter is required.");
}
const panelApi = getPanelApi();
if (!panelApi) {
return createMachineSessionReadonlyStatus();
}
return createMachineSessionReadonlyStatus({
stateBundle: panelApi.getMachineSessionStateBundle?.() ?? null,
workflowStatus: panelApi.getMachineSessionWorkflowStatus?.() ?? null,
controlView: getControlView(),
});
}