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.

feat(terminal): no copy pill for an agent that reports its own copies

enesa5c5ddf03fe2
diff --git a/src/renderer/components/kanban/ModalTerminal.tsx b/src/renderer/components/kanban/ModalTerminal.tsx
index 11e39ae4a..fc115f39e 100644
--- a/src/renderer/components/kanban/ModalTerminal.tsx
+++ b/src/renderer/components/kanban/ModalTerminal.tsx
@@ -2,7 +2,8 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { Terminal } from '@xterm/xterm'
import { FitAddon } from '@xterm/addon-fit'
import { SearchAddon } from '@xterm/addon-search'
-import { hasUsage } from '@shared/agents/config'
+import { hasUsage, reportsOwnCopy } from '@shared/agents/config'
+import type { AgentId } from '@shared/agents/config'
import { FindBar } from '../FindBar'
import { useAgentStatus } from '../../state/agentStatus'
import { useProjects } from '../../state/projects'
@@ -89,10 +90,12 @@ export function ModalTerminal({ nodeId, spawn, searchOpen, onCloseSearch }: Moda
const visual = useXtermVisualSettings()
const [dropping, setDropping] = useState(false)
const [uploading, setUploading] = useState(false)
- // Same copy feedback as the canvas node — a copy here is the same act as a copy there.
+ // Same copy feedback as the canvas node — a copy here is the same act as a copy there, including
+ // the agent gate: a claude card stays silent because claude prints its own copy line.
const copy = useCopyFeedback({
hostRef,
- hasSelection: () => !!termRef.current?.hasSelection()
+ hasSelection: () => !!termRef.current?.hasSelection(),
+ enabled: !reportsOwnCopy(spawn.agentId as AgentId | undefined)
})
// Same search machinery as the canvas node: capture-indexed matches + xterm highlight.
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index a69dae0bb..e749558fd 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -106,7 +106,7 @@ import { useWorktrees } from '../state/worktrees'
import { isRemoteSessionNode } from '@shared/worktree'
import { useSession, useActiveSessionPresence } from '../session/session'
import { accountChipLabel, COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'
-import { hasHooks, canRecur, canContextLink, hasUsage, canChat, canResume, canRename, createdAgentId, resumeCommand, withPermissionMode, agentConfig } from '@shared/agents/config'
+import { hasHooks, canRecur, canContextLink, hasUsage, canChat, canResume, canRename, createdAgentId, reportsOwnCopy, resumeCommand, withPermissionMode, agentConfig } from '@shared/agents/config'
import { ensureActivePermissionMode } from '../state/permissionMode'
import { buildSshArgs, type SshConnection } from '@shared/ssh'
import { hintLabel } from '@shared/platform-utils'
@@ -671,9 +671,15 @@ export function TerminalNode({
// node — never reach this listener. Hosting it on `.term-node__body` would make every node-move
// drag a hint candidate and burn the once-per-installation hint on a gesture that has nothing to
// do with copying.
+ // OFF for an agent whose own CLI reports its copies (`reportsOwnCopy` — claude prints "copied N
+ // chars to tmux buffer" itself), so that terminal is byte-identical to before the feature.
+ // `createdAgentId` is called again here rather than reusing the `agentId` const below: this hook
+ // sits above it, and duplicating a pure read of `data` is cheaper than reordering declarations
+ // in this file's lifecycle block.
const copy = useCopyFeedback({
hostRef: bodyRef,
- hasSelection: () => !!termRef.current?.hasSelection()
+ hasSelection: () => !!termRef.current?.hasSelection(),
+ enabled: !reportsOwnCopy(createdAgentId(data))
})
useEffect(() => {
copySubs.set(termKey, copy.notifyCopy)
diff --git a/src/renderer/terminal/useCopyFeedback.ts b/src/renderer/terminal/useCopyFeedback.ts
index 226c27e11..3dadfabb1 100644
--- a/src/renderer/terminal/useCopyFeedback.ts
+++ b/src/renderer/terminal/useCopyFeedback.ts
@@ -46,8 +46,12 @@ export function useCopyFeedback(opts: {
hostRef: React.RefObject<HTMLElement | null>
/** Does xterm hold a selection of its own right now? (⌥/Shift drag.) */
hasSelection: () => boolean
+ /** Off for a terminal whose own CLI already reports its copies (`reportsOwnCopy`) — then this
+ * hook binds no listeners, keeps no timers and never raises a pill, so that terminal behaves
+ * exactly as it did before the feature existed. Defaults to on. */
+ enabled?: boolean
}): CopyFeedbackApi {
- const { hostRef } = opts
+ const { hostRef, enabled = true } = opts
const [feedback, setFeedback] = useState<CopyFeedback>(null)
const dwellTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
const decideTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
@@ -58,6 +62,10 @@ export function useCopyFeedback(opts: {
// Read through a ref so the listener effect never re-runs when the caller passes a fresh closure.
const hasSelectionRef = useRef(opts.hasSelection)
hasSelectionRef.current = opts.hasSelection
+ // Also read through a ref, so `notifyCopy` keeps ONE identity for the component's lifetime:
+ // TerminalNode stores it in a module-level map and compares identity on cleanup.
+ const enabledRef = useRef(enabled)
+ enabledRef.current = enabled
const show = useCallback((next: CopyFeedback, dwellMs: number): void => {
if (dwellTimer.current) clearTimeout(dwellTimer.current)
@@ -67,6 +75,7 @@ export function useCopyFeedback(opts: {
const notifyCopy = useCallback(
(text: string): void => {
+ if (!enabledRef.current) return
// The gesture itself succeeded (tmux copy-mode ran), so the drag decision is told either way:
// whatever the clipboard did, "hold ⌥ to select text" is not the advice this drag needs.
lastCopyAt.current = Date.now()
@@ -81,6 +90,7 @@ export function useCopyFeedback(opts: {
)
useEffect(() => {
+ if (!enabled) return
const host = hostRef.current
if (!host) return
let downAt: { x: number; y: number; t: number } | null = null
@@ -118,7 +128,7 @@ export function useCopyFeedback(opts: {
host.removeEventListener('mousedown', onDown)
window.removeEventListener('mouseup', onUp)
}
- }, [hostRef, show])
+ }, [hostRef, show, enabled])
// Browser honesty: on the Server Edition `clipboard.writeText` can fail (a non-secure context),
// and the stub already raises a `nodeterm:toast` error banner. A green "Copied" pill beside that
diff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.ts
index 86c616bf2..887fdfdf9 100644
--- a/src/shared/agents/config.capabilities.test.ts
+++ b/src/shared/agents/config.capabilities.test.ts
@@ -14,8 +14,7 @@ import {
createdAgentId,
hasHooks,
hasPermissionMode,
- hasUsage
-} from './config'
+ hasUsage, reportsOwnCopy } from './config'
describe('CONTEXT_LINK_CAPABLE', () => {
it('all three builtin agents can context-link', () => {
@@ -131,3 +130,22 @@ describe('grok capabilities', () => {
expect(canSubagent('grok')).toBe(false)
})
})
+
+describe('copy feedback', () => {
+ it('stays quiet for claude, whose CLI announces its own copies', () => {
+ // Claude Code captures the mouse and prints "copied N chars to tmux buffer · paste with
+ // prefix + ]" itself, so nodeterm's pill would be a second message for one gesture.
+ expect(reportsOwnCopy('claude')).toBe(true)
+ })
+
+ it('speaks for every agent that says nothing itself', () => {
+ // codex leaves the mouse to tmux: the drag copies via OSC 52 and the highlight vanishes on
+ // release with no word from anyone. That silence is what the pill exists for.
+ for (const id of ['codex', 'gemini', 'opencode', 'grok']) expect(reportsOwnCopy(id)).toBe(false)
+ })
+
+ it('speaks for a plain terminal and a custom agent (no agent id at all)', () => {
+ expect(reportsOwnCopy(undefined)).toBe(false)
+ expect(reportsOwnCopy('my-custom-agent')).toBe(false)
+ })
+})
diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.ts
index 720901168..3f58b7137 100644
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@ -127,6 +127,15 @@ export const CANVAS_CONTROL_CAPABLE = ['claude', 'codex', 'gemini', 'opencode',
// renderer/state/permissionMode.ts. grok has accepted every mode we emit since 1.0.0, its first
// release, so it must never inherit a gate fed by a `claude --version` probe.
export const PERMISSION_MODE_CAPABLE = ['claude', 'grok'] as const
+// Agents whose own CLI already tells the user when it copies, so nodeterm must not say it again.
+// Claude Code captures the mouse itself and prints its own line — "copied N chars to tmux buffer ·
+// paste with prefix + ]" — which makes our copy pill a second message for one gesture. Membership
+// switches the WHOLE copy-feedback layer off for that agent's terminals: the receipt and the
+// one-time "Hold ⌥ to select text" hint alike, since a drag there is not swallowed at all.
+//
+// This is a list rather than a `=== 'claude'` for the usual reason: the next CLI to grow its own
+// copy notice joins by being added here, and nothing else changes.
+export const SELF_REPORTS_COPY = ['claude'] as const
const includes = (list: readonly string[], id: AgentId): boolean => list.includes(id)
@@ -142,6 +151,10 @@ export const canTransferFrom = (id: AgentId): boolean => includes(TRANSFER_SOURC
export const canRename = (id: AgentId): boolean => includes(RENAME_CAPABLE, id)
export const canControlCanvas = (id: AgentId): boolean => includes(CANVAS_CONTROL_CAPABLE, id)
export const hasPermissionMode = (id: AgentId): boolean => includes(PERMISSION_MODE_CAPABLE, id)
+/** Does this agent's CLI report its own copies? Undefined (a plain terminal, a custom agent) is
+ * `false` — nobody speaks for those, so nodeterm's own feedback is the only feedback there is. */
+export const reportsOwnCopy = (id: AgentId | undefined): boolean =>
+ !!id && includes(SELF_REPORTS_COPY, id)
// Returns the builtin config for an id, or undefined for custom/unknown agents.
export const agentConfig = (id: AgentId): AgentConfig | undefined =>