fix: dynamic chat command discovery + removed toast notification
This commit is contained in:
@@ -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 = [
|
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);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 200));
|
||||||
|
|
||||||
|
// Debug: discover all available chat/submit commands
|
||||||
|
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',
|
||||||
'workbench.action.chat.submit',
|
'workbench.action.chat.submit',
|
||||||
|
'workbench.action.chat.sendInput',
|
||||||
|
'workbench.action.chat.send',
|
||||||
|
...chatCmds, // Also try dynamically discovered ones
|
||||||
];
|
];
|
||||||
let submitted = false;
|
|
||||||
for (const cmd of submitCommands) {
|
for (const cmd of submitAttempts) {
|
||||||
try {
|
try {
|
||||||
await vscode.commands.executeCommand(cmd);
|
await vscode.commands.executeCommand(cmd);
|
||||||
submitted = true;
|
console.log(`Gravity Bridge: ✅ submitted with "${cmd}"`);
|
||||||
console.log(`Gravity Bridge: chat submitted with "${cmd}"`);
|
|
||||||
break;
|
break;
|
||||||
} catch { /* try next */ }
|
} catch { /* try next */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!submitted) {
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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 */ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user