Skip to content

armgit / SOMA

Public Imported from GitHub
0

Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice

App: Modelle als .soma speichern, ZIP weiter öffnen, Export als ZIP (E79)

Kai-Jungsthoefel1506707008df
diff --git a/app/resources/template/AGENTS.md b/app/resources/template/AGENTS.md
index 3d3dc68..d3964bb 100644
--- a/app/resources/template/AGENTS.md
+++ b/app/resources/template/AGENTS.md
@@ -17,7 +17,7 @@ The app shows the result in a 3D viewer next to this terminal. Notes and wishes
| `animations/` | Optional. Motion, camera flights and captions in Python (`soma.anim`), one file per topic. The skill for animation explains them |
| `analyses/` | Optional. Load cases for `soma analyze fem` in Python (`soma.fem`), one file per load case. The skill for FEM explains them |
| `drawings/` | Optional. Technical drawings in Python (`soma.drawing`), one file per drawing or set of sheets. `soma drawing build` writes PDF and DXF to `output/drawings/`, all sheets together to `output/drawings.pdf`. The skill for technical drawings explains them |
-| `renders/` | Pictures and videos written by `soma render`. Not in the version history and not in the saved ZIP |
+| `renders/` | Pictures and videos written by `soma render`. Not in the version history and not in the saved .soma file |
| `.soma/` | App data (viewer cache, build status, feedback images, skills, built animations, analysis results, drawing pictures). Do not edit. Read the skills in `.soma/skills/` as the list at the end of this file says, and files in `.soma/feedback/` when the user points you to them |
## Rules for model.py
diff --git a/app/src/main/dialogs.ts b/app/src/main/dialogs.ts
index b5e326f..62a54bf 100644
--- a/app/src/main/dialogs.ts
+++ b/app/src/main/dialogs.ts
@@ -16,14 +16,19 @@ function nextAnswer<T>(what: string): T {
return answers.shift() as T;
}
+/**
+ * Modelldatei wählen. Gespeichert wird als .soma (E79), geöffnet wird auch eine ZIP (ältere Modelle, „Export als ZIP“).
+ * `defaultName`: Dateiname in Dokumente oder ein absoluter Pfad.
+ */
export async function choosePath(win: BrowserWindow | null, kind: 'save' | 'open', defaultName: string): Promise<string | null> {
if (testMode()) return nextAnswer<string | null>(`${kind} path`);
- const filters = [{ name: 'SOMA model (ZIP)', extensions: ['zip'] }];
- const defaultPath = path.join(app.getPath('documents'), defaultName);
+ const defaultPath = path.isAbsolute(defaultName) ? defaultName : path.join(app.getPath('documents'), defaultName);
if (kind === 'save') {
+ const filters = [{ name: 'SOMA model', extensions: ['soma'] }];
const r = win ? await dialog.showSaveDialog(win, { title: 'Save model', defaultPath, filters }) : await dialog.showSaveDialog({ title: 'Save model', defaultPath, filters });
return r.canceled || !r.filePath ? null : r.filePath;
}
+ const filters = [{ name: 'SOMA model (.soma, .zip)', extensions: ['soma', 'zip'] }];
const opts = { title: 'Open model', filters, properties: ['openFile' as const] };
const r = win ? await dialog.showOpenDialog(win, opts) : await dialog.showOpenDialog(opts);
return r.canceled || !r.filePaths[0] ? null : r.filePaths[0];
diff --git a/app/src/main/main.ts b/app/src/main/main.ts
index 6d41ab4..1e8485d 100644
--- a/app/src/main/main.ts
+++ b/app/src/main/main.ts
@@ -34,6 +34,7 @@ function registerIpc(ctl: ProjectController): void {
ipcMain.handle('project:saveState', () => ctl.saveState());
ipcMain.handle('project:save', (_e, saveAs?: boolean) => ctl.save(!!saveAs));
ipcMain.handle('project:openZip', () => ctl.openZip());
+ ipcMain.handle('project:exportZip', () => ctl.exportZip());
ipcMain.handle('project:reveal', () => ctl.reveal());
ipcMain.handle('project:setThumb', (_e, dataUrl: string) => {
const m = /^data:image\/jpeg;base64,([A-Za-z0-9+/=]+)$/.exec(String(dataUrl));
diff --git a/app/src/main/projects.ts b/app/src/main/projects.ts
index a2124d9..fe8ff9e 100644
--- a/app/src/main/projects.ts
+++ b/app/src/main/projects.ts
@@ -50,12 +50,17 @@ interface Session {
const POLL_MS = 2000;
const safeFileName = (n: string) => n.replace(/[<>:"/\\|?*\x00-\x1f]/g, '_').trim() || 'Model';
+/** Modelle werden als .soma gespeichert (E79), innen eine ZIP. Geöffnet wird auch eine .zip. */
+const MODEL_EXT = '.soma';
+const isModelFile = (p: string) => p.toLowerCase().endsWith(MODEL_EXT);
+/** Pfad mit .soma: „x“ und „x.zip“ werden „x.soma“. */
+const modelPath = (p: string) => (isModelFile(p) ? p : `${p.replace(/\.zip$/i, '')}${MODEL_EXT}`);
/**
* Das offene Projekt und alles, was mit Speichern, Öffnen und Verlauf zu tun hat.
*
* Grundsätze: Speichern nur ausdrücklich (E21). Nichts wird still überschrieben oder gelöscht: ein Arbeitsordner, den eine
- * ZIP ersetzt, wandert in die Sicherungen. Der Agent committet selbst, die App legt nur beim Speichern einen Snapshot an (E8).
+ * Modelldatei (.soma oder .zip) ersetzt, wandert in die Sicherungen. Der Agent committet selbst, die App legt nur beim Speichern einen Snapshot an (E8).
*/
export class ProjectController {
session: Session | null = null;
@@ -105,7 +110,7 @@ export class ProjectController {
}
async open(id: string): Promise<ProjectInfo> {
- // Dasselbe Modell neu öffnen (etwa „Arbeitsstand behalten“ beim Öffnen seiner ZIP) verwirft es nie
+ // Dasselbe Modell neu öffnen (etwa „Arbeitsstand behalten“ beim Öffnen seiner Datei) verwirft es nie
if (this.session?.id === id) this.close(); else await this.leave();
const dir = projectDir(id);
const builds = new BuildManager(dir);
@@ -129,7 +134,7 @@ export class ProjectController {
// Gilt der letzte Build noch (seit seinem Start nichts geändert), zeigt der Viewer ihn gleich, statt neu zu bauen. Sonst
// erster Build direkt beim Öffnen, damit der Viewer nicht leer ist (der Nutzer kann Auto-Build danach abschalten).
const last = currentBuild(dir);
- // Fehlen Pakete aus requirements.txt (ZIP von einem anderen Rechner), erst installieren, dann bauen
+ // Fehlen Pakete aus requirements.txt (Modell von einem anderen Rechner), erst installieren, dann bauen
if (!this.installPackages(session, !last) && !last) builds.start('project opened');
const info = this.info();
this.send('project:changed', info);
@@ -206,7 +211,7 @@ export class ProjectController {
return { zipPath: app.zipPath ?? null, savedHead: app.savedHead ?? null, head: st.head, dirtyFiles: st.changed, unsaved, hasRepo, savedAt: app.zipPath ? app.savedAt ?? null : null };
}
- /** ZIP im Dateimanager zeigen. Noch nicht gespeichert (oder ZIP verschwunden): den Arbeitsordner öffnen. */
+ /** Modelldatei im Dateimanager zeigen. Noch nicht gespeichert (oder Datei verschwunden): den Arbeitsordner öffnen. */
async reveal(): Promise<void> {
const s = this.need();
const zip = getAppState(s.id).zipPath;
@@ -272,34 +277,94 @@ export class ProjectController {
}
}
- /** Speichern: Snapshot im Verlauf, dann ZIP. Fragt beim ersten Mal nach dem Ort. */
+ /**
+ * Das ganze Modell als ZIP exportieren (E79), etwa für jemanden ohne SOMA: derselbe Inhalt wie die .soma-Datei (Code,
+ * Ergebnisse, Verlauf). Anders als Speichern ohne Snapshot und ohne die Modelldatei zu ändern, der Speicherstand bleibt.
+ * Änderungen seit dem letzten Commit stecken nur als Dateien darin, der Marker sagt das (`dirty`). Die App öffnet die
+ * ZIP wieder wie eine .soma.
+ */
+ async exportZip(): Promise<ExportResult> {
+ const s = this.need();
+ const app = getAppState(s.id);
+ const startDir = app.exportDir && fs.existsSync(app.exportDir) ? app.exportDir : documentsDir();
+ const pj = readProjectJson(s.id);
+ const target = await chooseExportTarget(this.getWin(), {
+ kind: 'file', title: 'Export the model as a ZIP', defaultPath: path.join(startDir, `${safeFileName(pj?.name ?? 'Model')}.zip`), ext: 'zip', label: 'ZIP',
+ });
+ if (!target) return { ok: false, files: [], cancelled: true };
+ const dest = /\.zip$/i.test(target) ? target : `${target}.zip`;
+ if (app.zipPath && fs.existsSync(dest) && samePath(dest, app.zipPath)) {
+ return { ok: false, files: [], error: 'This is the model’s own file. Choose another name for the ZIP.' };
+ }
+ if (dest !== target && fs.existsSync(dest)) {
+ const c = await choose(this.getWin(), { title: 'Export', message: `${path.basename(dest)} already exists. Replace it?`, detail: dest, buttons: ['Replace', 'Cancel'] });
+ if (c !== 0) return { ok: false, files: [], cancelled: true };
+ }
+ const warnings: string[] = [];
+ try {
+ // Wie beim Speichern: aktuelles Ergebnis, Verlauf gepackt
+ if (!s.builds.busy && buildIsStale(s.dir)) s.builds.start('before exporting');
+ await s.builds.whenIdle();
+ if (s.builds.status.state === 'error') warnings.push('The last build failed. The ZIP contains the last successful version of output/model.step.');
+ let dirty = false;
+ if (await s.git.isRepo()) {
+ try { await s.git.pack(); } catch { /* nur größer */ }
+ dirty = (await s.git.status()).dirty;
+ }
+ const info: ZipInfo = { savedAt: new Date().toISOString(), head: await s.git.head(), id: s.id, name: pj?.name ?? s.id, ...(dirty ? { dirty } : {}) };
+ await saveProjectZip(s.dir, dest, info);
+ patchAppState(s.id, { exportDir: path.dirname(dest) });
+ return { ok: true, files: [dest], target: dest, ...(warnings.length ? { warnings } : {}) };
+ } catch (e) {
+ return { ok: false, files: [], error: `Export failed: ${e instanceof Error ? e.message : String(e)}` };
+ }
+ }
+
+ /**
+ * Speichern: Snapshot im Verlauf, dann die Modelldatei (.soma, eine ZIP, E79). Fragt beim ersten Mal nach dem Ort. Ein
+ * Modell, das bisher in einer ZIP steckte (ältere Fassung, geöffnete ZIP), wird einmal mit Rückfrage als .soma daneben
+ * gespeichert. Die ZIP bleibt unverändert.
+ */
async save(saveAs = false): Promise<SaveResult> {
const s = this.need();
const app = getAppState(s.id);
let zipPath = saveAs ? undefined : app.zipPath;
if (zipPath && !fs.existsSync(path.dirname(zipPath))) zipPath = undefined; // Zielordner weg (z. B. USB-Stick ab): neu fragen
+ const legacy = zipPath && !isModelFile(zipPath) ? zipPath : null;
+ if (legacy) zipPath = undefined;
if (!zipPath) {
const pj = readProjectJson(s.id);
- const chosen = await choosePath(this.getWin(), 'save', `${safeFileName(pj?.name ?? 'Model')}.zip`);
+ const prev = legacy ?? app.zipPath;
+ const name = `${safeFileName(pj?.name ?? 'Model')}${MODEL_EXT}`;
+ // Vorschlag: neben der bisherigen Datei, sonst in Dokumente
+ const suggest = legacy ? modelPath(legacy) : prev && fs.existsSync(path.dirname(prev)) ? path.join(path.dirname(prev), name) : name;
+ const chosen = await choosePath(this.getWin(), 'save', suggest);
if (!chosen) return { cancelled: true };
- zipPath = /\.zip$/i.test(chosen) ? chosen : `${chosen}.zip`;
- renameProject(s.id, path.basename(zipPath).replace(/\.zip$/i, '')); // der Modellname folgt dem Dateinamen
+ zipPath = modelPath(chosen);
+ // Den Namen mit .soma hat der Dialog nicht gesehen: eine vorhandene Datei nicht ohne Rückfrage ersetzen
+ if (zipPath !== chosen && fs.existsSync(zipPath)) {
+ const c = await choose(this.getWin(), {
+ title: 'Save model', message: `${path.basename(zipPath)} already exists. Replace it?`, detail: zipPath, buttons: ['Replace', 'Cancel'],
+ });
+ if (c !== 0) return { cancelled: true };
+ }
+ renameProject(s.id, path.basename(zipPath, path.extname(zipPath))); // der Modellname folgt dem Dateinamen
}
const warnings: string[] = [];
try {
- // Die ZIP soll das aktuelle Ergebnis enthalten: laufenden Build abwarten, veralteten vorher nachholen.
+ // Die Datei soll das aktuelle Ergebnis enthalten: laufenden Build abwarten, veralteten vorher nachholen.
if (!s.builds.busy && buildIsStale(s.dir)) s.builds.start('before saving');
await s.builds.whenIdle();
- if (s.builds.status.state === 'error') warnings.push('The last build failed. The ZIP contains the last successful version of output/model.step.');
+ if (s.builds.status.state === 'error') warnings.push('The last build failed. The file contains the last successful version of output/model.step.');
stampAppVersion(s.id); // mit welcher Version zuletzt gespeichert (E68), steht so auch im Snapshot
let snapshot: string | null = null;
if (await s.git.isRepo()) {
try { snapshot = await s.git.snapshot('Automatic snapshot on save'); }
catch (e) { warnings.push(`Could not add a snapshot to the history: ${e instanceof Error ? e.message : String(e)}`); }
- // Ähnliche Fassungen (vor allem output/model.step) als Unterschied ablegen, das macht die ZIP deutlich kleiner (E75)
+ // Ähnliche Fassungen (vor allem output/model.step) als Unterschied ablegen, das macht die Datei deutlich kleiner (E75)
try { await s.git.pack(); }
- catch (e) { warnings.push(`Git could not pack the history, the ZIP is larger than necessary: ${e instanceof Error ? e.message : String(e)}`); }
+ catch (e) { warnings.push(`Git could not pack the history, the file is larger than necessary: ${e instanceof Error ? e.message : String(e)}`); }
} else warnings.push('No Git history: no snapshot was created.');
const head = await s.git.head();
@@ -324,13 +389,14 @@ export class ProjectController {
}
/**
- * Öffnet eine ZIP als Projekt (E21). Existiert der Arbeitsordner schon, entscheidet der Nutzer bei Abweichungen:
- * Arbeitsstand behalten oder ZIP laden. Beim Laden wandert der Arbeitsordner in die Sicherungen, nichts wird gelöscht.
+ * Öffnet eine Modelldatei (.soma oder .zip, E21, E79). Existiert der Arbeitsordner schon, entscheidet der Nutzer bei
+ * Abweichungen: Arbeitsstand behalten oder die Datei laden. Beim Laden wandert der Arbeitsordner in die Sicherungen,
+ * nichts wird gelöscht.
*/
async openZipFile(zipPath: string): Promise<OpenResult> {
let texts: Record<string, string | null>;
try { texts = await readZipTexts(zipPath, ['.soma/project.json', ZIP_INFO_PATH]); }
- catch (e) { return { cancelled: false, error: `Cannot read the ZIP: ${e instanceof Error ? e.message : String(e)}` }; }
+ catch (e) { return { cancelled: false, error: `Cannot read the file (not a .soma or ZIP file?): ${e instanceof Error ? e.message : String(e)}` }; }
let id: string;
let info: ZipInfo | null = null;
try {
@@ -353,22 +419,24 @@ export class ProjectController {
const git = new GitRepo(dir);
const wsHead = (await git.isRepo()) ? await git.head() : null;
const st = wsHead ? await git.status() : { dirty: false };
- if (info?.head && info.head === wsHead && !st.dirty) { // identisch: nichts zu entscheiden, Chats und Arbeitsordner bleiben
+ // Identisch: nichts zu entscheiden, Chats und Arbeitsordner bleiben. Ein Export mit Änderungen seit dem Commit ist es nie
+ if (info?.head && info.head === wsHead && !st.dirty && !info.dirty) {
remember();
await this.open(id);
return { cancelled: false, opened: true };
}
let why: string;
if (st.dirty) why = 'The working folder has unsaved changes.';
- else if (info?.head && wsHead && (await git.isAncestor(info.head, wsHead))) why = 'The working folder is newer than the ZIP.';
- else if (info?.head && wsHead && (await git.isAncestor(wsHead, info.head))) why = 'The ZIP is newer than the working folder.';
- else why = 'The working folder and the ZIP have different versions.';
+ else if (info?.dirty) why = 'The file has changes that are not in its history.';
+ else if (info?.head && wsHead && (await git.isAncestor(info.head, wsHead))) why = 'The working folder is newer than the file.';
+ else if (info?.head && wsHead && (await git.isAncestor(wsHead, info.head))) why = 'The file is newer than the working folder.';
+ else why = 'The working folder and the file have different versions.';
const choice = await choose(this.getWin(), {
- title: 'Working folder and ZIP differ',
+ title: 'Working folder and file differ',
message: `${why} What do you want to open?`,
detail: 'Keep current work: the model opens as it is on this computer.\n' +
- 'Load ZIP: the version from the ZIP opens. The previous working folder is backed up, nothing is deleted.',
- buttons: ['Keep current work', 'Load ZIP', 'Cancel'],
+ 'Load file: the version from the file opens. The previous working folder is backed up, nothing is deleted.',
+ buttons: ['Keep current work', 'Load file', 'Cancel'],
});
if (choice === 0) { patchAppState(id, { zipPath }); await this.open(id); return { cancelled: false, opened: true }; }
if (choice !== 1) return { cancelled: true };
@@ -376,7 +444,7 @@ export class ProjectController {
if (this.session?.id === id) this.close(); // offene Handles würden das Umbenennen blockieren
await backupWorkspace(id);
await extractProject(zipPath, id);
- } catch (e) { return { cancelled: false, error: `Loading the ZIP failed: ${e instanceof Error ? e.message : String(e)}` }; }
+ } catch (e) { return { cancelled: false, error: `Loading the file failed: ${e instanceof Error ? e.message : String(e)}` }; }
remember();
await this.open(id);
return { cancelled: false, opened: true };
@@ -706,7 +774,7 @@ export class ProjectController {
const c = await choose(this.getWin(), {
title: 'Quit SOMA',
message: 'The model has unsaved changes.',
- detail: `${inEditor}Your current work stays on this computer, the start page shows it among the recent models. The ZIP file is only updated when you save.`,
+ detail: `${inEditor}Your current work stays on this computer, the start page shows it among the recent models. The model file is only updated when you save.`,
buttons: ['Save', 'Don’t save', 'Cancel'],
});
if (c === 2) return false;
@@ -721,7 +789,7 @@ export class ProjectController {
/**
* Modell von der Startseite entfernen (E69): Der Arbeitsordner kommt in den Papierkorb (dort lässt er sich wiederherstellen),
* die Daten der App dazu werden gelöscht, Sicherungen bleiben. Die Rückfrage sagt, was dabei verloren geht: nichts, wenn
- * der Stand in der ZIP-Datei steckt, sonst die Änderungen seit dem Speichern bzw. das ganze Modell. Ein unverändertes neues
+ * der Stand in der Modelldatei steckt, sonst die Änderungen seit dem Speichern bzw. das ganze Modell. Ein unverändertes neues
* Modell geht ohne Rückfrage. Das gerade geöffnete Modell nicht (erst ein anderes öffnen).
*/
async remove(id: string): Promise<RemoveResult> {
@@ -738,9 +806,9 @@ export class ProjectController {
const where = 'The working folder on this computer goes to the Recycle Bin, where it can be restored.';
const c = await choose(this.getWin(), {
title: 'Remove model',
- message: inZip ? `Remove “${name}” from this computer?` : zip ? `“${name}” has changes that are not in the ZIP file.` : `“${name}” was never saved.`,
- detail: inZip ? `${where} The ZIP file stays (${zip}), opening it brings the model back.`
- : zip ? `${where} The ZIP file (${zip}) stays, but it lacks the changes since the last save.`
+ message: inZip ? `Remove “${name}” from this computer?` : zip ? `“${name}” has changes that are not in the saved file.` : `“${name}” was never saved.`,
+ detail: inZip ? `${where} The model file stays (${zip}), opening it brings the model back.`
+ : zip ? `${where} The model file (${zip}) stays, but it lacks the changes since the last save.`
: `${where} If it is deleted there, the model is lost.`,
buttons: ['Remove', 'Cancel'],
});
diff --git a/app/src/main/workspace.ts b/app/src/main/workspace.ts
index 2494574..81dc34b 100644
--- a/app/src/main/workspace.ts
+++ b/app/src/main/workspace.ts
@@ -77,7 +77,7 @@ export async function createProject(name = 'New model'): Promise<{ id: string; d
return { id, dir };
}
-/** Angaben, die nur die App braucht (Pfad der ZIP, zuletzt gespeicherter Stand). */
+/** Angaben, die nur die App braucht (Pfad der Modelldatei, zuletzt gespeicherter Stand). */
export function getAppState(id: string): AppState {
return readJson<ProjectState>(stateFile(id))?.app ?? {};
}
@@ -165,7 +165,7 @@ export function inspectProject(id: string): { name: string; problems: string[] }
if (!fs.existsSync(path.join(dir, SKILLS_DIR, `${s}.md`))) problems.push(`The skill “${s}” is switched on, but ${SKILLS_DIR}/${s}.md is missing.`);
}
for (const bad of ['.venv', 'venv', 'env']) {
- if (fs.existsSync(path.join(dir, bad, 'pyvenv.cfg'))) problems.push(`The project contains its own Python environment (${bad}/). It is ignored and not packed into the ZIP.`);
+ if (fs.existsSync(path.join(dir, bad, 'pyvenv.cfg'))) problems.push(`The project contains its own Python environment (${bad}/). It is ignored and not packed into the saved file.`);
}
return { name: pj?.name ?? backup?.name ?? id, problems };
}
@@ -269,7 +269,7 @@ const hasFiles = (dir: string): boolean => {
};
/**
- * Ein neues Modell, das noch genau der Vorlage entspricht (E69): nie als ZIP gespeichert, im Verlauf nur der Startcommit,
+ * Ein neues Modell, das noch genau der Vorlage entspricht (E69): nie gespeichert, im Verlauf nur der Startcommit,
* nichts geändert oder hinzugekommen, auch nicht dort, wo Git nicht hinsieht, und keine Sicherungen. Verschwindet es,
* geht nichts verloren. Im Zweifel (Git unlesbar, Fehler) gilt es als verändert und bleibt.
*/
@@ -326,7 +326,7 @@ export function sweepDiscarded(): void {
for (const n of names) void fs.promises.rm(path.join(workspacesDir(), n), { recursive: true, force: true, maxRetries: 5, retryDelay: 300 }).catch(() => {});
}
-/** Entpackt eine ZIP als Arbeitsordner `id`. Erst in einen Temp-Ordner, dann umbenennen: nie ein halb entpacktes Projekt. */
+/** Entpackt eine Modelldatei (.soma oder .zip) als Arbeitsordner `id`. Erst in einen Temp-Ordner, dann umbenennen: nie ein halb entpacktes Projekt. */
export async function extractProject(zipPath: string, id: string): Promise<string> {
const dst = projectDir(id);
if (fs.existsSync(dst)) throw new Error('The working folder already exists (back it up first).');
diff --git a/app/src/main/zip.ts b/app/src/main/zip.ts
index e64adea..edbbd62 100644
--- a/app/src/main/zip.ts
+++ b/app/src/main/zip.ts
@@ -4,8 +4,12 @@ import { pipeline } from 'node:stream/promises';
import yauzl from 'yauzl';
import yazl from 'yazl';
-/** Marker, den die App beim Speichern in die ZIP legt. Damit erkennt sie beim Öffnen, ob der Arbeitsordner abweicht (E21). */
-export interface ZipInfo { savedAt: string; head: string | null; id: string; name: string }
+/**
+ * Marker, den die App beim Speichern in die Modelldatei legt (eine .soma ist eine ZIP, E79). Damit erkennt sie beim Öffnen,
+ * ob der Arbeitsordner abweicht (E21). `dirty`: Beim Export als ZIP gab es Änderungen seit dem letzten Commit, die Datei
+ * entspricht dann keinem Stand im Verlauf.
+ */
+export interface ZipInfo { savedAt: string; head: string | null; id: string; name: string; dirty?: boolean }
export const ZIP_INFO_PATH = '.soma/zip-info.json';
/** Wird nie gepackt: Umgebungen und Caches (Umgebung wird aus requirements.txt neu gebaut, Cache neu erzeugt). */
@@ -19,7 +23,7 @@ const SKIP_FILES = new Set(['.soma/model.glb', '.soma/model.map.json', '.soma/bu
*/
const SKIP_PATHS = new Set(['.soma/geometry', '.soma/anim', '.soma/results', '.soma/drawings', '.soma/env', 'renders']);
/** Schon gepackt (Git-Objekte sind zlib, Bilder und Videos komprimiert): nur ablegen, nochmal Deflate kostet nur Zeit. */
-const STORED = /^\.git\/objects\/|\.(png|jpe?g|webp|mp4|webm|zip|gz|7z|pack)$/i;
+const STORED = /^\.git\/objects\/|\.(png|jpe?g|webp|mp4|webm|zip|soma|gz|7z|pack)$/i;
const MAX_UNPACKED = 2 * 1024 ** 3;
function collect(root: string): string[] {
diff --git a/app/src/preload/preload.ts b/app/src/preload/preload.ts
index 6c17a9c..9ef6b0b 100644
--- a/app/src/preload/preload.ts
+++ b/app/src/preload/preload.ts
@@ -14,6 +14,7 @@ const api: SomaApi = {
saveState: () => ipcRenderer.invoke('project:saveState'),
save: (saveAs) => ipcRenderer.invoke('project:save', saveAs),
openZip: () => ipcRenderer.invoke('project:openZip'),
+ exportZip: () => ipcRenderer.invoke('project:exportZip'),
onSaveState: (cb) => { ipcRenderer.on('save:state', (_e, st) => cb(st)); },
reveal: () => ipcRenderer.invoke('project:reveal'),
setThumb: (dataUrl) => ipcRenderer.invoke('project:setThumb', dataUrl),
diff --git a/app/src/renderer/filetree.ts b/app/src/renderer/filetree.ts
index 2462471..7c5c71e 100644
--- a/app/src/renderer/filetree.ts
+++ b/app/src/renderer/filetree.ts
@@ -49,7 +49,7 @@ const FILE_ICONS: [RegExp, string][] = [
[/\.(png|jpe?g|gif|webp|bmp|tiff?)$/i, 'f-image'],
[/\.(mp4|webm|m4v|mov)$/i, 'f-video'],
[/\.pdf$/i, 'f-pdf'],
- [/\.(zip|7z|rar|tar|gz)$/i, 'f-zip'],
+ [/\.(zip|soma|7z|rar|tar|gz)$/i, 'f-zip'],
[/^\.gitignore$/i, 'f-lock'],
];
export const fileIcon = (name: string) => FILE_ICONS.find(([re]) => re.test(name))?.[1] ?? 'file';
diff --git a/app/src/renderer/index.html b/app/src/renderer/index.html
index 590ef35..62353d2 100644
--- a/app/src/renderer/index.html
+++ b/app/src/renderer/index.html
@@ -31,7 +31,7 @@
<button id="btn-lay-agent" aria-pressed="true" title="Expand or collapse the agent (Ctrl 3). Collapsed, it keeps running." aria-label="Agent"><i data-icon="panel" data-size="17" data-stroke="1.7"></i></button>
</div>
<button id="btn-export" class="btn" aria-haspopup="menu" aria-expanded="false"><i data-icon="export" data-size="15"></i>Export<i data-icon="down" data-size="13" data-stroke="2"></i></button>
- <button id="btn-save" class="btn primary" title="Add a snapshot to the history and write the ZIP">Save <span class="kbd">Ctrl S</span></button>
+ <button id="btn-save" class="btn primary" title="Add a snapshot to the history and write the .soma file">Save <span class="kbd">Ctrl S</span></button>
</header>
<div id="body">
@@ -421,6 +421,9 @@
<div class="chips"><button class="chip" data-fmt="dxf" title="Section through the middle of the part">DXF · Section</button><button class="chip" data-fmt="svg" title="Projection">SVG · View</button></div>
<div class="msep"></div>
<div class="mnote">One part: choose the location. All parts: choose a folder, each part becomes its own file. Reference and purchased parts are not included in “All parts”.</div>
+ <div class="msep"></div>
+ <div class="mh">WHOLE MODEL</div>
+ <button id="exp-zip" class="mi two" role="menuitem"><i data-icon="f-zip" data-size="15"></i><span class="t"><span>Everything as ZIP …</span><span class="sub">Code, results and history in one ZIP file, for example for someone without SOMA. The .soma file stays as it is.</span></span></button>
</div>
<div id="menu-agents" class="menu" role="menu" hidden>
@@ -464,10 +467,10 @@
<div class="start-grid">
<div>
<h1>Models</h1>
- <p class="c2 lead">A model is a ZIP file with code, result and history. You can move it and share it freely.</p>
+ <p class="c2 lead">A model is a .soma file with code, result and history. You can move it and share it freely.</p>
<div class="bigcards">
<button id="start-new" class="bigcard"><span class="ico acc"><i data-icon="plus" data-size="22" data-stroke="2.2"></i></span><b>New model</b><span class="c2">Template with an example part, plus a terminal in the model folder</span><span class="c3 small">Ctrl N</span></button>
- <button id="start-open" class="bigcard"><span class="ico"><i data-icon="folder" data-size="22"></i></span><b>Open …</b><span class="c2">ZIP file from this or another computer</span><span class="c3 small">Ctrl O</span></button>
+ <button id="start-open" class="bigcard"><span class="ico"><i data-icon="folder" data-size="22"></i></span><b>Open …</b><span class="c2">.soma or ZIP file from this or another computer</span><span class="c3 small">Ctrl O</span></button>
</div>
<div class="cap">RECENT</div>
<div id="start-recent" class="recent-grid"></div>
diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.ts
index d04d2e2..46cb2c5 100644
--- a/app/src/renderer/main.ts
+++ b/app/src/renderer/main.ts
@@ -832,7 +832,7 @@ function renderSaveState(st: SaveState): void {
else { dot.style.background = 'var(--ok)'; text = `Saved${st.savedAt ? ` · ${fmtWhen(st.savedAt)}` : ''}`; }
const b = $('save-badge');
b.replaceChildren(dot, text);
- b.title = st.zipPath ? `ZIP: ${st.zipPath}` : 'Not saved as a ZIP yet. Ctrl+S saves.';
+ b.title = st.zipPath ? `File: ${st.zipPath}` : 'Not saved yet. Ctrl+S saves.';
versions.setSaved(st.zipPath ? st.savedHead : null);
document.title = `SOMA – ${project?.name ?? ''}${unsaved ? ' ●' : ''}`;
}
@@ -843,7 +843,7 @@ async function refreshSaveState(): Promise<void> {
/**
* Strg+S im Editor und „Speichern und bauen“: geänderte Dateien schreiben. Gebaut wird nur, wenn darunter eine ist,
- * die das Modell betrifft (Python, inputs/). Keine ZIP, kein Snapshot, das macht „Speichern“ oben.
+ * die das Modell betrifft (Python, inputs/). Keine Modelldatei, kein Snapshot, das macht „Speichern“ oben.
*/
async function saveCode(): Promise<void> {
const r = await code.saveAll();
@@ -869,7 +869,7 @@ async function leaveEditor(title: string): Promise<boolean> {
let saving = false;
/**
- * Speichern kann dauern (ein laufender oder veralteter Build wird abgewartet, dann Snapshot und ZIP): Der Knopf zeigt das
+ * Speichern kann dauern (ein laufender oder veralteter Build wird abgewartet, dann Snapshot und .soma-Datei): Der Knopf zeigt das
* sofort, weitere Klicks und Strg+S zählen solange nicht.
*/
async function doSave(saveAs = false): Promise<void> {
@@ -881,7 +881,7 @@ async function doSave(saveAs = false): Promise<void> {
btn.classList.add('busy');
btn.replaceChildren(el('span', { className: 'spin' }, icon('spin', 14, 2.4)), 'Saving …');
try {
- // Erst die Eingaben im Editor, sonst fehlten sie in Snapshot und ZIP. Das Speichern baut danach, falls nötig.
+ // Erst die Eingaben im Editor, sonst fehlten sie in Snapshot und Datei. Das Speichern baut danach, falls nötig.
const c = await code.saveAll();
if (!c.ok) { toast('Not everything in the editor could be saved (see the note in the code). So the model is not saved.', 'error'); return; }
const r = await api.project.save(saveAs);
@@ -925,7 +925,7 @@ window.addEventListener('keydown', (e) => {
const k = e.key.toLowerCase();
// Ohne offenes Modell (Startseite beim Start, E69) gibt es nur Neu und Öffnen
if (!project && k !== 'n' && k !== 'o') return;
- // Im Editor speichert Strg+S den Code und baut, sonst das ganze Modell als ZIP
+ // Im Editor speichert Strg+S den Code und baut, sonst das ganze Modell als .soma-Datei
if (k === 's') { e.preventDefault(); if (!e.shiftKey && (e.target as HTMLElement | null)?.closest?.('#code-view')) void saveCode(); else void doSave(e.shiftKey); }
else if (k === 'o' && !e.shiftKey) { e.preventDefault(); void doOpen().then((ok) => { if (ok) showStart(false); }); }
else if (k === 'n' && !e.shiftKey) { e.preventDefault(); void doNew().then(() => showStart(false)); }
@@ -1026,6 +1026,22 @@ $('btn-sel-export').addEventListener('click', () => {
$('exp-all').addEventListener('click', () => { exportScope = 'all'; renderExportScope(); });
$('exp-sel').addEventListener('click', () => { exportScope = 'sel'; renderExportScope(); });
document.querySelectorAll<HTMLButtonElement>('#menu-export [data-fmt]').forEach((b) => b.addEventListener('click', () => void doExport(b.dataset.fmt!, b.textContent!)));
+$('exp-zip').addEventListener('click', () => { menus.close(); void doExportZip(); });
+
+/**
+ * Das ganze Modell als ZIP (E79). Eingaben im Editor, die noch nicht gespeichert sind, fehlen darin wie in jedem Export:
+ * Die Meldung nennt sie, statt sie ungefragt zu speichern.
+ */
+async function doExportZip(): Promise<ExportResult> {
+ const r = await api.project.exportZip();
+ if (r.cancelled) return r;
+ const open = code.unsaved();
+ if (r.ok) {
+ const notes = [...(r.warnings ?? []), ...(open.length ? [`Not included (not saved in the editor): ${open.join(', ')}`] : [])];
+ toast([`Model exported as ZIP:\n${r.target ?? ''}`, ...notes].join('\n'), notes.length ? 'error' : 'ok');
+ } else toast(r.error ?? 'Export failed', 'error');
+ return r;
+}
/** Exportieren: Der Hauptprozess fragt nach Datei (ein Bauteil) oder Ordner (alle Bauteile) und schreibt erst danach. */
async function doExport(fmt: string, label: string): Promise<ExportResult> {
@@ -1402,6 +1418,8 @@ if (api.testMode) {
settingsSave: () => settings.save(),
/** Export wie über das Menü (`sel`: das ausgewählte Bauteil), liefert das Ergebnis. */
exportAs: (fmt: string, scope: 'all' | 'sel') => { exportScope = scope; return doExport(fmt, fmt.toUpperCase()); },
+ /** „Everything as ZIP“ im Export-Menü (E79). */
+ exportZip: () => doExportZip(),
showStart: (on: boolean) => showStart(on),
setAgentCollapsed,
fileRows: () => [...document.querySelectorAll('#tab-files .frow .fn')].map((x) => x.textContent),
diff --git a/app/src/shared/types.ts b/app/src/shared/types.ts
index a022607..462ff46 100644
--- a/app/src/shared/types.ts
+++ b/app/src/shared/types.ts
@@ -9,7 +9,7 @@ export interface ProjectInfo {
autoBuild: boolean;
}
-/** `saved`: Es gibt eine ZIP-Datei dazu (das Modell wurde mindestens einmal gespeichert). */
+/** `saved`: Es gibt eine Modelldatei dazu (das Modell wurde mindestens einmal gespeichert). */
export interface ProjectListEntry { id: string; name: string; modified: number; saved?: boolean }
/** Modell von der Startseite entfernen (E69). `cancelled`: Rückfrage abgebrochen, nichts geändert. */
export interface RemoveResult { removed: boolean; cancelled?: boolean; error?: string }
@@ -67,7 +67,7 @@ export interface BuildStatus {
* Export über einen Dateidialog. `files`: geschriebene Dateien mit absolutem Pfad, `target`: gewählte Datei oder gewählter
* Ordner. `cancelled`: Dialog oder Rückfrage abgebrochen, nichts geschrieben.
*/
-export interface ExportResult { ok: boolean; files: string[]; target?: string; cancelled?: boolean; error?: string }
+export interface ExportResult { ok: boolean; files: string[]; target?: string; cancelled?: boolean; error?: string; warnings?: string[] }
/** Dateien, die per Ziehen nach inputs/ kopiert wurden (E33). */
export interface ImportResult { files: string[]; errors: string[] }
/**
@@ -209,6 +209,7 @@ export type MeasureSource = 'live' | { preview: string };
/** Stand der Speicherung: was ist gesichert, was nicht (E21). */
export interface SaveState {
+ /** Modelldatei (.soma, bei älteren oder als ZIP geöffneten Modellen bis zum nächsten Speichern eine .zip, E79). */
zipPath: string | null;
savedHead: string | null;
head: string | null;
@@ -290,9 +291,12 @@ export interface SomaApi {
onChanged(cb: (p: ProjectInfo) => void): void;
saveState(): Promise<SaveState>;
save(saveAs?: boolean): Promise<SaveResult>;
+ /** Öffnet eine Modelldatei (.soma, auch .zip, E79). */
openZip(): Promise<OpenResult>;
+ /** Das ganze Modell als ZIP exportieren (E79), ohne Snapshot. Die Modelldatei bleibt, wie sie ist. */
+ exportZip(): Promise<ExportResult>;
onSaveState(cb: (s: SaveState) => void): void;
- /** Zeigt die ZIP im Dateimanager (noch nicht gespeichert: den Arbeitsordner). */
+ /** Zeigt die Modelldatei im Dateimanager (noch nicht gespeichert: den Arbeitsordner). */
reveal(): Promise<void>;
/** Vorschaubild des offenen Modells für die Startseite (JPEG als Data-URL). */
setThumb(dataUrl: string): Promise<void>;
diff --git a/app/test/editor.mjs b/app/test/editor.mjs
index 5d62c74..2592f15 100644
--- a/app/test/editor.mjs
+++ b/app/test/editor.mjs
@@ -264,7 +264,7 @@ try {
// 11) „Speichern" oben: speichert auch die Eingaben im Editor, dann Snapshot und ZIP
await replace('LENGTH = param(79.0', 'LENGTH = param(81.0');
- const zipPath = path.join(ud, 'Editortest.zip');
+ const zipPath = path.join(ud, 'Editortest.soma');
await app.answers([zipPath]);
await domClick('btn-save');
await waitFor('gespeichert', () => !!window.__t.saveState()?.zipPath && !window.__t.saveState().unsaved, 60000).catch(() => {});
diff --git a/app/test/packages.mjs b/app/test/packages.mjs
index 8541825..e8a933b 100644
--- a/app/test/packages.mjs
+++ b/app/test/packages.mjs
@@ -18,7 +18,7 @@ const { check } = t;
let app;
const workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'soma-packages-'));
const wheels = path.join(workDir, 'wheels');
-const zipPath = path.join(workDir, 'Paketmodell.zip');
+const zipPath = path.join(workDir, 'Paketmodell.soma');
/** Ein Wheel ohne Build-Werkzeuge: Modul, METADATA, WHEEL und RECORD in einer ZIP. */
function makeWheel(name, version, code, requires = []) {
diff --git a/app/test/params.mjs b/app/test/params.mjs
index 6718c14..5f4b07d 100644
--- a/app/test/params.mjs
+++ b/app/test/params.mjs
@@ -266,7 +266,7 @@ try {
b0 = await builds();
await typeValue('SIZE', '50');
await built(b0, 'Size 50');
- const zipPath = path.join(workDir, 'Parameter.zip');
+ const zipPath = path.join(workDir, 'Parameter.soma');
await app.answers([zipPath]);
await domClick('btn-save');
await waitFor('gespeichert', () => window.__t.saveState() && !window.__t.saveState().unsaved && window.__t.saveState().zipPath, 60000)
diff --git a/app/test/skills.mjs b/app/test/skills.mjs
index 8acc144..3cc19be 100644
--- a/app/test/skills.mjs
+++ b/app/test/skills.mjs
@@ -308,7 +308,7 @@ try {
check('Nächstes Umstellen schreibt den Abschnitt neu: Meldung weg', !(await skill('laser')).problems.length && demand().includes('laser.md'));
// 9) Speichern: Skills im Snapshot und in der ZIP
- const zipPath = path.join(workDir, 'Skills.zip');
+ const zipPath = path.join(workDir, 'Skills.soma');
await app.answers([zipPath]);
await domClick('btn-save');
await waitFor('gespeichert', () => window.__t.saveState() && !window.__t.saveState().unsaved && window.__t.saveState().zipPath, 60000)
diff --git a/app/test/versions.mjs b/app/test/versions.mjs
index 674c956..0a3032b 100644
--- a/app/test/versions.mjs
+++ b/app/test/versions.mjs
@@ -1,4 +1,5 @@
-// Test für Git-Verlauf, ZIP speichern/öffnen, Vorschau und Wiederherstellen, dazu die Störfälle aus PLAN.md Abschnitt 9.
+// Test für Git-Verlauf, Speichern als .soma (innen eine ZIP), Öffnen von .soma und .zip, Export als ZIP (E79), Vorschau und
+// Wiederherstellen, dazu die Störfälle aus PLAN.md Abschnitt 9.
// Aufruf: npm run test:versions (baut vorher).
import { exec } from 'dugite';
import fs from 'node:fs';
@@ -34,7 +35,7 @@ try {
const term = () => ev(() => window.__t.terminals.activeId);
const type = async (cmd) => { const id = await term(); await ev(([i, c]) => window.soma.term.write(i, c + '\r'), [id, cmd]); };
const termText = async () => ev((i) => window.__t.termText(i), await term());
- const zipPath = path.join(workDir, 'Testmodell.zip');
+ const zipPath = path.join(workDir, 'Testmodell.soma');
const versions = () => ev(() => window.__t.versions());
const saveState = () => ev(() => window.__t.saveState());
// Vorschau-Cache eines Standes (previews/<Projekt>/<Commit>) und Warten auf Dateien außerhalb des Fensters
@@ -81,16 +82,18 @@ try {
fs.appendFileSync(path.join(dir, 'NOTES.md'), '\nWunsch: Deckel mit Lippe\n');
await waitFor('Notizänderung', () => window.__t.saveState() && window.__t.saveState().dirtyFiles === 1);
check('Vor dem Speichern: Badge „ungespeichert"', (await saveState()).unsaved === true);
- await app.answers([zipPath]);
+ // Im Dialog ohne Endung eingegeben: Die App hängt .soma an
+ await app.answers([zipPath.replace(/\.soma$/, '')]);
await domClick('btn-save');
await waitFor('gespeichert', () => window.__t.saveState() && !window.__t.saveState().unsaved && window.__t.saveState().zipPath, 60000);
- check('ZIP wurde geschrieben', fs.existsSync(zipPath), `${Math.round(fs.statSync(zipPath).size / 1024)} KB`);
+ check('Modell als .soma gespeichert (Endung angehängt)', fs.existsSync(zipPath) && (await saveState()).zipPath === zipPath,
+ `${fs.existsSync(zipPath) ? Math.round(fs.statSync(zipPath).size / 1024) : 0} KB, ${(await saveState()).zipPath}`);
const names = await listZip(zipPath);
- check('ZIP enthält Modell, .git, Projektdaten und Marker', ['model.py', '.git/HEAD', '.soma/project.json', '.soma/zip-info.json', 'AGENTS.md'].every((n) => names.includes(n)));
+ check('Die .soma ist eine ZIP mit Modell, .git, Projektdaten und Marker', ['model.py', '.git/HEAD', '.soma/project.json', '.soma/zip-info.json', 'AGENTS.md'].every((n) => names.includes(n)));
check('ZIP enthält keine Caches (GLB, Mapping, build.json, __pycache__)', !names.some((n) => /model\.glb|model\.map\.json|build\.json|__pycache__/.test(n)));
await waitFor('Meldung und Name', () => window.__t.toast().text.startsWith('Saved') && window.__t.project().name === 'Testmodell', 20000);
check('Auto-Snapshot beim Speichern hat die Notiz gesichert', (await g('log', '-1', '--format=%s')) === 'Automatic snapshot on save');
- check('Modellname folgt dem Dateinamen der ZIP', (await ev(() => window.__t.project())).name === 'Testmodell');
+ check('Modellname folgt dem Dateinamen', (await ev(() => window.__t.project())).name === 'Testmodell');
check('Nach dem Speichern: sauber, Anzeige „Saved · Uhrzeit"', (await saveState()).dirtyFiles === 0 && /^Saved · \d\d:\d\d$/.test(await ev(() => document.getElementById('save-badge').textContent)), await ev(() => document.getElementById('save-badge').textContent));
await waitFor('grüner Punkt', () => document.querySelectorAll('#vdots .vdot.saved').length === 1, 10000).catch(() => {});
check('Verlaufsleiste markiert den gespeicherten Stand', await ev(() => document.querySelectorAll('#vdots .vdot.saved').length) === 1);
@@ -100,6 +103,19 @@ try {
await sleep(2500);
check('Zweites Speichern ohne Änderung legt keinen leeren Snapshot an', (await g('rev-list', '--count', 'HEAD')) === commitsBefore);
+ // ---- 3b) Export „Everything as ZIP“ (E79): gleicher Inhalt, kein Snapshot, die .soma bleibt die Modelldatei ----
+ const exported = path.join(workDir, 'Weitergabe.zip');
+ const somaBytes = fs.readFileSync(zipPath);
+ await app.answers([exported]);
+ await domClick('exp-zip');
+ await waitFor('exportiert', () => window.__t.toast().text.startsWith('Model exported as ZIP'), 60000).catch(() => {});
+ const expNames = fs.existsSync(exported) ? await listZip(exported) : [];
+ check('Export als ZIP: Modell, .git und Marker darin', ['model.py', '.git/HEAD', '.soma/project.json', '.soma/zip-info.json'].every((n) => expNames.includes(n)),
+ (await ev(() => window.__t.toast())).text.slice(0, 120));
+ const st3 = await saveState();
+ check('Export ändert nichts am Modell: kein neuer Commit, .soma unverändert und weiter die Modelldatei, gespeichert',
+ (await g('rev-list', '--count', 'HEAD')) === commitsBefore && st3.zipPath === zipPath && !st3.unsaved && somaBytes.equals(fs.readFileSync(zipPath)), JSON.stringify(st3).slice(0, 160));
+
// ---- 4) Vorschau alter Stände ----
const first = await g('rev-list', '--max-parents=0', 'HEAD');
check('Erster Stand liegt schon als Vorschau bereit (beim Anlegen abgelegt)', fs.existsSync(path.join(cached(first), 'model.glb')));
@@ -129,8 +145,9 @@ try {
await waitFor('Zeichenfläche', () => window.__t.markup().active, 30000).catch(() => {});
await domClick('btn-mark-send');
const firstShort = await g('rev-parse', '--short', first);
- await waitFor('Markierung im Terminal', (i) => window.__t.termText(i).includes('[Markup: .soma/feedback/'), 30000, await term()).catch(() => {});
- check('Markierung in der Vorschau nennt den alten Stand', (await termText()).includes(`shows the older version ${firstShort} "New model created"]`), (await termText()).match(/\[Markup:[^\]]*\]/)?.[0]?.slice(0, 90) ?? '');
+ // Bis zur schließenden Klammer warten: Unter Last kommt das Echo der Shell stückweise
+ await waitFor('Markierung im Terminal', (i) => /\[Markup: \.soma\/feedback\/[^\]]*\]/.test(window.__t.termText(i)), 30000, await term()).catch(() => {});
+ check('Markierung in der Vorschau nennt den alten Stand', (await termText()).includes(`shows the older version ${firstShort} "New model created"]`), (await termText()).match(/\[Markup:[^\]]*\]/)?.[0]?.slice(0, 200) ?? '');
check('Nach der Markierung läuft die Vorschau weiter', !!(await versions()).previewing && await ev(() => document.getElementById('viewer').classList.contains('preview')));
await ev((i) => window.soma.term.write(i, '\x03'), await term()); // Zeile verwerfen
@@ -219,6 +236,18 @@ try {
check(`Böse ZIP („../evil.txt", ${replaced} Einträge im Archiv) wird abgelehnt`, /Unsafe|invalid relative path/.test(evilToast), evilToast.slice(0, 70));
check('Nichts außerhalb des Zielordners geschrieben, keine Reste', !fs.existsSync(path.join(ud, 'evil.txt')) && !fs.existsSync(path.join(ud, 'workspaces', 'evil.txt')) && !fs.readdirSync(path.join(ud, 'workspaces')).some((n) => n.startsWith('.tmp-')));
check('Keine ZIP-Datei im Weg: Projekt bleibt offen und nutzbar', (await ev(() => window.__t.project().id)) === proj.id);
+ // E) ZIP öffnen (älteres Modell oder Export): Speichern fragt einmal nach dem Ort der .soma, die ZIP bleibt (E79)
+ const zipBytes = fs.readFileSync(exported);
+ await app.answers([exported, 0]); // Arbeitsordner ist neuer: behalten
+ await domClick('btn-open');
+ await waitFor('ZIP als Modelldatei', (f) => window.__t.saveState()?.zipPath === f, 30000, exported).catch(() => {});
+ check('ZIP öffnen: Modell offen, die ZIP ist vorerst seine Datei', (await ev(() => window.__t.project().id)) === proj.id && (await saveState()).zipPath === exported);
+ const somaFromZip = path.join(workDir, 'Weitergabe.soma');
+ await app.answers([somaFromZip]);
+ await domClick('btn-save');
+ await waitFor('als .soma gespeichert', (f) => window.__t.saveState()?.zipPath === f && !window.__t.saveState().unsaved, 60000, somaFromZip).catch(() => {});
+ check('Speichern nach dem Öffnen einer ZIP: neue .soma, ZIP unverändert', fs.existsSync(somaFromZip) && (await listZip(somaFromZip)).includes('model.py')
+ && zipBytes.equals(fs.readFileSync(exported)) && (await saveState()).zipPath === somaFromZip, JSON.stringify(await saveState()).slice(0, 160));
// ---- 8) Absturz-Wiederherstellung: ungespeicherte Änderung überlebt ----
fs.appendFileSync(path.join(dir, 'NOTES.md'), '\nungespeichert vor dem Absturz\n');