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): copy receipt + one-time selection hint on the canvas node

enescd240760b707
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 46b70f82b..2fdbaf0c1 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -90,6 +90,7 @@ import { IconSearch, IconChat, IconMic, IconReload } from '../components/icons'
import { NodeLabels } from '../components/kanban/NodeLabels'
import { Tooltip } from '../components/Tooltip'
import { useTerminalSearch } from '../terminal/useTerminalSearch'
+import { useCopyFeedback } from '../terminal/useCopyFeedback'
import { ContextMeter } from '../components/ContextMeter'
import { isZoomModifierHeld } from '../lib/zoomModifier'
import { isHidden } from '../lib/ui-visibility'
@@ -554,6 +555,15 @@ const coSubs = new Map<string, (s: CoState) => void>()
*/
const restartSubs = new Map<string, () => void>()
+/**
+ * The mounted instance publishes its copy-feedback sink here, for the same reason as
+ * `restartSubs`: the OSC 52 handler is registered ONCE per xterm instance and that instance
+ * SURVIVES A PARK (project switch → remount within TERM_PARK_MS), so a handler holding this
+ * component's `setState` would be feeding a component that unmounted two projects ago. Looked up
+ * at call time instead. No entry = nobody is mounted = nothing to show.
+ */
+const copySubs = new Map<string, (text: string) => void>()
+
function getCo(key: string): CoState {
return coStates.get(key) ?? NO_CO
}
@@ -654,6 +664,18 @@ export function TerminalNode({
// ResizeObserver in the lifecycle effect.
const rootRef = useRef<HTMLDivElement>(null)
const termRef = useRef<Terminal | null>(null)
+ // Copy feedback: the `Copied` pill (fed by the OSC 52 handler below, through `copySubs`) and the
+ // one-time "hold ⌥ to select" hint for a pane whose app captured the mouse.
+ const copy = useCopyFeedback({
+ hostRef: bodyRef,
+ hasSelection: () => !!termRef.current?.hasSelection()
+ })
+ useEffect(() => {
+ copySubs.set(termKey, copy.notifyCopy)
+ return () => {
+ if (copySubs.get(termKey) === copy.notifyCopy) copySubs.delete(termKey)
+ }
+ }, [termKey, copy.notifyCopy])
const fitRef = useRef<FitAddon | null>(null)
const searchAddonRef = useRef<SearchAddon | null>(null)
// The live session's "measure my grid, render it, report it" routine (set by the lifecycle
@@ -1661,7 +1683,11 @@ export function TerminalNode({
// read the local clipboard. Returning true swallows the sequence (also the read query).
term.parser.registerOscHandler(52, (data) => {
const text = parseOsc52(data)
- if (text !== null) window.nodeTerminal.clipboard.writeText(text)
+ if (text !== null) {
+ window.nodeTerminal.clipboard.writeText(text)
+ // Through the registry, never a captured setState: this handler outlives a park.
+ copySubs.get(termKey)?.(text)
+ }
return true
})
// Cmd (mac) / Ctrl+click link opening. URLs → default browser via createUrlLinkProvider
@@ -3091,6 +3117,11 @@ export function TerminalNode({
RUNNING
</span>
)}
+ {copy.feedback && (
+ <span className={`term-node__status term-node__status--${copy.feedback.kind}`}>
+ {copy.feedback.label}
+ </span>
+ )}
{showLoop && status?.loop && (
<span
className="term-node__status term-node__status--loop"
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 8a1db23f1..d8031ed0e 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -1408,6 +1408,22 @@ body,
gap: 4px;
}
+/* Copy receipt (1.6 s) — green like the base chip, and deliberately quieter than RUNNING /
+ NEEDS YOU: this is a receipt, not an alert. */
+.term-node__status--copied {
+ color: var(--success);
+ letter-spacing: 0.04em;
+}
+
+/* The one-time "hold ⌥ to select text" hint. Sentence case, muted: it is instruction, not status,
+ and the header's other chips are SHOUTED status words. */
+.term-node__status--hint {
+ color: var(--muted);
+ font-weight: 600;
+ letter-spacing: 0;
+ text-transform: none;
+}
+
.term-node__queued-run {
background: none;
border: none;