推进 INI 面板 shell handoff package render-state

This commit is contained in:
2026-06-15 11:07:09 +08:00
parent bb8ac55905
commit 1d06fd4cd4
10 changed files with 284 additions and 7 deletions

View File

@@ -28,6 +28,7 @@ import {
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
createIniPanelShellSessionHandoffSnapshot,
@@ -203,6 +204,12 @@ Use `createIniPanelShellSessionHandoffPackageDisplayViewModel()` or
`linuxCncIniPanelLaunchApi.getShellSessionHandoffPackageDisplayViewModel()`
when an outer shell needs the package report compressed into stable read-only
label/value rows for DOM display.
Use `createIniPanelShellSessionHandoffPackageRenderState()` or
`linuxCncIniPanelLaunchApi.getShellSessionHandoffPackageRenderState()` when an
outer shell needs the package display view-model compressed into launch-side
DOM state. The launch page renders `[data-handoff-status]` and
`[data-handoff-rows]` from the package render-state so the first page shows
package-level schema/report status.
The browser workflow smoke
`tests/browser/ini_panel_shell_integration_workflow_smoke.html` verifies the
same external shell handoff: read integration manifest, pass readiness gate,

View File

@@ -114,10 +114,11 @@
link.textContent = linkModel.label;
link.href = linkModel.href;
}
const handoffRenderState = shellViewModel.shellSessionHandoffRenderState;
const handoffRenderState = shellViewModel.shellSessionHandoffPackageRenderState;
const handoffShell = document.querySelector("[data-handoff-shell]");
handoffShell.dataset.handoffPhase = handoffRenderState.dataset.handoffPhase;
handoffShell.dataset.handoffReady = handoffRenderState.dataset.handoffReady;
handoffShell.dataset.handoffScope = handoffRenderState.dataset.handoffScope;
document.querySelector("[data-handoff-status]").textContent = handoffRenderState.statusLine;
const handoffRows = document.querySelector("[data-handoff-rows]");
for (const row of handoffRenderState.rows) {
@@ -150,6 +151,7 @@
getShellSessionHandoffPackage: () => shellViewModel.shellSessionHandoffPackage,
getShellSessionHandoffPackageReport: () => shellViewModel.shellSessionHandoffPackageReport,
getShellSessionHandoffPackageDisplayViewModel: () => shellViewModel.shellSessionHandoffPackageDisplayViewModel,
getShellSessionHandoffPackageRenderState: () => shellViewModel.shellSessionHandoffPackageRenderState,
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
getLauncherLinks: () => shellViewModel.launcherLinks,
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,

View File

@@ -139,6 +139,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
"getShellSessionHandoffPackage",
"getShellSessionHandoffPackageReport",
"getShellSessionHandoffPackageDisplayViewModel",
"getShellSessionHandoffPackageRenderState",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -905,6 +906,38 @@ export function createIniPanelShellSessionHandoffPackageDisplayViewModel(
};
}
export function createIniPanelShellSessionHandoffPackageRenderState(
displayViewModel = createIniPanelShellSessionHandoffPackageDisplayViewModel(),
) {
const rows = Array.isArray(displayViewModel?.rows)
? displayViewModel.rows.map(({ id, label, value }) => ({
id,
label,
value: value == null ? "" : String(value),
}))
: [];
const ready = displayViewModel?.phase === "ready" && displayViewModel?.statusText === "Ready";
const statusText = displayViewModel?.statusText ?? (ready ? "Ready" : "Blocked");
const detailText = displayViewModel?.detailText ?? "No blocking reasons";
return {
apiName: "ini-panel-shell-session-handoff-package-render-state",
renderStateVersion: 1,
phase: ready ? "ready" : "blocked",
ready,
title: displayViewModel?.title ?? "Shell handoff package",
statusText,
detailText,
statusLine: `${statusText}: ${detailText}`,
rows,
dataset: {
handoffPhase: ready ? "ready" : "blocked",
handoffReady: ready ? "true" : "false",
handoffScope: "package",
},
};
}
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
@@ -955,6 +988,9 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
const shellSessionHandoffPackageDisplayViewModel = createIniPanelShellSessionHandoffPackageDisplayViewModel(
shellSessionHandoffPackageReport,
);
const shellSessionHandoffPackageRenderState = createIniPanelShellSessionHandoffPackageRenderState(
shellSessionHandoffPackageDisplayViewModel,
);
return {
pages: entries.map(({ id, href, title }) => ({
id,
@@ -978,6 +1014,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
shellSessionHandoffPackageSchema: createIniPanelShellSessionHandoffPackageSchema(),
shellSessionHandoffPackageReport,
shellSessionHandoffPackageDisplayViewModel,
shellSessionHandoffPackageRenderState,
launchApiSchema: createIniPanelLaunchApiSchema(),
launchApiManifest: createIniPanelLaunchApiManifest(entries),
isSupportedShellIntegrationManifest: isSupportedIniPanelShellIntegrationManifest,
@@ -996,6 +1033,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
createShellSessionHandoffPackageSchema: createIniPanelShellSessionHandoffPackageSchema,
createShellSessionHandoffPackageReport: createIniPanelShellSessionHandoffPackageReport,
createShellSessionHandoffPackageDisplayViewModel: createIniPanelShellSessionHandoffPackageDisplayViewModel,
createShellSessionHandoffPackageRenderState: createIniPanelShellSessionHandoffPackageRenderState,
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
controlPage: {
browserApiSchema: createControlPageBrowserApiSchema(),

View File

@@ -86,6 +86,7 @@
!launchApi?.getShellSessionHandoffPackage ||
!launchApi?.getShellSessionHandoffPackageReport ||
!launchApi?.getShellSessionHandoffPackageDisplayViewModel ||
!launchApi?.getShellSessionHandoffPackageRenderState ||
!launchApi?.isSupportedShellSessionHandoffPackage ||
!launchApi?.getLauncherLinks ||
!launchApi?.getControlPageApiMethods
@@ -126,7 +127,7 @@
);
assertEqual(
launchApiManifest.methods.join(","),
"isSupportedLaunchApiManifest,getLaunchApiSchema,getLaunchApiManifest,getShellIntegrationSchema,getShellIntegrationManifest,getShellIntegrationReadiness,getShellSessionHandoffSummarySchema,getShellSessionHandoffSummary,isSupportedShellSessionHandoffSummary,getShellSessionHandoffCompatibilityReport,getShellSessionHandoffDisplayViewModel,getShellSessionHandoffSnapshot,getShellSessionHandoffRenderState,getShellSessionHandoffActionPlan,getShellSessionHandoffChecklist,getShellSessionHandoffPackageSchema,getShellSessionHandoffPackage,getShellSessionHandoffPackageReport,getShellSessionHandoffPackageDisplayViewModel,isSupportedShellSessionHandoffPackage,getLauncherLinks,getControlPageApiMethods",
"isSupportedLaunchApiManifest,getLaunchApiSchema,getLaunchApiManifest,getShellIntegrationSchema,getShellIntegrationManifest,getShellIntegrationReadiness,getShellSessionHandoffSummarySchema,getShellSessionHandoffSummary,isSupportedShellSessionHandoffSummary,getShellSessionHandoffCompatibilityReport,getShellSessionHandoffDisplayViewModel,getShellSessionHandoffSnapshot,getShellSessionHandoffRenderState,getShellSessionHandoffActionPlan,getShellSessionHandoffChecklist,getShellSessionHandoffPackageSchema,getShellSessionHandoffPackage,getShellSessionHandoffPackageReport,getShellSessionHandoffPackageDisplayViewModel,getShellSessionHandoffPackageRenderState,isSupportedShellSessionHandoffPackage,getLauncherLinks,getControlPageApiMethods",
"launch API manifest methods",
);
const shellIntegrationSchema = launchApi.getShellIntegrationSchema();
@@ -144,6 +145,7 @@
const shellSessionHandoffPackage = launchApi.getShellSessionHandoffPackage();
const shellSessionHandoffPackageReport = launchApi.getShellSessionHandoffPackageReport();
const shellSessionHandoffPackageDisplayViewModel = launchApi.getShellSessionHandoffPackageDisplayViewModel();
const shellSessionHandoffPackageRenderState = launchApi.getShellSessionHandoffPackageRenderState();
assertEqual(
shellIntegrationSchema.manifestVersion,
1,
@@ -339,6 +341,21 @@
shellSessionHandoffPackageReport.rows.length,
"shell session handoff package display rows",
);
assertEqual(
shellSessionHandoffPackageRenderState.renderStateVersion,
1,
"shell session handoff package render-state version",
);
assertEqual(
shellSessionHandoffPackageRenderState.ready,
true,
"shell session handoff package render-state readiness",
);
assertEqual(
shellSessionHandoffPackageRenderState.rows.length,
shellSessionHandoffPackageDisplayViewModel.rows.length,
"shell session handoff package render-state rows",
);
assertEqual(
shellSessionHandoffPackage.ready,
true,
@@ -405,9 +422,24 @@
"shell session handoff DOM ready",
);
assertEqual(
launchDoc.querySelector('[data-handoff-value="missing-fields"]').textContent,
launchDoc.querySelector("[data-handoff-shell]").dataset.handoffScope,
"package",
"shell session handoff DOM scope",
);
assertEqual(
launchDoc.querySelector('[data-handoff-value="package-supported"]').textContent,
"supported",
"shell session handoff DOM package support",
);
assertEqual(
launchDoc.querySelector('[data-handoff-value="package-ready"]').textContent,
"ready",
"shell session handoff DOM package readiness",
);
assertEqual(
launchDoc.querySelector('[data-handoff-value="missing-package-fields"]').textContent,
"none",
"shell session handoff DOM missing fields",
"shell session handoff DOM missing package fields",
);
assertEqual(
launchDoc.querySelector('[data-handoff-value="blocking-reasons"]').textContent,

View File

@@ -77,6 +77,7 @@ TOOL_TABLE = browser-shell-tool.tbl
!launchApi?.getShellSessionHandoffPackage ||
!launchApi?.getShellSessionHandoffPackageReport ||
!launchApi?.getShellSessionHandoffPackageDisplayViewModel ||
!launchApi?.getShellSessionHandoffPackageRenderState ||
!launchApi?.isSupportedShellSessionHandoffPackage
) {
throw new Error("launch API namespace did not expose shell integration helpers");
@@ -96,6 +97,7 @@ TOOL_TABLE = browser-shell-tool.tbl
const handoffPackage = launchApi.getShellSessionHandoffPackage();
const handoffPackageReport = launchApi.getShellSessionHandoffPackageReport();
const handoffPackageDisplay = launchApi.getShellSessionHandoffPackageDisplayViewModel();
const handoffPackageRenderState = launchApi.getShellSessionHandoffPackageRenderState();
assertEqual(handoffSummarySchema.summaryVersion, 1, "shell handoff summary schema version");
assertEqual(
launchApi.isSupportedShellSessionHandoffSummary(handoffSummary),
@@ -148,6 +150,13 @@ TOOL_TABLE = browser-shell-tool.tbl
handoffPackageReport.rows.length,
"shell handoff package display rows",
);
assertEqual(handoffPackageRenderState.ready, true, "shell handoff package render-state readiness");
assertEqual(handoffPackageRenderState.statusLine, "Ready: No blocking reasons", "shell handoff package render-state status");
assertEqual(
handoffPackageRenderState.rows.length,
handoffPackageDisplay.rows.length,
"shell handoff package render-state rows",
);
assertEqual(handoffPackage.checklist.ready, handoffChecklist.ready, "shell handoff package checklist");
assertEqual(
handoffPackage.actionPlan.nextSteps.map(({ id }) => id).join(","),

View File

@@ -25,6 +25,7 @@ import {
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
createIniPanelShellSessionHandoffSnapshot,
@@ -86,6 +87,7 @@ const requiredShellExports = [
"createIniPanelShellSessionHandoffPackage",
"createIniPanelShellSessionHandoffPackageDisplayViewModel",
"createIniPanelShellSessionHandoffPackageReport",
"createIniPanelShellSessionHandoffPackageRenderState",
"createIniPanelShellSessionHandoffPackageSchema",
"createIniPanelShellSessionHandoffRenderState",
"createIniPanelShellSessionHandoffSnapshot",
@@ -244,6 +246,12 @@ assert.deepEqual(
createIniPanelShellViewModel().shellSessionHandoffPackageReport,
),
);
assert.deepEqual(
createIniPanelShellViewModel().shellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageRenderState(
createIniPanelShellViewModel().shellSessionHandoffPackageDisplayViewModel,
),
);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(createIniPanelShellViewModel().shellSessionHandoffPackage), true);
assert.equal(isSupportedIniPanelShellIntegrationManifest(createIniPanelShellViewModel().shellIntegrationManifest), true);
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());

View File

@@ -59,6 +59,7 @@ assert.deepEqual(manifest, {
"getShellSessionHandoffPackage",
"getShellSessionHandoffPackageReport",
"getShellSessionHandoffPackageDisplayViewModel",
"getShellSessionHandoffPackageRenderState",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -173,6 +174,7 @@ assert.match(launchText, /\bgetShellSessionHandoffPackageSchema\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackage\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackageReport\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackageRenderState\b/);
assert.match(launchText, /\bisSupportedShellSessionHandoffPackage\b/);
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);

View File

@@ -21,6 +21,7 @@ import {
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
createIniPanelShellSessionHandoffSnapshot,
@@ -75,6 +76,9 @@ const handoffPackageReport = createIniPanelShellSessionHandoffPackageReport(hand
const handoffPackageDisplayViewModel = createIniPanelShellSessionHandoffPackageDisplayViewModel(
handoffPackageReport,
);
const handoffPackageRenderState = createIniPanelShellSessionHandoffPackageRenderState(
handoffPackageDisplayViewModel,
);
assert.deepEqual(schema, {
apiName: "ini-panel-shell-integration",
@@ -130,7 +134,7 @@ assert.deepEqual(readiness, {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 22,
launchMethods: 23,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -192,7 +196,7 @@ assert.deepEqual(handoffSummary, {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 22,
launchMethods: 23,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -555,6 +559,22 @@ assert.deepEqual(handoffPackageDisplayViewModel, {
detailText: "No blocking reasons",
rows: handoffPackageReport.rows,
});
assert.deepEqual(handoffPackageRenderState, {
apiName: "ini-panel-shell-session-handoff-package-render-state",
renderStateVersion: 1,
phase: "ready",
ready: true,
title: "Shell handoff package",
statusText: "Ready",
detailText: "No blocking reasons",
statusLine: "Ready: No blocking reasons",
rows: handoffPackageDisplayViewModel.rows,
dataset: {
handoffPhase: "ready",
handoffReady: "true",
handoffScope: "package",
},
});
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(handoffPackage), true);
assert.equal(
isSupportedIniPanelShellSessionHandoffPackage({ ...handoffPackage, packageVersion: 2 }),
@@ -601,6 +621,58 @@ assert.equal(
).statusText,
"Blocked",
);
assert.deepEqual(
createIniPanelShellSessionHandoffPackageRenderState(createIniPanelShellSessionHandoffPackageDisplayViewModel(
createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
)),
{
apiName: "ini-panel-shell-session-handoff-package-render-state",
renderStateVersion: 1,
phase: "blocked",
ready: false,
title: "Shell handoff package",
statusText: "Blocked",
detailText: "packageVersion",
statusLine: "Blocked: packageVersion",
rows: [
{
id: "package-supported",
label: "Package schema",
value: "blocked",
},
{
id: "package-ready",
label: "Package readiness",
value: "blocked",
},
{
id: "missing-package-fields",
label: "Missing package fields",
value: "none",
},
{
id: "missing-manifest-fields",
label: "Missing manifest fields",
value: "none",
},
{
id: "mismatch-fields",
label: "Mismatched fields",
value: "packageVersion",
},
{
id: "blocking-reasons",
label: "Blocking reasons",
value: "none",
},
],
dataset: {
handoffPhase: "blocked",
handoffReady: "false",
handoffScope: "package",
},
},
);
assert.deepEqual(
createIniPanelShellSessionHandoffPackageReport(missingManifestField).missingManifestFields,
["controlPageMethods"],
@@ -832,7 +904,7 @@ assert.deepEqual(createIniPanelShellIntegrationReadiness(blockedManifest), {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 22,
launchMethods: 23,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -999,6 +1071,7 @@ assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffDisp
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackage\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageSchema\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffSnapshot\b/);
@@ -1020,6 +1093,7 @@ assert.match(docText, /\bcreateIniPanelShellSessionHandoffDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackage\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageReport\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageSchema\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffSnapshot\b/);

View File

@@ -21,6 +21,7 @@ import {
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
createIniPanelShellSessionHandoffSnapshot,
@@ -87,6 +88,7 @@ assert.equal(typeof createIniPanelShellSessionHandoffDisplayViewModel, "function
assert.equal(typeof createIniPanelShellSessionHandoffPackage, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageDisplayViewModel, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageReport, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageRenderState, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageSchema, "function");
assert.equal(typeof createIniPanelShellSessionHandoffRenderState, "function");
assert.equal(typeof createIniPanelShellSessionHandoffSnapshot, "function");
@@ -216,6 +218,10 @@ assert.deepEqual(
shellViewModel.shellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageDisplayViewModel(shellViewModel.shellSessionHandoffPackageReport),
);
assert.deepEqual(
shellViewModel.shellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageRenderState(shellViewModel.shellSessionHandoffPackageDisplayViewModel),
);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(shellViewModel.shellSessionHandoffPackage), true);
assert.deepEqual(shellViewModel.shellSessionHandoffDisplayViewModel, {
phase: "ready",
@@ -442,6 +448,22 @@ assert.deepEqual(shellViewModel.shellSessionHandoffPackageDisplayViewModel, {
detailText: "No blocking reasons",
rows: shellViewModel.shellSessionHandoffPackageReport.rows,
});
assert.deepEqual(shellViewModel.shellSessionHandoffPackageRenderState, {
apiName: "ini-panel-shell-session-handoff-package-render-state",
renderStateVersion: 1,
phase: "ready",
ready: true,
title: "Shell handoff package",
statusText: "Ready",
detailText: "No blocking reasons",
statusLine: "Ready: No blocking reasons",
rows: shellViewModel.shellSessionHandoffPackageDisplayViewModel.rows,
dataset: {
handoffPhase: "ready",
handoffReady: "true",
handoffScope: "package",
},
});
assert.equal(
isSupportedIniPanelShellIntegrationManifest(shellViewModel.shellIntegrationManifest),
true,
@@ -494,6 +516,10 @@ assert.equal(
shellViewModel.createShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
);
assert.equal(
shellViewModel.createShellSessionHandoffPackageRenderState,
createIniPanelShellSessionHandoffPackageRenderState,
);
assert.equal(shellViewModel.createShellSessionHandoffPackageReport, createIniPanelShellSessionHandoffPackageReport);
assert.equal(shellViewModel.createShellSessionHandoffPackageSchema, createIniPanelShellSessionHandoffPackageSchema);
assert.equal(shellViewModel.isSupportedShellSessionHandoffPackage, isSupportedIniPanelShellSessionHandoffPackage);