推进 INI 面板 shell handoff snapshot API
This commit is contained in:
@@ -46,6 +46,27 @@
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.handoff-status {
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 12px;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.handoff-status dl {
|
||||
margin: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(120px, 180px) 1fr;
|
||||
gap: 6px 12px;
|
||||
font: 13px/1.4 "Segoe UI", "Noto Sans", sans-serif;
|
||||
}
|
||||
.handoff-status dt {
|
||||
color: var(--muted);
|
||||
}
|
||||
.handoff-status dd {
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
a {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
@@ -70,6 +91,10 @@
|
||||
<a data-entry-id="edit-run" href="./index.html">Open edit and run panel</a>
|
||||
<a data-entry-id="control-view" href="./control-page.html">Open read-only control view</a>
|
||||
</div>
|
||||
<section class="handoff-status" aria-label="Shell handoff compatibility">
|
||||
<p data-handoff-status>Checking shell handoff compatibility.</p>
|
||||
<dl data-handoff-rows></dl>
|
||||
</section>
|
||||
</section>
|
||||
</main>
|
||||
<script type="module">
|
||||
@@ -89,6 +114,18 @@
|
||||
link.textContent = linkModel.label;
|
||||
link.href = linkModel.href;
|
||||
}
|
||||
const handoffDisplay = shellViewModel.shellSessionHandoffDisplayViewModel;
|
||||
document.querySelector("[data-handoff-status]").textContent = `${handoffDisplay.statusText}: ${handoffDisplay.detailText}`;
|
||||
const handoffRows = document.querySelector("[data-handoff-rows]");
|
||||
for (const row of handoffDisplay.rows) {
|
||||
const term = document.createElement("dt");
|
||||
term.dataset.handoffRow = row.id;
|
||||
term.textContent = row.label;
|
||||
const detail = document.createElement("dd");
|
||||
detail.dataset.handoffValue = row.id;
|
||||
detail.textContent = row.value;
|
||||
handoffRows.append(term, detail);
|
||||
}
|
||||
|
||||
window.linuxCncIniPanelLaunchApi = {
|
||||
isSupportedLaunchApiManifest: isSupportedIniPanelLaunchApiManifest,
|
||||
@@ -97,7 +134,12 @@
|
||||
getShellIntegrationSchema: () => shellViewModel.shellIntegrationSchema,
|
||||
getShellIntegrationManifest: () => shellViewModel.shellIntegrationManifest,
|
||||
getShellIntegrationReadiness: () => shellViewModel.shellIntegrationReadiness,
|
||||
getShellSessionHandoffSummarySchema: () => shellViewModel.shellSessionHandoffSummarySchema,
|
||||
getShellSessionHandoffSummary: () => shellViewModel.shellSessionHandoffSummary,
|
||||
isSupportedShellSessionHandoffSummary: shellViewModel.isSupportedShellSessionHandoffSummary,
|
||||
getShellSessionHandoffCompatibilityReport: () => shellViewModel.shellSessionHandoffCompatibilityReport,
|
||||
getShellSessionHandoffDisplayViewModel: () => shellViewModel.shellSessionHandoffDisplayViewModel,
|
||||
getShellSessionHandoffSnapshot: () => shellViewModel.shellSessionHandoffSnapshot,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
};
|
||||
|
||||
@@ -126,7 +126,12 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
"getShellIntegrationSchema",
|
||||
"getShellIntegrationManifest",
|
||||
"getShellIntegrationReadiness",
|
||||
"getShellSessionHandoffSummarySchema",
|
||||
"getShellSessionHandoffSummary",
|
||||
"isSupportedShellSessionHandoffSummary",
|
||||
"getShellSessionHandoffCompatibilityReport",
|
||||
"getShellSessionHandoffDisplayViewModel",
|
||||
"getShellSessionHandoffSnapshot",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
],
|
||||
@@ -381,11 +386,44 @@ export function createIniPanelShellIntegrationWorkflowPlan({
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellSessionHandoffSummarySchema() {
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-summary",
|
||||
summaryVersion: 1,
|
||||
fields: [
|
||||
"apiName",
|
||||
"summaryVersion",
|
||||
"phase",
|
||||
"ready",
|
||||
"targetPage",
|
||||
"readiness",
|
||||
"persistenceCapabilities",
|
||||
"readonlyStatusFields",
|
||||
"handoffMethods",
|
||||
"blockingReasons",
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function isSupportedIniPanelShellSessionHandoffSummary(
|
||||
summary,
|
||||
schema = createIniPanelShellSessionHandoffSummarySchema(),
|
||||
) {
|
||||
if (!summary || typeof summary !== "object") {
|
||||
return false;
|
||||
}
|
||||
if (summary.apiName !== schema.apiName || summary.summaryVersion !== schema.summaryVersion) {
|
||||
return false;
|
||||
}
|
||||
return schema.fields.every((fieldName) => Object.hasOwn(summary, fieldName));
|
||||
}
|
||||
|
||||
export function createIniPanelShellSessionHandoffSummary({
|
||||
manifest = createIniPanelShellIntegrationManifest(),
|
||||
readiness = createIniPanelShellIntegrationReadiness(manifest),
|
||||
workflowPlan = createIniPanelShellIntegrationWorkflowPlan({ manifest, readiness }),
|
||||
} = {}) {
|
||||
const schema = createIniPanelShellSessionHandoffSummarySchema();
|
||||
const persistenceCapabilities = Array.isArray(manifest?.persistenceCapabilities)
|
||||
? manifest.persistenceCapabilities.map(({ id, label, scope }) => ({ id, label, scope }))
|
||||
: [];
|
||||
@@ -393,6 +431,8 @@ export function createIniPanelShellSessionHandoffSummary({
|
||||
? [...workflowPlan.readonlyStatusHandoff.expectedStatusFields]
|
||||
: [];
|
||||
return {
|
||||
apiName: schema.apiName,
|
||||
summaryVersion: schema.summaryVersion,
|
||||
phase: workflowPlan.ready ? "ready" : "blocked",
|
||||
ready: Boolean(workflowPlan.ready),
|
||||
targetPage: workflowPlan.targetPage,
|
||||
@@ -412,6 +452,107 @@ export function createIniPanelShellSessionHandoffSummary({
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellSessionHandoffCompatibilityReport(
|
||||
summary = createIniPanelShellSessionHandoffSummary(),
|
||||
schema = createIniPanelShellSessionHandoffSummarySchema(),
|
||||
) {
|
||||
const summaryObject = summary && typeof summary === "object" ? summary : {};
|
||||
const missingFields = schema.fields.filter((fieldName) => !Object.hasOwn(summaryObject, fieldName));
|
||||
const mismatchFields = [
|
||||
...(summaryObject.apiName === schema.apiName ? [] : ["apiName"]),
|
||||
...(summaryObject.summaryVersion === schema.summaryVersion ? [] : ["summaryVersion"]),
|
||||
];
|
||||
const summarySupported = missingFields.length === 0 && mismatchFields.length === 0;
|
||||
const blockingReasons = Array.isArray(summaryObject.blockingReasons)
|
||||
? [...summaryObject.blockingReasons]
|
||||
: [];
|
||||
const handoffReady = summarySupported && summaryObject.ready === true && blockingReasons.length === 0;
|
||||
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-compatibility-report",
|
||||
reportVersion: 1,
|
||||
phase: handoffReady ? "ready" : "blocked",
|
||||
compatible: handoffReady,
|
||||
summarySupported,
|
||||
handoffReady,
|
||||
schema: {
|
||||
apiName: schema.apiName,
|
||||
summaryVersion: schema.summaryVersion,
|
||||
fields: [...schema.fields],
|
||||
},
|
||||
summary: {
|
||||
apiName: summaryObject.apiName ?? null,
|
||||
summaryVersion: summaryObject.summaryVersion ?? null,
|
||||
phase: summaryObject.phase ?? null,
|
||||
ready: summaryObject.ready ?? false,
|
||||
},
|
||||
missingFields,
|
||||
mismatchFields,
|
||||
blockingReasons,
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellSessionHandoffDisplayViewModel(
|
||||
report = createIniPanelShellSessionHandoffCompatibilityReport(),
|
||||
) {
|
||||
const missingFields = Array.isArray(report?.missingFields) ? report.missingFields : [];
|
||||
const mismatchFields = Array.isArray(report?.mismatchFields) ? report.mismatchFields : [];
|
||||
const blockingReasons = Array.isArray(report?.blockingReasons) ? report.blockingReasons : [];
|
||||
const problems = [...missingFields, ...mismatchFields, ...blockingReasons];
|
||||
|
||||
return {
|
||||
phase: report?.phase === "ready" ? "ready" : "blocked",
|
||||
title: "Shell handoff compatibility",
|
||||
statusText: report?.compatible ? "Ready" : "Blocked",
|
||||
detailText: problems.length === 0 ? "No blocking reasons" : problems.join(", "),
|
||||
rows: [
|
||||
{
|
||||
id: "summary-supported",
|
||||
label: "Summary schema",
|
||||
value: report?.summarySupported ? "supported" : "blocked",
|
||||
},
|
||||
{
|
||||
id: "handoff-ready",
|
||||
label: "Handoff readiness",
|
||||
value: report?.handoffReady ? "ready" : "blocked",
|
||||
},
|
||||
{
|
||||
id: "missing-fields",
|
||||
label: "Missing fields",
|
||||
value: missingFields.length === 0 ? "none" : missingFields.join(", "),
|
||||
},
|
||||
{
|
||||
id: "mismatch-fields",
|
||||
label: "Mismatched fields",
|
||||
value: mismatchFields.length === 0 ? "none" : mismatchFields.join(", "),
|
||||
},
|
||||
{
|
||||
id: "blocking-reasons",
|
||||
label: "Blocking reasons",
|
||||
value: blockingReasons.length === 0 ? "none" : blockingReasons.join(", "),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellSessionHandoffSnapshot({
|
||||
readiness = createIniPanelShellIntegrationReadiness(),
|
||||
summary = createIniPanelShellSessionHandoffSummary(),
|
||||
compatibilityReport = createIniPanelShellSessionHandoffCompatibilityReport(summary),
|
||||
displayViewModel = createIniPanelShellSessionHandoffDisplayViewModel(compatibilityReport),
|
||||
} = {}) {
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-snapshot",
|
||||
snapshotVersion: 1,
|
||||
phase: compatibilityReport.phase,
|
||||
ready: Boolean(compatibilityReport.compatible),
|
||||
readiness,
|
||||
summary,
|
||||
compatibilityReport,
|
||||
displayViewModel,
|
||||
};
|
||||
}
|
||||
|
||||
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
|
||||
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
|
||||
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
|
||||
@@ -419,6 +560,23 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
manifest: shellIntegrationManifest,
|
||||
readiness: shellIntegrationReadiness,
|
||||
});
|
||||
const shellSessionHandoffSummary = createIniPanelShellSessionHandoffSummary({
|
||||
manifest: shellIntegrationManifest,
|
||||
readiness: shellIntegrationReadiness,
|
||||
workflowPlan: shellIntegrationWorkflowPlan,
|
||||
});
|
||||
const shellSessionHandoffCompatibilityReport = createIniPanelShellSessionHandoffCompatibilityReport(
|
||||
shellSessionHandoffSummary,
|
||||
);
|
||||
const shellSessionHandoffDisplayViewModel = createIniPanelShellSessionHandoffDisplayViewModel(
|
||||
shellSessionHandoffCompatibilityReport,
|
||||
);
|
||||
const shellSessionHandoffSnapshot = createIniPanelShellSessionHandoffSnapshot({
|
||||
readiness: shellIntegrationReadiness,
|
||||
summary: shellSessionHandoffSummary,
|
||||
compatibilityReport: shellSessionHandoffCompatibilityReport,
|
||||
displayViewModel: shellSessionHandoffDisplayViewModel,
|
||||
});
|
||||
return {
|
||||
pages: entries.map(({ id, href, title }) => ({
|
||||
id,
|
||||
@@ -430,17 +588,22 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
shellIntegrationManifest,
|
||||
shellIntegrationReadiness,
|
||||
shellIntegrationWorkflowPlan,
|
||||
shellSessionHandoffSummary: createIniPanelShellSessionHandoffSummary({
|
||||
manifest: shellIntegrationManifest,
|
||||
readiness: shellIntegrationReadiness,
|
||||
workflowPlan: shellIntegrationWorkflowPlan,
|
||||
}),
|
||||
shellSessionHandoffSummarySchema: createIniPanelShellSessionHandoffSummarySchema(),
|
||||
shellSessionHandoffSummary,
|
||||
shellSessionHandoffCompatibilityReport,
|
||||
shellSessionHandoffDisplayViewModel,
|
||||
shellSessionHandoffSnapshot,
|
||||
launchApiSchema: createIniPanelLaunchApiSchema(),
|
||||
launchApiManifest: createIniPanelLaunchApiManifest(entries),
|
||||
isSupportedShellIntegrationManifest: isSupportedIniPanelShellIntegrationManifest,
|
||||
createShellIntegrationReadiness: createIniPanelShellIntegrationReadiness,
|
||||
createShellIntegrationWorkflowPlan: createIniPanelShellIntegrationWorkflowPlan,
|
||||
isSupportedShellSessionHandoffSummary: isSupportedIniPanelShellSessionHandoffSummary,
|
||||
createShellSessionHandoffSummarySchema: createIniPanelShellSessionHandoffSummarySchema,
|
||||
createShellSessionHandoffSummary: createIniPanelShellSessionHandoffSummary,
|
||||
createShellSessionHandoffCompatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport,
|
||||
createShellSessionHandoffDisplayViewModel: createIniPanelShellSessionHandoffDisplayViewModel,
|
||||
createShellSessionHandoffSnapshot: createIniPanelShellSessionHandoffSnapshot,
|
||||
controlPage: {
|
||||
browserApiSchema: createControlPageBrowserApiSchema(),
|
||||
browserApiManifest: createControlPageBrowserApiManifest(),
|
||||
|
||||
Reference in New Issue
Block a user