diff --git a/package-lock.json b/package-lock.json index 4c2a2ab..79dea07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@anyware/cli", + "name": "@diggerhq/anyware", "version": "0.7.27", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@anyware/cli", + "name": "@diggerhq/anyware", "version": "0.7.27", "dependencies": { "chokidar": "^4.0.0", diff --git a/src/claude/sessionScanner.ts b/src/claude/sessionScanner.ts index 9a51112..7b1c03c 100644 --- a/src/claude/sessionScanner.ts +++ b/src/claude/sessionScanner.ts @@ -205,8 +205,8 @@ export async function createSessionScanner(opts: SessionScannerOptions): Promise watcher.on('add', scheduleSync); } - // Periodic sync as backup (every 3 seconds) - const intervalId = setInterval(scheduleSync, 3000); + // Periodic sync as backup (every 5 seconds) + const intervalId = setInterval(scheduleSync, 5000); return { cleanup: async () => { diff --git a/src/ui/statusBar.ts b/src/ui/statusBar.ts index db71790..7a5e8e7 100644 --- a/src/ui/statusBar.ts +++ b/src/ui/statusBar.ts @@ -20,6 +20,8 @@ export class StatusBar { private connected: boolean = true; private started: boolean = false; private resizeHandler: (() => void) | null = null; + private redrawTimeout: NodeJS.Timeout | null = null; + private lastRedrawTime: number = 0; constructor(opts: StatusBarOptions) { this.sessionId = opts.sessionId; @@ -93,10 +95,33 @@ export class StatusBar { } /** - * Force an immediate redraw - call this when you know the terminal is stable + * Force a redraw with debouncing - prevents rapid redraws that can interrupt terminal output + * Minimum 1 second between redraws */ redraw(): void { - this.draw(); + const now = Date.now(); + const timeSinceLastRedraw = now - this.lastRedrawTime; + const minInterval = 1000; // Minimum 1 second between redraws + + // Clear any pending redraw + if (this.redrawTimeout) { + clearTimeout(this.redrawTimeout); + this.redrawTimeout = null; + } + + if (timeSinceLastRedraw >= minInterval) { + // Enough time has passed, redraw immediately + this.lastRedrawTime = now; + this.draw(); + } else { + // Schedule redraw for later + const delay = minInterval - timeSinceLastRedraw; + this.redrawTimeout = setTimeout(() => { + this.lastRedrawTime = Date.now(); + this.draw(); + this.redrawTimeout = null; + }, delay); + } } /** @@ -106,6 +131,12 @@ export class StatusBar { if (!this.started) return; this.started = false; + // Clear any pending redraw timeout + if (this.redrawTimeout) { + clearTimeout(this.redrawTimeout); + this.redrawTimeout = null; + } + // Remove resize handler if (this.resizeHandler) { process.stdout.off('resize', this.resizeHandler);