Skip to content

Conversation

@DonDawsy
Copy link

@DonDawsy DonDawsy commented Jun 22, 2025

When using Warp or iTerm, ccusage will print new blocks instead of clearing the screen, causing flicker on update. This fixes that.

Summary by CodeRabbit

  • Improvements
    • Enhanced terminal content updates for smoother and more reliable screen clearing and content refresh.
    • Improved tracking and clearing of previously displayed terminal lines, resulting in cleaner output during live monitoring.
    • Reduced redundant screen clearing for a more efficient and flicker-free user experience.
    • Added brief delays after clearing the terminal to ensure proper screen refresh during live monitoring.

@coderabbitai
Copy link

coderabbitai bot commented Jun 22, 2025

Walkthrough

The changes enhance terminal output management by improving how content is cleared and written in the TerminalManager class. New methods were added for precise control over clearing previously written lines, and line tracking was introduced. In the live monitoring command, screen clearing responsibilities were refactored and short delays were added after clearing to ensure proper terminal updates.

Changes

File(s) Change Summary
src/_terminal-utils.ts Enhanced TerminalManager with line tracking, improved screen clearing using readline, added clearPreviousContent, clearLine, moveUp, moveToLineStart, and writeRaw methods, and updated write to track line counts.
src/commands/_blocks.live.ts Added short delays after screen clearing, removed redundant clear from renderLiveDisplay, and centralized clearing logic in startLiveMonitoring.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TerminalManager
    participant startLiveMonitoring
    participant renderLiveDisplay

    User->>startLiveMonitoring: Trigger live monitoring
    startLiveMonitoring->>TerminalManager: clearScreen()
    startLiveMonitoring->>startLiveMonitoring: await small delay
    alt No active session block
        startLiveMonitoring->>TerminalManager: write("No active block")
    else Active block found
        startLiveMonitoring->>TerminalManager: clearScreen()
        startLiveMonitoring->>startLiveMonitoring: await small delay
        startLiveMonitoring->>renderLiveDisplay: Render block
        renderLiveDisplay->>TerminalManager: write(block content)
    end
Loading

Poem

A hop, a skip, a terminal clear,
Now lines are counted, tracked with cheer.
With pauses brief and screens anew,
The output shines, refreshed for you.
Rabbits tap and blink with glee—
Terminal magic, bug-free!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @DonDawsy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to significantly improve the user experience in terminal applications like Warp and iTerm by eliminating screen flicker during display updates. It achieves this by refining the underlying terminal clearing logic, introducing a mechanism to clear only the previously rendered content, and adding small delays to ensure terminal commands are processed smoothly.

Highlights

  • Enhanced Terminal Clearing: The TerminalManager now leverages node:readline for more precise screen clearing (cursorTo, clearScreenDown) and introduces a new clearPreviousContent method. This new method clears only the previously rendered output by moving the cursor up and clearing lines, which significantly reduces visual flicker during updates.
  • Improved Write Operations: The write method in TerminalManager has been updated to track the number of lines written (lastContentLines). This line count is crucial for the new clearPreviousContent functionality. Additionally, a new writeRaw method was introduced for writing text without affecting the line tracking, useful for control characters or non-content output.
  • Flicker Mitigation in Live Monitoring: Small, asynchronous delays (10ms) have been strategically added after terminal.clearScreen() calls within the startLiveMonitoring function. This provides terminal emulators (like Warp and iTerm) sufficient time to process the clear command before new content is written, directly addressing the reported flicker issue. A redundant clearScreen call was also removed from renderLiveDisplay.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/commands/_blocks.live.ts (2)

101-102: Consider using a more robust delay mechanism.

The hardcoded 10ms delay may not be sufficient for all terminal emulators. Consider making this configurable or using a more sophisticated approach.

-				// Small delay to ensure terminal processes the clear command
-				await new Promise(resolve => setTimeout(resolve, 10));
+				// Small delay to ensure terminal processes the clear command
+				await delay(10);

This maintains consistency with the delay function already imported and used elsewhere in the code.


118-119: Duplicate delay implementation - consolidate for consistency.

The same delay pattern is repeated here. Consider extracting this into a helper function or using the already imported delay utility.

-			// Small delay to ensure terminal processes the clear command
-			await new Promise(resolve => setTimeout(resolve, 10));
+			// Small delay to ensure terminal processes the clear command
+			await delay(10);

This approach is more consistent with the existing codebase and provides better maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a6189fe and 43b8cc9.

📒 Files selected for processing (2)
  • src/_terminal-utils.ts (4 hunks)
  • src/commands/_blocks.live.ts (2 hunks)
🧰 Additional context used
🪛 ESLint
src/commands/_blocks.live.ts

[error] 102-102: Unsafe return of a value of type error.

(ts/no-unsafe-return)


[error] 102-102: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 119-119: Unsafe return of a value of type error.

(ts/no-unsafe-return)


[error] 119-119: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)

src/_terminal-utils.ts

[error] 66-66: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 66-66: Unsafe member access .cursorTo on an error typed value.

(ts/no-unsafe-member-access)


[error] 67-67: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 67-67: Unsafe member access .clearScreenDown on an error typed value.

(ts/no-unsafe-member-access)


[error] 77-77: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 77-77: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 79-79: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 79-79: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 81-81: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 81-81: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 117-117: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 117-117: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 127-127: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 127-127: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (6)
src/_terminal-utils.ts (6)

3-3: Good addition of readline import for better terminal control.

Using the native readline module provides more reliable cursor positioning and screen clearing compared to raw ANSI escape sequences.


33-33: Line tracking property added for content management.

The lastContentLines property enables precise tracking of written content for better clearing operations.


65-71: Improved screen clearing implementation with better reliability.

The switch to using readline.cursorTo and readline.clearScreenDown provides more reliable screen clearing across different terminal emulators, which directly addresses the flicker issue.


73-84: New method for precise content clearing.

The clearPreviousContent method provides fine-grained control over clearing previously written content, which is essential for smooth updates without flicker.


114-121: Enhanced write method with line counting.

The line counting logic correctly tracks newlines to support the new clearing functionality.


123-128: Useful addition of writeRaw method.

The writeRaw method provides a way to write content without affecting line count tracking, which is useful for control sequences and other non-content output.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix screen flickering issues in certain terminals by changing the screen clearing mechanism. The changes look good and should address the problem. I've made a few suggestions to improve code consistency and remove potentially unused code.

Overall, a good set of changes to improve the user experience.

@ryoppippi
Copy link
Owner

could you resolve conflicts?
it looks really cool

@ryoppippi
Copy link
Owner

if you all done mention me!!!!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🔭 Outside diff range comments (1)
src/_terminal-utils.ts (1)

105-109: Remove leftover code from old implementation.

This old implementation using ansiEscapes should be removed as it's replaced by the new readline-based approach.

-		// Only clear screen in TTY environments to prevent issues with non-interactive streams
-		this.stream.write(ansiEscapes.clearScreen);
-		this.stream.write(ansiEscapes.cursorTo(0, 0));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eac86e6 and a2467ab.

📒 Files selected for processing (1)
  • src/_terminal-utils.ts (4 hunks)
🧰 Additional context used
🪛 ESLint
src/_terminal-utils.ts

[error] 55-55: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 55-55: Unsafe member access .cursorTo on an error typed value.

(ts/no-unsafe-member-access)


[error] 56-56: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 56-56: Unsafe member access .clearScreenDown on an error typed value.

(ts/no-unsafe-member-access)


[error] 66-66: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 66-66: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 68-68: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 68-68: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 68-68: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 68-68: Unsafe member access .MOVE_UP on an error typed value.

(ts/no-unsafe-member-access)


[error] 70-70: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 70-70: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 79-79: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 79-79: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 80-80: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 80-80: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 80-80: Unsafe member access .CLEAR_LINE on an error typed value.

(ts/no-unsafe-member-access)


[error] 88-88: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 88-88: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 89-89: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 89-89: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 89-89: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 89-89: Unsafe member access .MOVE_UP on an error typed value.

(ts/no-unsafe-member-access)


[error] 97-97: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 97-97: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 98-98: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 98-98: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 98-98: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 98-98: Unsafe member access .MOVE_TO_COLUMN on an error typed value.

(ts/no-unsafe-member-access)


[error] 117-117: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 117-117: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 127-127: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 127-127: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)

🔇 Additional comments (3)
src/_terminal-utils.ts (3)

3-3: Good addition for enhanced cursor control.

Adding the readline import enables more precise terminal cursor positioning, which aligns well with the PR objective of reducing flicker.


116-121: Good enhancement for line tracking.

The modification to track line counts is essential for the new clearPreviousContent() functionality and supports the flicker reduction objective.


126-128: Good addition for raw output without line tracking.

The writeRaw() method provides a clean way to write content without affecting the line count tracking, which is useful for terminal control sequences.

Comment on lines 51 to +60
clearScreen(): void {
if (this.stream.isTTY) {

// Use readline to clear and reposition cursor
readline.cursorTo(this.stream, 0, 0);
readline.clearScreenDown(this.stream);
// Reset line counter for next content
this.lastContentLines = 0;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical issue: Leftover code creates duplication.

The method contains both new and old implementations. Lines 105-109 show the old ansiEscapes implementation that should be removed.

	clearScreen(): void {
		if (this.stream.isTTY) {
-
			// Use readline to clear and reposition cursor
			readline.cursorTo(this.stream, 0, 0);
			readline.clearScreenDown(this.stream);
			// Reset line counter for next content
			this.lastContentLines = 0;
		}
	}

Also remove the duplicate implementation at lines 105-109.

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 ESLint

[error] 52-52: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 52-52: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 52-54: Block must not be padded by blank lines.

(style/padded-blocks)


[error] 55-55: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 55-55: Unsafe member access .cursorTo on an error typed value.

(ts/no-unsafe-member-access)


[error] 56-56: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 56-56: Unsafe member access .clearScreenDown on an error typed value.

(ts/no-unsafe-member-access)

🤖 Prompt for AI Agents
In src/_terminal-utils.ts around lines 51 to 60 and also lines 105 to 109, the
clearScreen method contains both the new readline-based implementation and the
old ansiEscapes implementation, causing duplication. Remove the old ansiEscapes
code block at lines 105 to 109 entirely to keep only the new readline-based
implementation and avoid redundant code.

DonDawsy and others added 5 commits June 22, 2025 19:09
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
src/_terminal-utils.ts (2)

52-59: Remove duplicate clearScreen implementation.

The method now uses readline correctly, but there's still leftover code at lines 104-108 that creates duplication and should be removed entirely.


88-88: Critical issue: Replace undefined TERMINAL_CONTROL with ANSI escape sequence.

The TERMINAL_CONTROL.MOVE_UP() reference is still undefined and will cause runtime errors.

-			this.stream.write(TERMINAL_CONTROL.MOVE_UP(lines));
+			this.stream.write(`\u001B[${lines}A`);
🧹 Nitpick comments (2)
src/_terminal-utils.ts (2)

16-16: Fix indentation to match project style.

The property declaration uses spaces instead of tabs, which doesn't match the project's indentation style.

-  private lastContentLines = 0;
+	private lastContentLines = 0;

77-81: Fix indentation and formatting issues.

The method has inconsistent indentation that doesn't match the project style.

-clearLine(): void {
-    if (this.stream.isTTY) {
-        this.stream.write('\u001B[2K');
-    }
-}
+	clearLine(): void {
+		if (this.stream.isTTY) {
+			this.stream.write('\u001B[2K');
+		}
+	}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2467ab and 52b062e.

📒 Files selected for processing (1)
  • src/_terminal-utils.ts (4 hunks)
🧰 Additional context used
🪛 ESLint
src/_terminal-utils.ts

[error] 16-16: Expected indentation of 1 tab but found 2 spaces.

(style/indent)


[error] 54-54: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 54-54: Unsafe member access .cursorTo on an error typed value.

(ts/no-unsafe-member-access)


[error] 55-55: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 55-55: Unsafe member access .clearScreenDown on an error typed value.

(ts/no-unsafe-member-access)


[error] 65-65: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 65-65: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 67-67: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 67-67: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 69-69: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 69-69: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 77-77: Expected indentation of 1 tab but found 0.

(style/indent)


[error] 78-78: Expected indentation of 2 tabs but found 4 spaces.

(style/indent)


[error] 78-78: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 78-78: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 79-79: Expected indentation of 3 tabs but found 8 spaces.

(style/indent)


[error] 79-79: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 79-79: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 80-80: Expected indentation of 2 tabs but found 4 spaces.

(style/indent)


[error] 81-81: Expected indentation of 1 tab but found 0.

(style/indent)


[error] 87-87: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 87-87: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 88-88: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 88-88: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 88-88: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 88-88: Unsafe member access .MOVE_UP on an error typed value.

(ts/no-unsafe-member-access)


[error] 96-96: Unexpected any value in conditional. An explicit comparison or type conversion is required.

(ts/strict-boolean-expressions)


[error] 96-96: Unsafe member access .isTTY on an error typed value.

(ts/no-unsafe-member-access)


[error] 97-97: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 97-97: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 116-116: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 116-116: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)


[error] 126-126: Unsafe call of a(n) error type typed value.

(ts/no-unsafe-call)


[error] 126-126: Unsafe member access .write on an error typed value.

(ts/no-unsafe-member-access)

🔇 Additional comments (3)
src/_terminal-utils.ts (3)

117-120: Approve the line tracking enhancement.

The line counting logic correctly tracks newlines in written content, which is essential for the clearPreviousContent() functionality. This addresses the core issue of preventing flicker during terminal updates.


122-127: Good addition of writeRaw method.

The writeRaw method provides a clean way to write content without affecting line tracking, which is useful for control sequences and non-content output.


64-72: Verify the clearPreviousContent implementation.

The method correctly implements the core functionality to prevent flicker by moving the cursor up and clearing content. However, ensure this works properly with the terminal emulators mentioned in the PR (Warp and iTerm).

#!/bin/bash
# Description: Check if there are any test files that verify terminal behavior
# Expected: Find tests related to terminal clearing functionality

fd -e ts -e js | xargs rg -l "clearPreviousContent|TerminalManager" | head -10

@ryoppippi ryoppippi requested a review from Copilot June 22, 2025 19:06
@ryoppippi
Copy link
Owner

in my environment it still causes flicker hmm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the live monitoring display by improving how the terminal is cleared and refreshed to eliminate flicker.

  • Introduces small delays after clearing the screen to ensure the terminal processes clear commands.
  • Updates TerminalManager.clearScreen to use readline APIs and track the number of written lines.
  • Adds new methods (clearPreviousContent, clearLine, moveUp, moveToLineStart, writeRaw) to better control cursor movement and content clearing.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/commands/_blocks.live.ts Added await delay(10) after each terminal.clearScreen() to prevent flicker.
src/_terminal-utils.ts Switched screen-clearing logic to readline, added line-tracking and new cursor/clearing APIs.
Comments suppressed due to low confidence (3)

src/_terminal-utils.ts:115

  • Consider updating the JSDoc comment for write to mention that it now tracks line counts, to keep documentation in sync with behavior.
	write(text: string): void {

src/_terminal-utils.ts:64

  • There are no tests covering the new clearPreviousContent, clearLine, and cursor movement methods; consider adding unit tests to verify their behavior.
	clearPreviousContent(): void {

src/_terminal-utils.ts:77

  • [nitpick] The indentation of this method is inconsistent with other class methods; aligning it will improve readability and maintain consistency.
clearLine(): void {

if (activeBlock == null) {
terminal.clearScreen();
// Small delay to ensure terminal processes the clear command
await delay(10);
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract the 10ms magic number into a named constant (e.g., CLEAR_DELAY_MS) for clarity and easier future adjustments.

Suggested change
await delay(10);
await delay(CLEAR_DELAY_MS);

Copilot uses AI. Check for mistakes.
@ryoppippi
Copy link
Owner

I'm so sorry but in my env this pr is worth than the main

@ryoppippi
Copy link
Owner

I'm using m3 pro with ghostty, which is fast enough not to see flicker

@ryoppippi
Copy link
Owner

@DonDawsy Instead of refreshing screen with delay, I optimise the screen refresh.
could you try this patch and test it on your env?

#166

@ryoppippi
Copy link
Owner

#167
ok I tried this PR and it is better.
I gonna merge #167 so please try it and decide whether to keep this PR. please let me know!

@DonDawsy
Copy link
Author

#167 ok I tried this PR and it is better. I gonna merge #167 so please try it and decide whether to keep this PR. please let me know!

Yeah that one looks good to me! I'll close this one

@DonDawsy DonDawsy closed this Jun 22, 2025
@ryoppippi
Copy link
Owner

Thank you! we merged it!!
Again, thank you for your hard work and contribution!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants