Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/claude/sessionScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
35 changes: 33 additions & 2 deletions src/ui/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

/**
Expand All @@ -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);
Expand Down