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: Startet die Shell nicht, meldet das Terminal den Grund

Kai-Jungsthoefel6f514f161163
diff --git a/app/src/main/terminals.ts b/app/src/main/terminals.ts
index 1ef4b8b..02e3ac4 100644
--- a/app/src/main/terminals.ts
+++ b/app/src/main/terminals.ts
@@ -40,9 +40,15 @@ export class TerminalManager {
create(opts: { command?: string } = {}): number {
const win = process.platform === 'win32';
const shell = win ? 'powershell.exe' : (process.env.SHELL || 'bash');
- const p = pty.spawn(shell, win ? ['-NoLogo'] : [], {
- name: 'xterm-256color', cols: 100, rows: 30, cwd: this.dir, env: terminalEnv(this.dir) as Record<string, string>,
- });
+ let p: pty.IPty;
+ try {
+ p = pty.spawn(shell, win ? ['-NoLogo'] : [], {
+ name: 'xterm-256color', cols: 100, rows: 30, cwd: this.dir, env: terminalEnv(this.dir) as Record<string, string>,
+ });
+ } catch (e) {
+ console.error('[terminal]', e);
+ throw new Error(`Could not start the terminal (${shell}): ${e instanceof Error ? e.message : String(e)}`);
+ }
const id = nextId++;
this.terms.set(id, p);
p.onData((d) => { if (!this.wc.isDestroyed()) this.wc.send('term:data', id, d); });
diff --git a/app/src/renderer/terminals.ts b/app/src/renderer/terminals.ts
index f90d871..97ac885 100644
--- a/app/src/renderer/terminals.ts
+++ b/app/src/renderer/terminals.ts
@@ -2,7 +2,7 @@ import { FitAddon } from '@xterm/addon-fit';
import { WebglAddon } from '@xterm/addon-webgl';
import { Terminal } from '@xterm/xterm';
import { icon } from './icons';
-import { el } from './ui';
+import { el, toast } from './ui';
interface Tab { id: number; term: Terminal; fit: FitAddon; pane: HTMLElement; tab: HTMLElement; title: string; agent: boolean; exited: boolean }
@@ -38,10 +38,17 @@ export class TerminalTabs {
new ResizeObserver(() => this.fitActive()).observe(panes);
}
- async add(opts: { command?: string; title?: string } = {}): Promise<number> {
+ async add(opts: { command?: string; title?: string } = {}): Promise<number | null> {
// Vor dem Anlegen der Shell warten: Danach darf bis zum Eintrag in `tabs` nichts mehr warten, sonst gehen Ausgaben verloren
await fontsReady;
- const id = await window.soma.term.create({ command: opts.command });
+ let id: number;
+ try {
+ id = await window.soma.term.create({ command: opts.command });
+ } catch (e) {
+ // Shell startet nicht (fehlt, keine Rechte): sagen, statt still kein Terminal zu zeigen
+ toast(String(e instanceof Error ? e.message : e).replace(/^Error invoking remote method '[^']+': (Error: )?/, ''), 'error');
+ return null;
+ }
const term = new Terminal({
fontFamily: '"IBM Plex Mono", "Cascadia Mono", Consolas, monospace', fontSize: 13, lineHeight: 1, cursorBlink: true, scrollback: 5000,
fontWeight: '400', fontWeightBold: '700',