clean up deprecated buttons

This commit is contained in:
Pierre committed 2026-10-04 13:43:50 +02:00
1 parent 99422d8cfc
commit 5614ad049d
12 files changed
+36 -161

No files matched your search

-5
View File
@@ -14,8 +14,6 @@ function normalizeUrl(raw: string): string {
export class ADClient {
private productionMode = false;
private _onProductionModeChanged = new vscode.EventEmitter<boolean>();
readonly onProductionModeChanged = this._onProductionModeChanged.event;
private log: vscode.OutputChannel;
constructor(log: vscode.OutputChannel) {
@@ -120,7 +118,6 @@ export class ADClient {
async setProductionMode(mode: boolean): Promise<void> {
await this.request('POST', '/api/appdaemon/service/admin/production_mode/set', { mode });
this.productionMode = mode;
this._onProductionModeChanged.fire(mode);
}
/**
@@ -135,7 +132,6 @@ export class ADClient {
if (key.includes('production_mode')) {
const val = (state[key] as { state?: unknown })?.state;
this.productionMode = val === true || val === 'True' || val === 'true';
this._onProductionModeChanged.fire(this.productionMode);
return this.productionMode;
}
}
@@ -155,6 +151,5 @@ export class ADClient {
}
dispose() {
this._onProductionModeChanged.dispose();
}
}
-14
View File
@@ -11,10 +11,6 @@ export class ErrorViewer {
private diagnosticCollection: vscode.DiagnosticCollection;
private watcher: fs.FSWatcher | undefined;
private lastSize = 0;
private errorCount = 0;
private _onErrorCountChanged = new vscode.EventEmitter<number>();
readonly onErrorCountChanged = this._onErrorCountChanged.event;
constructor() {
this.outputChannel = vscode.window.createOutputChannel('AppDaemon Errors');
@@ -30,12 +26,6 @@ export class ErrorViewer {
clearDiagnostics() {
this.diagnosticCollection.clear();
this.errorCount = 0;
this._onErrorCountChanged.fire(0);
}
getErrorCount(): number {
return this.errorCount;
}
// ── file watching ────────────────────────────────────────────────────────
@@ -115,12 +105,9 @@ export class ErrorViewer {
this.outputChannel.appendLine(trimmed);
if (/\b(ERROR|CRITICAL|WARNING)\b/.test(trimmed)) {
this.errorCount++;
this.parseDiagnostic(trimmed);
}
}
this._onErrorCountChanged.fire(this.errorCount);
} finally {
fs.closeSync(fd);
}
@@ -183,6 +170,5 @@ export class ErrorViewer {
}
this.outputChannel.dispose();
this.diagnosticCollection.dispose();
this._onErrorCountChanged.dispose();
}
}
+1 -16
View File
@@ -347,12 +347,9 @@ export async function activate(context: vscode.ExtensionContext) {
errorViewer = new ErrorViewer();
const logExplorer = new LogExplorer(context, count => statusBar.setLogErrorCount(count));
context.subscriptions.push(logExplorer, vscode.commands.registerCommand('appdaemon.exploreLogs', () => logExplorer.show()));
statusBar = new StatusBarManager(adClient);
statusBar = new StatusBarManager();
logExplorer.startPolling();
// Wire error count → status bar badge
errorViewer.onErrorCountChanged((count) => statusBar.setErrorCount(count));
// ── Contextual per-file restart button ───────────────────────────────────
updateContextualButton(vscode.window.activeTextEditor);
context.subscriptions.push(
@@ -544,18 +541,6 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('appdaemon.showErrors', () => {
errorViewer.show();
}),
vscode.commands.registerCommand('appdaemon.handleErrors', async () => {
const pick = await vscode.window.showErrorMessage(
'AppDaemon errors detected',
'Show log',
'Clear'
);
if (pick === 'Show log') {
errorViewer.show();
} else if (pick === 'Clear') {
errorViewer.clearDiagnostics();
}
}),
vscode.commands.registerCommand('appdaemon.refreshEntities', async () => {
const entities = await haClient.fetchEntities();
vscode.window.showInformationMessage(`AppDaemon: ${entities.length} entities loaded`);
+2 -16
View File
@@ -14,7 +14,6 @@ export class LogExplorer implements vscode.Disposable {
private timer?: ReturnType<typeof setInterval>;
private entries = new Map<string, LogEntry>();
private cursors = new Map<string, Cursor>();
private imported = new Set<string>();
private warnings = new Set<string>();
private busy = false;
private sourceDocuments?: Promise<SourceDocument[]>;
@@ -58,10 +57,6 @@ export class LogExplorer implements vscode.Disposable {
.replace('{{CSS}}', media('logExplorer.css').toString()).replace('{{JS}}', media('logExplorer.js').toString());
this.messageListener?.dispose();
this.messageListener = webview.onDidReceiveMessage(async message => {
if (message.type === 'copy' && typeof message.text === 'string' && message.text.length <= 1024 * 1024) {
try { await vscode.env.clipboard.writeText(message.text); webview.postMessage({ type: 'copied' }); }
catch (error) { vscode.window.showWarningMessage(`Unable to copy: ${String(error)}`); }
}
if (message.type === 'ready') { this.publish(); }
if (message.type === 'open' && typeof message.id === 'string') {
const entry = this.entries.get(message.id);
@@ -92,11 +87,6 @@ export class LogExplorer implements vscode.Disposable {
editor.revealRange(new vscode.Range(position, position));
} catch (error) { vscode.window.showWarningMessage(`Source unavailable: ${String(error)}`); }
}
if (message.type === 'import') {
const files = await vscode.window.showOpenDialog({ canSelectMany: true, filters: { Logs: ['log', '1', '2', '3'] } });
files?.forEach(uri => this.imported.add(uri.fsPath));
this.poll();
}
if (message.type === 'clear') { this.clearLogs(); }
}, undefined, this.context.subscriptions);
this.activeWebview = webview;
@@ -116,12 +106,9 @@ export class LogExplorer implements vscode.Disposable {
const configured = config.get<string[]>('logExplorerPaths', ['logs/appdaemon.log', 'logs/error.log', 'logs/virtualsensors.log']);
return [...new Set(configured.map(p => path.resolve(folder, p)))];
}
private files(): string[] {
return [...new Set([...this.configuredFiles(), ...this.imported])];
}
private clearLogs() {
const folder = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
const cleared = new Set<string>(this.imported);
const cleared = new Set<string>();
const failures: string[] = [];
if (folder) {
const realRoot = fs.realpathSync(folder);
@@ -138,7 +125,6 @@ export class LogExplorer implements vscode.Disposable {
}
}
}
this.imported.clear();
for (const [id, entry] of this.entries) { if (entry.file && cleared.has(entry.file)) { this.entries.delete(id); } }
failures.forEach(failure => this.warnings.add(`Unable to clear ${failure}`));
this.publish();
@@ -151,7 +137,7 @@ export class LogExplorer implements vscode.Disposable {
try {
const encoding = vscode.workspace.getConfiguration('appdaemon').get<string>('logEncoding', 'auto');
const zone = vscode.workspace.getConfiguration('appdaemon').get<string>('logTimezone', 'Europe/Berlin');
for (const file of this.files()) {
for (const file of this.configuredFiles()) {
if (!fs.existsSync(file)) { continue; }
try {
const stat = fs.statSync(file);
+1 -49
View File
@@ -1,15 +1,12 @@
import * as vscode from 'vscode';
import { ADClient } from './adClient';
export class StatusBarManager {
private restartADItem: vscode.StatusBarItem;
private restartHAItem: vscode.StatusBarItem;
private productionModeItem: vscode.StatusBarItem;
private errorItem: vscode.StatusBarItem;
private contextualItem: vscode.StatusBarItem;
private logsItem: vscode.StatusBarItem;
constructor(private adClient: ADClient) {
constructor() {
// Reload AppDaemon apps
this.restartADItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
this.restartADItem.command = 'appdaemon.restartAD';
@@ -24,19 +21,6 @@ export class StatusBarManager {
this.restartHAItem.tooltip = 'Restart Home Assistant';
this.restartHAItem.show();
// Production mode toggle
this.productionModeItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 98);
this.productionModeItem.command = 'appdaemon.toggleProductionMode';
this.updateProductionModeDisplay();
this.productionModeItem.show();
// Error log shortcut
this.errorItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 97);
this.errorItem.command = 'appdaemon.showErrors';
this.errorItem.text = '$(check) AD Errors';
this.errorItem.tooltip = 'Show AppDaemon Error Log';
this.errorItem.show();
// Log explorer shortcut, available even when no editor is open.
this.logsItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 96);
this.logsItem.command = 'appdaemon.exploreLogs';
@@ -47,9 +31,6 @@ export class StatusBarManager {
// Contextual per-file restart button (hidden by default)
this.contextualItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 101);
this.contextualItem.command = 'appdaemon.restartCurrentFileApps';
// React to production mode changes
adClient.onProductionModeChanged(() => this.updateProductionModeDisplay());
}
/**
@@ -69,33 +50,6 @@ export class StatusBarManager {
this.contextualItem.show();
}
updateProductionModeDisplay() {
const isProduction = this.adClient.isProductionMode();
if (isProduction) {
this.productionModeItem.text = '$(eye-closed) Prod ON';
this.productionModeItem.tooltip = 'Production Mode: ON — click to disable';
this.productionModeItem.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground');
} else {
this.productionModeItem.text = '$(eye) Prod OFF';
this.productionModeItem.tooltip = 'Production Mode: OFF — click to enable';
this.productionModeItem.backgroundColor = undefined;
}
}
setErrorCount(count: number) {
if (count > 0) {
this.errorItem.text = `$(warning) AD Errors (${count})`;
this.errorItem.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground');
this.errorItem.tooltip = `${count} error(s) — click to show or clear`;
this.errorItem.command = 'appdaemon.handleErrors';
} else {
this.errorItem.text = '$(check) AD Errors';
this.errorItem.backgroundColor = undefined;
this.errorItem.tooltip = 'No AppDaemon errors — click to view log';
this.errorItem.command = 'appdaemon.showErrors';
}
}
setLogErrorCount(count: number) {
this.logsItem.backgroundColor = count > 0 ? new vscode.ThemeColor('statusBarItem.errorBackground') : undefined;
this.logsItem.tooltip = count > 0
@@ -106,8 +60,6 @@ export class StatusBarManager {
dispose() {
this.restartADItem.dispose();
this.restartHAItem.dispose();
this.productionModeItem.dispose();
this.errorItem.dispose();
this.logsItem.dispose();
this.contextualItem.dispose();
}