fix: try openNewConversation + sendTextToChat, clipboard paste as fallback
This commit is contained in:
@@ -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;
|
|
||||||
for (const flag of [false, true]) {
|
|
||||||
try {
|
try {
|
||||||
await vscode.commands.executeCommand('antigravity.sendTextToChat', flag, command.text);
|
// Try opening the agent chat panel first
|
||||||
console.log(`Gravity Bridge: ✅ sent via antigravity.sendTextToChat(${flag}): "${command.text.substring(0, 50)}"`);
|
|
||||||
sent = true;
|
|
||||||
break;
|
|
||||||
} catch (e) {
|
|
||||||
console.log(`Gravity Bridge: sendTextToChat(${flag}) failed: ${e}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sent) {
|
|
||||||
try {
|
try {
|
||||||
await vscode.commands.executeCommand('workbench.action.chat.open', { query: command.text });
|
await vscode.commands.executeCommand('antigravity.prioritized.chat.openNewConversation');
|
||||||
console.log('Gravity Bridge: fallback to workbench.action.chat.open with query');
|
await new Promise(resolve => setTimeout(resolve, 300));
|
||||||
|
} catch { /* panel may already be open */ }
|
||||||
|
|
||||||
|
await vscode.commands.executeCommand('antigravity.sendTextToChat', false, command.text);
|
||||||
|
console.log(`Gravity Bridge: ✅ sent via sendTextToChat(false)`);
|
||||||
|
} catch (e1) {
|
||||||
|
console.log(`Gravity Bridge: sendTextToChat failed: ${e1}`);
|
||||||
|
// Method 2: focus chat panel + clipboard paste (proven to work for input)
|
||||||
|
try {
|
||||||
|
await vscode.commands.executeCommand('workbench.panel.chat.view.copilot.focus');
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user