Skip to content

Commit 4407f42

Browse files
cleanup(markdown-renderer): streamline loading indicator to prevent stuck state during markdown render; improves UX and avoids memory leaks.
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 788aefe commit 4407f42

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

npm-app/src/display/markdown-renderer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,16 @@ export class MarkdownStreamRenderer {
440440

441441
this.isShowingIndicator = false
442442

443-
// Clear the indicator line completely and move cursor to beginning of line
444-
// Use enough spaces to clear the longest possible indicator (5 chars + padding)
445-
process.stderr.write('\r' + ' '.repeat(10) + '\r')
446-
447-
// Clear timer
443+
// Clear timer first to prevent race conditions
448444
if (this.loadingIndicatorTimer) {
449445
clearInterval(this.loadingIndicatorTimer)
450446
this.loadingIndicatorTimer = null
451447
}
448+
449+
// Clear the indicator line completely and move cursor to beginning of line
450+
// Use enough spaces to clear the longest possible indicator + padding
451+
// Format is ' ●●● ' so we need at least 5 chars + some buffer
452+
process.stderr.write('\r' + ' '.repeat(20) + '\r')
452453
}
453454

454455
private processConservativeMode(text: string, outs: string[]) {

0 commit comments

Comments
 (0)