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:
parent
4995afed90
commit
b448bf9400
1 changed files with 5 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue