推进 INI 面板 shell handoff readonly status workflow helper

This commit is contained in:
2026-06-15 13:48:36 +08:00
parent c3d9b90de1
commit 859d01356b
9 changed files with 228 additions and 4 deletions

View File

@@ -148,6 +148,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
"renderShellSessionHandoffMountState",
"mountShellSessionHandoff",
"mountShellSessionHandoffFromControlPage",
"readShellSessionHandoffStatusFromControlPage",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -1328,6 +1329,53 @@ export function mountIniPanelShellSessionHandoffFromControlPage({
};
}
export function readIniPanelShellSessionHandoffStatusFromControlPage({
controlPageApi = null,
readonlyStatus = null,
readStatusMethod = "readControlPageStatus",
handoffSummary = createIniPanelShellSessionHandoffSummary(),
expectedStatusFields = handoffSummary?.readonlyStatusFields ?? [],
} = {}) {
let observedStatus = readonlyStatus;
let readError = null;
if (!observedStatus) {
const readStatus = controlPageApi?.[readStatusMethod];
if (typeof readStatus === "function") {
try {
observedStatus = readStatus.call(controlPageApi);
} catch (error) {
readError = error?.message ?? String(error);
observedStatus = null;
}
} else {
readError = `Missing ${readStatusMethod}`;
observedStatus = null;
}
}
const statusObject = observedStatus && typeof observedStatus === "object" ? observedStatus : {};
const expectedFields = Array.isArray(expectedStatusFields) ? [...expectedStatusFields] : [];
const presentStatusFields = expectedFields.filter((fieldName) => Object.hasOwn(statusObject, fieldName));
const missingStatusFields = expectedFields.filter((fieldName) => !Object.hasOwn(statusObject, fieldName));
const ready = !readError && missingStatusFields.length === 0;
return {
apiName: "ini-panel-shell-session-handoff-readonly-status-result",
resultVersion: 1,
phase: ready ? "ready" : "blocked",
ready,
statusLine: ready
? "Ready: readonly status fields available"
: `Blocked: ${readError ?? missingStatusFields.join(", ")}`,
readStatusMethod,
expectedStatusFields: expectedFields,
presentStatusFields,
missingStatusFields,
readonlyStatus: observedStatus,
readError,
};
}
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
@@ -1447,6 +1495,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
renderShellSessionHandoffMountState: renderIniPanelShellSessionHandoffMountState,
mountShellSessionHandoff: mountIniPanelShellSessionHandoff,
mountShellSessionHandoffFromControlPage: mountIniPanelShellSessionHandoffFromControlPage,
readShellSessionHandoffStatusFromControlPage: readIniPanelShellSessionHandoffStatusFromControlPage,
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
controlPage: {
browserApiSchema: createControlPageBrowserApiSchema(),