fix: improve text rendering in prompts and enhance ANSI stripping - #80
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughIn ChangesANSI-aware terminal row calculation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
| const stripAnsi = (str) => { | ||
| const ansiEscape = String.fromCharCode(27); | ||
| return str.replace(new RegExp(`${ansiEscape}\\[[0-9;]*m`, "g"), ""); | ||
| }; |
There was a problem hiding this comment.
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.
| 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, ""); | |
| }; |
✅ CI/CD Test ResultsOverall Status: success |
Summary by CodeRabbit