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: „Send to agent“ kopiert die Notiz auch in die Zwischenablage

Kai-Jungsthoefel6aaf82e82472
diff --git a/app/src/main/main.ts b/app/src/main/main.ts
index 9978868..1cfd071 100644
--- a/app/src/main/main.ts
+++ b/app/src/main/main.ts
@@ -153,6 +153,12 @@ function registerIpc(ctl: ProjectController): void {
return err ? { ok: false, error: err } : { ok: true, path: String(rel ?? '') };
});
// Links aus Markdown-Dateien (E51). Nur Web und Mail: file:, Programme und eigene Protokolle könnten etwas ausführen.
+ // „Send to agent“ legt den Text auch in die Zwischenablage, für Agenten-Apps außerhalb der App (Claude Desktop, Codex-App)
+ ipcMain.handle('app:copyText', (_e, text: unknown): FileOpResult => {
+ if (typeof text !== 'string' || text.length > 1_000_000) return { ok: false, error: 'Nothing to copy.' };
+ if (process.env.SOMA_TEST === '1') testClipboard = text; else clipboard.writeText(text);
+ return { ok: true };
+ });
ipcMain.handle('app:openUrl', async (_e, url: unknown): Promise<FileOpResult> => {
const u = String(url ?? '');
if (!/^(https?:\/\/|mailto:)/i.test(u)) return { ok: false, error: `Only web and mail addresses can be opened: ${u.slice(0, 100)}` };
diff --git a/app/src/preload/preload.ts b/app/src/preload/preload.ts
index fb90113..5ec76c4 100644
--- a/app/src/preload/preload.ts
+++ b/app/src/preload/preload.ts
@@ -150,6 +150,7 @@ const api: SomaApi = {
},
},
openUrl: (url) => ipcRenderer.invoke('app:openUrl', url),
+ copyText: (text) => ipcRenderer.invoke('app:copyText', text),
// Nur im Testmodus: vorbereitete Antworten für native Dialoge
test: process.env.SOMA_TEST === '1'
? {
diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.ts
index cc001ac..451ab06 100644
--- a/app/src/renderer/main.ts
+++ b/app/src/renderer/main.ts
@@ -583,11 +583,14 @@ function errorText(): string | null {
function insertToAgent(text: string | null, done?: string): void {
if (!text) return;
const pre = done ? `${done}\n` : '';
- if (!terminals.count) { toast(`${pre}No terminal is open. Start an agent or a terminal with +.`, 'error'); return; }
+ // Immer auch in die Zwischenablage: Eine Agenten-App außerhalb der App (Claude Desktop, Codex-App) erreicht die Notiz nur so.
+ // Ob im Terminal ein Agent läuft, lässt sich nicht für jeden Agenten verlässlich erkennen
+ void api.copyText(text);
+ if (!terminals.count) { toast(`${pre}Copied to the clipboard. Paste it into your agent, or start one with +.`, 'info'); return; }
setAgentCollapsed(false);
const title = terminals.insert(text);
- if (title) toast(`${pre}Added to the input of ${title}. Enter sends it.`);
- else toast(`${pre}All terminals have ended. Open a new one with +.`, 'error');
+ if (title) toast(`${pre}Added to the input of ${title}. Enter sends it. Also copied to the clipboard.`);
+ else toast(`${pre}Copied to the clipboard. All terminals have ended, open a new one with +.`, 'info');
}
// ---- Messen (E9) ------------------------------------------------------------------------------------------------
diff --git a/app/src/shared/types.ts b/app/src/shared/types.ts
index 9fc0072..5a2c13a 100644
--- a/app/src/shared/types.ts
+++ b/app/src/shared/types.ts
@@ -627,6 +627,8 @@ export interface SomaApi {
};
/** Öffnet eine Web-Adresse (http, https, mailto) im Browser des Systems. Andere Adressen lehnt der Hauptprozess ab. */
openUrl(url: string): Promise<FileOpResult>;
+ /** Text in die Zwischenablage (etwa „Send to agent“ für Agenten-Apps außerhalb der App). */
+ copyText(text: string): Promise<FileOpResult>;
}
/** Schnittstelle des unsichtbaren Render-Fensters (E58, render-preload.ts). */
diff --git a/app/test/smoke.mjs b/app/test/smoke.mjs
index 7f15f04..581255f 100644
--- a/app/test/smoke.mjs
+++ b/app/test/smoke.mjs
@@ -132,6 +132,7 @@ try {
const afterInsert = await ev((id) => window.__t.termText(id), tid);
check('„Send to agent" fügt den Text in die Eingabezeile ein, ohne abzuschicken', afterInsert.includes('[Selection: part "Lid"') && !/Selection:.*\n.*(nicht erkannt|not recognized)/.test(afterInsert));
check('Bestätigung „Added to the input of Terminal"', (await ev(() => window.__t.toast())).text.includes('Added to the input of Terminal'));
+ check('… und derselbe Text in der Zwischenablage (für Agenten-Apps außerhalb der App)', (await ev(() => window.soma.test.clipboard())) === selText);
await ev((id) => window.soma.term.write(id, '\x03'), tid); // Zeile verwerfen
// Markierung (E16): Viewer-Bild einfrieren, zeichnen, als PNG nach .soma/feedback/, Pfad in die Eingabe