refactor: remove unused commands and visibility handling from ChatViewProvider

This commit is contained in:
Bohdan Triapitsyn
2025-12-13 21:14:18 +02:00
parent 8c25908d0a
commit 4df60f3ee6
3 changed files with 6 additions and 65 deletions
+1 -23
View File
@@ -35,7 +35,7 @@
"activationEvents": [],
"contributes": {
"viewsContainers": {
"secondarySidebar": [
"activitybar": [
{
"id": "openchamber",
"title": "OpenChamber",
@@ -53,33 +53,11 @@
]
},
"commands": [
{
"command": "openchamber.newSession",
"title": "OpenChamber: New Chat Session"
},
{
"command": "openchamber.focusChat",
"title": "OpenChamber: Focus Chat"
},
{
"command": "openchamber.restartApi",
"title": "OpenChamber: Restart API Connection"
},
{
"command": "openchamber.showInSecondarySidebar",
"title": "OpenChamber: Show in Secondary Side Bar",
"icon": "assets/icon.svg"
}
],
"menus": {
"editor/title": [
{
"command": "openchamber.showInSecondarySidebar",
"when": "editorIsOpen",
"group": "navigation@100"
}
]
},
"configuration": {
"title": "OpenChamber",
"properties": {
-16
View File
@@ -7,7 +7,6 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
public static readonly viewType = 'openchamber.chatView';
private _view?: vscode.WebviewView;
private _isVisible = false;
constructor(
private readonly _context: vscode.ExtensionContext,
@@ -19,11 +18,6 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
webviewView: vscode.WebviewView
) {
this._view = webviewView;
this._isVisible = webviewView.visible;
webviewView.onDidChangeVisibility(() => {
this._isVisible = webviewView.visible;
});
const distUri = vscode.Uri.joinPath(this._extensionUri, 'dist');
@@ -47,12 +41,6 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
});
}
public newSession() {
if (this._view) {
this._view.webview.postMessage({ type: 'command', command: 'newSession' });
}
}
public updateTheme(kind: vscode.ColorThemeKind) {
if (this._view) {
const themeKind = getThemeKindName(kind);
@@ -73,10 +61,6 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
}
}
public isVisible(): boolean {
return this._isVisible;
}
private _getHtmlForWebview(webview: vscode.Webview) {
const scriptPath = vscode.Uri.joinPath(this._extensionUri, 'dist', 'webview', 'assets', 'index.js');
const scriptUri = webview.asWebviewUri(scriptPath);
+5 -26
View File
@@ -20,35 +20,14 @@ export function activate(context: vscode.ExtensionContext) {
)
);
context.subscriptions.push(
vscode.commands.registerCommand('openchamber.newSession', () => {
chatViewProvider?.newSession();
})
);
context.subscriptions.push(
vscode.commands.registerCommand('openchamber.focusChat', () => {
vscode.commands.executeCommand('openchamber.chatView.focus');
})
);
context.subscriptions.push(
vscode.commands.registerCommand('openchamber.restartApi', async () => {
await openCodeManager?.restart();
})
);
context.subscriptions.push(
vscode.commands.registerCommand('openchamber.showInSecondarySidebar', async () => {
const viewId = ChatViewProvider.viewType;
const isVisible = chatViewProvider?.isVisible() === true;
if (isVisible) {
await vscode.commands.executeCommand('workbench.action.toggleAuxiliaryBar');
return;
try {
await openCodeManager?.restart();
vscode.window.showInformationMessage('OpenChamber: API connection restarted');
} catch (e) {
vscode.window.showErrorMessage(`OpenChamber: Failed to restart API - ${e}`);
}
await vscode.commands.executeCommand('workbench.action.focusAuxiliaryBar');
await vscode.commands.executeCommand(`${viewId}.focus`);
})
);