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(canvas): terminal capture notice banner

enesd59a9f1a9762
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 6b40e73d9..cb111da81 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -152,6 +152,7 @@ import { UpdateCard } from '../components/UpdateCard'
import { AnnouncementBanner } from '../components/AnnouncementBanner'
import { TmuxBanner } from '../components/TmuxBanner'
import { PtyPressureBanner } from '../components/PtyPressureBanner'
+import { ShortcutCaptureBanner } from '../components/ShortcutCaptureBanner'
import { ConflictBar } from '../components/ConflictBar'
import { ConfirmDialog } from '../components/ConfirmDialog'
import { CapabilityNotice } from '../components/CapabilityNotice'
@@ -178,12 +179,13 @@ import {
type GlobalKeyEvent,
type GlobalKeydownDeps
} from '../lib/globalKeybindings'
-import type { ContextElement } from '../lib/keyContext'
+import { isTerminalTarget, type ContextElement } from '../lib/keyContext'
import {
activeKeybindingOverrides,
chipFor,
commandTooltip,
dictationBinding,
+ noteTerminalCapture,
terminalShortcutPolicy
} from '../lib/keybindingOverrides'
import { UsageIndicator } from '../components/UsageIndicator'
@@ -3993,12 +3995,32 @@ export function Canvas() {
// node's × button. With nothing selected it falls back to closing the window.
useEffect(() => {
return window.nodeTerminal.onCloseNode(() => {
+ // The two main-intercepted chords never reach the window dispatcher, so their capture
+ // notice has to be raised HERE, at the IPC receiver — asking the live focus, because the
+ // IPC carries no context. Notice only: nothing is consumed, and the close below runs
+ // exactly as it did before (`noteTerminalCapture` is silent under terminal-first, on a
+ // repeat, and outside a focused terminal).
+ if (isTerminalTarget(document.activeElement as unknown as ContextElement | null)) {
+ noteTerminalCapture('node.close')
+ }
const ids = nodesRef.current.filter((n) => n.selected).map((n) => n.id)
if (ids.length) deleteNodes(ids)
else window.nodeTerminal.closeWindow()
})
}, [deleteNodes])
+ // The second main-intercepted chord (⌘/Ctrl+M). Canvas does NOT own the markdown toggle —
+ // TerminalNode and EditorNode each subscribe for themselves — so this listener exists ONLY to
+ // raise the same notice, and must stay side-effect-free: it consumes nothing, prevents nothing,
+ // and the nodes' own subscriptions are untouched by it.
+ useEffect(() => {
+ return window.nodeTerminal.onMarkdownToggle(() => {
+ if (isTerminalTarget(document.activeElement as unknown as ContextElement | null)) {
+ noteTerminalCapture('node.toggleMarkdown')
+ }
+ })
+ }, [])
+
// Native View menu → renderer. The menu item click sends IPC; these listeners fire the canvas
// action. Snap-to-Grid flips the setting (the `autoAlignGrid` effect above runs the arrange on
// the false→true edge), and main rebuilds the menu on the settings change so the checkmark moves.
@@ -5230,6 +5252,10 @@ export function Canvas() {
// Read per keystroke (the deps object is rebuilt each render anyway, but the thunk is what
// the contract asks for): a policy change takes effect immediately, with no re-registration.
terminalFirst: () => terminalShortcutPolicy() === 'terminal-first',
+ // The notice half. `noteTerminalCapture` re-asks the policy and the once-per-command ledger
+ // itself, so this is a plain pass-through — the dispatcher decides that a capture HAPPENED,
+ // the lib decides whether it is worth saying.
+ onTerminalCapture: noteTerminalCapture,
handlers: {
'app.commandPalette': () => { setPaletteOpen((v) => !v); return true },
'app.settings': () => { setSettingsSection(undefined); setSettingsOpen(true); return true },
@@ -9170,6 +9196,14 @@ export function Canvas() {
{/* This MACHINE is running out of pty devices — subscribes for itself; a failed
"Fix automatically…" lands in the same notice strip as every other async op. */}
<PtyPressureBanner onError={(text) => setNotice({ kind: 'error', text })} />
+ {/* App-first just took a chord from a focused terminal, once per command ever —
+ subscribes for itself; only the route into Settings is Canvas's to give. */}
+ <ShortcutCaptureBanner
+ onOpenShortcuts={() => {
+ setSettingsSection('shortcuts')
+ setSettingsOpen(true)
+ }}
+ />
{migrationNote && (
<div className="announce-banner announce-banner--info">
<span className="announce-banner__dot" />
diff --git a/src/renderer/components/ShortcutCaptureBanner.tsx b/src/renderer/components/ShortcutCaptureBanner.tsx
new file mode 100644
index 000000000..bc89a904c
--- /dev/null
+++ b/src/renderer/components/ShortcutCaptureBanner.tsx
@@ -0,0 +1,72 @@
+import { useEffect, useState } from 'react'
+import type { CommandId } from '@shared/keybindings'
+import { shortcutCaptureCopy } from './shortcutCaptureCopy'
+
+// The one time the app explains itself: a chord the user pressed inside a focused terminal ran an
+// APP command instead of reaching the shell. `noteTerminalCapture` decides WHEN that is worth
+// saying (app-first only, once per command, ever, persisted in settings) — this strip only says it.
+//
+// Its own component, subscribing for itself, for the same reason PtyPressureBanner and TmuxBanner
+// are: Canvas.tsx is a hot file every other branch touches, and a banner is not canvas logic. The
+// one thing it cannot own is opening Settings (the page's state lives in Canvas), so that arrives
+// as a prop.
+
+/** Informational, not a warning: it names something that already happened correctly and offers a
+ * setting. Longer than a toast because there are two sentences to read, far shorter than the
+ * pty-pressure strips, which stay until the machine's state changes. */
+const CAPTURE_NOTICE_MS = 12_000
+
+export function ShortcutCaptureBanner({
+ onOpenShortcuts
+}: {
+ /** Open Settings on the Keyboard Shortcuts section — where both exits the copy names live. */
+ onOpenShortcuts: () => void
+}): JSX.Element | null {
+ // Queue-less on purpose: a second capture REPLACES the first. These fire once per command ever,
+ // so a queue would only exist to replay a notice the user has already been shown the shape of.
+ const [current, setCurrent] = useState<{ id: CommandId } | null>(null)
+
+ useEffect(() => {
+ const onCaptured = (e: Event): void => {
+ const id = (e as CustomEvent<{ commandId: CommandId }>).detail?.commandId
+ if (id) setCurrent({ id })
+ }
+ window.addEventListener('nodeterm:shortcut-captured', onCaptured)
+ return () => window.removeEventListener('nodeterm:shortcut-captured', onCaptured)
+ }, [])
+
+ // A fresh object per capture, so a second one restarts the clock rather than inheriting the
+ // remainder of the first one's.
+ useEffect(() => {
+ if (!current) return
+ const t = setTimeout(() => setCurrent(null), CAPTURE_NOTICE_MS)
+ return () => clearTimeout(t)
+ }, [current])
+
+ // Resolved at RENDER, not at capture: an id we cannot name — or one whose chord is gone by now —
+ // shows nothing at all rather than a sentence with a hole in it.
+ const copy = current ? shortcutCaptureCopy(current.id) : null
+ if (!copy) return null
+
+ return (
+ <div className="announce-banner announce-banner--info">
+ <span className="announce-banner__dot" />
+ <div className="announce-banner__content">
+ <span className="announce-banner__title">{copy.title}</span>
+ <span className="announce-banner__body">{copy.body}</span>
+ </div>
+ <button
+ className="announce-banner__btn"
+ onClick={() => {
+ setCurrent(null)
+ onOpenShortcuts()
+ }}
+ >
+ Open Shortcuts
+ </button>
+ <button className="announce-banner__close" title="Dismiss" onClick={() => setCurrent(null)}>
+ ✕
+ </button>
+ </div>
+ )
+}
diff --git a/src/renderer/components/kanban/ModalTerminal.tsx b/src/renderer/components/kanban/ModalTerminal.tsx
index 4c58bacb2..f9805fae6 100644
--- a/src/renderer/components/kanban/ModalTerminal.tsx
+++ b/src/renderer/components/kanban/ModalTerminal.tsx
@@ -7,6 +7,7 @@ import { reportsOwnCopy } from '@shared/agents/config'
import type { AgentId } from '@shared/agents/config'
import { readsClaudeTranscript } from '../../lib/transcriptGates'
import { liveProjectJumpTarget } from '../../lib/projectJump'
+import { terminalShortcutPolicy } from '../../lib/keybindingOverrides'
import { FindBar } from '../FindBar'
import { useAgentStatus } from '../../state/agentStatus'
import { useProjects } from '../../state/projects'
@@ -192,9 +193,12 @@ export function ModalTerminal({ nodeId, spawn, searchOpen, onCloseSearch }: Moda
// Ctrl+Shift+C would fall through to the pty as \x03/SIGINT); plain Ctrl+C is left alone.
// MIRROR TerminalNode: Cmd/Ctrl+1-9 (jump to the Nth project) is swallowed here, before xterm
// turns Ctrl+2..Ctrl+8 into control bytes — but only when the app owns the key (desktop shell,
- // digit addressing an open project), which `liveProjectJumpTarget` decides for both surfaces.
+ // digit addressing an open project, AND app-first: under terminal-first the digit belongs to
+ // the PTY), which `liveProjectJumpTarget` + the policy decide for both surfaces.
term.attachCustomKeyEventHandler((e) => {
- const action = terminalKeyAction(e, term.hasSelection(), liveProjectJumpTarget(e) !== null)
+ const ownsProjectJump =
+ terminalShortcutPolicy() !== 'terminal-first' && liveProjectJumpTarget(e) !== null
+ const action = terminalKeyAction(e, term.hasSelection(), ownsProjectJump)
if (action === 'pass') return true
e.preventDefault()
if (action === 'copy') window.nodeTerminal.clipboard.writeText(term.getSelection())
diff --git a/src/renderer/components/shortcutCaptureCopy.test.ts b/src/renderer/components/shortcutCaptureCopy.test.ts
new file mode 100644
index 000000000..490f36c3b
--- /dev/null
+++ b/src/renderer/components/shortcutCaptureCopy.test.ts
@@ -0,0 +1,46 @@
+import { describe, it, expect, beforeEach } from 'vitest'
+import { DEFAULT_SETTINGS } from '@shared/types'
+import type { CommandId } from '@shared/keybindings'
+import { useSettings } from '../state/settings'
+import { shortcutCaptureCopy } from './shortcutCaptureCopy'
+
+const setKb = (kb: unknown) =>
+ useSettings.setState({ settings: { ...DEFAULT_SETTINGS, keybindings: kb as never } })
+
+beforeEach(() => setKb(undefined))
+
+describe('shortcutCaptureCopy', () => {
+ it('names the command and the chord that took the key', () => {
+ const copy = shortcutCaptureCopy('app.commandPalette', true)
+ expect(copy?.title).toBe('Command palette')
+ expect(copy?.body).toContain('⌘K')
+ expect(copy?.body).toContain('Command palette')
+ // The two ways out are what the banner is FOR — a notice that only reports is noise.
+ expect(copy?.body.toLowerCase()).toContain('terminal-first')
+ })
+
+ it('spells the chord the way the platform does', () => {
+ expect(shortcutCaptureCopy('app.commandPalette', false)?.body).toContain('Ctrl+K')
+ })
+
+ it('follows a remap, so the notice quotes the chord the user actually pressed', () => {
+ setKb({ 'app.commandPalette': ['Cmd+Shift+P'] })
+ expect(shortcutCaptureCopy('app.commandPalette', true)?.body).toContain('⌘⇧P')
+ })
+
+ // Both halves of "say nothing": there is no chord to quote, so a banner could only claim a
+ // key was taken without naming one.
+ it('is null for an unbound command', () => {
+ expect(shortcutCaptureCopy('canvas.fitAll', true)).toBeNull()
+ })
+
+ it('is null for a DISABLED command', () => {
+ setKb({ 'app.commandPalette': [] })
+ expect(shortcutCaptureCopy('app.commandPalette', true)).toBeNull()
+ })
+
+ // The event's detail crosses a `window` boundary, so the id is not a compile-time fact.
+ it('is null for an id the registry does not know', () => {
+ expect(shortcutCaptureCopy('bogus.command' as CommandId, true)).toBeNull()
+ })
+})
diff --git a/src/renderer/components/shortcutCaptureCopy.ts b/src/renderer/components/shortcutCaptureCopy.ts
new file mode 100644
index 000000000..1285c3c66
--- /dev/null
+++ b/src/renderer/components/shortcutCaptureCopy.ts
@@ -0,0 +1,41 @@
+/**
+ * What the capture notice SAYS, kept pure so it can be tested without a DOM and so the banner
+ * stays a subscription plus markup.
+ *
+ * Two things this returns `null` for, and they mean the same thing to the caller — **show
+ * nothing**:
+ * - an id the registry does not know. The id arrives inside a `CustomEvent.detail` off
+ * `window`, so its `CommandId` type is a compile-time claim, not a runtime fact.
+ * - a command with no effective chord (unbound, or the user disabled it). The whole sentence is
+ * built around the chord that took the key; with none to quote the notice could only assert
+ * that *something* was captured, which is worse than silence.
+ *
+ * The chord is read through `chipFor`, so the notice quotes the binding IN FORCE — a remapped
+ * command names the user's own chord, never the registry default they no longer use.
+ */
+import { COMMANDS_BY_ID, type CommandId } from '@shared/keybindings'
+import { isMacPlatform } from '@shared/platform-utils'
+import { chipFor } from '../lib/keybindingOverrides'
+
+export interface ShortcutCaptureCopy {
+ title: string
+ body: string
+}
+
+export function shortcutCaptureCopy(
+ id: CommandId,
+ isMac: boolean = isMacPlatform()
+): ShortcutCaptureCopy | null {
+ const def = COMMANDS_BY_ID.get(id)
+ if (!def) return null
+ const chip = chipFor(id, isMac)
+ if (!chip) return null
+ return {
+ title: def.title,
+ // Names both exits the user has — remap this one chord, or hand every chord to the terminal.
+ // A notice that only reports what happened teaches the user to dismiss notices.
+ body:
+ `${chip} ran “${def.title}” instead of reaching your terminal. You can remap it, ` +
+ 'or switch to terminal-first so terminals keep every chord.'
+ }
+}
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 56e68f3b4..771642f08 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -166,7 +166,7 @@ import { agentEnvSnapshot } from '@renderer/lib/agentEnv'
import { normalizedAgentModel } from '@shared/agents/model-gateway'
import { ensureActivePermissionMode } from '../state/permissionMode'
import { buildSshArgs, sshConnectionIdForProject, sshHostKey, type SshConnection } from '@shared/ssh'
-import { chipFor, effectiveBindings } from '../lib/keybindingOverrides'
+import { chipFor, effectiveBindings, terminalShortcutPolicy } from '../lib/keybindingOverrides'
import { matchesShortcut } from '@shared/shortcut'
import { isMacPlatform } from '@shared/platform-utils'
import { ColumnPill } from '../components/kanban/ColumnPill'
@@ -2370,9 +2370,14 @@ export function TerminalNode({
// ESC+CR (`SHIFT_ENTER_SEQ`) — agent CLIs read that as "insert newline" (see terminal-config.ts).
// Cmd/Ctrl+1-9 (jump to the Nth project) must be swallowed before xterm turns Ctrl+2..Ctrl+8
// into control bytes — but ONLY when the app owns the key: desktop shell, digit addressing an
- // open project. `liveProjectJumpTarget` is the same decision Canvas's handler makes.
+ // open project, AND app-first. Under terminal-first the user reserved every chord for the
+ // shell, so the digit must reach the PTY: this handler runs inside xterm, ahead of the window
+ // dispatcher that honors the policy for every other chord, so it owes the check itself.
+ // `liveProjectJumpTarget` is the same decision Canvas's handler makes.
term.attachCustomKeyEventHandler((e) => {
- const action = terminalKeyAction(e, term.hasSelection(), liveProjectJumpTarget(e) !== null)
+ const ownsProjectJump =
+ terminalShortcutPolicy() !== 'terminal-first' && liveProjectJumpTarget(e) !== null
+ const action = terminalKeyAction(e, term.hasSelection(), ownsProjectJump)
if (action === 'pass') return true
e.preventDefault()
if (action === 'copy') window.nodeTerminal.clipboard.writeText(term.getSelection())