推进 INI 面板 shell handoff control-page mount workflow helper

This commit is contained in:
2026-06-15 12:23:51 +08:00
parent 298aa5e403
commit c3d9b90de1
9 changed files with 234 additions and 9 deletions

View File

@@ -33,6 +33,7 @@ import {
createIniPanelShellSessionHandoffMountDomContract,
createIniPanelShellSessionHandoffMountDomReadiness,
mountIniPanelShellSessionHandoff,
mountIniPanelShellSessionHandoffFromControlPage,
renderIniPanelShellSessionHandoffMountState,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
@@ -240,6 +241,11 @@ that the required document and nodes exist before calling the renderer. Use
`linuxCncIniPanelLaunchApi.mountShellSessionHandoff()` when an outer shell
needs one browser-side workflow result containing the contract, DOM readiness,
mount render-state, renderer result, and any mount error as data. Use
`mountIniPanelShellSessionHandoffFromControlPage()` or
`linuxCncIniPanelLaunchApi.mountShellSessionHandoffFromControlPage()` when an
outer shell has a control-page API or already-observed session-load state and
needs one read-only result containing the derived mount-state, mount display
view-model, mount render-state, and DOM mount workflow result. Use
`renderIniPanelShellSessionHandoffMountState()` or
`linuxCncIniPanelLaunchApi.renderShellSessionHandoffMountState()` when an outer
shell needs the shared read-only DOM renderer for those rows. The launch page
@@ -251,7 +257,7 @@ The browser workflow smoke
same external shell handoff: read integration manifest, pass readiness gate,
open the control page target, mount waiting and ready mount-state into an
external shell-owned `[data-external-shell-mount]` DOM region through the shared
mount workflow, then read readonly machine-session status.
mount workflows, then read readonly machine-session status.
The control-page refresh workflow lives in
`runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use

View File

@@ -109,6 +109,7 @@
createIniPanelShellSessionHandoffMountDomContract,
createIniPanelShellSessionHandoffMountDomReadiness,
mountIniPanelShellSessionHandoff,
mountIniPanelShellSessionHandoffFromControlPage,
renderIniPanelShellSessionHandoffMountState,
} from "./ui-shell.js";
@@ -198,6 +199,14 @@
documentRef: document,
})
),
mountShellSessionHandoffFromControlPage: (options) => (
mountIniPanelShellSessionHandoffFromControlPage({
handoffPackage: shellViewModel.shellSessionHandoffPackage,
packageRenderState: shellViewModel.shellSessionHandoffPackageRenderState,
documentRef: document,
...(options ?? {}),
})
),
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
getLauncherLinks: () => shellViewModel.launcherLinks,
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,

View File

@@ -147,6 +147,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
"getShellSessionHandoffMountDomReadiness",
"renderShellSessionHandoffMountState",
"mountShellSessionHandoff",
"mountShellSessionHandoffFromControlPage",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -1263,6 +1264,70 @@ export function mountIniPanelShellSessionHandoff({
}
}
export function mountIniPanelShellSessionHandoffFromControlPage({
controlPageApi = null,
sessionLoadState = null,
loadSessionStateMethod = "loadControlPageSessionState",
handoffPackage = createIniPanelShellSessionHandoffPackage(),
packageRenderState = createIniPanelShellSessionHandoffPackageRenderState(),
rowDatasetPrefix = "handoffMount",
contract = createIniPanelShellSessionHandoffMountDomContract({ rowDatasetPrefix }),
documentRef = globalThis.document,
mountNode = documentRef?.querySelector?.(contract.selectors.mount),
statusNode = documentRef?.querySelector?.(contract.selectors.status),
rowsNode = documentRef?.querySelector?.(contract.selectors.rows),
} = {}) {
let observedSessionLoadState = sessionLoadState;
let sessionLoadError = null;
if (!observedSessionLoadState) {
const loadSessionState = controlPageApi?.[loadSessionStateMethod];
if (typeof loadSessionState === "function") {
try {
observedSessionLoadState = loadSessionState.call(controlPageApi);
} catch (error) {
sessionLoadError = error?.message ?? String(error);
observedSessionLoadState = createControlPageSessionLoadState({
phase: "error",
error: sessionLoadError,
});
}
} else {
observedSessionLoadState = createControlPageSessionLoadState({ phase: "waiting-api" });
}
}
const mountState = createIniPanelShellSessionHandoffPackageMountState({
handoffPackage,
packageRenderState,
sessionLoadState: observedSessionLoadState,
});
const mountDisplayViewModel = createIniPanelShellSessionHandoffPackageMountDisplayViewModel(mountState);
const mountRenderState = createIniPanelShellSessionHandoffPackageMountRenderState(mountDisplayViewModel);
const mountWorkflow = mountIniPanelShellSessionHandoff({
renderState: mountRenderState,
contract,
documentRef,
mountNode,
statusNode,
rowsNode,
});
return {
apiName: "ini-panel-shell-session-handoff-control-page-mount-workflow",
workflowVersion: 1,
phase: mountWorkflow.phase,
ready: mountWorkflow.ready,
statusLine: mountWorkflow.statusLine,
loadSessionStateMethod,
sessionLoadState: observedSessionLoadState,
sessionLoadError,
mountState,
mountDisplayViewModel,
mountRenderState,
mountWorkflow,
};
}
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
@@ -1381,6 +1446,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
createShellSessionHandoffMountDomReadiness: createIniPanelShellSessionHandoffMountDomReadiness,
renderShellSessionHandoffMountState: renderIniPanelShellSessionHandoffMountState,
mountShellSessionHandoff: mountIniPanelShellSessionHandoff,
mountShellSessionHandoffFromControlPage: mountIniPanelShellSessionHandoffFromControlPage,
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
controlPage: {
browserApiSchema: createControlPageBrowserApiSchema(),

View File

@@ -89,6 +89,7 @@ TOOL_TABLE = browser-shell-tool.tbl
!launchApi?.getShellSessionHandoffMountDomReadiness ||
!launchApi?.renderShellSessionHandoffMountState ||
!launchApi?.mountShellSessionHandoff ||
!launchApi?.mountShellSessionHandoffFromControlPage ||
!launchApi?.isSupportedShellSessionHandoffPackage
) {
throw new Error("launch API namespace did not expose shell integration helpers");
@@ -287,21 +288,24 @@ TOOL_TABLE = browser-shell-tool.tbl
"ready",
"shell integration control-page session readiness",
);
const readyMountState = launchApi.getShellSessionHandoffPackageMountState(
controlPageApi[handoffSummary.handoffMethods.loadSessionState](),
);
const readySessionLoadState = controlPageApi[handoffSummary.handoffMethods.loadSessionState]();
const readyMountState = launchApi.getShellSessionHandoffPackageMountState(readySessionLoadState);
const readyMountDisplay = launchApi.getShellSessionHandoffPackageMountDisplayViewModel(readyMountState);
const readyMountRenderState = launchApi.getShellSessionHandoffPackageMountRenderState(readyMountState);
const readyMountWorkflow = launchApi.mountShellSessionHandoff({
renderState: readyMountRenderState,
const readyControlPageMountWorkflow = launchApi.mountShellSessionHandoffFromControlPage({
sessionLoadState: readySessionLoadState,
contract: externalMountDomContract,
documentRef: document,
});
const readyMountWorkflow = readyControlPageMountWorkflow.mountWorkflow;
const readyMountRenderResult = readyMountWorkflow.renderResult;
assertEqual(readyMountState.ready, true, "shell handoff package mount-state readiness");
assertEqual(readyMountState.sessionLoadState.phase, "ready", "shell handoff package mount-state ready session");
assertEqual(readyMountDisplay.detailText, "No blocking reasons", "shell handoff package ready mount display");
assertEqual(readyMountRenderState.statusLine, "Ready: No blocking reasons", "shell handoff package ready mount render-state");
assertEqual(readyControlPageMountWorkflow.phase, "ready", "external shell control-page mount workflow phase");
assertEqual(readyControlPageMountWorkflow.sessionLoadState.phase, "ready", "external shell control-page mount workflow session");
assertEqual(readyControlPageMountWorkflow.mountState.ready, true, "external shell control-page mount workflow state");
assertEqual(readyMountRenderResult.rendered, true, "external shell ready mount render result");
assertEqual(readyMountWorkflow.phase, "ready", "external shell ready mount workflow phase");
assertEqual(readyMountRenderResult.dataset.handoffReady, "true", "external shell ready mount render dataset");

View File

@@ -30,6 +30,7 @@ import {
createIniPanelShellSessionHandoffMountDomContract,
createIniPanelShellSessionHandoffMountDomReadiness,
mountIniPanelShellSessionHandoff,
mountIniPanelShellSessionHandoffFromControlPage,
renderIniPanelShellSessionHandoffMountState,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
@@ -99,6 +100,7 @@ const requiredShellExports = [
"createIniPanelShellSessionHandoffMountDomContract",
"createIniPanelShellSessionHandoffMountDomReadiness",
"mountIniPanelShellSessionHandoff",
"mountIniPanelShellSessionHandoffFromControlPage",
"renderIniPanelShellSessionHandoffMountState",
"createIniPanelShellSessionHandoffPackageReport",
"createIniPanelShellSessionHandoffPackageRenderState",
@@ -297,6 +299,10 @@ assert.equal(
mountIniPanelShellSessionHandoff({ documentRef: null }).phase,
"blocked",
);
assert.equal(
mountIniPanelShellSessionHandoffFromControlPage({ documentRef: null }).mountWorkflow.phase,
"blocked",
);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(createIniPanelShellViewModel().shellSessionHandoffPackage), true);
assert.equal(isSupportedIniPanelShellIntegrationManifest(createIniPanelShellViewModel().shellIntegrationManifest), true);
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());
@@ -457,6 +463,7 @@ assert.match(docText, /\blinuxCncIniPanelLaunchApi\.renderShellSessionHandoffMou
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getShellSessionHandoffMountDomContract\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getShellSessionHandoffMountDomReadiness\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.mountShellSessionHandoff\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.mountShellSessionHandoffFromControlPage\b/);
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
assert.match(docText, /\bini_panel_shell_integration_workflow_smoke\.html\b/);
assert.match(browserIniPanelText, /\bini_panel_shell_integration_workflow_smoke\.html\b/);
@@ -476,6 +483,7 @@ assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffPackage
assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffMountDomContract\b/);
assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffMountDomReadiness\b/);
assert.match(shellIntegrationWorkflowSmokeText, /\bmountShellSessionHandoff\b/);
assert.match(shellIntegrationWorkflowSmokeText, /\bmountShellSessionHandoffFromControlPage\b/);
assert.match(shellIntegrationWorkflowSmokeText, /\brenderShellSessionHandoffMountState\b/);
assert.match(shellIntegrationWorkflowSmokeText, /\bdata-external-shell-mount\b/);
assert.match(shellIntegrationWorkflowSmokeText, /\bdata-external-mount-value\b/);

View File

@@ -67,6 +67,7 @@ assert.deepEqual(manifest, {
"getShellSessionHandoffMountDomReadiness",
"renderShellSessionHandoffMountState",
"mountShellSessionHandoff",
"mountShellSessionHandoffFromControlPage",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -189,6 +190,7 @@ assert.match(launchText, /\bgetShellSessionHandoffMountDomContract\b/);
assert.match(launchText, /\bgetShellSessionHandoffMountDomReadiness\b/);
assert.match(launchText, /\brenderShellSessionHandoffMountState\b/);
assert.match(launchText, /\bmountShellSessionHandoff\b/);
assert.match(launchText, /\bmountShellSessionHandoffFromControlPage\b/);
assert.match(launchText, /\bisSupportedShellSessionHandoffPackage\b/);
assert.match(launchText, /\bdata-handoff-mount\b/);
assert.match(launchText, /\bdata-handoff-mount-status\b/);

View File

@@ -26,6 +26,7 @@ import {
createIniPanelShellSessionHandoffMountDomContract,
createIniPanelShellSessionHandoffMountDomReadiness,
mountIniPanelShellSessionHandoff,
mountIniPanelShellSessionHandoffFromControlPage,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageSchema,
@@ -152,7 +153,7 @@ assert.deepEqual(readiness, {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 30,
launchMethods: 31,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -214,7 +215,7 @@ assert.deepEqual(handoffSummary, {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 30,
launchMethods: 31,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -706,6 +707,10 @@ assert.equal(
mountIniPanelShellSessionHandoff({ documentRef: null }).statusLine,
"Blocked: document, mount, status, rows",
);
assert.equal(
mountIniPanelShellSessionHandoffFromControlPage({ documentRef: null }).sessionLoadState.phase,
"waiting-api",
);
assert.deepEqual(
createIniPanelShellSessionHandoffPackageMountState({
handoffPackage,
@@ -1117,7 +1122,7 @@ assert.deepEqual(createIniPanelShellIntegrationReadiness(blockedManifest), {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 30,
launchMethods: 31,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -1289,6 +1294,7 @@ assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPack
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffMountDomContract\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffMountDomReadiness\b/);
assert.match(shellText, /\bexport function mountIniPanelShellSessionHandoff\b/);
assert.match(shellText, /\bexport function mountIniPanelShellSessionHandoffFromControlPage\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageSchema\b/);
@@ -1317,6 +1323,7 @@ assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageMountState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffMountDomContract\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffMountDomReadiness\b/);
assert.match(docText, /\bmountIniPanelShellSessionHandoff\b/);
assert.match(docText, /\bmountIniPanelShellSessionHandoffFromControlPage\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageReport\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageSchema\b/);

View File

@@ -26,6 +26,7 @@ import {
createIniPanelShellSessionHandoffMountDomContract,
createIniPanelShellSessionHandoffMountDomReadiness,
mountIniPanelShellSessionHandoff,
mountIniPanelShellSessionHandoffFromControlPage,
renderIniPanelShellSessionHandoffMountState,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
@@ -100,6 +101,7 @@ assert.equal(typeof createIniPanelShellSessionHandoffPackageMountState, "functio
assert.equal(typeof createIniPanelShellSessionHandoffMountDomContract, "function");
assert.equal(typeof createIniPanelShellSessionHandoffMountDomReadiness, "function");
assert.equal(typeof mountIniPanelShellSessionHandoff, "function");
assert.equal(typeof mountIniPanelShellSessionHandoffFromControlPage, "function");
assert.equal(typeof renderIniPanelShellSessionHandoffMountState, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageReport, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageRenderState, "function");
@@ -702,6 +704,10 @@ assert.equal(
renderIniPanelShellSessionHandoffMountState,
);
assert.equal(shellViewModel.mountShellSessionHandoff, mountIniPanelShellSessionHandoff);
assert.equal(
shellViewModel.mountShellSessionHandoffFromControlPage,
mountIniPanelShellSessionHandoffFromControlPage,
);
assert.equal(shellViewModel.createShellSessionHandoffPackageReport, createIniPanelShellSessionHandoffPackageReport);
assert.equal(shellViewModel.createShellSessionHandoffPackageSchema, createIniPanelShellSessionHandoffPackageSchema);
assert.equal(shellViewModel.isSupportedShellSessionHandoffPackage, isSupportedIniPanelShellSessionHandoffPackage);
@@ -840,6 +846,43 @@ assert.equal(mountWorkflowResult.domReadiness.ready, true);
assert.equal(mountWorkflowResult.renderResult.rendered, true);
assert.equal(mountWorkflowResult.renderResult.rowCount, 5);
assert.equal(mountWorkflowResult.error, null);
const controlPageMountWorkflow = mountIniPanelShellSessionHandoffFromControlPage({
handoffPackage: shellViewModel.shellSessionHandoffPackage,
packageRenderState: shellViewModel.shellSessionHandoffPackageRenderState,
sessionLoadState: createControlPageSessionLoadState({
phase: "ready",
panelReady: true,
apiReady: true,
controlViewReady: true,
controlView: { status: { runStatus: "not-run" } },
}),
documentRef: mountDocument,
mountNode,
statusNode: mountStatusNode,
rowsNode: mountRowsNode,
});
assert.equal(controlPageMountWorkflow.apiName, "ini-panel-shell-session-handoff-control-page-mount-workflow");
assert.equal(controlPageMountWorkflow.workflowVersion, 1);
assert.equal(controlPageMountWorkflow.phase, "ready");
assert.equal(controlPageMountWorkflow.ready, true);
assert.equal(controlPageMountWorkflow.sessionLoadState.phase, "ready");
assert.equal(controlPageMountWorkflow.mountState.ready, true);
assert.equal(controlPageMountWorkflow.mountRenderState.ready, true);
assert.equal(controlPageMountWorkflow.mountWorkflow.renderResult.dataset.handoffReady, "true");
assert.equal(controlPageMountWorkflow.sessionLoadError, null);
const controlPageApiMountWorkflow = mountIniPanelShellSessionHandoffFromControlPage({
handoffPackage: shellViewModel.shellSessionHandoffPackage,
packageRenderState: shellViewModel.shellSessionHandoffPackageRenderState,
controlPageApi: {
loadControlPageSessionState: () => createControlPageSessionLoadState({ phase: "waiting-session" }),
},
documentRef: mountDocument,
mountNode,
statusNode: mountStatusNode,
rowsNode: mountRowsNode,
});
assert.equal(controlPageApiMountWorkflow.phase, "blocked");
assert.equal(controlPageApiMountWorkflow.sessionLoadState.phase, "waiting-session");
assert.deepEqual(
mountIniPanelShellSessionHandoff({ documentRef: mountDocument }).renderResult,
null,