fix: dynamic chat command discovery + removed toast notification
This commit is contained in:
@@ -284,56 +284,41 @@ async function handleCommand(filePath: string) {
|
||||
if (chatOpened) {
|
||||
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 then simulate Enter
|
||||
// Paste text into chat input
|
||||
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 = [
|
||||
// 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',
|
||||
'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 {
|
||||
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}"`);
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
console.log(`Gravity Bridge: ✅ submitted with "${cmd}"`);
|
||||
break;
|
||||
} catch { /* try next */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Always mark as consumed + show notification
|
||||
// Always mark as consumed (no toast notification)
|
||||
command.consumed = true;
|
||||
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) {
|
||||
console.error('Gravity Bridge: error handling command', err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user