Merge branch 'worktree-agent-ac19ea2d9f670cb36' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-16 10:53:37 +00:00
commit 9f196afcdd
22 files changed
+643 -30

No files matched your search

+12
View File
@@ -69,6 +69,7 @@ import {
useObjectSettingsShortcut,
useCloseObjectSettingsOnEscape,
useFitShortcuts,
useFileShortcuts,
useUndoRedoShortcut,
} from "./state/useKeyboardShortcuts";
import { registerSelectionActions } from "./state/selectionActions";
@@ -386,12 +387,21 @@ export default function App() {
// Projektdatei-I/O (Speichern/Öffnen/Lock), Schnellexport (CSV/IFC/OBJ/STL)
// und die Ausführung eines bestätigten DXF/DWG-Imports — gebündelt in
// useProjectFileActions(), siehe dort.
// [170] Electron: `dossier datei.obp` / Doppelklick — direkt in den Editor, auch wenn noch Splash/Startbildschirm stehen.
const bootPhaseRef = useRef(bootPhase);
bootPhaseRef.current = bootPhase;
const launchFileOpened = () => {
const wasBooting = bootPhaseRef.current !== "editor";
if (wasBooting) setBootPhase("editor");
return { wasBooting };
};
const files = useProjectFileActions(
setImportState,
setExportSaveFormat,
activeCategoryCode,
setActiveLevelId,
planViewRef,
launchFileOpened,
);
const {
projectFileInputRef, projectTemplateFileInputRef, openImportForFile, onSaveProject, onSaveProjectAs, onRestoreBackup,
@@ -575,6 +585,7 @@ export default function App() {
const fitSelectionKey = () => (planViewRef.current ? planViewRef.current.fitSelection() : fitView3d());
registerSelectionActions({ fitAll: fitAllKey, fitSelection: fitSelectionKey });
useFitShortcuts(fitAllKey, fitSelectionKey, shortcutOverrides);
useFileShortcuts({ save: onSaveProject, saveAs: onSaveProjectAs, open: onOpenProject }); // [170] ohne natives Menü
// Papier-Massstab anwenden: gewählten Nenner merken UND den Plan-Zoom exakt
// auf 1:N setzen (PlanView rechnet die viewBox aus N + Canvas + dpi).
const applyScale = (n: number) => {
@@ -710,6 +721,7 @@ export default function App() {
onImport: () => dxfInputRef.current?.click(),
onImportPointCloud: () => openPointCloudFileDialog(),
onImportMesh: () => openMeshFileDialog(),
onOpenExportPdf: () => setExportOpen(true), // [170] Browser/Electron: Plan als PDF/SVG (sonst nur im nativen Menü)
onOpenExportDxf: () => setExportDxfOpen(true),
onExportIfc,
onExportObj,
+78
View File
@@ -0,0 +1,78 @@
// [170] Linux-Paket (electron-builder): alles, was der Electron-Hauptprozess zur Laufzeit lädt, muss im Paket stehen.
// Befund 16.11.: `scripts/electron-files.cjs` ([116]) fehlte in `files` — das AppImage startete gar nicht
// („Cannot find module './electron-files.cjs'“). Dazu: Buildnummer ([261]) aus dem gebauten `dist` ins Paket.
import { describe, expect, it } from "vitest";
import { createRequire } from "node:module";
import { readFileSync, mkdtempSync, writeFileSync, rmSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
const root = join(__dirname, "..", "..");
const read = (rel: string) => readFileSync(join(root, rel), "utf8");
/** Einträge der Liste `files:` in electron-builder.yml (eine Zeile ` - muster` je Eintrag). */
function packagedFiles(): string[] {
const lines = read("electron-builder.yml").split("\n");
const start = lines.findIndex((l) => /^files:\s*$/.test(l));
expect(start, "files: in electron-builder.yml").toBeGreaterThanOrEqual(0);
const out: string[] = [];
for (const l of lines.slice(start + 1)) {
const m = /^\s+-\s+"?([^"#]+?)"?\s*(#.*)?$/.exec(l);
if (!m) break;
out.push(m[1]);
}
return out;
}
/** Relative `require("./…")` eines Skripts, rekursiv (nur scripts/*.cjs). */
function localRequires(rel: string, seen = new Set<string>()): Set<string> {
if (seen.has(rel)) return seen;
seen.add(rel);
for (const m of read(rel).matchAll(/require\(\s*["']\.\/([^"']+)["']\s*\)/g)) localRequires(`scripts/${m[1]}`, seen);
return seen;
}
describe("[170] electron-builder: Paketinhalt", () => {
it("jedes vom Hauptprozess und Preload geladene Skript ist im Paket", () => {
const files = new Set(packagedFiles());
const needed = new Set([...localRequires("scripts/electron-main.cjs"), ...localRequires("scripts/electron-preload.cjs")]);
const missing = [...needed].filter((f) => !files.has(f));
expect(missing).toEqual([]);
});
it("Preload-Pfad und Einstieg zeigen auf Dateien im Paket", () => {
const files = new Set(packagedFiles());
expect(read("scripts/electron-main.cjs")).toMatch(/preload: path\.join\(__dirname, "electron-preload\.cjs"\)/);
expect(files.has("scripts/electron-preload.cjs")).toBe(true);
expect(read("electron-builder.yml")).toMatch(/^\s+main: scripts\/electron-main\.cjs$/m);
expect(files.has("dist/**")).toBe(true);
});
});
const { packConfig, readDistBuild } = createRequire(import.meta.url)("../../scripts/electron-pack.cjs") as {
packConfig: (build: string, version?: string) => { extends: string; buildVersion: unknown; extraMetadata: Record<string, unknown> };
readDistBuild: (distDir: string) => { version: string; build: string } | null;
};
describe("[170][261] Buildnummer im Linux-Paket", () => {
it("electron-builder bekommt die Buildnummer als Zeichenkette (buildVersion + Metadaten), erbt electron-builder.yml", () => {
// Befund 16.11.: über `-c.extraMetadata.dossierBuild=261116.10` machte die Kommandozeile daraus die Zahl 261116.1.
const c = packConfig("261116.10");
expect(c.extends).toBe("./electron-builder.yml");
expect(c.buildVersion).toBe("261116.10");
expect(c.extraMetadata).toEqual({ dossierBuild: "261116.10" });
// Release aus dem Tag: Version überschreibt die aus package.json.
expect(packConfig("261116.3", "1.0.0").extraMetadata).toEqual({ dossierBuild: "261116.3", version: "1.0.0" });
});
it("Buildnummer kommt aus dem gebauten dist (build-info.json), nicht neu berechnet", () => {
const dir = mkdtempSync(join(tmpdir(), "dossier-dist-"));
try {
expect(readDistBuild(dir)).toBeNull();
writeFileSync(join(dir, "build-info.json"), JSON.stringify({ version: "1.0.0-beta.1", build: "261116.2" }));
expect(readDistBuild(dir)).toEqual({ version: "1.0.0-beta.1", build: "261116.2" });
writeFileSync(join(dir, "build-info.json"), JSON.stringify({ version: "1.0.0-beta.1", build: "kaputt" }));
expect(readDistBuild(dir)).toBeNull();
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
});
+19
View File
@@ -3,6 +3,7 @@ import { setLanguage } from "../i18n";
import {
comboFromEvent,
comboMatches,
fileShortcutFor,
findConflict,
formatCombo,
isReservedCombo,
@@ -201,3 +202,21 @@ describe("[252] tabKeyAction", () => {
expect(tabKeyAction(ev({ key: "a", ctrlKey: true }))).toBeNull();
});
});
describe("[170] Datei-Kürzel ausserhalb von Tauri (Browser/Electron-Linux)", () => {
it("Strg/Cmd+S speichert, +Umschalt speichert unter, Strg/Cmd+O öffnet", () => {
expect(fileShortcutFor(key("s", { ctrlKey: true }))).toBe("save");
expect(fileShortcutFor(key("s", { metaKey: true }))).toBe("save");
expect(fileShortcutFor(key("S", { ctrlKey: true, shiftKey: true }))).toBe("saveAs");
expect(fileShortcutFor(key("o", { ctrlKey: true }))).toBe("open");
});
it("ohne Strg/Cmd oder mit Alt: nichts (s = Spiegeln bleibt frei)", () => {
expect(fileShortcutFor(key("s"))).toBeNull();
expect(fileShortcutFor(key("s", { ctrlKey: true, altKey: true }))).toBeNull();
expect(fileShortcutFor(key("o", { ctrlKey: true, shiftKey: true }))).toBeNull();
});
it("kollidiert mit keinem belegbaren Kürzel", () => {
const combos = SHORTCUT_DEFS.map((d) => d.defaultCombo);
for (const c of ["mod+s", "mod+shift+s", "mod+o"]) expect(combos).not.toContain(c);
});
});
+15
View File
@@ -323,6 +323,21 @@ export function comboMatches(e: KeyboardEvent, combo: string): boolean {
return k === key;
}
/** [170] Datei-Kürzel ausserhalb von Tauri. */
export type FileShortcut = "save" | "saveAs" | "open";
/**
* [170] Strg/Cmd+S, Strg/Cmd+Umschalt+S, Strg/Cmd+O im Browser und in der Linux-App (Electron, ohne native Menüleiste).
* Unter Tauri liefert das native Menü dieselben Kürzel (`native/appMenu.ts`, Accelerator) — dort nicht verwenden.
* Fest wie die Menü-Accelerators, nicht umbelegbar (nicht in {@link SHORTCUT_DEFS}).
*/
export function fileShortcutFor(e: KeyboardEvent): FileShortcut | null {
if (comboMatches(e, "mod+shift+s")) return "saveAs";
if (comboMatches(e, "mod+s")) return "save";
if (comboMatches(e, "mod+o")) return "open";
return null;
}
/** Kurzform: matcht `e` gegen die (übersteuerte oder Default-)Kombination von `id`. */
export function matchesShortcut(
e: KeyboardEvent,
+22 -1
View File
@@ -32,7 +32,8 @@ import {
} from "../editors/elementClipboard";
import type { ElementClipboard, ElementSelectionIds, PastedIds } from "../editors/elementClipboard";
import { parseClipboardText, serializeClipboardText } from "../editors/elementClipboardSerialize";
import { matchesShortcut, tabKeyAction, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
import { fileShortcutFor, matchesShortcut, tabKeyAction, type FileShortcut, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
import { isTauriRuntime } from "../native/projectFile";
import { isolateSelectionLayerCodes, showAllLayerCodes } from "./layerIsolate";
import { isInModalDialog } from "./modalScope";
import { toggleTraceAction } from "./traceActions";
@@ -751,3 +752,23 @@ export function useFitShortcuts(fitAll: () => void, fitSelection: () => void, ov
return () => window.removeEventListener("keydown", onKey);
}, [overrides]);
}
/**
* [170] Strg/Cmd+S (Speichern), +Umschalt (Speichern unter), Strg/Cmd+O (Öffnen) im Browser und in der Linux-App (Electron hat
* keine native Menüleiste). Unter Tauri übernimmt das native Menü (Accelerator) — dort nichts tun. Nicht in modalen Dialogen.
*/
export function useFileShortcuts(handlers: Record<FileShortcut, () => void>): void {
const ref = useRef(handlers);
ref.current = handlers;
useEffect(() => {
if (isTauriRuntime()) return;
const onKey = (e: KeyboardEvent) => {
const action = fileShortcutFor(e);
if (!action || isInModalDialog(e.target)) return;
e.preventDefault();
ref.current[action]();
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, []);
}
+19 -4
View File
@@ -119,6 +119,12 @@ export function useProjectFileActions(
activeCategoryCode: string,
setActiveLevelId: (id: string) => void,
planViewRef: RefObject<PlanViewHandle | null>,
/**
* [170] Electron: eine per Argument/Doppelklick übergebene Datei ist angekommen. Der Aufrufer wechselt in den Editor
* (sonst bliebe der Startbildschirm davor) und meldet, ob die App noch im Startablauf war — dann gibt es nichts zu
* verwerfen und die Rückfrage „Ungespeicherte Änderungen" entfällt.
*/
onLaunchFile?: () => { wasBooting: boolean },
) {
// Verstecktes Datei-Input zum Laden eines Projekts (Datei-Burger „Öffnen").
// Wird NUR im Browser-Pfad benutzt (ohne Tauri) — unter Tauri geht „Öffnen"
@@ -760,7 +766,7 @@ export function useProjectFileActions(
}
};
const onProjectFileChosen = (file: File, knownPath?: string | null) => {
const onProjectFileChosen = (file: File, knownPath?: string | null, askDiscard = true) => {
const r = new FileReader();
r.onload = () => {
const content = String(r.result ?? "");
@@ -768,14 +774,16 @@ export function useProjectFileActions(
const path = knownPath ?? electronFiles()?.pathForFile(file) ?? null;
// Browser-Pfad hat keinen echten Dateipfad → kein Lock für die neue
// Datei, aber ein evtl. vorher (unter Tauri) gehaltener Lock wird frei.
guardDiscard(() => {
const apply = () => {
const loaded = openOrOfferBackup(content, path, false);
if (!loaded) return;
releaseCurrentProjectLock();
lastSavedProjectRef.current = loaded;
if (path) savePathRef.current = path;
setAnonymityProjectFileName(path ?? file.name); // [208] Browser/Electron-Start: kein Pfad, aber der Dateiname
});
};
if (askDiscard) guardDiscard(apply);
else apply();
};
r.onerror = () => notify(`${t("project.open.failed")} ${r.error?.message ?? ""}`, "error");
r.readAsText(file);
@@ -783,12 +791,19 @@ export function useProjectFileActions(
// [170] Electron: per Kommandozeile/Doppelklick übergebene .obp (beim Start und von einer zweiten
// Instanz) wie eine im Browser gewählte Datei öffnen. Der Ref hält die jeweils aktuelle Fassung.
// Kommt die Datei noch im Startablauf (Splash/Startbildschirm), wechselt `onLaunchFile` in den Editor ([170], Befund 16.11.:
// vorher wurde die Datei hinter dem Startbildschirm geladen bzw. wartete auf eine Rückfrage, die dort nicht angezeigt wird).
const chosenRef = useRef(onProjectFileChosen);
chosenRef.current = onProjectFileChosen;
const launchRef = useRef(onLaunchFile);
launchRef.current = onLaunchFile;
useEffect(() => {
const api = window.dossierLaunch;
if (!api) return;
const open = (f: LaunchProject) => chosenRef.current(new File([f.text], f.name), f.path);
const open = (f: LaunchProject) => {
const wasBooting = launchRef.current?.().wasBooting ?? false;
chosenRef.current(new File([f.text], f.name), f.path, !wasBooting);
};
void api.takeOpenFile().then((f) => f && open(f));
return api.onOpenFile(open);
}, []);
+4 -1
View File
@@ -33,6 +33,7 @@ export interface AppMenuBarProps {
onImportPointCloud?: () => void;
onImportMesh?: () => void;
/** Datei: Export-Dialoge (im Browser/Electron die einzige Quelle — das native Menü gibt es nur unter Tauri). */
onExportPdf?: () => void;
onExportDxf?: () => void;
onExportIfc?: () => void;
onExportObj?: () => void;
@@ -79,6 +80,7 @@ export const AppMenuBar = memo(function AppMenuBar({
onImport,
onImportPointCloud,
onImportMesh,
onExportPdf,
onExportDxf,
onExportIfc,
onExportObj,
@@ -116,7 +118,8 @@ export const AppMenuBar = memo(function AppMenuBar({
{ label: t("file.import"), onSelect: onImport },
...(onImportPointCloud ? [{ label: t("menu.native.importPointCloud"), onSelect: onImportPointCloud }] : []),
...(onImportMesh ? [{ label: t("menu.native.importMesh"), onSelect: onImportMesh }] : []),
...(onExportDxf || onExportIfc || onExportObj || onExportStl ? [{ divider: true }] : []),
...(onExportPdf || onExportDxf || onExportIfc || onExportObj || onExportStl ? [{ divider: true }] : []),
...(onExportPdf ? [{ label: `${t("menu.native.export")}: PDF`, onSelect: onExportPdf }] : []),
...(onExportDxf ? [{ label: `${t("menu.native.export")}: DXF`, onSelect: onExportDxf }] : []),
...(onExportIfc ? [{ label: `${t("menu.native.export")}: IFC`, onSelect: onExportIfc }] : []),
...(onExportObj ? [{ label: `${t("menu.native.export")}: OBJ`, onSelect: onExportObj }] : []),
+2
View File
@@ -47,6 +47,7 @@ export type TopBarEvents = Required<
| "onOpenHistory"
>
> & {
onOpenExportPdf: () => void;
onOpenExportDxf: () => void;
applyScale: ViewRibbonTabProps["onApplyScale"];
fitPlan: ViewRibbonTabProps["onFit"];
@@ -139,6 +140,7 @@ export function useTopBarElements(opts: {
onImport={ev.onImport}
onImportPointCloud={ev.onImportPointCloud}
onImportMesh={ev.onImportMesh}
onExportPdf={ev.onOpenExportPdf}
onExportDxf={ev.onOpenExportDxf}
onExportIfc={ev.onExportIfc}
onExportObj={ev.onExportObj}