推进 INI 面板 shell handoff package display view-model

This commit is contained in:
2026-06-15 10:59:02 +08:00
parent e1029ede0f
commit bb8ac55905
10 changed files with 198 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ import {
createIniPanelShellSessionHandoffCompatibilityReport,
createIniPanelShellSessionHandoffDisplayViewModel,
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
@@ -198,6 +199,10 @@ Use `createIniPanelShellSessionHandoffPackageReport()` or
shell needs display-ready diagnostics for package schema support, missing
package fields, missing manifest fields, api/version mismatches, and checklist
blocking reasons.
Use `createIniPanelShellSessionHandoffPackageDisplayViewModel()` or
`linuxCncIniPanelLaunchApi.getShellSessionHandoffPackageDisplayViewModel()`
when an outer shell needs the package report compressed into stable read-only
label/value rows for DOM display.
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

@@ -149,6 +149,7 @@
getShellSessionHandoffPackageSchema: () => shellViewModel.shellSessionHandoffPackageSchema,
getShellSessionHandoffPackage: () => shellViewModel.shellSessionHandoffPackage,
getShellSessionHandoffPackageReport: () => shellViewModel.shellSessionHandoffPackageReport,
getShellSessionHandoffPackageDisplayViewModel: () => shellViewModel.shellSessionHandoffPackageDisplayViewModel,
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
getLauncherLinks: () => shellViewModel.launcherLinks,
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,

View File

@@ -138,6 +138,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
"getShellSessionHandoffPackageSchema",
"getShellSessionHandoffPackage",
"getShellSessionHandoffPackageReport",
"getShellSessionHandoffPackageDisplayViewModel",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -875,6 +876,35 @@ export function createIniPanelShellSessionHandoffPackageReport(
};
}
export function createIniPanelShellSessionHandoffPackageDisplayViewModel(
report = createIniPanelShellSessionHandoffPackageReport(),
) {
const missingPackageFields = Array.isArray(report?.missingPackageFields) ? report.missingPackageFields : [];
const missingManifestFields = Array.isArray(report?.missingManifestFields) ? report.missingManifestFields : [];
const mismatchFields = Array.isArray(report?.mismatchFields) ? report.mismatchFields : [];
const blockingReasons = Array.isArray(report?.blockingReasons) ? report.blockingReasons : [];
const problems = [
...missingPackageFields,
...missingManifestFields,
...mismatchFields,
...blockingReasons,
];
return {
phase: report?.phase === "ready" ? "ready" : "blocked",
title: "Shell handoff package",
statusText: report?.ready ? "Ready" : "Blocked",
detailText: problems.length === 0 ? "No blocking reasons" : problems.join(", "),
rows: Array.isArray(report?.rows)
? report.rows.map(({ id, label, value }) => ({
id,
label,
value,
}))
: [],
};
}
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
@@ -922,6 +952,9 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
const shellSessionHandoffPackageReport = createIniPanelShellSessionHandoffPackageReport(
shellSessionHandoffPackage,
);
const shellSessionHandoffPackageDisplayViewModel = createIniPanelShellSessionHandoffPackageDisplayViewModel(
shellSessionHandoffPackageReport,
);
return {
pages: entries.map(({ id, href, title }) => ({
id,
@@ -944,6 +977,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
shellSessionHandoffPackage,
shellSessionHandoffPackageSchema: createIniPanelShellSessionHandoffPackageSchema(),
shellSessionHandoffPackageReport,
shellSessionHandoffPackageDisplayViewModel,
launchApiSchema: createIniPanelLaunchApiSchema(),
launchApiManifest: createIniPanelLaunchApiManifest(entries),
isSupportedShellIntegrationManifest: isSupportedIniPanelShellIntegrationManifest,
@@ -961,6 +995,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
createShellSessionHandoffPackage: createIniPanelShellSessionHandoffPackage,
createShellSessionHandoffPackageSchema: createIniPanelShellSessionHandoffPackageSchema,
createShellSessionHandoffPackageReport: createIniPanelShellSessionHandoffPackageReport,
createShellSessionHandoffPackageDisplayViewModel: createIniPanelShellSessionHandoffPackageDisplayViewModel,
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
controlPage: {
browserApiSchema: createControlPageBrowserApiSchema(),

View File

@@ -85,6 +85,7 @@
!launchApi?.getShellSessionHandoffPackageSchema ||
!launchApi?.getShellSessionHandoffPackage ||
!launchApi?.getShellSessionHandoffPackageReport ||
!launchApi?.getShellSessionHandoffPackageDisplayViewModel ||
!launchApi?.isSupportedShellSessionHandoffPackage ||
!launchApi?.getLauncherLinks ||
!launchApi?.getControlPageApiMethods
@@ -125,7 +126,7 @@
);
assertEqual(
launchApiManifest.methods.join(","),
"isSupportedLaunchApiManifest,getLaunchApiSchema,getLaunchApiManifest,getShellIntegrationSchema,getShellIntegrationManifest,getShellIntegrationReadiness,getShellSessionHandoffSummarySchema,getShellSessionHandoffSummary,isSupportedShellSessionHandoffSummary,getShellSessionHandoffCompatibilityReport,getShellSessionHandoffDisplayViewModel,getShellSessionHandoffSnapshot,getShellSessionHandoffRenderState,getShellSessionHandoffActionPlan,getShellSessionHandoffChecklist,getShellSessionHandoffPackageSchema,getShellSessionHandoffPackage,getShellSessionHandoffPackageReport,isSupportedShellSessionHandoffPackage,getLauncherLinks,getControlPageApiMethods",
"isSupportedLaunchApiManifest,getLaunchApiSchema,getLaunchApiManifest,getShellIntegrationSchema,getShellIntegrationManifest,getShellIntegrationReadiness,getShellSessionHandoffSummarySchema,getShellSessionHandoffSummary,isSupportedShellSessionHandoffSummary,getShellSessionHandoffCompatibilityReport,getShellSessionHandoffDisplayViewModel,getShellSessionHandoffSnapshot,getShellSessionHandoffRenderState,getShellSessionHandoffActionPlan,getShellSessionHandoffChecklist,getShellSessionHandoffPackageSchema,getShellSessionHandoffPackage,getShellSessionHandoffPackageReport,getShellSessionHandoffPackageDisplayViewModel,isSupportedShellSessionHandoffPackage,getLauncherLinks,getControlPageApiMethods",
"launch API manifest methods",
);
const shellIntegrationSchema = launchApi.getShellIntegrationSchema();
@@ -142,6 +143,7 @@
const shellSessionHandoffPackageSchema = launchApi.getShellSessionHandoffPackageSchema();
const shellSessionHandoffPackage = launchApi.getShellSessionHandoffPackage();
const shellSessionHandoffPackageReport = launchApi.getShellSessionHandoffPackageReport();
const shellSessionHandoffPackageDisplayViewModel = launchApi.getShellSessionHandoffPackageDisplayViewModel();
assertEqual(
shellIntegrationSchema.manifestVersion,
1,
@@ -327,6 +329,16 @@
"",
"shell session handoff package report missing fields",
);
assertEqual(
shellSessionHandoffPackageDisplayViewModel.statusText,
"Ready",
"shell session handoff package display status",
);
assertEqual(
shellSessionHandoffPackageDisplayViewModel.rows.length,
shellSessionHandoffPackageReport.rows.length,
"shell session handoff package display rows",
);
assertEqual(
shellSessionHandoffPackage.ready,
true,

View File

@@ -76,6 +76,7 @@ TOOL_TABLE = browser-shell-tool.tbl
!launchApi?.getShellSessionHandoffPackageSchema ||
!launchApi?.getShellSessionHandoffPackage ||
!launchApi?.getShellSessionHandoffPackageReport ||
!launchApi?.getShellSessionHandoffPackageDisplayViewModel ||
!launchApi?.isSupportedShellSessionHandoffPackage
) {
throw new Error("launch API namespace did not expose shell integration helpers");
@@ -94,6 +95,7 @@ TOOL_TABLE = browser-shell-tool.tbl
const handoffPackageSchema = launchApi.getShellSessionHandoffPackageSchema();
const handoffPackage = launchApi.getShellSessionHandoffPackage();
const handoffPackageReport = launchApi.getShellSessionHandoffPackageReport();
const handoffPackageDisplay = launchApi.getShellSessionHandoffPackageDisplayViewModel();
assertEqual(handoffSummarySchema.summaryVersion, 1, "shell handoff summary schema version");
assertEqual(
launchApi.isSupportedShellSessionHandoffSummary(handoffSummary),
@@ -139,6 +141,13 @@ TOOL_TABLE = browser-shell-tool.tbl
assertEqual(handoffPackageReport.ready, true, "shell handoff package report readiness");
assertEqual(handoffPackageReport.packageSupported, true, "shell handoff package report support");
assertEqual(handoffPackageReport.rows.length, 6, "shell handoff package report rows");
assertEqual(handoffPackageDisplay.statusText, "Ready", "shell handoff package display status");
assertEqual(handoffPackageDisplay.detailText, "No blocking reasons", "shell handoff package display detail");
assertEqual(
handoffPackageDisplay.rows.length,
handoffPackageReport.rows.length,
"shell handoff package display rows",
);
assertEqual(handoffPackage.checklist.ready, handoffChecklist.ready, "shell handoff package checklist");
assertEqual(
handoffPackage.actionPlan.nextSteps.map(({ id }) => id).join(","),

View File

@@ -23,6 +23,7 @@ import {
createIniPanelShellSessionHandoffCompatibilityReport,
createIniPanelShellSessionHandoffDisplayViewModel,
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
@@ -83,6 +84,7 @@ const requiredShellExports = [
"createIniPanelShellSessionHandoffCompatibilityReport",
"createIniPanelShellSessionHandoffDisplayViewModel",
"createIniPanelShellSessionHandoffPackage",
"createIniPanelShellSessionHandoffPackageDisplayViewModel",
"createIniPanelShellSessionHandoffPackageReport",
"createIniPanelShellSessionHandoffPackageSchema",
"createIniPanelShellSessionHandoffRenderState",
@@ -236,6 +238,12 @@ assert.deepEqual(
createIniPanelShellViewModel().shellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageReport(createIniPanelShellViewModel().shellSessionHandoffPackage),
);
assert.deepEqual(
createIniPanelShellViewModel().shellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageDisplayViewModel(
createIniPanelShellViewModel().shellSessionHandoffPackageReport,
),
);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(createIniPanelShellViewModel().shellSessionHandoffPackage), true);
assert.equal(isSupportedIniPanelShellIntegrationManifest(createIniPanelShellViewModel().shellIntegrationManifest), true);
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());

View File

@@ -58,6 +58,7 @@ assert.deepEqual(manifest, {
"getShellSessionHandoffPackageSchema",
"getShellSessionHandoffPackage",
"getShellSessionHandoffPackageReport",
"getShellSessionHandoffPackageDisplayViewModel",
"isSupportedShellSessionHandoffPackage",
"getLauncherLinks",
"getControlPageApiMethods",
@@ -171,6 +172,7 @@ assert.match(launchText, /\bgetShellSessionHandoffChecklist\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackageSchema\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackage\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackageReport\b/);
assert.match(launchText, /\bgetShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(launchText, /\bisSupportedShellSessionHandoffPackage\b/);
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);

View File

@@ -19,6 +19,7 @@ import {
createIniPanelShellSessionHandoffCompatibilityReport,
createIniPanelShellSessionHandoffDisplayViewModel,
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
@@ -71,6 +72,9 @@ const handoffPackage = createIniPanelShellSessionHandoffPackage({
});
const handoffPackageSchema = createIniPanelShellSessionHandoffPackageSchema();
const handoffPackageReport = createIniPanelShellSessionHandoffPackageReport(handoffPackage);
const handoffPackageDisplayViewModel = createIniPanelShellSessionHandoffPackageDisplayViewModel(
handoffPackageReport,
);
assert.deepEqual(schema, {
apiName: "ini-panel-shell-integration",
@@ -126,7 +130,7 @@ assert.deepEqual(readiness, {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 21,
launchMethods: 22,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -188,7 +192,7 @@ assert.deepEqual(handoffSummary, {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 21,
launchMethods: 22,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -544,6 +548,13 @@ assert.deepEqual(handoffPackageReport, {
},
],
});
assert.deepEqual(handoffPackageDisplayViewModel, {
phase: "ready",
title: "Shell handoff package",
statusText: "Ready",
detailText: "No blocking reasons",
rows: handoffPackageReport.rows,
});
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(handoffPackage), true);
assert.equal(
isSupportedIniPanelShellSessionHandoffPackage({ ...handoffPackage, packageVersion: 2 }),
@@ -574,6 +585,22 @@ assert.deepEqual(
createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }).mismatchFields,
["packageVersion"],
);
assert.deepEqual(
createIniPanelShellSessionHandoffPackageDisplayViewModel(
createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
).rows.find((row) => row.id === "mismatch-fields"),
{
id: "mismatch-fields",
label: "Mismatched fields",
value: "packageVersion",
},
);
assert.equal(
createIniPanelShellSessionHandoffPackageDisplayViewModel(
createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
).statusText,
"Blocked",
);
assert.deepEqual(
createIniPanelShellSessionHandoffPackageReport(missingManifestField).missingManifestFields,
["controlPageMethods"],
@@ -805,7 +832,7 @@ assert.deepEqual(createIniPanelShellIntegrationReadiness(blockedManifest), {
counts: {
pages: 2,
launcherLinks: 2,
launchMethods: 21,
launchMethods: 22,
controlPageMethods: 11,
persistenceCapabilities: 3,
},
@@ -970,6 +997,7 @@ assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffChec
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffCompatibilityReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffDisplayViewModel\b/);
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 createIniPanelShellSessionHandoffPackageSchema\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffRenderState\b/);
@@ -990,6 +1018,7 @@ assert.match(docText, /\bcreateIniPanelShellSessionHandoffChecklist\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffCompatibilityReport\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackage\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageReport\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageSchema\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffRenderState\b/);

View File

@@ -19,6 +19,7 @@ import {
createIniPanelShellSessionHandoffCompatibilityReport,
createIniPanelShellSessionHandoffDisplayViewModel,
createIniPanelShellSessionHandoffPackage,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageSchema,
createIniPanelShellSessionHandoffRenderState,
@@ -84,6 +85,7 @@ assert.equal(typeof createIniPanelShellSessionHandoffChecklist, "function");
assert.equal(typeof createIniPanelShellSessionHandoffCompatibilityReport, "function");
assert.equal(typeof createIniPanelShellSessionHandoffDisplayViewModel, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackage, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageDisplayViewModel, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageReport, "function");
assert.equal(typeof createIniPanelShellSessionHandoffPackageSchema, "function");
assert.equal(typeof createIniPanelShellSessionHandoffRenderState, "function");
@@ -210,6 +212,10 @@ assert.deepEqual(
shellViewModel.shellSessionHandoffPackageReport,
createIniPanelShellSessionHandoffPackageReport(shellViewModel.shellSessionHandoffPackage),
);
assert.deepEqual(
shellViewModel.shellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageDisplayViewModel(shellViewModel.shellSessionHandoffPackageReport),
);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(shellViewModel.shellSessionHandoffPackage), true);
assert.deepEqual(shellViewModel.shellSessionHandoffDisplayViewModel, {
phase: "ready",
@@ -429,6 +435,13 @@ assert.deepEqual(shellViewModel.shellSessionHandoffPackageReport, {
},
],
});
assert.deepEqual(shellViewModel.shellSessionHandoffPackageDisplayViewModel, {
phase: "ready",
title: "Shell handoff package",
statusText: "Ready",
detailText: "No blocking reasons",
rows: shellViewModel.shellSessionHandoffPackageReport.rows,
});
assert.equal(
isSupportedIniPanelShellIntegrationManifest(shellViewModel.shellIntegrationManifest),
true,
@@ -477,6 +490,10 @@ assert.equal(shellViewModel.createShellSessionHandoffRenderState, createIniPanel
assert.equal(shellViewModel.createShellSessionHandoffActionPlan, createIniPanelShellSessionHandoffActionPlan);
assert.equal(shellViewModel.createShellSessionHandoffChecklist, createIniPanelShellSessionHandoffChecklist);
assert.equal(shellViewModel.createShellSessionHandoffPackage, createIniPanelShellSessionHandoffPackage);
assert.equal(
shellViewModel.createShellSessionHandoffPackageDisplayViewModel,
createIniPanelShellSessionHandoffPackageDisplayViewModel,
);
assert.equal(shellViewModel.createShellSessionHandoffPackageReport, createIniPanelShellSessionHandoffPackageReport);
assert.equal(shellViewModel.createShellSessionHandoffPackageSchema, createIniPanelShellSessionHandoffPackageSchema);
assert.equal(shellViewModel.isSupportedShellSessionHandoffPackage, isSupportedIniPanelShellSessionHandoffPackage);