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
fix(terminal): suppress the Copied pill when the clipboard toast fired first
enes1c7d2a881f36
diff --git a/src/renderer/terminal/copy-feedback.ts b/src/renderer/terminal/copy-feedback.tsindex 037f8da2b..1dcbfcd20 100644--- a/src/renderer/terminal/copy-feedback.ts+++ b/src/renderer/terminal/copy-feedback.ts@@ -22,6 +22,11 @@ export const DRAG_MIN_PX = 8export const OSC52_GRACE_MS = 600export const COPIED_DWELL_MS = 1600export const HINT_DWELL_MS = 5000+/** How long a clipboard-failure toast keeps the `copied` pill from being raised at all. It only has+ * to cover a SYNCHRONOUS dispatch: over plain http the browser shim has no Clipboard API, so its+ * execCommand fallback runs — and dispatches its error toast — inside `writeText`, i.e. before the+ * OSC 52 handler calls `notifyCopy`. Retracting after the fact cannot catch that ordering. */+export const ERROR_TOAST_SUPPRESS_MS = 50/** Once per installation — same convention as `seenShortcuts`. */export const HINT_STORAGE_KEY = 'nodeterm.seenSelectHint'diff --git a/src/renderer/terminal/useCopyFeedback.ts b/src/renderer/terminal/useCopyFeedback.tsindex 55b0c810e..226c27e11 100644--- a/src/renderer/terminal/useCopyFeedback.ts+++ b/src/renderer/terminal/useCopyFeedback.ts@@ -6,6 +6,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'import { isMacPlatform } from '@shared/platform-utils'import {COPIED_DWELL_MS,+ ERROR_TOAST_SUPPRESS_MS,HINT_DWELL_MS,HINT_STORAGE_KEY,OSC52_GRACE_MS,@@ -52,6 +53,8 @@ export function useCopyFeedback(opts: {const decideTimer = useRef<ReturnType<typeof setTimeout> | null>(null)/** When the last clipboard write landed — read by the drag decision. */const lastCopyAt = useRef(0)+ /** When the last clipboard-failure toast was dispatched — read by `notifyCopy`. */+ const lastErrorToastAt = useRef(0)// 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@@ -64,7 +67,13 @@ export function useCopyFeedback(opts: {const notifyCopy = useCallback((text: string): void => {+ // 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()+ // A failure toast that lands AFTER this call retracts the pill (the effect below); one+ // dispatched SYNCHRONOUSLY just before it — the plain-http execCommand path, where the shim+ // toasts inside `writeText` — can only be caught here, before any pill is raised.+ if (Date.now() - lastErrorToastAt.current < ERROR_TOAST_SUPPRESS_MS) returnconst label = copiedLabel(text)if (label) show({ kind: 'copied', label }, COPIED_DWELL_MS)},@@ -118,6 +127,7 @@ export function useCopyFeedback(opts: {const onToast = (e: Event): void => {const detail = (e as CustomEvent<{ kind?: string }>).detailif (detail?.kind !== 'error') return+ lastErrorToastAt.current = Date.now()setFeedback((cur) => (cur?.kind === 'copied' ? null : cur))}window.addEventListener('nodeterm:toast', onToast)