Skip to content

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.

Merge origin/main into feat/chat-typed-send-1103

review5033c829e205
diff --cc src/core/pty-manager.ts
index 7697903a5,e77664783..af15ee48e
--- a/src/core/pty-manager.ts
+++ b/src/core/pty-manager.ts
@@@ -309,25 -312,24 +318,43 @@@ function runWithStdin(file: string, arg
return p as unknown as Promise<unknown>
}
+/**
+ * The typed chat delivery's LOCAL leg (core/typed-input.ts): `/bin/sh` running the fixed script,
+ * with the tmux path in `env`. Kept apart from `runWithStdin` so the one helper that starts a shell
+ * only ever receives that fixed script — a shared runner handed `/bin/sh` by one caller is a shell
+ * for every caller's arguments (CodeQL reads it that way, and so should a reviewer). Same bounds
+ * as `runWithStdin`: `PROC_TIMEOUT_MS`, rejection on a non-zero exit, a swallowed EPIPE.
+ */
+function runTypedScript(args: readonly string[], input: string, env: NodeJS.ProcessEnv): Promise<void> {
+ return new Promise((resolve, reject) => {
+ const child = execFile('/bin/sh', [...args], { timeout: PROC_TIMEOUT_MS, env }, (err) =>
+ err === null ? resolve() : reject(err)
+ )
+ child.stdin?.on('error', () => {
+ /* child gone; the exit code is what decides success */
+ })
+ child.stdin?.end(input)
+ })
+}
+
+ /** `p`'s answer, or false once `ms` passed (the timer never holds the process). A rejection is false. */
+ function settleWithin(p: Promise<boolean>, ms: number): Promise<boolean> {
+ return new Promise<boolean>((resolve) => {
+ const timer = setTimeout(() => resolve(false), ms)
+ timer.unref?.()
+ p.then(
+ (v) => {
+ clearTimeout(timer)
+ resolve(v)
+ },
+ () => {
+ clearTimeout(timer)
+ resolve(false)
+ }
+ )
+ })
+ }
+
// Minimal tmux config so the user's ~/.tmux.conf never interferes. The tmux server
// (under our socket) keeps sessions alive while no client is attached, which is what
// gives us continuity across node remounts and full app restarts.
diff --cc src/core/remote-ssh/control-master.ts
index e0bde801d,dfb1d2e39..4f7182639
--- a/src/core/remote-ssh/control-master.ts
+++ b/src/core/remote-ssh/control-master.ts
@@@ -18,10 -18,9 +18,10 @@@ import
type PasteDelivery
} from '../tmux-naming'
import { sanitizePasteText } from '../paste-injection'
+import { typedInputScript } from '../typed-input'
import { canControlCanvas } from '../../shared/agents/config'
import { COMBINED_PANE_MARKER, PANE_OWNER_FMT, PS_FOREGROUND_FLAGS } from '../agents/pane-owner'
- import { VISIBLE_CAPTURE_FORMAT, exactPaneTarget } from '../watch-link/capture-route'
+ import { VISIBLE_CAPTURE_FORMAT, capturePaneTarget } from '../watch-link/capture-route'
import { WATCHER_CLIENT_FLAGS, WINDOW_SIZE_FORMAT } from '../watch-link/watcher-client'
// Dependency-free (no node-pty): safe to import from these pure builders.
diff --cc src/renderer/nodes/ChatPanel.tsx
index 9e704c3fc,24547e3e5..d62823c73
--- a/src/renderer/nodes/ChatPanel.tsx
+++ b/src/renderer/nodes/ChatPanel.tsx
@@@ -753,11 -780,22 +780,22 @@@ export function ChatPanel(
maybeLoadOlder()
}
+ // The optimistic bubbles sent into the CLI's queue mid-turn, drawn as "Queued" until the transcript
+ // has them. Object identity is enough: `applyTail` carries an unconfirmed send as the same object.
+ const queuedRef = useRef(new WeakSet<ChatMessage>())
+
- const send = useCallback(async () => {
+ const sendOnce = useCallback(async () => {
const text = input.trim()
+ if (!text) return
// Read the store at SEND time, not the render-time values: a PermissionRequest (or an Eco
// hibernation) that landed between the last render and this keypress must still block.
- if (!text || chatSendRefusal(agentId, useAgentStatus.getState().byId[nodeId] ?? {}) !== null) return
+ const mode = chatSendMode(agentId, useAgentStatus.getState().byId[nodeId] ?? {})
+ if (mode === null) return
+ if (mode === 'queue' && !canQueue(text)) {
+ const message = `${chatAgentLabel(agentId, useSettings.getState().settings.customAgents)} is working — send commands once the reply finishes.`
+ window.dispatchEvent(new CustomEvent('nodeterm:toast', { detail: { kind: 'error', message } }))
+ return
+ }
// The kernel's say (chatPaneGate.ts): an agent that announces no quit (codex) may have left a
// SHELL in the pane while the store still reads `done` — typed there, the message would run.
const pane = await chatPaneRefusal(agentId, nodeId, {
diff --cc src/shared/agents/config.capabilities.test.ts
index 64373b0dc,883563a2e..901354930
--- a/src/shared/agents/config.capabilities.test.ts
+++ b/src/shared/agents/config.capabilities.test.ts
@@@ -26,10 -26,8 +26,11 @@@ import
agentLaunchProgram,
resumeCommand,
hasHooksOverSsh,
+ CHAT_CAPABLE,
+ TYPED_INPUT_CAPABLE,
+ typesChatInput,
readsScreenDialogs,
+ queuesInputWhileWorking,
LOCAL_ONLY_HOOK_AGENTS,
reportsSessionEnd
} from './config'
diff --cc src/shared/agents/config.ts
index f699d8e9b,8c4021f33..a82d7f408
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@@ -551,8 -551,8 +558,9 @@@ export const canContextLink = (id: Agen
export const hasUsage = (id: AgentId): boolean => includes(USAGE_CAPABLE, id)
export const canChat = (id: AgentId): boolean => includes(CHAT_CAPABLE, id)
export const chatReadsLocalOnly = (id: AgentId): boolean => includes(CHAT_LOCAL_ONLY, id)
+export const typesChatInput = (id: AgentId): boolean => includes(TYPED_INPUT_CAPABLE, id)
export const readsScreenDialogs = (id: AgentId): boolean => includes(SCREEN_DIALOG_READABLE, id)
+ export const queuesInputWhileWorking = (id: AgentId): boolean => includes(INPUT_QUEUE_CAPABLE, id)
/** Can CLAUDE's transcript resolver locate and parse this agent's conversation? Never widen this
* to mean "can we read this agent" — see CLAUDE_TRANSCRIPT_READABLE. */
export const readsClaudeShapedTranscript = (id: AgentId): boolean =>