Skip to content
This repository was archived by the owner on Jul 4, 2026. It is now read-only.

fix: improve text rendering in prompts and enhance ANSI stripping - #80

Merged
gaureshpai merged 3 commits into
mainfrom
fix/all-active-issues
Jun 21, 2026
Merged

gaureshpai merged 3 commits into
mainfrom
fix/all-active-issues

Conversation

@gaureshpai

@gaureshpai gaureshpai commented Jun 21, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of colored and formatted text in terminal output. Fixed cursor movement miscalculations that occurred when ANSI escape sequences were present, ensuring more accurate positioning of terminal elements.

@gaureshpai gaureshpai self-assigned this Jun 21, 2026
@gaureshpai gaureshpai added the bug Something isn't working label Jun 21, 2026
@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@gaureshpai, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 49 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 20078926-e77f-4ed3-8e48-cdb6250fe1b2

📥 Commits

Reviewing files that changed from the base of the PR and between 9f4851b and e514bab.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • .github/workflows/publish.yml
  • package.json
📝 Walkthrough

Walkthrough

In src/lib/prompts.js, getRenderedRowCount now strips ANSI escape codes via a new ansiRegex/stripAnsi helper before computing visible string length for row counting. In renderList, each line is assembled as a full string and emitted with process.stdout.write, with the newline moved into the template literal.

Changes

ANSI-aware terminal row calculation

Layer / File(s) Summary
ANSI stripping in getRenderedRowCount and renderList output
src/lib/prompts.js
Adds ansiRegex and stripAnsi to strip escape codes before computing visible row count in getRenderedRowCount; updates renderList to construct each line string and write it via process.stdout.write.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 Hop hop, through the terminal glow,
Escape codes vanish, rows now flow!
No more cursors lost in colored haze,
The rabbit counts lines through ANSI maze.
Clean output lands where it should go! 🎨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely missing; no description was provided by the author despite a detailed template being available. Add a comprehensive description following the provided template, including: summary of changes, related issue link, type of change (bug fix selected), testing approach, and checklist verification.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes in the PR: fixing ANSI escape sequence handling in text rendering and improving the related functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/all-active-issues

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gaureshpai gaureshpai linked an issue Jun 21, 2026 that may be closed by this pull request

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

Copy link
Copy Markdown
Contributor

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 introduces a stripAnsi helper function to strip ANSI escape sequences from strings, ensuring that getRenderedRowCount calculates terminal row counts based on visible text length. It also refactors stdout writing in processQuestion. The review feedback suggests optimizing stripAnsi by using a static, more robust regular expression literal to avoid recreating the RegExp object on every call and to match all ANSI escape sequences.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/lib/prompts.js
Comment on lines +20 to +23
const stripAnsi = (str) => {
const ansiEscape = String.fromCharCode(27);
return str.replace(new RegExp(`${ansiEscape}\\[[0-9;]*m`, "g"), "");
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Creating a new RegExp instance on every call to stripAnsi is inefficient, especially since this function is called during terminal rendering and keypress events. Additionally, the current regular expression only matches ANSI sequences ending in m (color codes), whereas a more robust pattern (like the one used in your tests) would strip all ANSI escape sequences.

We can optimize this by using a static regular expression literal with the \x1b escape character.

Suggested change
const stripAnsi = (str) => {
const ansiEscape = String.fromCharCode(27);
return str.replace(new RegExp(`${ansiEscape}\\[[0-9;]*m`, "g"), "");
};
const ansiRegex = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
const stripAnsi = (str) => {
return str.replace(ansiRegex, "");
};

@github-actions

github-actions Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ CI/CD Test Results

Overall Status: success


View full workflow run

@gaureshpai
gaureshpai merged commit 577d420 into main Jun 21, 2026
2 of 3 checks passed
@gaureshpai
gaureshpai deleted the fix/all-active-issues branch June 21, 2026 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Duplication of commands

1 participant