diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 522a6bd..566da1f 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -284,56 +284,41 @@ async function handleCommand(filePath: string) { if (chatOpened) { await new Promise(resolve => setTimeout(resolve, 300)); - // Try to submit the chat input - const submitCommands = [ + // Paste text into chat input + 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); + await new Promise(resolve => setTimeout(resolve, 200)); + + // Debug: discover all available chat/submit commands + const allCmds = await vscode.commands.getCommands(true); + const chatCmds = allCmds.filter(c => + c.includes('chat') && (c.includes('accept') || c.includes('submit') || c.includes('send') || c.includes('enter')) + ); + console.log(`Gravity Bridge: available chat submit commands: ${JSON.stringify(chatCmds)}`); + + // Try every possible submit command + const submitAttempts = [ 'workbench.action.chat.acceptInput', 'workbench.action.chat.submit', + 'workbench.action.chat.sendInput', + 'workbench.action.chat.send', + ...chatCmds, // Also try dynamically discovered ones ]; - let submitted = false; - for (const cmd of submitCommands) { + + for (const cmd of submitAttempts) { try { await vscode.commands.executeCommand(cmd); - submitted = true; - console.log(`Gravity Bridge: chat submitted with "${cmd}"`); + console.log(`Gravity Bridge: ✅ submitted with "${cmd}"`); break; } catch { /* try next */ } } - - if (!submitted) { - // 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); - - // 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 */ } - } - } } - // Always mark as consumed + show notification + // Always mark as consumed (no toast notification) command.consumed = true; fs.writeFileSync(filePath, JSON.stringify(command, null, 2), 'utf-8'); - - const prefix = chatOpened ? '📨' : 'âš ī¸ (ėą„íŒ… 패널 ëĒģ ė—´ėŒ)'; - vscode.window.showInformationMessage(`${prefix} [${projectName}] Discord: ${command.text.substring(0, 80)}`); } catch (err) { console.error('Gravity Bridge: error handling command', err); }