Update DevChat commands and webview options

- Change DevChat.OPENAI_API_KEY title and add category
- Replace devchat.openChatPanel command with devchat-view.focus
- Update statusBarItem.command to devcaht.onStatusBarClick
- Set webviewOptions with retainContextWhenHidden: true for DevChatViewProvider
This commit is contained in:
bobo.yang 2023-05-16 17:49:13 +08:00
parent 6695bf1ae7
commit 0b6d783fb1
3 changed files with 14 additions and 34 deletions

View File

@ -2,7 +2,7 @@
"name": "devchat",
"displayName": "DevChat",
"description": "Write prompts, not code",
"version": "0.0.32",
"version": "0.0.33",
"icon": "assets/devchat.png",
"publisher": "merico",
"engines": {
@ -129,8 +129,9 @@
},
{
"command": "DevChat.OPENAI_API_KEY",
"title": "DevChat: OPENAI_API_KEY"
},
"title": "OPENAI_API_KEY",
"category": "DevChat"
},
{
"command": "devchat.openChatPanel",
"title": "DevChat"
@ -161,13 +162,6 @@
}
],
"menus": {
"view/title": [
{
"command": "devchat.createEntry",
"when": "view == devchat-view",
"group": "navigation"
}
],
"commandPalette": [
{
"command": "devchat.addConext",

View File

@ -77,28 +77,14 @@ function checkDependencyPackage() {
}
function registerOpenChatPanelCommand(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
if (vscode.workspace.workspaceFolders) {
ChatPanel.createOrShow(context.extensionUri);
} else {
vscode.window.showErrorMessage('Please open a directory before using the chat panel.');
}
let disposable = vscode.commands.registerCommand('devchat.openChatPanel',async () => {
await vscode.commands.executeCommand('devchat-view.focus');
});
context.subscriptions.push(disposable);
}
async function ensureChatPanel(context: vscode.ExtensionContext): Promise<boolean> {
console.log('Executing command to open devchat-sidebar');
await vscode.commands.executeCommand('workbench.view.extension.devchat-sidebar');
console.log('Command executed');
// if (!ChatPanel.currentPanel()) {
// if (vscode.workspace.workspaceFolders) {
// ChatPanel.createOrShow(context.extensionUri);
// } else {
// vscode.window.showErrorMessage('Please open a directory before using the chat panel.');
// return false;
// }
// }
await vscode.commands.executeCommand('devchat-view.focus');
return true;
}

View File

@ -106,7 +106,7 @@ function activate(context: vscode.ExtensionContext) {
statusBarItem.text = `$(pass)DevChat`;
statusBarItem.tooltip = `ready to chat`;
statusBarItem.command = 'devchat.openChatPanel';
statusBarItem.command = 'devcaht.onStatusBarClick';
}, 3000);
// Add the status bar item to the status bar
@ -115,16 +115,16 @@ function activate(context: vscode.ExtensionContext) {
// Register the command
context.subscriptions.push(
vscode.commands.registerCommand('devcaht.onStatusBarClick', () => {
vscode.window.showInformationMessage('My Status Bar Item was clicked!');
vscode.commands.registerCommand('devcaht.onStatusBarClick',async () => {
await vscode.commands.executeCommand('devchat-view.focus');
})
);
ExtensionContextHolder.provider = new DevChatViewProvider(context), {
webviewOptions: { retainContextWhenHidden: true }
};
ExtensionContextHolder.provider = new DevChatViewProvider(context);
context.subscriptions.push(
vscode.window.registerWebviewViewProvider('devchat-view', ExtensionContextHolder.provider)
vscode.window.registerWebviewViewProvider('devchat-view', ExtensionContextHolder.provider, {
webviewOptions: { retainContextWhenHidden: true }
})
);
}
exports.activate = activate;