fix: dynamic chat command discovery + removed toast notification

This commit is contained in:
2026-03-07 15:53:48 +09:00
parent 35f39abf39
commit 5780896273

View File

@@ -284,56 +284,41 @@ async function handleCommand(filePath: string) {
if (chatOpened) { if (chatOpened) {
await new Promise(resolve => setTimeout(resolve, 300)); await new Promise(resolve => setTimeout(resolve, 300));
// Try to submit the chat input // Paste text into 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 then simulate Enter
const oldClipboard = await vscode.env.clipboard.readText(); const oldClipboard = await vscode.env.clipboard.readText();
await vscode.env.clipboard.writeText(command.text); await vscode.env.clipboard.writeText(command.text);
await vscode.commands.executeCommand('editor.action.clipboardPasteAction'); await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
await vscode.env.clipboard.writeText(oldClipboard); await vscode.env.clipboard.writeText(oldClipboard);
// Wait for paste to complete, then simulate Enter
await new Promise(resolve => setTimeout(resolve, 200)); await new Promise(resolve => setTimeout(resolve, 200));
// Try multiple ways to submit/press Enter // Debug: discover all available chat/submit commands
const enterMethods = [ 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.acceptInput',
'default:type', // with \n 'workbench.action.chat.submit',
'workbench.action.chat.sendInput',
'workbench.action.chat.send',
...chatCmds, // Also try dynamically discovered ones
]; ];
for (const method of enterMethods) {
for (const cmd of submitAttempts) {
try { try {
if (method === 'default:type') { await vscode.commands.executeCommand(cmd);
await vscode.commands.executeCommand(method, { text: '\n' }); console.log(`Gravity Bridge: ✅ submitted with "${cmd}"`);
} else {
await vscode.commands.executeCommand(method);
}
console.log(`Gravity Bridge: Enter sent via "${method}"`);
break; break;
} catch { /* try next */ } } catch { /* try next */ }
} }
} }
}
// Always mark as consumed + show notification // Always mark as consumed (no toast notification)
command.consumed = true; command.consumed = true;
fs.writeFileSync(filePath, JSON.stringify(command, null, 2), 'utf-8'); 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) { } catch (err) {
console.error('Gravity Bridge: error handling command', err); console.error('Gravity Bridge: error handling command', err);
} }