fix: try openNewConversation + sendTextToChat, clipboard paste as fallback

This commit is contained in:
2026-03-07 16:31:44 +09:00
parent c688812089
commit 180dba18be

View File

@@ -263,25 +263,30 @@ async function handleCommand(filePath: string) {
return; return;
} }
// General text: use Antigravity native API to send to chat // General text: send to Antigravity chat
// Try false first (plain text), then true (tagged text) // Method 1: antigravity.sendTextToChat (native API)
let sent = false; try {
for (const flag of [false, true]) { // Try opening the agent chat panel first
try { try {
await vscode.commands.executeCommand('antigravity.sendTextToChat', flag, command.text); await vscode.commands.executeCommand('antigravity.prioritized.chat.openNewConversation');
console.log(`Gravity Bridge: ✅ sent via antigravity.sendTextToChat(${flag}): "${command.text.substring(0, 50)}"`); await new Promise(resolve => setTimeout(resolve, 300));
sent = true; } catch { /* panel may already be open */ }
break;
} catch (e) { await vscode.commands.executeCommand('antigravity.sendTextToChat', false, command.text);
console.log(`Gravity Bridge: sendTextToChat(${flag}) failed: ${e}`); console.log(`Gravity Bridge: ✅ sent via sendTextToChat(false)`);
} } catch (e1) {
} console.log(`Gravity Bridge: sendTextToChat failed: ${e1}`);
if (!sent) { // Method 2: focus chat panel + clipboard paste (proven to work for input)
try { try {
await vscode.commands.executeCommand('workbench.action.chat.open', { query: command.text }); await vscode.commands.executeCommand('workbench.panel.chat.view.copilot.focus');
console.log('Gravity Bridge: fallback to workbench.action.chat.open with query'); await new Promise(resolve => setTimeout(resolve, 300));
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: ✅ pasted via clipboard (manual Enter needed)');
} catch (e2) { } catch (e2) {
console.error('Gravity Bridge: all chat send methods failed', e2); console.error('Gravity Bridge: all methods failed', e2);
} }
} }