feat(vscode): Move Navigation into the title bar (#88)
* Move Navigation into the title bar * Fix spacing * Update Changelog * Remove unused function
This commit is contained in:
@@ -86,6 +86,16 @@
|
||||
{
|
||||
"command": "openchamber.improveCode",
|
||||
"title": "Improve Code"
|
||||
},
|
||||
{
|
||||
"command": "openchamber.newSession",
|
||||
"title": "New Session",
|
||||
"icon": "$(add)"
|
||||
},
|
||||
{
|
||||
"command": "openchamber.showSettings",
|
||||
"title": "Settings",
|
||||
"icon": "$(settings-gear)"
|
||||
}
|
||||
],
|
||||
"submenus": [
|
||||
@@ -107,6 +117,18 @@
|
||||
"group": "navigation@1"
|
||||
}
|
||||
],
|
||||
"view/title": [
|
||||
{
|
||||
"command": "openchamber.newSession",
|
||||
"when": "view == openchamber.chatView",
|
||||
"group": "navigation@1"
|
||||
},
|
||||
{
|
||||
"command": "openchamber.showSettings",
|
||||
"when": "view == openchamber.chatView",
|
||||
"group": "navigation@2"
|
||||
}
|
||||
],
|
||||
"openchamber.submenu": [
|
||||
{
|
||||
"command": "openchamber.explain"
|
||||
|
||||
@@ -116,6 +116,30 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public createNewSession() {
|
||||
if (this._view) {
|
||||
// Reveal the webview panel
|
||||
this._view.show(true);
|
||||
|
||||
this._view.webview.postMessage({
|
||||
type: 'command',
|
||||
command: 'newSession'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public showSettings() {
|
||||
if (this._view) {
|
||||
// Reveal the webview panel
|
||||
this._view.show(true);
|
||||
|
||||
this._view.webview.postMessage({
|
||||
type: 'command',
|
||||
command: 'showSettings'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _sendCachedState() {
|
||||
if (!this._view) {
|
||||
|
||||
@@ -296,6 +296,18 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.newSession', () => {
|
||||
chatViewProvider?.createNewSession();
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.showSettings', () => {
|
||||
chatViewProvider?.showSettings();
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('openchamber.showOpenCodeStatus', async () => {
|
||||
const config = vscode.workspace.getConfiguration('openchamber');
|
||||
|
||||
@@ -711,6 +711,23 @@ onCommand('createSessionWithPrompt', (payload) => {
|
||||
});
|
||||
});
|
||||
|
||||
// Listen for newSession command from extension title bar button
|
||||
onCommand('newSession', () => {
|
||||
import('../../ui/src/stores/useSessionStore').then(({ useSessionStore }) => {
|
||||
const store = useSessionStore.getState();
|
||||
store.openNewSessionDraft();
|
||||
});
|
||||
|
||||
// Also dispatch event to navigate to chat view in VSCodeLayout
|
||||
window.dispatchEvent(new CustomEvent('openchamber:navigate', { detail: { view: 'chat' } }));
|
||||
});
|
||||
|
||||
// Listen for showSettings command from extension title bar button
|
||||
onCommand('showSettings', () => {
|
||||
// Dispatch event to navigate to settings view in VSCodeLayout
|
||||
window.dispatchEvent(new CustomEvent('openchamber:navigate', { detail: { view: 'settings' } }));
|
||||
});
|
||||
|
||||
import('../../ui/src/main')
|
||||
.then(async () => {
|
||||
await waitForUiMount();
|
||||
|
||||
Reference in New Issue
Block a user