From 35f39abf3906901427cfa95ca12fb57245d67bd3 Mon Sep 17 00:00:00 2001 From: CD Date: Sat, 7 Mar 2026 15:29:12 +0900 Subject: [PATCH] fix: simulate Enter key after clipboard paste for chat submission --- extension/src/extension.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 9a9a3f3..522a6bd 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -300,12 +300,31 @@ async function handleCommand(filePath: string) { } if (!submitted) { - // Fallback: paste into focused input if query param didn't work + // Fallback: paste into focused input then simulate Enter const oldClipboard = await vscode.env.clipboard.readText(); await vscode.env.clipboard.writeText(command.text); await vscode.commands.executeCommand('editor.action.clipboardPasteAction'); await vscode.env.clipboard.writeText(oldClipboard); - console.log('Gravity Bridge: fallback to clipboard paste (no submit)'); + + // Wait for paste to complete, then simulate Enter + await new Promise(resolve => setTimeout(resolve, 200)); + + // Try multiple ways to submit/press Enter + const enterMethods = [ + 'workbench.action.chat.acceptInput', + 'default:type', // with \n + ]; + for (const method of enterMethods) { + try { + if (method === 'default:type') { + await vscode.commands.executeCommand(method, { text: '\n' }); + } else { + await vscode.commands.executeCommand(method); + } + console.log(`Gravity Bridge: Enter sent via "${method}"`); + break; + } catch { /* try next */ } + } } }