Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7798853
editor i18n: the Chinese UI names things the way SolidWorks does
lizaixi01 Nov 29, 2026
824608e
docs(design): record why the editor's Chinese wording follows SolidWorks
lizaixi01 Nov 29, 2026
97522cb
editor i18n: an assembly component is 零部件, as in SolidWorks
lizaixi01 Dec 1, 2026
8989e25
editor: manual mode can be switched on for development with VITE_MANU…
lizaixi01 Nov 29, 2026
be3760e
fix(editor): redo keeps a cell's id after an undo renamed it
lizaixi01 Nov 29, 2026
5284f9d
fix(editor): a slider value kept into its params cell no longer break…
lizaixi01 Nov 29, 2026
4b3556b
fix(editor): the left panel never scrolls sideways
lizaixi01 Nov 29, 2026
654594a
feat(editor): export says where the files went, writes STEP and STL, …
lizaixi01 Nov 29, 2026
71a9d66
editor: the feature tree and notices speak a person's words (step num…
lizaixi01 Nov 29, 2026
ccb0231
editor: clicking the picked tree row again or the empty list clears t…
lizaixi01 Nov 29, 2026
4992fae
editor: every slider has a box to type its value in
lizaixi01 Nov 29, 2026
437950b
editor: the inspector measures what is picked (sizes, and between two…
lizaixi01 Nov 29, 2026
5ec3006
editor: the floating cards can be dragged out of each other's way and…
lizaixi01 Nov 29, 2026
c4d1193
editor: the feature tree's name and note tags are matched without Chi…
lizaixi01 Nov 30, 2026
061f1d9
editor i18n: the inspector's word for an assembly component is 零部件 too
lizaixi01 Dec 1, 2026
1ef7c83
fix(editor): an exported file with a non-ASCII name downloads (RFC 59…
lizaixi01 Dec 1, 2026
791bdfe
fix(editor): a long export error keeps its beginning ("STEP export fa…
lizaixi01 Dec 1, 2026
04e7668
fix(editor): closing the export dialog by its button forgets what was…
lizaixi01 Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions design-docs/editor-sw-terms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Editor wording follows SolidWorks (Chinese UI)

The editor's manual mode is used by people who learned CAD on SolidWorks. Where the editor named a thing differently, they
looked for the SolidWorks word and did not find it. The Chinese translation table (`editor-web/src/i18n/locales/zh-CN.json`)
now uses the SolidWorks Chinese terms. Only words a person reads changed: the SDK, the notebook code, the keys of the table and
everything an agent reads stay as they were, so the kernel stays agent-friendly.

| Thing | Was | Now (SolidWorks) |
|---|---|---|
| A plane to sketch on | 工作平面 | 基准面 |
| Sketch fully determined | 已求解 | 完全定义 |
| Sketch still free to move | 欠约束 N 自由度 | 欠定义(还有 N 个自由度) |
| Sketch over-determined | 冲突 | 过定义 |
| Sketch constraints (as a group) | 约束 | 几何关系/尺寸 |
| Automatic horizontal/vertical | 自动约束 | 自动添加几何关系 |
| Construction geometry | 构造线 | 构造几何线 |
| Mirror | 镜像 | 镜向 |
| Extrude that adds | 拉伸(合并) | 拉伸凸台 |
| Extrude that removes | 拉伸(切除) | 拉伸切除 |
| Push or pull a face | 推拉 | 移动面 |
| Hole on a face | 在此打孔 | 简单直孔 |
| An edge to pick | 边 | 边线 |
| Assembly joints | …约束 | …配合(铰链、滑块、齿轮、齿条小齿轮、皮带/链、锁定) |
| A part or sub-assembly placed in an assembly | 组件 | 零部件 |

Not changed on purpose:

- **基本体** (box, cylinder, …): SolidWorks has no primitives (it sketches and extrudes), so there is no word to copy.
- Behaviour that differs from SolidWorks (pick-kind chips instead of hover selection, connectors instead of face mates, no
rollback bar) is not a wording question; it is listed with the editor's open issues.

The SolidWorks terms are the ones its Chinese releases commonly use; a few may differ slightly between versions.
31 changes: 28 additions & 3 deletions editor-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { viewPose } from "@/lib/sketch-plane";
import * as THREE from "three";
import { addConnectorFrame, connectorFrameFromFace, setConnectorsCommand, setRef } from "@/lib/assembly";
import { useAssemblyEditor, useConnectorDraft } from "@/lib/useAssembly";
import { ExportDialog, type ExportState } from "@/components/ExportDialog";
import { Header } from "@/components/Header";
import { Inspector } from "@/components/Inspector";
import { SketchMode, type FaceCheck, type SketchAfter, type SketchSession } from "@/components/sketch/SketchMode";
Expand Down Expand Up @@ -90,7 +91,7 @@ const MANUAL_TABS = ["features", "assembly"];
const CODE_TABS = ["notebook", "module"];

export function App() {
useI18n(); // a change of language renders the whole editor again
const { language } = useI18n(); // a change of language renders the whole editor again
const viewRef = useRef<SceneView | null>(null);
// Whether a model of the open notebook is on screen (it may be the last run's,
// restored while the kernel boots): then nothing is being waited for.
Expand Down Expand Up @@ -137,6 +138,7 @@ export function App() {
const [currentPath, setCurrentPath] = useState<string | null>(null);
const [kernelAlive, setKernelAlive] = useState(false);
const [status, setStatus] = useState(() => t("Connecting…"));
const [exportState, setExportState] = useState<ExportState>(null);

const [params, setParams] = useState<ParamMeta[]>([]);
const [cells, setCells] = useState<NotebookCell[]>([]);
Expand Down Expand Up @@ -464,6 +466,8 @@ export function App() {
if (envelope["error"]) {
log.push("error", envelope["error"]);
setLoading(null);
const message = envelope["error"];
setExportState((current) => (current?.phase === "working" ? { phase: "error", message } : current));
}
} else if (typeof envelope["info"] === "string") {
setStatus(t(envelope["info"]));
Expand All @@ -476,6 +480,10 @@ export function App() {
} else if (typeof envelope["exported"] === "string") {
setStatus(t("exported {{path}}", { path: envelope["exported"] }));
log.push("ok", t("exported {{file}}", { file: envelope["exported"] }));
setLoading(null);
const dir = envelope["export_dir"];
const files = envelope["export_files"];
if (typeof dir === "string" && Array.isArray(files)) setExportState({ phase: "done", dir, files: files.map(String) });
} else if (typeof envelope["created"] === "string") {
setStatus(t("created {{path}}", { path: envelope["created"] }));
log.push("ok", t("created {{name}}", { name: envelope["created"] }));
Expand Down Expand Up @@ -1700,6 +1708,18 @@ export function App() {
[selection, livePickedSurfaces],
);
const inspectorPanel = <Inspector selection={selection} sketches={[...inspectedSketches, ...inspectedCurves, ...inspectedSurfaces]} />;
// the names the feature tree shows (# 名称:…, or the operation in the person's language), for notices about a step
const stepNames = useMemo(() => {
const names = new Map(cellTitles);
for (const feature of gui.state.features) {
const spec = feature.gui ? gui.catalog?.specs.find((item) => item.id === feature.gui?.spec) : undefined;
const name = feature.title || (spec ? t(plainLabel(spec.id, spec.label)) : "");
if (name) names.set(feature.cell, name);
}
return names;
// the names are translated: a change of language makes them again
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [cellTitles, gui.state.features, gui.catalog, language]);

return (
<div className="flex h-screen flex-col overflow-hidden">
Expand All @@ -1711,7 +1731,12 @@ export function App() {
status={status}
themePreference={theme.preference}
onTheme={theme.cycle}
onExport={() => {
setExportState({ phase: "working" });
socketRef.current?.send({ type: "export.request" });
}}
/>
<ExportDialog state={exportState} onClose={() => setExportState(null)} />
</div>
<div className="relative flex min-h-0 flex-1 flex-col">
<ResizablePanelGroup className="min-h-0 flex-1">
Expand Down Expand Up @@ -1739,7 +1764,7 @@ export function App() {
</Button>
))}
</div>
<div inert={moving} className="min-h-0 flex-1 overflow-hidden">
<div inert={moving} className="min-h-0 flex-1 overflow-clip">
{!MANUAL_MODE ? (
panelFor("code")
) : (
Expand Down Expand Up @@ -1901,7 +1926,7 @@ export function App() {
task={taskOpen}
locked={sketching || moving}
leftNotice={!taskOpen && viewRef.current ? <TagSplits docked view={viewRef.current} splits={tagSplits} sceneVersion={sceneVersion} /> : null}
rightNotice={partial && !sketching ? <PartialNotice docked partial={partial} titles={cellTitles} /> : null}
rightNotice={partial && !sketching ? <PartialNotice docked partial={partial} titles={stepNames} /> : null}
/>
)}
{sketchSession && viewRef.current && (
Expand Down
135 changes: 135 additions & 0 deletions editor-web/src/components/ExportDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { Check, Copy, Download, Loader2 } from "lucide-react";
import { useState } from "react";

import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { useI18n } from "@/i18n";

/** Where an export stands: being made, written (the folder and the file names), or failed. */
export type ExportState = { phase: "working" } | { phase: "done"; dir: string; files: string[] } | { phase: "error"; message: string } | null;

/** What each kind of file is for, in a person's words (English keys of the translation table). */
const PURPOSE: Record<string, string> = {
step: "STEP: opens in other CAD programs (SolidWorks, FreeCAD, Fusion 360)",
stl: "STL: for a 3D printer's slicer",
scadpkg: "SimpleCAD package: the full model with its history, for this SDK",
};

type SavePicker = (options: { suggestedName: string }) => Promise<{ createWritable: () => Promise<{ write: (data: Blob) => Promise<void>; close: () => Promise<void> }> }>;

/** Save one exported file where the person chooses: the system "save as" dialog where the browser has one, else a download. */
async function saveAs(name: string): Promise<"saved" | "downloaded" | "cancelled"> {
const picker = (window as unknown as { showSaveFilePicker?: SavePicker }).showSaveFilePicker;
if (picker) {
let handle;
try {
handle = await picker({ suggestedName: name });
} catch {
return "cancelled"; // the person closed the dialog
}
try {
const response = await fetch(`/api/export/file/${encodeURIComponent(name)}`);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const writable = await handle.createWritable();
await writable.write(await response.blob());
await writable.close();
return "saved";
} catch {
// some browsers (an embedded one) show the dialog but refuse the write: a plain download still works
}
}
const link = document.createElement("a");
link.href = `/api/export/file/${encodeURIComponent(name)}`;
link.download = name;
link.click();
return "downloaded";
}

/** The export dialog: it waits for the files, then says where they were written and offers "save as" for each. */
export function ExportDialog({ state, onClose }: { state: ExportState; onClose: () => void }) {
const { t } = useI18n();
const [copied, setCopied] = useState(false);
const [saved, setSaved] = useState<Record<string, string>>({});
const open = state !== null;
const copy = (text: string) => {
void navigator.clipboard?.writeText(text).then(() => {
setCopied(true);
window.setTimeout(() => setCopied(false), 1500);
});
};
const save = (name: string) => {
saveAs(name)
.then((outcome) => {
if (outcome === "saved") setSaved((s) => ({ ...s, [name]: t("Saved where you chose.") }));
if (outcome === "downloaded") setSaved((s) => ({ ...s, [name]: t("Downloaded: look in the browser's downloads (usually the Downloads folder).") }));
})
.catch(() => setSaved((s) => ({ ...s, [name]: t("Could not save it here. Use the folder above: the file is already there.") })));
};
// every way out (the close button, Esc, a click outside) forgets what was saved: the next export starts clean
const close = () => {
setSaved({});
onClose();
};
return (
<Dialog
open={open}
onOpenChange={(next) => {
if (!next) close();
}}
>
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>{t("Export")}</DialogTitle>
<DialogDescription>
{state?.phase === "working" && t("Making the files from the model; this takes a few seconds…")}
{state?.phase === "done" && t("The files were written to this folder (next to the notebook):")}
{state?.phase === "error" && t("The export failed:")}
</DialogDescription>
</DialogHeader>
{state?.phase === "working" && (
<div className="flex items-center gap-2 text-muted-foreground">
<Loader2 className="size-4 animate-spin" />
{t("building the package")}
</div>
)}
{state?.phase === "error" && <p className="whitespace-pre-wrap text-[12px] text-fail">{state.message}</p>}
{state?.phase === "done" && (
<div className="flex flex-col gap-3">
<div className="flex items-center gap-2 border-2 border-border px-2 py-1.5">
<code className="min-w-0 flex-1 break-all text-[12px]">{state.dir}</code>
<Button size="sm" variant="ghost" onClick={() => copy(state.dir)} title={t("Copy the folder path")}>
{copied ? <Check /> : <Copy />}
{copied ? t("copied") : t("Copy path")}
</Button>
</div>
<ul className="flex flex-col gap-2">
{state.files.map((name) => {
const kind = name.split(".").pop()?.toLowerCase() ?? "";
return (
<li key={name} className="flex flex-col gap-1">
<div className="flex items-center gap-2">
<div className="min-w-0 flex-1">
<div className="text-name">{name}</div>
{PURPOSE[kind] && <div className="text-[11px] text-muted-foreground">{t(PURPOSE[kind])}</div>}
</div>
<Button size="sm" variant="outline" className="shrink-0" onClick={() => save(name)}>
<Download />
{t("Save as…")}
</Button>
</div>
{saved[name] && <p className="text-[11px] text-pass">{saved[name]}</p>}
</li>
);
})}
</ul>
</div>
)}
<DialogFooter>
<Button size="sm" onClick={close}>
{t("Close")}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
Loading