diff --git a/src/main/window/clipboard-ipc-handlers.ts b/src/main/window/clipboard-ipc-handlers.ts index f6c98d6bb2..8d727bff6b 100644 --- a/src/main/window/clipboard-ipc-handlers.ts +++ b/src/main/window/clipboard-ipc-handlers.ts @@ -142,7 +142,18 @@ export function registerClipboardHandlers(store: Store): void { ) ipcMain.handle('clipboard:writeText', async (event, text: string) => { assertTrustedClipboardSender(event) - return clipboard.writeText(await assertClipboardTextWriteWithinLimitWithYield(text)) + const newText = await assertClipboardTextWriteWithinLimitWithYield(text) + if (process.platform === 'win32') { + try { + // Use a PowerShell fallback for Windows to improve reliability + await runCommand('powershell', ['-Command', `Set-Clipboard -Value $input`], newText) + } catch (error) { + console.error('PowerShell clipboard write failed, falling back to Electron API', error) + clipboard.writeText(newText) + } + } else { + clipboard.writeText(newText) + } }) ipcMain.handle('clipboard:writeSelectionText', async (event, text: string) => { assertTrustedClipboardSender(event) diff --git a/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts b/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts index e1fe139d44..3512de6c6a 100644 --- a/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts +++ b/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts @@ -1130,9 +1130,14 @@ export function useTerminalPaneLifecycle({ if (!selection) { return } - void window.api.ui.writeClipboardText(selection).catch(() => { - /* ignore clipboard write failures */ - }) + void window.api.ui + .writeClipboardText(selection) + .then(() => { + // TODO(orca): Show a "Copied" toast notification + }) + .catch(() => { + // TODO(orca): Show a "Copy failed" toast notification + }) }) selectionDisposablesRef.current.set(pane.id, selectionDisposable) // Hide mouse cursor while typing — classic terminal UX, scoped to the