fix: chat input submit via acceptInput + query param, clipboard paste fallback
This commit is contained in:
@@ -263,18 +263,18 @@ async function handleCommand(filePath: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
// General text: try to open chat panel and paste
|
||||
const chatCommands = [
|
||||
'workbench.action.chat.open',
|
||||
'workbench.panel.chat.view.copilot.focus',
|
||||
'workbench.action.chat.openEditSession',
|
||||
'workbench.action.openChat',
|
||||
// General text: send to chat panel with query + submit
|
||||
let chatOpened = false;
|
||||
|
||||
// Method 1: Try opening chat with query parameter (fills + auto-focuses)
|
||||
const chatOpenCommands = [
|
||||
{ cmd: 'workbench.action.chat.open', args: { query: command.text } },
|
||||
{ cmd: 'workbench.panel.chat.view.copilot.focus', args: undefined },
|
||||
];
|
||||
|
||||
let chatOpened = false;
|
||||
for (const cmd of chatCommands) {
|
||||
for (const { cmd, args } of chatOpenCommands) {
|
||||
try {
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
await vscode.commands.executeCommand(cmd, args);
|
||||
chatOpened = true;
|
||||
console.log(`Gravity Bridge: chat opened with "${cmd}"`);
|
||||
break;
|
||||
@@ -282,11 +282,31 @@ async function handleCommand(filePath: string) {
|
||||
}
|
||||
|
||||
if (chatOpened) {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
// Try to submit the chat input
|
||||
const submitCommands = [
|
||||
'workbench.action.chat.acceptInput',
|
||||
'workbench.action.chat.submit',
|
||||
];
|
||||
let submitted = false;
|
||||
for (const cmd of submitCommands) {
|
||||
try {
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
submitted = true;
|
||||
console.log(`Gravity Bridge: chat submitted with "${cmd}"`);
|
||||
break;
|
||||
} catch { /* try next */ }
|
||||
}
|
||||
|
||||
if (!submitted) {
|
||||
// Fallback: paste into focused input if query param didn't work
|
||||
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)');
|
||||
}
|
||||
}
|
||||
|
||||
// Always mark as consumed + show notification
|
||||
|
||||
Reference in New Issue
Block a user