feat(ux): terminal width warning and dashboard dispose safety

- cli.ts: warn on stderr when terminal is narrower than 40 columns
- dashboard-overlay.ts: add disposed flag checked before scheduling
  refreshes and after async loadData() to prevent rendering on a
  stopped TUI
This commit is contained in:
Flux Labs 2026-03-15 09:56:45 -05:00
parent 4995afed90
commit b448bf9400

View file

@ -89,6 +89,7 @@ export class GSDDashboardOverlay {
private loading = true;
private loadedDashboardIdentity?: string;
private refreshInFlight: Promise<void> | null = null;
private disposed = false;
constructor(
tui: { requestRender: () => void },
@ -108,7 +109,7 @@ export class GSDDashboardOverlay {
}
private scheduleRefresh(initial = false): void {
if (this.refreshInFlight) return;
if (this.refreshInFlight || this.disposed) return;
this.refreshInFlight = this.refreshDashboard(initial)
.finally(() => {
this.refreshInFlight = null;
@ -136,11 +137,13 @@ export class GSDDashboardOverlay {
}
private async refreshDashboard(initial = false): Promise<void> {
if (this.disposed) return;
this.dashData = getAutoDashboardData();
const nextIdentity = this.computeDashboardIdentity(this.dashData);
if (initial || nextIdentity !== this.loadedDashboardIdentity) {
const loaded = await this.loadData();
if (this.disposed) return;
if (loaded) {
this.loadedDashboardIdentity = nextIdentity;
}
@ -529,6 +532,7 @@ export class GSDDashboardOverlay {
}
dispose(): void {
this.disposed = true;
clearInterval(this.refreshTimer);
}
}