Dispatch manifest workbench commands through desktop router
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,10 @@
|
||||
- Workbench 选择器扩展到 29 个模块(Part 保持原有 `PartWorkbenchMenu`);
|
||||
- 选中 BIM 后菜单显示 2D Drafting / 3D/BIM / Annotation / Manage / Flamingo /
|
||||
Fasteners / Utils;截图 `BIM-web-menu.png`;
|
||||
- Part 回归审计仍 0 错误/0 溢出;命令点击当前只写状态(execution wiring pending)。
|
||||
- Part 回归审计仍 0 错误/0 溢出。
|
||||
- 非 Part 菜单命令已接 `DesktopCommandDispatcher`:按 `command-matrix` 找记录、
|
||||
用空参数执行,状态栏显示 running/executed/error;20 秒超时提示改用工作台任务。
|
||||
BIM_TogglePanels 实测进入 running(该命令需要面板任务,尚需专用 React 桥)。
|
||||
- Python InitGui 解析改为位置感知变量解析(`self.*`、重赋值、`+` 拼接),
|
||||
菜单命令 513、工具栏命令 362,gui-missing 降至 623。
|
||||
- 说明:preview 页仅渲染清单与命令回调;统一执行路由尚待 P2/P3。
|
||||
|
||||
@@ -83,6 +83,8 @@ import { RecoveryController } from "./recovery-controller.js";
|
||||
import { mountQueueRecoveryPanel } from "./queue-recovery-panel.js";
|
||||
import { PartDesignWorkspace } from "./partdesign-workspace-component.js";
|
||||
import { ParityWorkbenchMenu } from "./shell/workbench-menu.js";
|
||||
import { DesktopCommandDispatcher } from "./desktop-command-dispatcher.js";
|
||||
import type { WorkbenchCommandRecord } from "./workbench-command-facade.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";
|
||||
|
||||
@@ -311,6 +313,8 @@ function App() {
|
||||
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 workbench = workbenches[active] ?? "Part";
|
||||
const desktopDispatcher = useRef<DesktopCommandDispatcher | null>(null);
|
||||
const desktopCommandRecords = useRef<Promise<Array<Record<string, unknown>>> | null>(null);
|
||||
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 [sheetRanges, setSheetRanges] = useState<Record<string, string>>({});
|
||||
@@ -1700,6 +1704,34 @@ function App() {
|
||||
|| !!workspaceTask || !!viewCommand || !!csvPanel
|
||||
|| item.command === "Part_ColorPerFace" && (compoundSelection.length !== 1
|
||||
|| !partSnapshots[active]?.objects?.some(object => object.name === compoundSelection[0] && object.topology?.Face && object.type !== "App::Link"));
|
||||
const executeManifestCommand = async (command: string) => {
|
||||
if (!active) return;
|
||||
setStatus(`${command}: running`);
|
||||
try {
|
||||
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) => {
|
||||
if (partActionDisabled(item)) return;
|
||||
resetTaskDrafts(); setViewCommand(""); setPartTaskMode(item); setRetainedPartResponse(null);
|
||||
@@ -1895,7 +1927,7 @@ function App() {
|
||||
</div></details>
|
||||
{workbench === "Part" && <PartWorkbenchMenu disabled={partActionDisabled} activate={activatePartAction} currentTask={workspaceTask} />}
|
||||
{workbench !== "Part" && <ParityWorkbenchMenu workbench={workbench}
|
||||
onCommand={command => setStatus(`${command}: selected (desktop menu; execution wiring pending)`)} />}
|
||||
onCommand={command => void executeManifestCommand(command)} />}
|
||||
{workbench !== "Part" && <WorkbenchParityMenu workbench={workbench} />}
|
||||
</nav>
|
||||
<PersistentToolbarWorkspace router={router} documentId={nativeName(active || initialDocumentId)} workbench={workbench}>
|
||||
|
||||
Reference in New Issue
Block a user