Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(speech): Insert without Enter — sendText gains an enter:false variant (desktop-dictation Task 10b)
enes3bdd1af4b390
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex b3f650bf9..4c351a10c 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -628,8 +628,8 @@ export class PtyManager {platform().handle(IPC.ptyReadScrollback, (persistKey: string) =>readScrollback(persistKey))- platform().handle(IPC.ptySendText, (persistKey: string, text: string) =>- this.sendText(persistKey, text)+ platform().handle(IPC.ptySendText, (persistKey: string, text: string, enter?: boolean) =>+ this.sendText(persistKey, text, enter === undefined ? undefined : { enter }))platform().handle(IPC.ptyTmuxStatus, () => this.tmuxStatus())}@@ -1720,17 +1720,25 @@ export class PtyManager {}/**- * Send literal text followed by Enter into a node's tmux session (e.g. a slash command).- * Works whether or not a client is attached. Returns false if tmux is unavailable or the- * session doesn't exist yet.+ * Send literal text, by default followed by Enter, into a node's tmux session (e.g. a slash+ * command). Works whether or not a client is attached. Returns false if tmux is unavailable or+ * the session doesn't exist yet.+ *+ * `opts.enter` defaults to `true` — every existing caller (slash commands, /rename, /branch,+ * note pushes) relies on the Enter being sent, so this stays bit-for-bit unless a caller opts+ * out. `enter: false` is for dictation's Insert action: it writes text into the terminal+ * WITHOUT submitting it, so the user can edit/append before running it themselves.*/- async sendText(persistKey: string, text: string): Promise<boolean> {+ async sendText(persistKey: string, text: string, opts?: { enter?: boolean }): Promise<boolean> {if (!this.tmuxPath) return falseconst target = sessionName(persistKey)+ const enter = opts?.enter ?? truetry {- // The literal text and the Enter must be sent in order, so await sequentially.+ // The literal text and the Enter (when sent) must go in order, so await sequentially.await runAsync(this.tmuxPath, ['-L', TMUX_SOCKET, 'send-keys', '-t', target, '-l', text])- await runAsync(this.tmuxPath, ['-L', TMUX_SOCKET, 'send-keys', '-t', target, 'Enter'])+ if (enter) {+ await runAsync(this.tmuxPath, ['-L', TMUX_SOCKET, 'send-keys', '-t', target, 'Enter'])+ }return true} catch {return falsediff --git a/src/preload/index.ts b/src/preload/index.tsindex 4cf10b4ee..6c507cfd7 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -64,7 +64,8 @@ const api: NodeTerminalApi = {ipcRenderer.invoke(IPC.ptyGenerateGroupName, memberKeys, cwd),capture: (persistKey, full) => ipcRenderer.invoke(IPC.ptyCapture, persistKey, full),readScrollback: (persistKey) => ipcRenderer.invoke(IPC.ptyReadScrollback, persistKey),- sendText: (persistKey, text) => ipcRenderer.invoke(IPC.ptySendText, persistKey, text),+ sendText: (persistKey, text, opts) =>+ ipcRenderer.invoke(IPC.ptySendText, persistKey, text, opts?.enter),tmuxStatus: () => ipcRenderer.invoke(IPC.ptyTmuxStatus),readSessionName: (sessionId, accountId) =>ipcRenderer.invoke(IPC.ptyReadSessionName, sessionId, accountId),diff --git a/src/renderer/bridge/ws-bridge.ts b/src/renderer/bridge/ws-bridge.tsindex 63c4b9a63..4eccab6e0 100644--- a/src/renderer/bridge/ws-bridge.ts+++ b/src/renderer/bridge/ws-bridge.ts@@ -207,8 +207,8 @@ export function buildRealApi(client.request(IPC.ptyCapture, persistKey, full).catch(() => '') as Promise<string>,readScrollback: (persistKey) =>client.request(IPC.ptyReadScrollback, persistKey) as Promise<string>,- sendText: (persistKey, text) =>- client.request(IPC.ptySendText, persistKey, text) as Promise<boolean>,+ sendText: (persistKey, text, opts) =>+ client.request(IPC.ptySendText, persistKey, text, opts?.enter) as Promise<boolean>,// Fail-open: an errored status must not raise the banner in the browser.tmuxStatus: () =>clientdiff --git a/src/renderer/components/DictationOverlay.tsx b/src/renderer/components/DictationOverlay.tsxindex e39fbd541..45517c190 100644--- a/src/renderer/components/DictationOverlay.tsx+++ b/src/renderer/components/DictationOverlay.tsx@@ -4,18 +4,15 @@//// NOTHING here auto-submits: only the explicit Send button ever pushes text into a session.//-// Insert-without-Enter gap (read before "fixing" this): the design wants Insert to write into a-// terminal WITHOUT the trailing Enter that `pty.sendText` always appends (it runs two separate-// `tmux send-keys` calls server-side — literal text, then a separate Enter — with no way to skip-// the second one). The only primitive that writes without an Enter is `pty.write(sessionId, data)`,-// but that takes the PTY's own ephemeral session id (`pty-<n>`, assigned in PtyManager.spawnSession),-// which is NOT the node id and is only ever known inside the mounted TerminalNode component (its-// `sessionId` local variable, set from `pty.create()`'s result) — nothing outside that component-// exposes it. Reaching it from here would mean either a new IPC channel keyed by persistKey (out of-// scope for this task) or modifying TerminalNode.tsx to publish a lookup (also out of this task's-// file list). Chat has the same shape of gap: ChatNode's compose box is local component state with-// no externally settable draft. So Insert is disabled for both target kinds, with a tooltip-// explaining why — Send (which already has an explicit-submission story) is the one working action.+// Insert (terminal): `pty.sendText(persistKey, text, { enter: false })` writes the literal text+// into the node's tmux session without the trailing Enter, so the user can edit/append before+// running it themselves (Task 10b — `enter` defaults to true everywhere else, so every other+// caller of sendText is untouched).+//+// Insert (chat): ChatNode's compose box is local component state with no externally settable+// draft, so there's no seam to write into without submitting — Insert stays disabled for chat+// targets, with a tooltip explaining why. Send (which already has an explicit-submission story)+// is the working action there.import { useCallback, useEffect, useRef, useState } from 'react'import { createPortal } from 'react-dom'import { PcmCapture } from '../lib/pcm-capture'@@ -207,13 +204,36 @@ export function DictationOverlay({ target, onClose }: DictationOverlayProps) {window.nodeTerminal.clipboard.writeText(value)}, [text])+ const insert = useCallback(async () => {+ if (!target || target.kind !== 'terminal') return+ const value = text.trim()+ if (!value) return+ setSending(true)+ setError(null)+ try {+ const ok = await api.pty.sendText(target.nodeId, value, { enter: false })+ if (!ok) {+ setError('Could not insert — the terminal session is not available.')+ return+ }+ onClose()+ } catch (err) {+ setError(err instanceof Error ? err.message : 'Failed to insert.')+ } finally {+ setSending(false)+ }+ }, [target, text, api, onClose])++ // Chat has no external draft field to write into without submitting (see the header comment) —+ // Insert stays disabled there. A terminal target is always insertable once there's text.const insertDisabledReason = !target? 'Select a terminal or chat node first.': target.kind === 'chat'- ? "Chat has no external draft field — use Send."- : "Inserting without submitting isn't available yet (needs the terminal's live session) — use Send."+ ? 'Chat has no external draft field — use Send.'+ : nullconst hasText = !!text.trim()+ const insertDisabled = !target || !hasText || sending || insertDisabledReason !== nullreturn createPortal(<div className="dictation nodrag nowheel" onMouseDown={(e) => e.stopPropagation()}>@@ -290,9 +310,22 @@ export function DictationOverlay({ target, onClose }: DictationOverlayProps) {<button type="button" className="dictation__btn" onClick={copy} disabled={!hasText}>Copy</button>- <button type="button" className="dictation__btn" disabled title={insertDisabledReason}>- Insert- </button>+ {insertDisabledReason ? (+ <span title={insertDisabledReason}>+ <button type="button" className="dictation__btn" disabled>+ Insert+ </button>+ </span>+ ) : (+ <button+ type="button"+ className="dictation__btn"+ onClick={() => void insert()}+ disabled={insertDisabled}+ >+ Insert+ </button>+ )}<buttontype="button"className="dictation__btn dictation__btn--primary"diff --git a/src/shared/types.ts b/src/shared/types.tsindex 8492baf0e..8d34f2ec6 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -299,8 +299,10 @@ export interface PtyApi {capture(persistKey: string, full?: boolean): Promise<string>/** Read the persisted scrollback snapshot for a node (for cold-restart replay). '' if none. */readScrollback(persistKey: string): Promise<string>- /** Send literal text + Enter into a session (e.g. a slash command). Returns false if unavailable. */- sendText(persistKey: string, text: string): Promise<boolean>+ /** Send literal text into a session, by default followed by Enter (e.g. a slash command).+ * `opts.enter: false` writes the text without submitting it (dictation's Insert). Returns+ * false if unavailable. */+ sendText(persistKey: string, text: string, opts?: { enter?: boolean }): Promise<boolean>/** Is tmux available on this host (else the silent plain-shell fallback), plus a suggested* install command for the "tmux not found" banner. */tmuxStatus(): Promise<TmuxStatus>