add new toolbar + commands

This commit is contained in:
Aneta Jastrzębska 2024-09-22 11:03:42 +02:00
parent 7269c4e582
commit 30b528402c
3 changed files with 39 additions and 1 deletions

View file

@ -63,6 +63,16 @@
{
"command": "void.discardDiff",
"title": "Discard Diff"
},
{
"command": "void.newChat",
"title": "New chat",
"icon": "$(add)"
},
{
"command": "void.prevChats",
"title": "Previous chats",
"icon": "$(history)"
}
],
"viewsContainers": {
@ -94,7 +104,21 @@
"key": "ctrl+k",
"mac": "cmd+k"
}
]
],
"menus": {
"view/title": [
{
"command": "void.newChat",
"when": "view == 'void.viewnumberone'",
"group": "navigation"
},
{
"command": "void.prevChats",
"when": "view == 'void.viewnumberone'",
"group": "navigation"
}
]
}
},
"scripts": {
"vscode:prepublish": "npm run compile",

View file

@ -83,6 +83,14 @@ export function activate(context: vscode.ExtensionContext) {
webviewProvider.webview.then(
webview => {
// top navigation bar commands
context.subscriptions.push(vscode.commands.registerCommand('void.newChat', async () => {
webview.postMessage({ type: 'startNewChat' } satisfies WebviewMessage)
}))
context.subscriptions.push(vscode.commands.registerCommand('void.prevChats', async () => {
webview.postMessage({ type: 'showPreviousChats' } satisfies WebviewMessage)
}))
// when config changes, send it to the sidebar
vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('void')) {

View file

@ -36,6 +36,12 @@ type WebviewMessage = (
// sidebar -> editor
| { type: 'updateThread', thread: ChatThread }
// editor -> sidebar
| { type: 'startNewChat' }
// editor -> sidebar
| { type: 'showPreviousChats' }
)
type Command = WebviewMessage['type']