fix: simulate Enter key after clipboard paste for chat submission
This commit is contained in:
@@ -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 */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user