Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ export const DEFAULT_SETTINGS: Settings = {
increaseFileReadLimit: false,
suppressLineNumbers: false,
suppressRateLimitOptions: false,
suppressRateLimitWarning: false,
mcpConnectionNonBlocking: true,
mcpServerBatchSize: null,
statuslineThrottleMs: null,
Expand Down
12 changes: 12 additions & 0 deletions src/patches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { writeHideStartupClawd } from './hideStartupClawd';
import { writeIncreaseFileReadLimit } from './increaseFileReadLimit';
import { writeSuppressLineNumbers } from './suppressLineNumbers';
import { writeSuppressRateLimitOptions } from './suppressRateLimitOptions';
import { writeSuppressRateLimitWarning } from './suppressRateLimitWarning';
import { writeSessionMemory } from './sessionMemory';
import { writeRememberSkill } from './rememberSkill';
import { writeThinkingBlockStyling } from './thinkingBlockStyling';
Expand Down Expand Up @@ -311,6 +312,13 @@ const PATCH_DEFINITIONS = [
description:
"/rate-limit-options won't be injected when limits are reached",
},
{
id: 'suppress-rate-limit-warning',
name: 'Suppress rate limit warning',
group: PatchGroup.MISC_CONFIGURABLE,
description:
'Rate limit warning banners will be suppressed (errors still shown)',
},
{
id: 'token-count-rounding',
name: 'Token count rounding',
Expand Down Expand Up @@ -781,6 +789,10 @@ export const applyCustomization = async (
fn: c => writeSuppressRateLimitOptions(c),
condition: !!config.settings.misc?.suppressRateLimitOptions,
},
'suppress-rate-limit-warning': {
fn: c => writeSuppressRateLimitWarning(c),
condition: !!config.settings.misc?.suppressRateLimitWarning,
},
'token-count-rounding': {
fn: c =>
writeTokenCountRounding(c, config.settings.misc!.tokenCountRounding!),
Expand Down
45 changes: 45 additions & 0 deletions src/patches/suppressRateLimitWarning.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { describe, it, expect } from 'vitest';
import { writeSuppressRateLimitWarning } from './suppressRateLimitWarning';

describe('writeSuppressRateLimitWarning', () => {
const makeInput = (delimiter = '}') =>
`function Ip8(H,$){let q=d2K(H,$)${delimiter}if(q&&q.severity==="warning")return q.message;return null}`;

it('should replace warning message return with null', () => {
const input = makeInput();
const result = writeSuppressRateLimitWarning(input);
expect(result).not.toBeNull();
expect(result).toContain('if(q&&q.severity==="warning")return null;');
expect(result).not.toContain('return q.message');
});

it('should return unchanged file when already patched', () => {
const input = makeInput();
const patched = writeSuppressRateLimitWarning(input)!;
const result = writeSuppressRateLimitWarning(patched);
expect(result).toBe(patched);
});

it('should return null when pattern not found', () => {
const result = writeSuppressRateLimitWarning('no matching content here');
expect(result).toBeNull();
});

it('should preserve error-path message returns', () => {
const input =
'function Rp8(H,$){let q=d2K(H,$)}if(q&&q.severity==="error")return q.message;return null}' +
'function Ip8(H,$){let q=d2K(H,$)}if(q&&q.severity==="warning")return q.message;return null}';
const result = writeSuppressRateLimitWarning(input);
expect(result).not.toBeNull();
expect(result).toContain('severity==="error")return q.message;');
expect(result).toContain('severity==="warning")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;');
}
});
});
35 changes: 35 additions & 0 deletions src/patches/suppressRateLimitWarning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { debug } from '../utils';
import { showDiff } from './index';

export const writeSuppressRateLimitWarning = (
oldFile: string
): string | null => {
const alreadyPatched =
/[,;{}]if\(([$\w]+)&&\1\.severity==="warning"\)return null;/;
if (alreadyPatched.test(oldFile)) return oldFile;

const pattern =
/[,;{}]if\(([$\w]+)&&\1\.severity==="warning"\)return \1\.message;/;

const match = oldFile.match(pattern);

if (!match || match.index === undefined) {
debug(
'patch: suppressRateLimitWarning: failed to find rate limit warning getter pattern'
);
return null;
}

const varName = match[1];
const original = match[0];
const delimiter = original[0];
const replacement = `${delimiter}if(${varName}&&${varName}.severity==="warning")return null;`;
const startIndex = match.index;
const endIndex = startIndex + original.length;

const newFile =
oldFile.slice(0, startIndex) + replacement + oldFile.slice(endIndex);

showDiff(oldFile, newFile, replacement, startIndex, endIndex);
return newFile;
};
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface MiscConfig {
increaseFileReadLimit: boolean;
suppressLineNumbers: boolean;
suppressRateLimitOptions: boolean;
suppressRateLimitWarning: boolean;
mcpConnectionNonBlocking: boolean;
mcpServerBatchSize: number | null;
statuslineThrottleMs: number | null;
Expand Down
15 changes: 15 additions & 0 deletions src/ui/components/MiscView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function MiscView({ onSubmit }: MiscViewProps) {
increaseFileReadLimit: false,
suppressLineNumbers: false,
suppressRateLimitOptions: false,
suppressRateLimitWarning: false,
mcpConnectionNonBlocking: true,
mcpServerBatchSize: null as number | null,
statuslineThrottleMs: null as number | null,
Expand Down Expand Up @@ -324,6 +325,20 @@ export function MiscView({ onSubmit }: MiscViewProps) {
});
},
},
{
id: 'suppressRateLimitWarning',
title: 'Suppress rate limit warning banners',
description:
'Hides rate limit warning banners in the status bar. Error messages when limits are actually reached are still shown.',
getValue: () => settings.misc?.suppressRateLimitWarning ?? false,
toggle: () => {
updateSettings(settings => {
ensureMisc();
settings.misc!.suppressRateLimitWarning =
!settings.misc!.suppressRateLimitWarning;
});
},
},
{
id: 'mcpNonBlocking',
title: 'Non-blocking MCP startup',
Expand Down