Echtzeit-UI in main.ts verdrahtet

Event-Stream-View registriert, StatusBar mit Live-Updates,
Ribbon-Icon für Event-Stream, Kommando 'Event-Stream
anzeigen', activateEventStream-Methode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Luca Oelfke 2026-02-12 10:55:28 +01:00
parent 22a6c2e188
commit bf63f5f9e3

View file

@ -11,6 +11,8 @@ import { EditorCollector } from './collectors/editor-collector';
import { SystemCollector } from './collectors/system-collector'; import { SystemCollector } from './collectors/system-collector';
import { LogfireSettingTab } from './ui/settings-tab'; import { LogfireSettingTab } from './ui/settings-tab';
import { InitialScanModal } from './ui/initial-scan-modal'; import { InitialScanModal } from './ui/initial-scan-modal';
import { StatusBar } from './ui/status-bar';
import { EventStreamView, EVENT_STREAM_VIEW_TYPE } from './ui/event-stream-view';
export default class LogfirePlugin extends Plugin { export default class LogfirePlugin extends Plugin {
settings!: LogfireSettings; settings!: LogfireSettings;
@ -24,6 +26,7 @@ export default class LogfirePlugin extends Plugin {
private navCollector!: NavCollector; private navCollector!: NavCollector;
private editorCollector!: EditorCollector; private editorCollector!: EditorCollector;
private systemCollector!: SystemCollector; private systemCollector!: SystemCollector;
private statusBar!: StatusBar;
private paused = false; private paused = false;
@ -77,6 +80,21 @@ export default class LogfirePlugin extends Plugin {
// UI: Settings tab // UI: Settings tab
this.addSettingTab(new LogfireSettingTab(this.app, this)); this.addSettingTab(new LogfireSettingTab(this.app, this));
// UI: Event stream view
this.registerView(
EVENT_STREAM_VIEW_TYPE,
(leaf) => new EventStreamView(leaf, this.eventBus),
);
// UI: Status bar
this.statusBar = new StatusBar(this);
this.statusBar.start();
// Ribbon icon
this.addRibbonIcon('activity', 'Logfire: Event-Stream', () => {
this.activateEventStream();
});
// Commands // Commands
this.registerCommands(); this.registerCommands();
@ -107,6 +125,7 @@ export default class LogfirePlugin extends Plugin {
async onunload(): Promise<void> { async onunload(): Promise<void> {
console.log('[Logfire] Entlade Plugin...'); console.log('[Logfire] Entlade Plugin...');
this.statusBar?.destroy();
this.stopTracking(); this.stopTracking();
if (this.sessionManager) { if (this.sessionManager) {
@ -217,6 +236,12 @@ export default class LogfirePlugin extends Plugin {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
private registerCommands(): void { private registerCommands(): void {
this.addCommand({
id: 'show-event-stream',
name: 'Event-Stream anzeigen',
callback: () => this.activateEventStream(),
});
this.addCommand({ this.addCommand({
id: 'toggle-tracking', id: 'toggle-tracking',
name: 'Tracking pausieren/fortsetzen', name: 'Tracking pausieren/fortsetzen',
@ -263,6 +288,23 @@ export default class LogfirePlugin extends Plugin {
}); });
} }
// ---------------------------------------------------------------------------
// Event stream view
// ---------------------------------------------------------------------------
private async activateEventStream(): Promise<void> {
const existing = this.app.workspace.getLeavesOfType(EVENT_STREAM_VIEW_TYPE);
if (existing.length > 0) {
this.app.workspace.revealLeaf(existing[0]);
return;
}
const leaf = this.app.workspace.getRightLeaf(false);
if (leaf) {
await leaf.setViewState({ type: EVENT_STREAM_VIEW_TYPE, active: true });
this.app.workspace.revealLeaf(leaf);
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Settings // Settings
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------