推进 INI 面板 shell handoff package mount-state
This commit is contained in:
@@ -152,6 +152,15 @@
|
||||
getShellSessionHandoffPackageReport: () => shellViewModel.shellSessionHandoffPackageReport,
|
||||
getShellSessionHandoffPackageDisplayViewModel: () => shellViewModel.shellSessionHandoffPackageDisplayViewModel,
|
||||
getShellSessionHandoffPackageRenderState: () => shellViewModel.shellSessionHandoffPackageRenderState,
|
||||
getShellSessionHandoffPackageMountState: (sessionLoadState) => (
|
||||
sessionLoadState
|
||||
? shellViewModel.createShellSessionHandoffPackageMountState({
|
||||
handoffPackage: shellViewModel.shellSessionHandoffPackage,
|
||||
packageRenderState: shellViewModel.shellSessionHandoffPackageRenderState,
|
||||
sessionLoadState,
|
||||
})
|
||||
: shellViewModel.shellSessionHandoffPackageMountState
|
||||
),
|
||||
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
|
||||
@@ -140,6 +140,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
"getShellSessionHandoffPackageReport",
|
||||
"getShellSessionHandoffPackageDisplayViewModel",
|
||||
"getShellSessionHandoffPackageRenderState",
|
||||
"getShellSessionHandoffPackageMountState",
|
||||
"isSupportedShellSessionHandoffPackage",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
@@ -938,6 +939,85 @@ export function createIniPanelShellSessionHandoffPackageRenderState(
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellSessionHandoffPackageMountState({
|
||||
handoffPackage = createIniPanelShellSessionHandoffPackage(),
|
||||
packageRenderState = createIniPanelShellSessionHandoffPackageRenderState(),
|
||||
sessionLoadState = createControlPageSessionLoadState({ phase: "waiting-panel" }),
|
||||
} = {}) {
|
||||
const actionPlan = handoffPackage?.actionPlan && typeof handoffPackage.actionPlan === "object"
|
||||
? handoffPackage.actionPlan
|
||||
: {};
|
||||
const requiredMethods = actionPlan.requiredMethods && typeof actionPlan.requiredMethods === "object"
|
||||
? actionPlan.requiredMethods
|
||||
: {};
|
||||
const targetPage = actionPlan.targetPage ?? null;
|
||||
const blockingReasons = [
|
||||
...(Array.isArray(actionPlan.blockingReasons) ? actionPlan.blockingReasons : []),
|
||||
...(sessionLoadState?.phase === "error" ? ["controlPageSessionError"] : []),
|
||||
];
|
||||
const packageReady = handoffPackage?.ready === true && packageRenderState?.ready === true;
|
||||
const targetReady = Boolean(targetPage?.href);
|
||||
const methodsReady = Boolean(requiredMethods.loadSessionState && requiredMethods.readStatus);
|
||||
const sessionReady = sessionLoadState?.phase === "ready";
|
||||
const ready = packageReady && targetReady && methodsReady && sessionReady && blockingReasons.length === 0;
|
||||
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-package-mount-state",
|
||||
mountStateVersion: 1,
|
||||
phase: ready ? "ready" : "blocked",
|
||||
ready,
|
||||
packageReady,
|
||||
targetReady,
|
||||
methodsReady,
|
||||
sessionReady,
|
||||
statusLine: ready
|
||||
? "Ready: Control page session mounted"
|
||||
: `Blocked: ${blockingReasons.length === 0 ? sessionLoadState?.phase ?? "waiting-panel" : blockingReasons.join(", ")}`,
|
||||
packageRenderState,
|
||||
targetPage,
|
||||
requiredMethods: {
|
||||
loadSessionState: requiredMethods.loadSessionState ?? null,
|
||||
readStatus: requiredMethods.readStatus ?? null,
|
||||
},
|
||||
sessionLoadState,
|
||||
blockingReasons,
|
||||
checks: [
|
||||
{
|
||||
id: "package-render-state",
|
||||
label: "Package render state",
|
||||
status: packageReady ? "pass" : "blocked",
|
||||
value: packageRenderState?.statusLine ?? "missing",
|
||||
},
|
||||
{
|
||||
id: "target-page",
|
||||
label: "Control target",
|
||||
status: targetReady ? "pass" : "blocked",
|
||||
value: targetPage?.href ?? "missing",
|
||||
},
|
||||
{
|
||||
id: "required-methods",
|
||||
label: "Readonly methods",
|
||||
status: methodsReady ? "pass" : "blocked",
|
||||
value: methodsReady
|
||||
? `${requiredMethods.loadSessionState}, ${requiredMethods.readStatus}`
|
||||
: "missing",
|
||||
},
|
||||
{
|
||||
id: "session-load-state",
|
||||
label: "Session load state",
|
||||
status: sessionReady ? "pass" : "blocked",
|
||||
value: sessionLoadState?.phase ?? "missing",
|
||||
},
|
||||
{
|
||||
id: "blocking-reasons",
|
||||
label: "Blocking reasons",
|
||||
status: blockingReasons.length === 0 ? "pass" : "blocked",
|
||||
value: blockingReasons.length === 0 ? "none" : blockingReasons.join(", "),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
|
||||
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
|
||||
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
|
||||
@@ -991,6 +1071,10 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
const shellSessionHandoffPackageRenderState = createIniPanelShellSessionHandoffPackageRenderState(
|
||||
shellSessionHandoffPackageDisplayViewModel,
|
||||
);
|
||||
const shellSessionHandoffPackageMountState = createIniPanelShellSessionHandoffPackageMountState({
|
||||
handoffPackage: shellSessionHandoffPackage,
|
||||
packageRenderState: shellSessionHandoffPackageRenderState,
|
||||
});
|
||||
return {
|
||||
pages: entries.map(({ id, href, title }) => ({
|
||||
id,
|
||||
@@ -1015,6 +1099,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
shellSessionHandoffPackageReport,
|
||||
shellSessionHandoffPackageDisplayViewModel,
|
||||
shellSessionHandoffPackageRenderState,
|
||||
shellSessionHandoffPackageMountState,
|
||||
launchApiSchema: createIniPanelLaunchApiSchema(),
|
||||
launchApiManifest: createIniPanelLaunchApiManifest(entries),
|
||||
isSupportedShellIntegrationManifest: isSupportedIniPanelShellIntegrationManifest,
|
||||
@@ -1034,6 +1119,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
createShellSessionHandoffPackageReport: createIniPanelShellSessionHandoffPackageReport,
|
||||
createShellSessionHandoffPackageDisplayViewModel: createIniPanelShellSessionHandoffPackageDisplayViewModel,
|
||||
createShellSessionHandoffPackageRenderState: createIniPanelShellSessionHandoffPackageRenderState,
|
||||
createShellSessionHandoffPackageMountState: createIniPanelShellSessionHandoffPackageMountState,
|
||||
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
|
||||
controlPage: {
|
||||
browserApiSchema: createControlPageBrowserApiSchema(),
|
||||
|
||||
Reference in New Issue
Block a user