Add React task frame bridge for manifest commands

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-11-13 16:46:09 +08:00
parent 452f0b976f
commit 4a45ffaf47
4 changed files with 35 additions and 32 deletions

View File

@@ -45,9 +45,10 @@
- 选中 BIM 后菜单显示 2D Drafting / 3D/BIM / Annotation / Manage / Flamingo / - 选中 BIM 后菜单显示 2D Drafting / 3D/BIM / Annotation / Manage / Flamingo /
Fasteners / Utils;截图 `BIM-web-menu.png`; Fasteners / Utils;截图 `BIM-web-menu.png`;
- Part 回归审计仍 0 错误/0 溢出。 - Part 回归审计仍 0 错误/0 溢出。
- 非 Part 菜单命令已接 `DesktopCommandDispatcher`:按 `command-matrix` 找记录、 - 非 Part 菜单命令改为打开 **React TaskFrame 模态**(`web/src/shell/task-frame.tsx`),
用空参数执行,状态栏显示 running/executed/error;20 秒超时提示改用工作台任务。 iframe 复用 `/workbench.html?module=<id>&command=<id>` 的现有任务面板;
BIM_TogglePanels 实测进入 running(该命令需要面板任务,尚需专用 React 桥)。 BIM_TogglePanels 实测弹出 "Bottom panels" 任务并可点按钮,0 pageError;
截图 `BIM-task-frame.png`。统一执行/文档共享仍待 P2 的原生任务桥。
- Python InitGui 解析改为位置感知变量解析(`self.*`、重赋值、`+` 拼接), - Python InitGui 解析改为位置感知变量解析(`self.*`、重赋值、`+` 拼接),
菜单命令 513、工具栏命令 362,gui-missing 降至 623。 菜单命令 513、工具栏命令 362,gui-missing 降至 623。
- 说明:preview 页仅渲染清单与命令回调;统一执行路由尚待 P2/P3。 - 说明:preview 页仅渲染清单与命令回调;统一执行路由尚待 P2/P3。

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View File

@@ -83,8 +83,7 @@ import { RecoveryController } from "./recovery-controller.js";
import { mountQueueRecoveryPanel } from "./queue-recovery-panel.js"; import { mountQueueRecoveryPanel } from "./queue-recovery-panel.js";
import { PartDesignWorkspace } from "./partdesign-workspace-component.js"; import { PartDesignWorkspace } from "./partdesign-workspace-component.js";
import { ParityWorkbenchMenu } from "./shell/workbench-menu.js"; import { ParityWorkbenchMenu } from "./shell/workbench-menu.js";
import { DesktopCommandDispatcher } from "./desktop-command-dispatcher.js"; import { TaskFrame } from "./shell/task-frame.js";
import type { WorkbenchCommandRecord } from "./workbench-command-facade.js";
import { DocumentTree, type DocumentTreeNode } from "./document-tree.js"; import { DocumentTree, type DocumentTreeNode } from "./document-tree.js";
import { PARTDESIGN_DOCUMENT_COMMAND, PARTDESIGN_DOCUMENT_SCHEMA, type DesignAction, type DesignPayload, type DesignResult } from "./partdesign-document-facade.js"; import { PARTDESIGN_DOCUMENT_COMMAND, PARTDESIGN_DOCUMENT_SCHEMA, type DesignAction, type DesignPayload, type DesignResult } from "./partdesign-document-facade.js";
@@ -313,8 +312,7 @@ function App() {
const [designSnapshots, setDesignSnapshots] = useState<Record<string, DesignResult>>({}); const [designSnapshots, setDesignSnapshots] = useState<Record<string, DesignResult>>({});
const [workbenches, setWorkbenches] = useState<Record<string, "Part" | "Sketcher" | "PartDesign" | "Spreadsheet" | "Surface" | "Assembly" | "Draft" | "Architecture" | "TechDraw" | "CAM">>(() => initialWorkbench ? { [initialDocumentId]: initialWorkbench } : {}); const [workbenches, setWorkbenches] = useState<Record<string, "Part" | "Sketcher" | "PartDesign" | "Spreadsheet" | "Surface" | "Assembly" | "Draft" | "Architecture" | "TechDraw" | "CAM">>(() => initialWorkbench ? { [initialDocumentId]: initialWorkbench } : {});
const workbench = workbenches[active] ?? "Part"; const workbench = workbenches[active] ?? "Part";
const desktopDispatcher = useRef<DesktopCommandDispatcher | null>(null); const [parityTask, setParityTask] = useState<{ module: string; command: string } | null>(null);
const desktopCommandRecords = useRef<Promise<Array<Record<string, unknown>>> | null>(null);
const [selectedSheets, setSelectedSheets] = useState<Record<string, string>>({}); const [selectedSheets, setSelectedSheets] = useState<Record<string, string>>({});
const [csvPanel, setCsvPanel] = useState<{ id: string; mode: "import" | "export"; selected?: string; done(result: Record<string, unknown>): void } | null>(null); const [csvPanel, setCsvPanel] = useState<{ id: string; mode: "import" | "export"; selected?: string; done(result: Record<string, unknown>): void } | null>(null);
const [sheetRanges, setSheetRanges] = useState<Record<string, string>>({}); const [sheetRanges, setSheetRanges] = useState<Record<string, string>>({});
@@ -1704,32 +1702,10 @@ function App() {
|| !!workspaceTask || !!viewCommand || !!csvPanel || !!workspaceTask || !!viewCommand || !!csvPanel
|| item.command === "Part_ColorPerFace" && (compoundSelection.length !== 1 || item.command === "Part_ColorPerFace" && (compoundSelection.length !== 1
|| !partSnapshots[active]?.objects?.some(object => object.name === compoundSelection[0] && object.topology?.Face && object.type !== "App::Link")); || !partSnapshots[active]?.objects?.some(object => object.name === compoundSelection[0] && object.topology?.Face && object.type !== "App::Link"));
const executeManifestCommand = async (command: string) => { const executeManifestCommand = (command: string) => {
if (!active) return; if (!active) return;
setStatus(`${command}: running`); setParityTask({ module: workbench, command });
try { setStatus(`${command}: opened React task frame`);
desktopDispatcher.current ??= new DesktopCommandDispatcher(router);
if (!desktopCommandRecords.current) {
desktopCommandRecords.current = fetch("/api/workbench-command-matrix.json").then(async response => {
if (!response.ok) throw new Error(`command matrix HTTP ${response.status}`);
const payload = await response.json() as { records?: WorkbenchCommandRecord[] };
return payload.records ?? [];
});
}
const records = await desktopCommandRecords.current as WorkbenchCommandRecord[];
const record = records.find(item => item.command === command
&& [workbench, "Web", "Std"].includes(item.module))
?? records.find(item => item.command === command);
if (!record) throw new Error("no command matrix record");
const response = await Promise.race([
desktopDispatcher.current.execute(record, {}, nativeName(active)),
new Promise<never>((_, reject) => setTimeout(() => reject(new Error("command timed out; open its workbench task")), 20000)),
]);
if (response.kind === "error") setStatus(`${command}: ${response.error.message}`);
else setStatus(`${command}: executed`);
} catch (error) {
setStatus(`${command}: ${String((error as Error)?.message ?? error)}`);
}
}; };
const activatePartAction = (item: PartUiAction) => { const activatePartAction = (item: PartUiAction) => {
@@ -3148,6 +3124,8 @@ function App() {
<div className="stat"><strong>Recent files</strong><small>{store.recent().length}</small></div> <div className="stat"><strong>Recent files</strong><small>{store.recent().length}</small></div>
{developerMode && <div className="stat"><strong>Checkpoint</strong><small>localStorage metadata only</small></div>} {developerMode && <div className="stat"><strong>Checkpoint</strong><small>localStorage metadata only</small></div>}
</aside>{referenceOpen && <DeltaReferencePanel onClose={() => setReferenceOpen(false)} />} </aside>{referenceOpen && <DeltaReferencePanel onClose={() => setReferenceOpen(false)} />}
{parityTask && <TaskFrame module={parityTask.module} command={parityTask.command}
onClose={() => setParityTask(null)} />}
{lineReferenceOpen && <LineReferencePanel onClose={() => setLineReferenceOpen(false)} />}</div><footer className="desktop-status-bar" aria-label="Status bar"><p role="status" data-import-phase={importPhase} className={`status ${response?.kind === "error" ? "error" : response?.kind === "result" ? "ok" : ""}`}>{status}</p></footer></PersistentToolbarWorkspace></div>; {lineReferenceOpen && <LineReferencePanel onClose={() => setLineReferenceOpen(false)} />}</div><footer className="desktop-status-bar" aria-label="Status bar"><p role="status" data-import-phase={importPhase} className={`status ${response?.kind === "error" ? "error" : response?.kind === "result" ? "ok" : ""}`}>{status}</p></footer></PersistentToolbarWorkspace></div>;
} }

View File

@@ -0,0 +1,24 @@
import React from "react";
export function TaskFrame({ module, command, onClose }: {
module: string;
command: string;
onClose: () => void;
}) {
const src = `/workbench.html?module=${encodeURIComponent(module)}&command=${encodeURIComponent(command)}`;
return <div className="parity-task-frame" role="dialog" aria-label={`${module} task: ${command}`}>
<style>{`
.parity-task-frame{position:fixed;inset:0;background:#000b;z-index:80;display:flex;align-items:center;justify-content:center;padding:20px}
.parity-task-frame>section{width:min(1280px,96vw);height:min(860px,92vh);background:#0f1419;border:1px solid #3f3f3f;border-radius:8px;display:flex;flex-direction:column;overflow:hidden}
.parity-task-frame header{display:flex;align-items:center;gap:10px;padding:8px 12px;background:#1b242c;border-bottom:1px solid #3f3f3f;color:#dbe6ee;font:13px system-ui,"Noto Sans SC",sans-serif}
.parity-task-frame header strong{font-size:13px}
.parity-task-frame header button{margin-left:auto;background:#2b2b2b;color:#dbe6ee;border:1px solid #555;border-radius:4px;padding:3px 10px;cursor:pointer}
.parity-task-frame iframe{flex:1;width:100%;border:0;background:#0f1419}
`}</style>
<section>
<header><strong>{module} · {command}</strong><span style={{ color: "#93a6b3" }}>任务桥(复用工作台任务面板)</span>
<button type="button" aria-label="Close task frame" onClick={onClose}>关闭</button></header>
<iframe title={`${module} ${command} task`} src={src} />
</section>
</div>;
}