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: Dateibaum mit Suche und eingeklappten Ordnern, Videos nach Ordnern, Lautstärke im Player

Kai-Jungsthoefel3b4b9865e9dc
diff --git a/app/src/renderer/animpanel.ts b/app/src/renderer/animpanel.ts
index fd2396e..0d2f82b 100644
--- a/app/src/renderer/animpanel.ts
+++ b/app/src/renderer/animpanel.ts
@@ -5,6 +5,8 @@ import { el } from './ui';
// Reiter Animation (E82): Liste der Animationen mit den Videos darunter und der Ablauf der gezeigten. Die Schritte kommen aus der
// Animation (ausdrücklich oder aus den Untertiteln), ein Klick springt hin. Abgespielt wird in der Leiste unten im Bild (animtool.ts).
+// Videos stehen nach Ordnern, ein Ordner lässt sich einklappen (der Agent legt oft viele Einzelclips neben die Hauptvideos).
+// Rechtsklick auf ein Video öffnet das Menü der Datei wie im Dateibaum.
interface Ui {
list: HTMLElement; listCount: HTMLElement; rows: HTMLElement;
@@ -20,11 +22,17 @@ interface Deps {
insert(text: string): void;
isNew(key: string): boolean;
seen(key: string): void;
+ /** Menü der Datei (wie im Dateibaum) an dieser Stelle. */
+ fileMenu(rel: string, x: number, y: number): void;
+ /** Eingeklappte Ordner der Videoliste, pro Modell gemerkt. */
+ closedDirs(): string[];
+ setClosedDirs(dirs: string[]): void;
}
export const animKey = (a: AnimEntry) => `a:${a.id}`;
export const videoKey = (v: string) => `v:${v}`;
const base = (rel: string) => rel.split('/').pop() ?? rel;
+const dirOf = (rel: string) => (rel.includes('/') ? rel.slice(0, rel.lastIndexOf('/')) : '');
export class AnimPanel {
private mode: 'list' | 'report' = 'report';
@@ -66,15 +74,50 @@ export class AnimPanel {
this.ui.body.querySelectorAll('.cx-seq').forEach((r, i) => r.classList.toggle('cur', i === cur));
}
- private videoRow(v: string): HTMLButtonElement {
- const b = el('button', { className: 'al-row ic3', title: `${v}: open in the player` }, el('span', { className: 'ic' }, icon('f-video', 16)),
- el('div', {}, el('div', { className: 't', textContent: base(v) }),
- el('div', { className: 'm' }, v.slice(0, v.length - base(v).length) || './', this.d.isNew(videoKey(v)) ? el('span', { className: 'tag acc', textContent: 'new' }) : null)),
+ /** `showDir`: Ordner unter dem Namen (nur ohne Ordnerköpfe, sonst steht er schon darüber). */
+ private videoRow(v: string, showDir: boolean): HTMLButtonElement {
+ const isNew = this.d.isNew(videoKey(v));
+ const meta = showDir || isNew ? el('div', { className: 'm' }, showDir ? v.slice(0, v.length - base(v).length) || './' : '',
+ isNew ? el('span', { className: 'tag acc', textContent: 'new' }) : null) : null;
+ const b = el('button', { className: 'al-row ic3' + (showDir ? '' : ' in'), title: `${v}: open in the player. Right-click for file actions.` }, el('span', { className: 'ic' }, icon('f-video', 16)),
+ el('div', {}, el('div', { className: 't', textContent: base(v) }), meta),
el('div', { className: 'v' }));
+ b.dataset.video = v;
b.addEventListener('click', () => { this.d.seen(videoKey(v)); this.d.openVideo(v); this.render(); });
+ this.withFileMenu(b, v);
return b;
}
+ private withFileMenu(b: HTMLElement, rel: string): void {
+ b.addEventListener('contextmenu', (e) => { e.preventDefault(); e.stopPropagation(); this.d.fileMenu(rel, e.clientX, e.clientY); });
+ }
+
+ /** Videos nach Ordnern. Bei nur einem Ordner ohne Köpfe wie bisher. */
+ private videoRows(videos: string[]): HTMLElement[] {
+ const dirs = new Map<string, string[]>();
+ for (const v of videos) { const d = dirOf(v); const list = dirs.get(d); if (list) list.push(v); else dirs.set(d, [v]); }
+ if (dirs.size === 1) return videos.map((v) => this.videoRow(v, true));
+ const closed = new Set(this.d.closedDirs());
+ const rows: HTMLElement[] = [];
+ for (const [dir, list] of [...dirs].sort(([a], [b]) => a.localeCompare(b))) {
+ const open = !closed.has(dir);
+ const anyNew = !open && list.some((v) => this.d.isNew(videoKey(v)));
+ const head = el('button', { className: 'al-dir', title: `${dir || 'Project folder'}: ${open ? 'collapse' : 'expand'}` },
+ el('span', { className: 'chev' }, icon(open ? 'down' : 'right', 12, 2.2)), icon('folder', 14), el('span', { textContent: `${dir || '.'}/` }),
+ anyNew ? el('span', { className: 'tag acc', textContent: 'new' }) : null, el('span', { className: 'cnt', textContent: String(list.length) }));
+ head.dataset.dir = dir;
+ head.setAttribute('aria-expanded', String(open));
+ head.addEventListener('click', () => {
+ if (open) closed.add(dir); else closed.delete(dir);
+ this.d.setClosedDirs([...closed]);
+ this.render();
+ });
+ rows.push(head);
+ if (open) rows.push(...list.map((v) => this.videoRow(v, false)));
+ }
+ return rows;
+ }
+
private renderList(): void {
const { animations, errors } = this.d.tool.entries;
const cur = this.d.tool.currentId;
@@ -93,12 +136,14 @@ export class AnimPanel {
if (!animations.length && !errors.length) rows.push(el('div', { className: 'al-empty', textContent: 'No animations yet.' }));
const videos = this.d.videos();
if (videos.length) {
- rows.push(el('div', { className: 'al-sh' }, 'VIDEOS ', el('span', { className: 'cnt', textContent: String(videos.length) }), el('span', { className: 'r', textContent: 'renders/' })));
- rows.push(...videos.map((v) => this.videoRow(v)));
+ // Mit Ordnerköpfen steht der Ordner schon darunter
+ const oneDir = new Set(videos.map(dirOf)).size === 1;
+ rows.push(el('div', { className: 'al-sh' }, 'VIDEOS ', el('span', { className: 'cnt', textContent: String(videos.length) }), oneDir ? el('span', { className: 'r', textContent: `${dirOf(videos[0]) || '.'}/` }) : null));
+ rows.push(...this.videoRows(videos));
}
this.ui.rows.replaceChildren(...rows, el('div', { className: 'al-note' },
'The agent creates animations in ', el('code', { textContent: 'animations/' }), ' and videos with ', el('code', { textContent: 'soma render' }),
- ' (skill “Animation and video”). A video opens in the player.'));
+ ' (skill “Animation and video”). A video opens in the player, right-click it to rename, delete or find it in the files.'));
}
private renderReport(): void {
@@ -129,6 +174,7 @@ export class AnimPanel {
if (mine.length) vids.append(...mine.map((v) => {
const b = el('button', { className: 'cx-file', title: `${v}: open in the player` }, icon('f-video', 15), el('span', { textContent: base(v) }), el('span', { className: 's' }));
b.addEventListener('click', () => { this.d.seen(videoKey(v)); this.d.openVideo(v); });
+ this.withFileMenu(b, v);
return b;
}));
else vids.append(el('div', { className: 'cx-empty', textContent: 'No video yet. “Make video” writes one to renders/.' }));
@@ -146,6 +192,8 @@ export class AnimPanel {
hint: this.ui.body.querySelector('.cx-line')?.textContent ?? null,
steps: [...this.ui.body.querySelectorAll<HTMLElement>('.cx-seq')].map((x) => ({ text: x.textContent, cur: x.classList.contains('cur') })),
videos: [...this.ui.body.querySelectorAll<HTMLElement>('.cx-file')].map((x) => x.textContent),
+ dirs: [...this.ui.rows.querySelectorAll<HTMLElement>('.al-dir')].map((x) => ({ dir: x.dataset.dir ?? '', open: x.getAttribute('aria-expanded') === 'true' })),
+ listVideos: [...this.ui.rows.querySelectorAll<HTMLElement>('.al-row[data-video]')].map((x) => x.dataset.video ?? ''),
};
}
}
diff --git a/app/src/renderer/filetree.ts b/app/src/renderer/filetree.ts
index 7a172d3..b745fbf 100644
--- a/app/src/renderer/filetree.ts
+++ b/app/src/renderer/filetree.ts
@@ -29,6 +29,8 @@ export interface FileTreeDeps {
mark(rel: string): void;
toAgent(rel: string): void;
copyPath(rel: string): void;
+ /** Dateibaum zeigen und die Datei darin finden, mit `rename` gleich das Namensfeld öffnen (Menü aus anderen Panels). */
+ showInTree(rel: string, rename: boolean): void;
}
/** Offenes Namensfeld: neue Datei oder neuer Ordner in `parent`, oder Umbenennen von `node`. */
@@ -57,12 +59,16 @@ export const fileIcon = (name: string) => FILE_ICONS.find(([re]) => re.test(name
const parentOf = (rel: string) => (rel.includes('/') ? rel.slice(0, rel.lastIndexOf('/')) : '');
/**
- * Dateien-Panel: kompakter Baum, Ordner einklappbar. Ein Klick auf eine Textdatei öffnet sie im Code-Panel.
+ * Dateien-Panel: kompakter Baum, Ordner anfangs eingeklappt, darüber ein Suchfeld. Ein Klick auf eine Textdatei öffnet sie im Code-Panel.
* Rechtsklick (oder Umschalt+F10) öffnet das Menü mit Anlegen, Umbenennen (F2), Löschen (Entf), Öffnen und Pfad.
* Was gesperrt ist, regelt `fileOpBlockReason`, dieselbe Regel prüft der Hauptprozess noch einmal.
*/
export class FileTree {
- private collapsed = new Set<string>(['#managed', SKILLS]);
+ /** Aufgeklappte Ordner und Gruppen. Anfangs ist alles zu, sonst wird der Baum mit vielen Unterordnern unübersichtlich. */
+ private expanded = new Set<string>();
+ /** Suchtext: nur passende Dateien mit ihren Ordnern, dabei alles aufgeklappt. */
+ private query = '';
+ private search: HTMLInputElement | null = null;
private nodes: FileNode[] = [];
private edit: Edit | null = null;
private input: HTMLInputElement | null = null;
@@ -96,23 +102,24 @@ export class FileTree {
this.nodes = nodes;
// Verschwindet die Datei, deren Name gerade bearbeitet wird (etwa durch den Agenten), geht das Feld zu
if (this.edit?.mode === 'rename' && !this.find(this.edit.node.path) && !this.submitting) { this.edit = null; this.input = null; }
- const managed = nodes.filter((n) => !n.dir && MANAGED.has(n.name));
- const feedback = nodes.find((n) => n.path === FEEDBACK);
- const skills = nodes.find((n) => n.path === SKILLS);
- const rest = nodes.filter((n) => !managed.includes(n) && n !== feedback && n !== skills);
+ const shown = this.filter(nodes);
+ const managed = shown.filter((n) => !n.dir && MANAGED.has(n.name));
+ const feedback = shown.find((n) => n.path === FEEDBACK);
+ const skills = shown.find((n) => n.path === SKILLS);
+ const rest = shown.filter((n) => !managed.includes(n) && n !== feedback && n !== skills);
const rows: HTMLElement[] = [];
const ed = this.edit;
const walk = (list: FileNode[], depth: number, parent: string) => {
if (ed && ed.mode !== 'rename' && ed.parent === parent) rows.push(this.inputRow(depth, ed.mode === 'dir' ? 'folder' : 'file', ''));
for (const n of list) {
rows.push(ed?.mode === 'rename' && ed.node.path === n.path ? this.inputRow(depth, n.dir ? 'folder' : fileIcon(n.name), n.name) : this.row(n, depth));
- if (n.dir && n.children && !this.collapsed.has(n.path)) walk(n.children, depth + 1, n.path);
+ if (n.dir && n.children && this.isOpen(n.path)) walk(n.children, depth + 1, n.path);
}
};
/** Kopf einer Gruppe unter den Projektdateien, liefert, ob sie aufgeklappt ist. `rel` macht den Kopf zum Ordner fürs Menü. */
const group = (key: string, ico: string, label: string, count: number, title: string, rel?: string): boolean => {
rows.push(el('div', { className: 'gap' }));
- const open = !this.collapsed.has(key);
+ const open = this.isOpen(key);
const head = this.button(0, open ? 'down' : 'right', ico, label, String(count), 'dim');
head.title = title;
head.setAttribute('aria-expanded', String(open));
@@ -122,7 +129,8 @@ export class FileTree {
return open;
};
walk(rest, 0, '');
- if (!rest.length && !ed) rows.push(el('div', { className: 'hint', textContent: 'No files yet.' }));
+ if (this.query && !shown.length) rows.push(el('div', { className: 'hint', textContent: `No file name contains “${this.query}”.` }));
+ else if (!rest.length && !ed) rows.push(el('div', { className: 'hint', textContent: 'No files yet.' }));
// Markierungen (E16) aus .soma/feedback/: eigene Gruppe, neueste zuerst. Zum Wiederfinden und erneut an den Agenten geben.
if (feedback?.children?.length && group(FEEDBACK, 'image', 'Markups', feedback.children.length,
'Images from “Mark up”, stored in .soma/feedback/. Click to open for markup, right-click to send the path to the agent or open in an image viewer.', FEEDBACK)) {
@@ -143,6 +151,68 @@ export class FileTree {
if (hadFocus || this.input?.dataset.fresh) this.focusInput();
}
+ // ---- Suchen und Finden ----------------------------------------------------------------------------------------
+
+ /** Suchfeld über dem Baum. Escape leert es, Pfeil nach unten springt in die Treffer. */
+ attachSearch(input: HTMLInputElement): void {
+ this.search = input;
+ input.addEventListener('input', () => { this.query = input.value.trim(); this.render(); });
+ input.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape' && input.value) { e.preventDefault(); e.stopPropagation(); this.clearQuery(); this.render(); }
+ else if (e.key === 'ArrowDown') { e.preventDefault(); this.root.querySelector<HTMLElement>('.frow')?.focus(); }
+ });
+ }
+
+ private clearQuery(): void {
+ this.query = '';
+ if (this.search) this.search.value = '';
+ }
+
+ private isOpen(key: string): boolean { return !!this.query || this.expanded.has(key); }
+
+ /** Trifft der Suchtext den Namen (mit „/“ im Suchtext: den Pfad)? Groß- und Kleinschreibung zählt nicht. */
+ private hit(n: FileNode): boolean {
+ const q = this.query.toLowerCase();
+ return (q.includes('/') ? n.path : n.name).toLowerCase().includes(q);
+ }
+
+ /** Nur Treffer und die Ordner darüber. Ein passender Ordner bleibt auch ohne passende Datei darin stehen. */
+ private filter(list: FileNode[]): FileNode[] {
+ if (!this.query) return list;
+ return list.flatMap((n) => {
+ if (!n.dir) return this.hit(n) ? [n] : [];
+ const kids = this.filter(n.children ?? []);
+ return kids.length || this.hit(n) ? [{ ...n, children: kids }] : [];
+ });
+ }
+
+ /** Ordner über einer Datei aufklappen. Liefert, ob sich etwas geändert hat. */
+ private openAncestors(rel: string): boolean {
+ const before = this.expanded.size;
+ const parts = rel.split('/');
+ for (let i = 1; i < parts.length; i++) this.expanded.add(parts.slice(0, i).join('/'));
+ if (parts.length === 1 && MANAGED.has(rel)) this.expanded.add('#managed');
+ return this.expanded.size !== before;
+ }
+
+ /**
+ * Datei im Baum zeigen: Suche leeren, Ordner darüber aufklappen, hinscrollen. Steht sie noch nicht in der Liste (die kommt
+ * gleich nach), bleiben die Ordner trotzdem offen.
+ */
+ reveal(rel: string, focus = true): void {
+ this.clearQuery();
+ this.openAncestors(rel);
+ this.render();
+ const row = this.root.querySelector<HTMLElement>(`.frow[data-path="${CSS.escape(rel)}"]`);
+ row?.scrollIntoView({ block: 'nearest' });
+ if (focus) row?.focus();
+ }
+
+ /** Menü einer Datei aus einem anderen Panel (Videos im Reiter Animation): wie im Baum, dazu „Show in file tree“. */
+ menuFor(rel: string, x: number, y: number): void {
+ this.openMenu(this.find(rel) ?? { name: rel.split('/').pop() ?? rel, path: rel, dir: false }, x, y, true);
+ }
+
// ---- Anlegen und Umbenennen -----------------------------------------------------------------------------------
/** Namensfeld für eine neue Datei oder einen neuen Ordner in `parent` ('' = Projektordner). */
@@ -150,7 +220,9 @@ export class FileTree {
if (fileOpBlockReason(parent, 'create') || this.submitting) return;
this.edit = { mode: dir ? 'dir' : 'file', parent };
this.input = null;
- if (parent) this.collapsed.delete(parent); // Ordner aufklappen, damit das Feld zu sehen ist
+ // Ordner aufklappen und die Suche leeren, damit das Feld zu sehen ist
+ this.clearQuery();
+ if (parent) { this.openAncestors(parent); this.expanded.add(parent); }
this.render();
}
@@ -158,9 +230,17 @@ export class FileTree {
if (fileOpBlockReason(n.path, 'rename') || this.submitting) return;
this.edit = { mode: 'rename', node: n };
this.input = null;
+ if (this.query && !this.hit(n)) this.clearQuery();
+ this.openAncestors(n.path);
this.render();
}
+ /** Umbenennen einer Datei, die gerade im Baum steht (aus dem Menü eines anderen Panels). */
+ startRenameAt(rel: string): void {
+ const n = this.find(rel);
+ if (n) this.startRename(n);
+ }
+
private inputRow(depth: number, ico: string, value: string): HTMLElement {
const prev = this.input;
// Neu gezeichnet, während das Feld offen ist: das Getippte übernehmen
@@ -213,7 +293,8 @@ export class FileTree {
// ---- Menü -----------------------------------------------------------------------------------------------------
- private openMenu(n: FileNode | null, x: number, y: number): void {
+ /** `outside`: aus einem anderen Panel geöffnet. Dann ohne Anlegen, Umbenennen geht im Baum weiter. */
+ private openMenu(n: FileNode | null, x: number, y: number, outside = false): void {
const d = this.deps;
const folder = n ? (n.dir ? n.path : parentOf(n.path)) : '';
const blockCreate = fileOpBlockReason(folder, 'create');
@@ -223,6 +304,7 @@ export class FileTree {
if (TEXT_EXT.test(n.name) || /\.(pdf|dxf)$/i.test(n.name)) items.push(menuItem('Open', { icon: 'code', onClick: () => d.open(n) }));
if (IMAGE_EXT.test(n.name)) items.push(menuItem('Mark up', { icon: 'camera', onClick: () => d.mark(n.path) }));
if (VIDEO_EXT.test(n.name)) items.push(menuItem('Play', { icon: 'play', onClick: () => d.open(n) }));
+ if (outside) items.push(menuItem('Show in file tree', { icon: 'file', onClick: () => d.showInTree(n.path, false) }));
items.push(menuItem('Open with default app', { icon: 'openext', onClick: () => d.openExternal(n.path) }));
}
items.push(menuItem('Show in Explorer', { icon: 'folder', onClick: () => d.reveal(n?.path ?? '') }));
@@ -231,11 +313,13 @@ export class FileTree {
menuItem('Send path to agent', { icon: 'send', onClick: () => d.toAgent(n.path) }),
menuItem('Copy path', { icon: 'copy', onClick: () => d.copyPath(n.path) }));
}
- items.push(el('div', { className: 'msep' }),
- blocked(menuItem(n?.dir ? 'New file here' : 'New file', { icon: 'fileplus', onClick: () => this.startCreate(folder, false) }), blockCreate),
- blocked(menuItem(n?.dir ? 'New folder here' : 'New folder', { icon: 'folderplus', onClick: () => this.startCreate(folder, true) }), blockCreate));
+ items.push(el('div', { className: 'msep' }));
+ if (!outside) {
+ items.push(blocked(menuItem(n?.dir ? 'New file here' : 'New file', { icon: 'fileplus', onClick: () => this.startCreate(folder, false) }), blockCreate),
+ blocked(menuItem(n?.dir ? 'New folder here' : 'New folder', { icon: 'folderplus', onClick: () => this.startCreate(folder, true) }), blockCreate));
+ }
if (n) {
- items.push(blocked(menuItem('Rename', { icon: 'pen', kbd: 'F2', onClick: () => this.startRename(n) }), fileOpBlockReason(n.path, 'rename')),
+ items.push(blocked(menuItem('Rename', { icon: 'pen', kbd: outside ? undefined : 'F2', onClick: () => (outside ? d.showInTree(n.path, true) : this.startRename(n)) }), fileOpBlockReason(n.path, 'rename')),
blocked(menuItem('Delete', { icon: 'trash', kbd: 'Del', onClick: () => d.trash(n.path) }), fileOpBlockReason(n.path, 'delete')));
}
this.menu.replaceChildren(...items);
@@ -253,13 +337,13 @@ export class FileTree {
}
private toggle(key: string): void {
- if (this.collapsed.has(key)) this.collapsed.delete(key); else this.collapsed.add(key);
+ if (this.expanded.has(key)) this.expanded.delete(key); else this.expanded.add(key);
this.render();
}
private row(n: FileNode, depth: number): HTMLElement {
if (n.dir) {
- const open = !this.collapsed.has(n.path);
+ const open = this.isOpen(n.path);
const b = this.button(depth, open ? 'down' : 'right', 'folder', n.name, '', 'dir');
b.setAttribute('aria-expanded', String(open));
b.title = n.path;
@@ -280,7 +364,10 @@ export class FileTree {
/** Datei, die gerade im Code offen ist: im Baum hervorheben, damit man sieht, wo man ist. */
setActive(rel: string | null): void {
+ const changed = rel !== this.active;
this.active = rel;
+ // Neu geöffnete Datei: Ordner darüber aufklappen, damit man sieht, wo sie liegt
+ if (rel && changed && this.openAncestors(rel)) { this.render(); return; }
this.root.querySelectorAll<HTMLElement>('.frow[data-path]').forEach((r) => r.classList.toggle('sel', r.dataset.path === rel));
}
@@ -294,9 +381,17 @@ export class FileTree {
const b = el('button', { className: 'frow' + (cls ? ' ' + cls : '') },
el('span', { className: 'chev' }, chev ? icon(chev, 12, 2.2) : ''),
el('span', { className: 'fi' }, icon(ico, 15)),
- el('span', { className: 'fn', textContent: name }),
+ this.nameEl(name),
tag ? el('span', { className: 'tag', textContent: tag }) : null);
b.style.paddingLeft = `${8 + depth * 18}px`;
return b;
}
+
+ /** Name, beim Suchen mit hervorgehobenem Treffer. Nur Textknoten, Namen kommen aus dem Projekt. */
+ private nameEl(name: string): HTMLElement {
+ const q = this.query.toLowerCase();
+ const at = q && !q.includes('/') ? name.toLowerCase().indexOf(q) : -1;
+ if (at < 0) return el('span', { className: 'fn', textContent: name });
+ return el('span', { className: 'fn' }, name.slice(0, at), el('span', { className: 'hit', textContent: name.slice(at, at + q.length) }), name.slice(at + q.length));
+ }
}
diff --git a/app/src/renderer/icons.ts b/app/src/renderer/icons.ts
index 56a3a3a..db5969e 100644
--- a/app/src/renderer/icons.ts
+++ b/app/src/renderer/icons.ts
@@ -77,6 +77,10 @@ const PATHS: Record<string, string> = {
play: '<path d="M7 5v14l11-7z"/>',
// Animation, Analyse und Video (E58)
pause: '<path d="M8 5v14M16 5v14"/>',
+ // Lautstärke im Video-Player: Lautsprecher mit zwei, einer oder keiner Welle (stumm)
+ volume: '<path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z"/><path d="M15.5 9a4.2 4.2 0 0 1 0 6M18.2 6.3a8 8 0 0 1 0 11.4"/>',
+ volumelow: '<path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z"/><path d="M15.5 9a4.2 4.2 0 0 1 0 6"/>',
+ mute: '<path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z"/><path d="m16 9.5 5 5M21 9.5l-5 5"/>',
anim: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m10 9 5 3-5 3z"/>',
// Zeichnungen (E76): Blatt quer mit Schriftfeld unten rechts und einer Ansicht
drawing: '<rect x="2.5" y="4.5" width="19" height="15" rx="1"/><path d="M13 19.5v-4.5h8.5"/><rect x="5.5" y="8" width="5" height="4.5"/><path d="M13.5 10.2h4.5"/>',
diff --git a/app/src/renderer/index.html b/app/src/renderer/index.html
index b4a4e13..add7b80 100644
--- a/app/src/renderer/index.html
+++ b/app/src/renderer/index.html
@@ -70,6 +70,7 @@
<button id="btn-folder-new" class="ibtn s" title="New folder" aria-label="New folder"><i data-icon="folderplus" data-size="15"></i></button>
<button id="btn-reveal" class="ibtn s" title="Show in Explorer" aria-label="Show in Explorer"><i data-icon="openext" data-size="15"></i></button>
<button class="ibtn s side-close" aria-label="Close files"><i data-icon="x" data-size="15" data-stroke="2"></i></button></div>
+ <label class="ftree-search"><i data-icon="search" data-size="13" data-stroke="2"></i><input id="files-filter" type="search" placeholder="Search files" spellcheck="false" autocomplete="off" aria-label="Search files by name"></label>
<div id="tab-files" class="ftree"></div>
<div id="dropzone" class="dropzone" title="STEP files, images and sketches go to inputs/. Existing files are not overwritten."><i data-icon="upload" data-size="16"></i><span><b>Drop here:</b> goes to <code>inputs/</code></span></div>
</section>
@@ -340,9 +341,13 @@
<button id="btn-video-play" class="ibtn" aria-label="Play" title="Play or pause (Space)"><i data-icon="play" data-size="16" data-stroke="2"></i></button>
<button id="btn-video-fwd" class="ibtn" aria-label="One frame forward" title="One frame forward (Right arrow)"><i data-icon="stepfwd" data-size="15" data-stroke="1.9"></i></button>
<input id="video-range" type="range" min="0" max="1" step="0.01" value="0" aria-label="Time in the video">
- <span id="video-time" class="an-time"></span><span class="vsep"></span>
+ <span id="video-time" class="an-time"></span>
+ <button id="btn-video-mute" class="ibtn" aria-label="Mute" title="Mute or unmute (M)"><i data-icon="volume" data-size="16" data-stroke="1.9"></i></button>
+ <input id="video-volume" class="vv-vol" type="range" min="0" max="1" step="0.05" value="1" aria-label="Volume" title="Volume">
+ <span class="vsep"></span>
<button id="btn-video-mark" class="btn sm" title="Mark up this frame on the canvas and send it to the agent with a timestamp"><i data-icon="camera" data-size="14" data-stroke="1.9"></i>Mark up</button>
<button id="btn-video-agent" class="btn sm acc" title="Add the file and timestamp to the agent's input"><i data-icon="send" data-size="14" data-stroke="1.9"></i>Time to agent</button>
+ <button id="btn-video-more" class="ibtn" aria-label="File actions" title="Show in file tree or Explorer, rename, delete …" aria-haspopup="menu"><i data-icon="more" data-size="16"></i></button>
<button id="btn-video-close" class="ibtn" aria-label="Close video" title="Close video (Escape)"><i data-icon="x" data-size="15" data-stroke="2"></i></button>
</div>
</div>
diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.ts
index 451ab06..b08f4a5 100644
--- a/app/src/renderer/main.ts
+++ b/app/src/renderer/main.ts
@@ -326,11 +326,14 @@ const files = new FileTree($('tab-files'), $('menu-ctx'), {
rename: async (rel, name) => {
if (!fileOpAllowed(rel, 'rename')) return true;
const wasOpen = code.openUnder(rel);
+ const playing = videoView.current;
const r = await api.fs.rename(rel, name);
if (!r.ok || !r.path) { toast(r.error ?? `${rel} could not be renamed.`, 'error'); return false; }
// Reiter wandern mit: der alte zu, die Datei unter neuem Namen wieder auf (ohne das Panel zu wechseln)
code.forget(rel);
for (const f of wasOpen) void code.open(r.path + f.slice(rel.length), undefined, false);
+ // Das laufende Video ebenso, sonst zeigte der Player einen Namen, den es nicht mehr gibt
+ if (playing && isUnder(playing, rel)) void videoView.open(r.path + playing.slice(rel.length));
await refreshFiles();
return true;
},
@@ -340,6 +343,7 @@ const files = new FileTree($('tab-files'), $('menu-ctx'), {
if (r.canceled) return;
if (!r.ok) { toast(r.error ?? `${rel} could not be deleted.`, 'error'); return; }
code.forget(rel);
+ if (videoView.current && isUnder(videoView.current, rel)) videoView.close();
await refreshFiles();
toast(`${rel} is in the Recycle Bin.`);
})(),
@@ -348,8 +352,20 @@ const files = new FileTree($('tab-files'), $('menu-ctx'), {
mark: (rel) => void markImage(rel),
toAgent: (rel) => insertToAgent(`[File: ${rel}] `),
copyPath: (rel) => void navigator.clipboard.writeText(rel).then(() => toast(`Path copied: ${rel}`), (e) => toast(`The path could not be copied: ${e instanceof Error ? e.message : String(e)}`, 'error')),
+ showInTree: (rel, rename) => void showInTree(rel, rename),
});
fileTree = files;
+files.attachSearch($<HTMLInputElement>('files-filter'));
+
+const isUnder = (rel: string, dir: string) => rel === dir || rel.startsWith(`${dir}/`);
+
+/** Aus einem anderen Panel (Videos im Reiter Animation): Dateibaum zeigen, die Datei darin finden, auf Wunsch umbenennen. */
+async function showInTree(rel: string, rename: boolean): Promise<void> {
+ showPanel('files');
+ await refreshFiles();
+ files.reveal(rel, !rename);
+ if (rename) files.startRenameAt(rel);
+}
files.setActive(code.activeFile);
async function openExternal(rel: string): Promise<void> {
@@ -838,6 +854,9 @@ const animPanel = new AnimPanel({
tool: animTool, videos: () => viewLists.videos, openVideo: (rel) => void videoView.open(rel),
openCode: (file, line) => void openCode(file, line ? { from: line, to: line, label: animTool.currentName ?? 'Animation' } : undefined),
insert: (t) => insertToAgent(t), isNew: (k) => !seen.has(k), seen: (k) => { seen.add(k); },
+ fileMenu: (rel, x, y) => files.menuFor(rel, x, y),
+ closedDirs: () => { try { return project ? JSON.parse(store.get(`soma.anim.closedDirs.${project.id}`) ?? '[]') as string[] : []; } catch { return []; } },
+ setClosedDirs: (dirs) => { if (project) store.set(`soma.anim.closedDirs.${project.id}`, JSON.stringify(dirs)); },
});
// Messen und Explosion schalten die beiden aus, bevor sie selbst anfangen (Lauscher in der Erfassungsphase laufen vor denen
// der Werkzeuge): Beide rechnen mit der Einbaulage
@@ -848,9 +867,11 @@ const videoView = new VideoView({
root: $('videoview'), video: $<HTMLVideoElement>('video-el'), title: $('video-title'), play: $<HTMLButtonElement>('btn-video-play'),
back: $<HTMLButtonElement>('btn-video-back'), fwd: $<HTMLButtonElement>('btn-video-fwd'), range: $<HTMLInputElement>('video-range'), time: $('video-time'),
mark: $<HTMLButtonElement>('btn-video-mark'), agent: $<HTMLButtonElement>('btn-video-agent'), close: $<HTMLButtonElement>('btn-video-close'),
+ mute: $<HTMLButtonElement>('btn-video-mute'), volume: $<HTMLInputElement>('video-volume'), more: $<HTMLButtonElement>('btn-video-more'),
}, {
readBinary: (rel) => api.fs.readBinary(rel), insert: (t) => insertToAgent(t), toast,
markFrame: (label, c) => markSource(label, c, c.width, c.height),
+ fileMenu: (rel, x, y) => files.menuFor(rel, x, y), load: store.get, save: store.set,
});
$('btn-mark').addEventListener('click', startMarkup);
@@ -2046,6 +2067,7 @@ if (api.testMode) {
tourGo: (n: number) => tour.goTo(n),
setAgentCollapsed,
fileRows: () => [...document.querySelectorAll('#tab-files .frow .fn')].map((x) => x.textContent),
+ revealFile: (rel: string) => files.reveal(rel, false),
codeText: () => code.text(),
openCode: (file: string) => openCode(file),
buildStarts: () => buildStarts,
diff --git a/app/src/renderer/style.css b/app/src/renderer/style.css
index f688c2b..fff04f3 100644
--- a/app/src/renderer/style.css
+++ b/app/src/renderer/style.css
@@ -115,6 +115,10 @@ code { font-family:var(--mono); font-size:.95em; }
/* Dateien */
.ftree { flex:1; overflow:auto; padding:8px 0; }
+.ftree-search { display:flex; align-items:center; gap:7px; height:30px; flex-shrink:0; margin:8px 10px 0; padding:0 8px; border:1px solid var(--line2); border-radius:6px; background:var(--bg); color:var(--tx3); }
+.ftree-search:focus-within { border-color:var(--acc-line); }
+.ftree-search input { flex:1; min-width:0; height:26px; border:0; outline:0; background:none; color:var(--tx); font:inherit; padding:0; }
+.frow .fn .hit { color:var(--acc-tx); font-weight:600; }
.frow { display:flex; align-items:center; gap:8px; height:26px; padding:0 8px; margin:0 6px; border-radius:6px; width:calc(100% - 12px); text-align:left; color:var(--tx); white-space:nowrap; }
.frow:hover { background:var(--s3); }
.frow .fn { overflow:hidden; text-overflow:ellipsis; }
@@ -734,6 +738,13 @@ code { font-family:var(--mono); font-size:.95em; }
.al-row .m { font-size:12px; color:var(--tx3); margin-top:2px; }
.al-row .m .w { color:var(--warn); }
.al-row .tag { margin-left:2px; }
+/* Ordner der Videos (Wunsch des Nutzers): einklappbar, damit viele Einzelclips des Agenten die Hauptvideos nicht verdecken */
+.al-dir { display:flex; align-items:center; gap:6px; width:calc(100% - 12px); height:28px; margin:2px 6px 0; padding:0 10px 0 8px; border-radius:6px; color:var(--tx2); font:12px var(--mono); text-align:left; }
+.al-dir:hover { background:var(--s3); color:var(--tx); }
+.al-dir .chev { color:var(--tx3); display:flex; }
+.al-dir .cnt { margin-left:auto; color:var(--tx3); font-family:var(--sans); }
+.al-dir .tag { font-family:var(--sans); }
+.al-row.in { padding-left:30px; }
.al-row .v { text-align:right; font-size:13px; color:var(--tx); white-space:nowrap; }
.al-row .v span { display:block; font-size:12px; color:var(--tx3); margin-top:2px; }
.al-row.cur { background:var(--acc-tint); }
@@ -828,6 +839,7 @@ code { font-family:var(--mono); font-size:.95em; }
.videoview video { max-width:100%; max-height:100%; background:#000; border-radius:6px; box-shadow:var(--shadow); }
.vv-bar { left:50%; bottom:12px; transform:translateX(-50%); width:min(940px, calc(100% - 24px)); display:flex; align-items:center; gap:4px; padding:4px 6px; }
.vv-bar input[type=range] { flex:1 1 140px; min-width:90px; }
+.vv-bar input.vv-vol { flex:0 0 72px; min-width:0; }
.vv-bar .an-time { flex-shrink:0; }
.vv-title { display:flex; align-items:center; gap:7px; padding:0 6px; min-width:0; max-width:220px; flex-shrink:2; color:var(--tx2); }
.vv-title b { color:var(--tx); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
diff --git a/app/src/renderer/videoview.ts b/app/src/renderer/videoview.ts
index 6fd7cd5..035e38d 100644
--- a/app/src/renderer/videoview.ts
+++ b/app/src/renderer/videoview.ts
@@ -3,11 +3,13 @@ import { icon } from './icons';
// Videos aus dem Projekt abspielen (E58), etwa die von `soma render --video`. Anhalten, Bild für Bild, und ein Standbild mit
// Zeitstempel markieren oder nur die Zeit an den Agenten geben. Der Player liegt über dem Viewer, das Modell bleibt dahinter.
+// Lautstärke und Stumm gelten für alle Videos und bleiben über den Neustart erhalten. „…“ öffnet das Menü der Datei.
interface Ui {
root: HTMLElement; video: HTMLVideoElement; title: HTMLElement;
play: HTMLButtonElement; back: HTMLButtonElement; fwd: HTMLButtonElement;
range: HTMLInputElement; time: HTMLElement; mark: HTMLButtonElement; agent: HTMLButtonElement; close: HTMLButtonElement;
+ mute: HTMLButtonElement; volume: HTMLInputElement; more: HTMLButtonElement;
}
interface Deps {
readBinary(rel: string): Promise<ArrayBuffer>;
@@ -15,6 +17,11 @@ interface Deps {
markFrame(label: string, frame: HTMLCanvasElement): Promise<void>;
insert(text: string): void;
toast(text: string, kind?: 'ok' | 'info' | 'error'): void;
+ /** Menü der Datei (wie im Dateibaum) an dieser Stelle. */
+ fileMenu(rel: string, x: number, y: number): void;
+ /** Gemerkte Einstellungen des Benutzers (localStorage, darf fehlen). */
+ load(key: string): string | null;
+ save(key: string, value: string): void;
}
/** Schritt für „Bild vor/zurück“: Videos von soma haben 30 Bilder je Sekunde. */
@@ -33,6 +40,26 @@ export class VideoView {
ui.close.addEventListener('click', () => this.close());
ui.mark.addEventListener('click', () => void this.mark());
ui.agent.addEventListener('click', () => { if (this.file) d.insert(`[Video: ${this.file} at ${videoStamp(v.currentTime)}] `); });
+ const raw = d.load('soma.video.volume');
+ const vol = raw === null ? 1 : Number(raw);
+ v.volume = Number.isFinite(vol) && vol >= 0 && vol <= 1 ? vol : 1;
+ v.muted = d.load('soma.video.muted') === '1';
+ ui.mute.addEventListener('click', () => this.toggleMute());
+ ui.volume.addEventListener('input', () => {
+ v.volume = Number(ui.volume.value);
+ // Regler ganz links heißt stumm, wieder hochziehen hebt es auf
+ v.muted = v.volume === 0;
+ });
+ v.addEventListener('volumechange', () => {
+ d.save('soma.video.volume', String(v.volume));
+ d.save('soma.video.muted', v.muted ? '1' : '0');
+ this.renderVolume();
+ });
+ ui.more.addEventListener('click', () => {
+ if (!this.file) return;
+ const r = ui.more.getBoundingClientRect();
+ d.fileMenu(this.file, r.left, r.top);
+ });
for (const ev of ['timeupdate', 'seeked', 'loadedmetadata', 'play', 'pause', 'ended']) v.addEventListener(ev, () => this.render());
v.addEventListener('click', () => (v.paused ? void v.play().catch(() => {}) : v.pause()));
v.addEventListener('error', () => { if (this.file) d.toast(`${this.file} can't be played (format?). Right-click it in the file tree: “Open with default app”.`, 'error'); });
@@ -41,6 +68,7 @@ export class VideoView {
if (e.key === ' ') { e.preventDefault(); if (v.paused) void v.play().catch(() => {}); else v.pause(); }
else if (e.key === 'ArrowLeft') { e.preventDefault(); this.step(-1); }
else if (e.key === 'ArrowRight') { e.preventDefault(); this.step(1); }
+ else if ((e.key === 'm' || e.key === 'M') && !e.ctrlKey && !e.altKey && !e.metaKey) { e.preventDefault(); this.toggleMute(); }
else if (e.key === 'Escape' && !document.querySelector('.menu:not([hidden])')) this.close();
});
}
@@ -75,6 +103,21 @@ export class VideoView {
this.url = null;
}
+ private toggleMute(): void {
+ const v = this.ui.video;
+ // Stumm aufheben, nachdem der Regler auf null gezogen wurde: mit halber Lautstärke statt lautlos weiter
+ if (v.muted && v.volume === 0) v.volume = 0.5;
+ v.muted = !v.muted;
+ }
+
+ private renderVolume(): void {
+ const v = this.ui.video;
+ const off = v.muted || v.volume === 0;
+ this.ui.volume.value = String(off ? 0 : v.volume);
+ this.ui.mute.replaceChildren(icon(off ? 'mute' : v.volume < 0.5 ? 'volumelow' : 'volume', 16, 1.9));
+ this.ui.mute.setAttribute('aria-label', off ? 'Unmute' : 'Mute');
+ }
+
private step(dir: number): void {
const v = this.ui.video;
v.pause();
@@ -90,6 +133,7 @@ export class VideoView {
this.ui.time.textContent = `${videoStamp(v.currentTime)} / ${videoStamp(dur)}`;
this.ui.play.replaceChildren(icon(v.paused ? 'play' : 'pause', 16, 2));
this.ui.play.setAttribute('aria-label', v.paused ? 'Play' : 'Pause');
+ this.renderVolume();
}
/** Das gerade gezeigte Bild in voller Auflösung. */
@@ -114,7 +158,8 @@ export class VideoView {
/** Prüfhilfen. */
state() {
const v = this.ui.video;
- return { open: this.isOpen, file: this.file, time: this.ui.time.textContent, width: v.videoWidth, height: v.videoHeight, duration: v.duration, ready: v.readyState, error: v.error?.code ?? null };
+ return { open: this.isOpen, file: this.file, time: this.ui.time.textContent, width: v.videoWidth, height: v.videoHeight, duration: v.duration, ready: v.readyState, error: v.error?.code ?? null,
+ volume: v.volume, muted: v.muted, slider: Number(this.ui.volume.value), muteLabel: this.ui.mute.getAttribute('aria-label') };
}
async testSeek(t: number): Promise<void> {
const v = this.ui.video;