2023-04-14 08:05:41 +08:00
|
|
|
// The module 'vscode' contains the VS Code extensibility API
|
|
|
|
// Import the module and reference it with the alias vscode in your code below
|
2023-04-21 06:44:26 +08:00
|
|
|
const vscode = require('vscode');
|
|
|
|
const ChatPanel = require('./chatPanel').default;
|
2023-04-14 08:05:41 +08:00
|
|
|
|
2023-04-21 06:44:26 +08:00
|
|
|
function activate(context: { extensionUri: any; subscriptions: any[]; }) {
|
2023-04-22 21:15:08 +08:00
|
|
|
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', async () => {
|
|
|
|
const sessionNames = Object.keys(ChatPanel.sessions());
|
|
|
|
|
|
|
|
const createNewSessionOption = 'Create new session';
|
|
|
|
const options = [...sessionNames, createNewSessionOption];
|
|
|
|
|
|
|
|
const selectedOption = await vscode.window.showQuickPick(options, {
|
|
|
|
placeHolder: 'Select a session or create a new one',
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!selectedOption) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let sessionName = selectedOption;
|
|
|
|
|
|
|
|
if (selectedOption === createNewSessionOption) {
|
|
|
|
sessionName = await vscode.window.showInputBox({
|
|
|
|
prompt: 'Enter a new session name',
|
|
|
|
placeHolder: 'Session Name',
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!sessionName) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatPanel.createOrShow(context.extensionUri, sessionName);
|
2023-04-21 06:44:26 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
context.subscriptions.push(disposable);
|
2023-04-14 08:05:41 +08:00
|
|
|
}
|
2023-04-21 06:44:26 +08:00
|
|
|
exports.activate = activate;
|