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": [], "activationEvents": [],
"contributes": { "contributes": {
"viewsContainers": { "viewsContainers": {
"secondarySidebar": [ "activitybar": [
{ {
"id": "openchamber", "id": "openchamber",
"title": "OpenChamber", "title": "OpenChamber",
@@ -53,33 +53,11 @@
] ]
}, },
"commands": [ "commands": [
{
"command": "openchamber.newSession",
"title": "OpenChamber: New Chat Session"
},
{
"command": "openchamber.focusChat",
"title": "OpenChamber: Focus Chat"
},
{ {
"command": "openchamber.restartApi", "command": "openchamber.restartApi",
"title": "OpenChamber: Restart API Connection" "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": { "configuration": {
"title": "OpenChamber", "title": "OpenChamber",
"properties": { "properties": {
-16
View File
@@ -7,7 +7,6 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
public static readonly viewType = 'openchamber.chatView'; public static readonly viewType = 'openchamber.chatView';
private _view?: vscode.WebviewView; private _view?: vscode.WebviewView;
private _isVisible = false;
constructor( constructor(
private readonly _context: vscode.ExtensionContext, private readonly _context: vscode.ExtensionContext,
@@ -19,11 +18,6 @@ export class ChatViewProvider implements vscode.WebviewViewProvider {
webviewView: vscode.WebviewView webviewView: vscode.WebviewView
) { ) {
this._view = webviewView; this._view = webviewView;
this._isVisible = webviewView.visible;
webviewView.onDidChangeVisibility(() => {
this._isVisible = webviewView.visible;
});
const distUri = vscode.Uri.joinPath(this._extensionUri, 'dist'); 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) { public updateTheme(kind: vscode.ColorThemeKind) {
if (this._view) { if (this._view) {
const themeKind = getThemeKindName(kind); 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) { private _getHtmlForWebview(webview: vscode.Webview) {
const scriptPath = vscode.Uri.joinPath(this._extensionUri, 'dist', 'webview', 'assets', 'index.js'); const scriptPath = vscode.Uri.joinPath(this._extensionUri, 'dist', 'webview', 'assets', 'index.js');
const scriptUri = webview.asWebviewUri(scriptPath); 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( context.subscriptions.push(
vscode.commands.registerCommand('openchamber.restartApi', async () => { vscode.commands.registerCommand('openchamber.restartApi', async () => {
await openCodeManager?.restart(); try {
}) await openCodeManager?.restart();
); vscode.window.showInformationMessage('OpenChamber: API connection restarted');
context.subscriptions.push( } catch (e) {
vscode.commands.registerCommand('openchamber.showInSecondarySidebar', async () => { vscode.window.showErrorMessage(`OpenChamber: Failed to restart API - ${e}`);
const viewId = ChatViewProvider.viewType;
const isVisible = chatViewProvider?.isVisible() === true;
if (isVisible) {
await vscode.commands.executeCommand('workbench.action.toggleAuxiliaryBar');
return;
} }
await vscode.commands.executeCommand('workbench.action.focusAuxiliaryBar');
await vscode.commands.executeCommand(`${viewId}.focus`);
}) })
); );