Add suppress-rate-limit-warning patch#662
Add suppress-rate-limit-warning patch#662VitalyOstanin wants to merge 3 commits intoPiebald-AI:mainfrom
Conversation
Suppress rate limit warning banners (allowed_warning status) while preserving error messages when limits are actually reached. Patches the warning getter function to return null instead of the warning message.
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as MiscView (UI)
participant Config as Settings Store
participant Registry as Patch Registry
participant Processor as File Processor
User->>UI: Toggle "Suppress rate limit warning"
UI->>Config: updateSettings(misc.suppressRateLimitWarning)
Config->>Registry: expose config flag
Registry->>Processor: enable conditional patch "suppress-rate-limit-warning"
Processor->>Processor: run writeSuppressRateLimitWarning(oldFile)
Processor-->>Registry: report patch result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/patches/suppressRateLimitWarning.test.ts (1)
8-26: Add a regression test that preserves non-warning behavior.The suite does not directly assert that non-warning branches (e.g.
severity==="error") remain untouched after patching, which is a stated behavior goal for this patch.✅ Suggested test addition
+ it('should preserve error-path message returns', () => { + const input = + 'function X(a){if(a&&a.severity==="warning")return a.message;if(a&&a.severity==="error")return a.message;return null}'; + const result = writeSuppressRateLimitWarning(input); + expect(result).not.toBeNull(); + expect(result).toContain( + 'if(a&&a.severity==="error")return a.message;' + ); + expect(result).toContain( + 'if(a&&a.severity==="warning")return null;' + ); + });As per coding guidelines: Test edge cases and error conditions in test files.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/suppressRateLimitWarning.test.ts` around lines 8 - 26, Add a regression test that ensures non-warning branches remain unchanged after patching: update the test file to include a case that runs writeSuppressRateLimitWarning on input containing a non-warning branch (e.g. a branch with severity==="error" or return q.message) and assert that the non-warning code still exists (expect(result).toContain('severity==="error"') or expect(result).toContain('return q.message')). Use existing helpers like makeInput() to construct the input and reuse the test pattern in the file so the new test verifies only that non-warning behavior is preserved while the warning branch is replaced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/patches/suppressRateLimitWarning.ts`:
- Around line 7-10: The current regexes alreadyPatched and pattern are too loose
and can false-match unrelated "severity === 'warning'" branches; tighten them to
only match the exact minified shape used in these patches (an expression like
if(<id>&&<id>.severity==="warning")return null/return <id>.message) and anchor
them with a preceding literal delimiter (e.g., [,;{}]) so they don't trigger on
unrelated code; update the alreadyPatched regex to look for the exact minified
if(<id>&&<id>.severity==="warning")return null pattern and update pattern to
match if(<id>&&<id>.severity==="warning")return (<id>).message (reuse the same
capture name for the identifier) so both are idempotent and narrowly scoped when
testing oldFile and when generating the replacement.
---
Nitpick comments:
In `@src/patches/suppressRateLimitWarning.test.ts`:
- Around line 8-26: Add a regression test that ensures non-warning branches
remain unchanged after patching: update the test file to include a case that
runs writeSuppressRateLimitWarning on input containing a non-warning branch
(e.g. a branch with severity==="error" or return q.message) and assert that the
non-warning code still exists (expect(result).toContain('severity==="error"') or
expect(result).toContain('return q.message')). Use existing helpers like
makeInput() to construct the input and reuse the test pattern in the file so the
new test verifies only that non-warning behavior is preserved while the warning
branch is replaced.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ebcf7106-0047-4547-a999-fd819baffafc
📒 Files selected for processing (6)
src/defaultSettings.tssrc/patches/index.tssrc/patches/suppressRateLimitWarning.test.tssrc/patches/suppressRateLimitWarning.tssrc/types.tssrc/ui/components/MiscView.tsx
Remove \s* patterns (minified code has no whitespace), add [,;{}]
delimiter prefix, and use backreference \1 to tie the variable in
severity check to the same captured identifier. Add delimiter
variation test.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/patches/suppressRateLimitWarning.test.ts (1)
5-6: Add a$-identifier test case to lock regex intent.Current inputs only use
q; adding a$-prefixed variable case would guard the
[$\w]+expectation from regressions.Suggested test addition
describe('writeSuppressRateLimitWarning', () => { const makeInput = (delimiter = '}') => `function Ip8(H,$){let q=d2K(H,$)${delimiter}if(q&&q.severity==="warning")return q.message;return null}`; + const makeDollarVarInput = (delimiter = '}') => + `function Ip8(H,$){let $q=d2K(H,$)${delimiter}if($q&&$q.severity==="warning")return $q.message;return null}`; @@ it('should work with different delimiters', () => { for (const d of [',', ';', '}', '{']) { const result = writeSuppressRateLimitWarning(makeInput(d)); expect(result).not.toBeNull(); expect(result).toContain('severity==="warning")return null;'); } }); + + it('should work when warning var starts with $', () => { + const result = writeSuppressRateLimitWarning(makeDollarVarInput('}')); + expect(result).not.toBeNull(); + expect(result).toContain('if($q&&$q.severity==="warning")return null;'); + }); });Based on learnings, patch regexes under
src/patchesare expected to support[$\w]+identifiers (including$), and this is a useful edge case to keep tested.Also applies to: 38-44
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/suppressRateLimitWarning.test.ts` around lines 5 - 6, Update the test inputs to include a `$`-prefixed identifier to ensure the patch regex accepts [$\w]+ tokens: modify the test helper makeInput (function makeInput) or add a sibling test case that uses a `$`-named variable (e.g., `$x` or `$q`) in the generated function string so the regex exercise covers `$`-prefixed identifiers; also apply the same addition for the related tests around lines 38-44 to lock the intent across all cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/patches/suppressRateLimitWarning.test.ts`:
- Around line 5-6: Update the test inputs to include a `$`-prefixed identifier
to ensure the patch regex accepts [$\w]+ tokens: modify the test helper
makeInput (function makeInput) or add a sibling test case that uses a `$`-named
variable (e.g., `$x` or `$q`) in the generated function string so the regex
exercise covers `$`-prefixed identifiers; also apply the same addition for the
related tests around lines 38-44 to lock the intent across all cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a599b694-5ddd-498c-9b5e-4ea616fb1bc6
📒 Files selected for processing (1)
src/patches/suppressRateLimitWarning.test.ts
Summary
suppress-rate-limit-warningpatch that suppresses rate limit warning banners while preserving error messages when limits are actually reachedreturn <var>.messagewithreturn nullforseverity === "warning"casemisc.suppressRateLimitWarningsetting (default:false)Details
Claude Code shows warning banners when approaching rate limits (
allowed_warningstatus). This patch suppresses those warnings while keeping error-level messages (actual rate limit hits) intact.The patch targets the function that extracts warning messages from rate limit status objects — a small, stable pattern (
severity === "warning") with a single match in the codebase.Files
suppressRateLimitWarning.tssuppressRateLimitWarning.test.tsindex.tstypes.tssuppressRateLimitWarning: booleanin MiscConfigdefaultSettings.tsfalseMiscView.tsxSummary by CodeRabbit
New Features
Behavior
Tests