Save desktop GUI build fixes patch
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
231
web/docs/current/desktop-gui-build-fixes.patch
Normal file
231
web/docs/current/desktop-gui-build-fixes.patch
Normal file
@@ -0,0 +1,231 @@
|
||||
From 00e0097969bfb0b0490525bbcee449a6a371e4c7 Mon Sep 17 00:00:00 2001
|
||||
From: wangdequan <wangdequan@meswork.com>
|
||||
Date: Sat, 14 Nov 2026 06:10:38 +0800
|
||||
Subject: [PATCH] Pause parity work: handoff, parameter sync, Python console
|
||||
scaffold
|
||||
|
||||
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
||||
---
|
||||
.../current/desktop-parity-continuation.md | 16 +++++++
|
||||
web/src/project-shell.tsx | 23 +++++++--
|
||||
web/src/shell/bottom-dock.tsx | 33 +++++++++----
|
||||
web/src/shell/preferences-dialog.tsx | 7 ++-
|
||||
web/src/shell/python-console.tsx | 48 +++++++++++++++++++
|
||||
5 files changed, 112 insertions(+), 15 deletions(-)
|
||||
create mode 100644 web/src/shell/python-console.tsx
|
||||
|
||||
diff --git a/web/docs/current/desktop-parity-continuation.md b/web/docs/current/desktop-parity-continuation.md
|
||||
index f08e5188..27e8fdde 100644
|
||||
--- a/web/docs/current/desktop-parity-continuation.md
|
||||
+++ b/web/docs/current/desktop-parity-continuation.md
|
||||
@@ -113,6 +113,22 @@
|
||||
- TemplatePyMod 选择后 workbenchValue 为空(特殊工作台);
|
||||
- 证据:`desktop-parity-evidence/<workbench>-web{,-audit}.png/json`。
|
||||
|
||||
+## 最新增量(2026-11-14,暂停前)
|
||||
+
|
||||
+- **PartDesign/Sketcher ownership handoff 已实现(真实动作)**:Part 文档切换到
|
||||
+ PartDesign/Sketcher 时不再只报错,而是调用 `launchSpecialized("ParametricBody")`
|
||||
+ 创建 PartDesign 拥有的新文档。实测选择 PartDesign 后 `workbench=PartDesign`,
|
||||
+ 状态栏 “PartDesign document created for PartDesign ownership handoff”。
|
||||
+- **原生参数同步**:Preferences `onApply` 通过 `requestOwnerParameters` 写入
|
||||
+ `BaseApp/Preferences/General/UnitSchema` 与 `View/NavigationStyle`;
|
||||
+ 后台验证因 5181 导航前置失败(exit 1)未完成,属于前置未满足。
|
||||
+- **Python 控制台**:`shell/python-console.tsx` 已加入底停靠 Python tab,
|
||||
+ 使用 `python-runtime.worker.ts`;首次冒烟返回 `ready` 错误包,**尚未验证成功执行**。
|
||||
+- **浮动/全屏停靠**:BottomDock 增加“浮动/停靠”“全屏”按钮;尚未截图验收。
|
||||
+- **Measure/MassProperties 原生桥**:命令面板/快捷键命中时直接打开原生任务,
|
||||
+ 实测 `Std_MassProperties` 状态为 “opened native measure task”。
|
||||
+- **命令面板**:默认包含 Web/Std/Show/Measure/Material,`Std_MassProperties` 可检索。
|
||||
+
|
||||
## 真实残余
|
||||
|
||||
- 统一桌面壳尚未实现:project-shell 仍只支持 9 个 workbench、菜单仅 Start/File/Edit/View/Part;
|
||||
diff --git a/web/src/project-shell.tsx b/web/src/project-shell.tsx
|
||||
index b3439bc4..c62ea14f 100644
|
||||
--- a/web/src/project-shell.tsx
|
||||
+++ b/web/src/project-shell.tsx
|
||||
@@ -76,7 +76,7 @@ import { DeltaReferencePanel, LineReferencePanel } from "./delta-reference-panel
|
||||
import type { MeshPayload } from "./worker-protocol.js";
|
||||
import { ImportRenderBridge } from "./import-render-bridge.js";
|
||||
import { registerTestMdiHost } from "./test-desktop-adapter.js";
|
||||
-import { navigationPreferenceSource, requestOwnerParameters, SPREADSHEET_PARAMETER_PATH } from "./view-navigation-preferences.js";
|
||||
+import { navigationPreferenceSource, requestOwnerParameters, GENERAL_PARAMETER_PATH, VIEW_PARAMETER_PATH, SPREADSHEET_PARAMETER_PATH } from "./view-navigation-preferences.js";
|
||||
import { IMPORT_DESKTOP_COMMANDS, importDesktopPayload, type ImportDesktopCommand } from "./import-desktop-adapter.js";
|
||||
import { readImportExportSettings } from "./import-export-preferences.js";
|
||||
import { RecoveryController } from "./recovery-controller.js";
|
||||
@@ -2005,7 +2005,11 @@ function App() {
|
||||
}
|
||||
if ((next === "Sketcher" || next === "PartDesign") && !designDocuments.current.has(active)) {
|
||||
if (nativeDocuments.current.has(active) || objects.length) {
|
||||
- setStatus("This Part document needs a native ownership handoff before editing in PartDesign. Create a new document for Sketcher/PartDesign."); return;
|
||||
+ setStatus(`Creating a PartDesign-owned document for ${next} ownership handoff…`);
|
||||
+ void launchSpecialized("ParametricBody").then(created => {
|
||||
+ if (created) setStatus(`PartDesign document created for ${next} ownership handoff`);
|
||||
+ });
|
||||
+ return;
|
||||
}
|
||||
designDocuments.current.add(active);
|
||||
}
|
||||
@@ -3201,7 +3205,20 @@ function App() {
|
||||
</aside>{referenceOpen && <DeltaReferencePanel onClose={() => setReferenceOpen(false)} />}
|
||||
{parityTask && <TaskFrame module={parityTask.module} command={parityTask.command}
|
||||
onClose={() => setParityTask(null)} />}
|
||||
- {preferencesOpen && <PreferencesDialog onClose={() => setPreferencesOpen(false)} />}
|
||||
+ {preferencesOpen && <PreferencesDialog onClose={() => setPreferencesOpen(false)} onApply={async preferences => {
|
||||
+ if (!active) return;
|
||||
+ const unitSchema = preferences.unitSystem.startsWith("MKS") ? 1
|
||||
+ : preferences.unitSystem.startsWith("Imperial") ? 3
|
||||
+ : preferences.unitSystem.startsWith("Building US") ? 7
|
||||
+ : preferences.unitSystem.startsWith("Building cm") ? 4 : 0;
|
||||
+ try {
|
||||
+ await requestOwnerParameters(router, "DocumentProbe", nativeName(active), { path: GENERAL_PARAMETER_PATH,
|
||||
+ operation: "set", name: "UnitSchema", type: "Int", value: unitSchema });
|
||||
+ await requestOwnerParameters(router, "DocumentProbe", nativeName(active), { path: VIEW_PARAMETER_PATH,
|
||||
+ operation: "set", name: "NavigationStyle", type: "String", value: preferences.navigationStyle });
|
||||
+ setStatus("Preferences synced to BaseApp/Preferences");
|
||||
+ } catch (error) { setStatus(`Preferences native sync failed: ${String((error as Error)?.message ?? error)}`); }
|
||||
+ }} />}
|
||||
{shortcutsOpen && <ShortcutEditor onClose={() => setShortcutsOpen(false)} />}
|
||||
{paletteOpen && <CommandPalette workbench={workbench} onCommand={executeManifestCommand} onClose={() => setPaletteOpen(false)} />}
|
||||
{bottomDockOpen && <BottomDock report={reportLog}
|
||||
diff --git a/web/src/shell/bottom-dock.tsx b/web/src/shell/bottom-dock.tsx
|
||||
index 81cc7b50..85bcc066 100644
|
||||
--- a/web/src/shell/bottom-dock.tsx
|
||||
+++ b/web/src/shell/bottom-dock.tsx
|
||||
@@ -1,30 +1,43 @@
|
||||
-import React, { useState } from "react";
|
||||
+import React, { useRef, useState } from "react";
|
||||
+import { PythonConsole } from "./python-console.js";
|
||||
|
||||
export function BottomDock({ selection, report, onClose }: {
|
||||
selection: string[];
|
||||
report: string[];
|
||||
onClose: () => void;
|
||||
}) {
|
||||
- const [tab, setTab] = useState<"selection" | "report">("selection");
|
||||
- return <section className="bottom-dock" aria-label="Bottom dock">
|
||||
+ const [tab, setTab] = useState<"selection" | "report" | "python">("selection");
|
||||
+ const [floating, setFloating] = useState(false);
|
||||
+ const section = useRef<HTMLElement>(null);
|
||||
+ const floatStyle = floating ? { left: "auto", right: 20, width: 560, height: 300, bottom: 46 } : undefined;
|
||||
+ return <section ref={section} className="bottom-dock" aria-label="Bottom dock" style={floatStyle}>
|
||||
<style>{`
|
||||
.bottom-dock{position:fixed;left:300px;right:300px;bottom:26px;height:180px;background:#17212b;border:1px solid #3f3f3f;border-radius:6px 6px 0 0;z-index:55;display:flex;flex-direction:column;color:#dbe6ee;font:12px/1.5 system-ui,"Noto Sans SC",sans-serif;box-shadow:0 -6px 20px #0006}
|
||||
+ .bottom-dock:fullscreen{left:0;right:0;top:0;bottom:0;height:100%;border-radius:0}
|
||||
.bottom-dock header{display:flex;align-items:center;gap:4px;padding:3px 6px;background:#1b242c;border-bottom:1px solid #3f3f3f}
|
||||
.bottom-dock header button{background:transparent;border:0;color:#93a6b3;padding:2px 8px;border-radius:3px;cursor:pointer;font-size:12px}
|
||||
.bottom-dock header button[aria-selected=true]{background:#29444b;color:#73c6d4}
|
||||
- .bottom-dock header .close{margin-left:auto}
|
||||
+ .bottom-dock header .right{margin-left:auto;display:flex;gap:2px}
|
||||
.bottom-dock .body{flex:1;overflow:auto;padding:5px 10px;font-family:ui-monospace,monospace;font-size:11.5px;color:#b9c7d0}
|
||||
.bottom-dock .body p{margin:2px 0}
|
||||
`}</style>
|
||||
<header>
|
||||
<button type="button" aria-selected={tab === "selection"} onClick={() => setTab("selection")}>Selection view</button>
|
||||
<button type="button" aria-selected={tab === "report"} onClick={() => setTab("report")}>Report view</button>
|
||||
- <button type="button" className="close" aria-label="Close bottom dock" onClick={onClose}>×</button>
|
||||
+ <button type="button" aria-selected={tab === "python"} onClick={() => setTab("python")}>Python console</button>
|
||||
+ <div className="right">
|
||||
+ <button type="button" aria-label="Toggle floating dock" aria-pressed={floating}
|
||||
+ onClick={() => setFloating(value => !value)}>{floating ? "停靠" : "浮动"}</button>
|
||||
+ <button type="button" aria-label="Toggle dock fullscreen"
|
||||
+ onClick={() => section.current?.requestFullscreen?.().catch(() => {})}>全屏</button>
|
||||
+ <button type="button" aria-label="Close bottom dock" onClick={onClose}>×</button>
|
||||
+ </div>
|
||||
</header>
|
||||
- <div className="body" role="tabpanel" aria-label={tab === "selection" ? "Selection view" : "Report view"}>
|
||||
- {tab === "selection"
|
||||
- ? (selection.length ? selection.map(item => <p key={item}>{item}</p>) : <p>No selection</p>)
|
||||
- : (report.length ? report.map((item, index) => <p key={`${index}-${item.slice(0, 12)}`}>{item}</p>) : <p>No messages</p>)}
|
||||
- </div>
|
||||
+ {tab === "python" ? <div className="body" role="tabpanel" aria-label="Python console"><PythonConsole /></div>
|
||||
+ : <div className="body" role="tabpanel" aria-label={tab === "selection" ? "Selection view" : "Report view"}>
|
||||
+ {tab === "selection"
|
||||
+ ? (selection.length ? selection.map(item => <p key={item}>{item}</p>) : <p>No selection</p>)
|
||||
+ : (report.length ? report.map((item, index) => <p key={`${index}-${item.slice(0, 12)}`}>{item}</p>) : <p>No messages</p>)}
|
||||
+ </div>}
|
||||
</section>;
|
||||
}
|
||||
diff --git a/web/src/shell/preferences-dialog.tsx b/web/src/shell/preferences-dialog.tsx
|
||||
index 4f504cac..fda35e87 100644
|
||||
--- a/web/src/shell/preferences-dialog.tsx
|
||||
+++ b/web/src/shell/preferences-dialog.tsx
|
||||
@@ -24,7 +24,7 @@ export const loadWebPreferences = (): WebPreferences => {
|
||||
}
|
||||
};
|
||||
|
||||
-export function PreferencesDialog({ onClose }: { onClose: () => void }) {
|
||||
+export function PreferencesDialog({ onClose, onApply }: { onClose: () => void; onApply?: (preferences: WebPreferences) => void | Promise<void> }) {
|
||||
const [preferences, setPreferences] = useState<WebPreferences>(loadWebPreferences);
|
||||
const hydrated = useRef(false);
|
||||
useEffect(() => {
|
||||
@@ -35,7 +35,10 @@ export function PreferencesDialog({ onClose }: { onClose: () => void }) {
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
localStorage.setItem(KEY, JSON.stringify(preferences));
|
||||
- if (hydrated.current) void saveSettings("web-preferences.json", preferences);
|
||||
+ if (hydrated.current) {
|
||||
+ void saveSettings("web-preferences.json", preferences);
|
||||
+ void onApply?.(preferences);
|
||||
+ }
|
||||
window.dispatchEvent(new Event("freecad-preferences-changed"));
|
||||
}, [preferences]);
|
||||
const update = <K extends keyof WebPreferences>(key: K, value: WebPreferences[K]) =>
|
||||
diff --git a/web/src/shell/python-console.tsx b/web/src/shell/python-console.tsx
|
||||
new file mode 100644
|
||||
index 00000000..f670419e
|
||||
--- /dev/null
|
||||
+++ b/web/src/shell/python-console.tsx
|
||||
@@ -0,0 +1,48 @@
|
||||
+import React, { useEffect, useState } from "react";
|
||||
+import { createPythonRuntimeRequest, type PythonRuntimeResponse } from "../python-runtime-facade.js";
|
||||
+import { createCancel } from "../facade-envelope.js";
|
||||
+
|
||||
+export function PythonConsole() {
|
||||
+ const [expression, setExpression] = useState("6 * 7");
|
||||
+ const [response, setResponse] = useState<PythonRuntimeResponse | null>(null);
|
||||
+ const [status, setStatus] = useState("正在加载 Python WASM runtime…");
|
||||
+ const [ready, setReady] = useState(false);
|
||||
+ const [running, setRunning] = useState<string | null>(null);
|
||||
+ const [worker] = useState(() => new Worker(new URL("../python-runtime.worker.ts", import.meta.url), { type: "module" }));
|
||||
+ useEffect(() => {
|
||||
+ worker.onmessage = (event: MessageEvent<PythonRuntimeResponse | { kind: "ready"; action: string } | { kind: "reset"; requestId: string }>) => {
|
||||
+ const message = event.data;
|
||||
+ if (message.kind === "ready") { setReady(true); setStatus("Python WASM runtime ready"); return; }
|
||||
+ if (message.kind === "reset") { setResponse(null); setRunning(null); setStatus("Python runtime reset"); return; }
|
||||
+ setResponse(message); setRunning(null);
|
||||
+ setStatus(message.kind === "result" ? "Python expression complete" : message.error.code);
|
||||
+ };
|
||||
+ return () => worker.terminate();
|
||||
+ }, [worker]);
|
||||
+ const run = () => {
|
||||
+ if (!ready || !expression.trim()) return;
|
||||
+ const requestId = `shell-python-${Date.now()}`;
|
||||
+ setRunning(requestId); setStatus("Executing Python expression…");
|
||||
+ worker.postMessage(createPythonRuntimeRequest(requestId, { schema: "freecad-web-python/runtime-eval/v1", module: "Python", action: "eval", expression }));
|
||||
+ };
|
||||
+ return <div className="python-console" aria-label="Python console">
|
||||
+ <style>{`
|
||||
+ .python-console{display:flex;flex-direction:column;gap:6px;height:100%;font:12px ui-monospace,monospace;color:#dbe6ee}
|
||||
+ .python-console textarea{min-height:54px;resize:vertical;background:#0b1014;color:#dbe6ee;border:1px solid #3f3f3f;border-radius:4px;padding:6px}
|
||||
+ .python-console .row{display:flex;align-items:center;gap:8px}
|
||||
+ .python-console button{background:#2b2b2b;color:#dbe6ee;border:1px solid #555;border-radius:4px;padding:3px 9px;cursor:pointer}
|
||||
+ .python-console .result{flex:1;overflow:auto;white-space:pre-wrap;color:#9fd6de}
|
||||
+ .python-console .status{color:#93a6b3}
|
||||
+ `}</style>
|
||||
+ <textarea aria-label="Python expression" value={expression}
|
||||
+ onChange={event => setExpression(event.target.value)}
|
||||
+ onKeyDown={event => { if ((event.ctrlKey || event.metaKey) && event.key === "Enter") { event.preventDefault(); run(); } }} />
|
||||
+ <div className="row">
|
||||
+ <button type="button" disabled={!ready || !!running} onClick={run}>执行</button>
|
||||
+ <button type="button" disabled={!running} onClick={() => running && worker.postMessage(createCancel(`cancel-${Date.now()}`, running, "shell-python"))}>取消</button>
|
||||
+ <button type="button" disabled={!ready} onClick={() => worker.postMessage({ kind: "reset", requestId: `reset-${Date.now()}` })}>重置</button>
|
||||
+ <span className="status">{status}</span>
|
||||
+ </div>
|
||||
+ <div className="result">{response ? JSON.stringify(response, null, 2) : "等待 Python 结果"}</div>
|
||||
+ </div>;
|
||||
+}
|
||||
--
|
||||
2.43.0
|
||||
|
||||
Reference in New Issue
Block a user