add regeneration message

This commit is contained in:
bobo.yang 2023-05-23 11:16:48 +08:00
parent 42fec8a6cc
commit daf106c629
2 changed files with 16 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import { doCommit } from './doCommit';
import { historyMessages } from './historyMessages'; import { historyMessages } from './historyMessages';
import { regCommandList } from './regCommandList'; import { regCommandList } from './regCommandList';
import { regContextList } from './regContextList'; import { regContextList } from './regContextList';
import { sendMessage, stopDevChat } from './sendMessage'; import { sendMessage, stopDevChat, regeneration } from './sendMessage';
import { blockApply } from './showDiff'; import { blockApply } from './showDiff';
import { showDiff } from './showDiff'; import { showDiff } from './showDiff';
import { addConext } from './addContext'; import { addConext } from './addContext';
@ -64,4 +64,6 @@ messageHandler.registerHandler('addRefCommandContext', addRefCommandContext);
messageHandler.registerHandler('contextDetail', contextDetail); messageHandler.registerHandler('contextDetail', contextDetail);
// Debug handler // Debug handler
messageHandler.registerHandler('listAllMessages', listAllMessages); messageHandler.registerHandler('listAllMessages', listAllMessages);
// regeneration
// 应答与sendMessage相同
messageHandler.registerHandler('regeneration', regeneration);

View File

@ -10,6 +10,7 @@ import messageHistory from '../util/messageHistory';
import CustomCommands from '../command/customCommand'; import CustomCommands from '../command/customCommand';
import { regInMessage, regOutMessage } from '../util/reg_messages'; import { regInMessage, regOutMessage } from '../util/reg_messages';
let _lastMessage: any = undefined;
// Add this function to messageHandler.ts // Add this function to messageHandler.ts
@ -77,6 +78,8 @@ regOutMessage({ command: 'receiveMessagePartial', text: 'xxxx', user: 'xxx', dat
// { command: 'receiveMessage', text: 'xxxx', hash: 'xxx', user: 'xxx', date: 'xxx'} // { command: 'receiveMessage', text: 'xxxx', hash: 'xxx', user: 'xxx', date: 'xxx'}
// { command: 'receiveMessagePartial', text: 'xxxx', user: 'xxx', date: 'xxx'} // { command: 'receiveMessagePartial', text: 'xxxx', user: 'xxx', date: 'xxx'}
export async function sendMessage(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> { export async function sendMessage(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
_lastMessage = message;
const newText2 = await CommandManager.getInstance().processText(message.text); const newText2 = await CommandManager.getInstance().processText(message.text);
const parsedMessage = parseMessage(newText2); const parsedMessage = parseMessage(newText2);
const chatOptions: any = {}; const chatOptions: any = {};
@ -131,6 +134,15 @@ export async function sendMessage(message: any, panel: vscode.WebviewPanel|vscod
return; return;
} }
// regeneration last message again
regInMessage({command: 'regeneration'});
export async function regeneration(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
// call sendMessage to send last message again
if (_lastMessage) {
sendMessage(_lastMessage, panel);
}
}
regInMessage({command: 'stopDevChat'}); regInMessage({command: 'stopDevChat'});
export async function stopDevChat(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> { export async function stopDevChat(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
logger.channel()?.info(`Stopping devchat`); logger.channel()?.info(`Stopping devchat`);