diff --git a/src/utils/computerUse/win32/windowMessage.ts b/src/utils/computerUse/win32/windowMessage.ts index 5b904e1ba..626ca89b3 100644 --- a/src/utils/computerUse/win32/windowMessage.ts +++ b/src/utils/computerUse/win32/windowMessage.ts @@ -12,9 +12,6 @@ import { validateHwnd, runPs, VK_MAP, MODIFIER_KEYS } from './shared.js' -/** Character count above which we switch to clipboard paste */ -const CLIPBOARD_THRESHOLD = 32 - /** Cache findEditChild results — window structure doesn't change while bound */ const editChildCache = new Map() @@ -276,47 +273,7 @@ function buildWmCharLines(hwnd: string, text: string): string[] { } /** - * Paste text via clipboard into the target window. - * Uses Clipboard.SetText() + SendMessageW(Ctrl+V). - * NO global APIs (SendInput/keybd_event/SendKeys) — only window-targeted messages. - */ -function pasteViaClipboard(hwnd: string, text: string): boolean { - // Escape single quotes for PowerShell string literal - const escaped = text.replace(/'/g, "''") - const hwndExpr = `[IntPtr]::new([long]${hwnd})` - const script = `${WINMSG_TYPE} -Add-Type -AssemblyName System.Windows.Forms - -# Save current clipboard -$saved = $null -try { $saved = [System.Windows.Forms.Clipboard]::GetText() } catch {} - -# Set our text -[System.Windows.Forms.Clipboard]::SetText('${escaped}') - -# Ctrl+V via PostMessage to the target window (NOT global keybd_event) -# Must use PostMessage + correct lParam (scan code) for Windows Terminal / ConPTY -[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYDOWN, [IntPtr]0x11, [WinMsg]::KeyDownLParam(0x11)) # Ctrl down -[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYDOWN, [IntPtr]0x56, [WinMsg]::KeyDownLParam(0x56)) # V down -[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYUP, [IntPtr]0x56, [WinMsg]::KeyUpLParam(0x56)) # V up -[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYUP, [IntPtr]0x11, [WinMsg]::KeyUpLParam(0x11)) # Ctrl up - -# Brief wait for paste to complete -Start-Sleep -Milliseconds 50 - -# Restore clipboard -if ($saved -ne $null -and $saved -ne '') { - try { [System.Windows.Forms.Clipboard]::SetText($saved) } catch {} -} else { - try { [System.Windows.Forms.Clipboard]::Clear() } catch {} -} -Write-Output 'OK' -` - return runPs(script) === 'OK' -} - -/** - * Send text to a window via WM_CHAR per Unicode codepoint. + * Send text to a window * Always uses the WM_CHAR path — reliable across all window types including * Windows Terminal / ConPTY where clipboard-based Ctrl+V doesn't work. * Window-targeted, no global input APIs. diff --git a/src/utils/messages.ts b/src/utils/messages.ts index 15e420db5..86c618af0 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -1431,7 +1431,6 @@ export function updateMessageLookupsIncremental( const msg = messages[i]! if (msg.type === 'assistant') { const aMsg = msg as AssistantMessage - const id = aMsg.message.id! if (Array.isArray(aMsg.message.content)) { const newToolUseIDs: string[] = [] for (const content of aMsg.message.content) { @@ -2707,17 +2706,6 @@ export function mergeAssistantMessages( } } -function isToolResultMessage(msg: Message): boolean { - if (msg.type !== 'user') { - return false - } - const content = msg.message?.content - if (!content || typeof content === 'string') return false - return (content as Array<{ type: string }>).some( - block => block.type === 'tool_result', - ) -} - export function mergeUserMessages(a: UserMessage, b: UserMessage): UserMessage { const lastContent = normalizeUserTextContent( a.message.content as string | ContentBlockParam[],