Fix patching errors for CC 2.1.50+ and remove the swarm mode patch#532
Fix patching errors for CC 2.1.50+ and remove the swarm mode patch#532
Conversation
📝 WalkthroughWalkthroughThis PR removes the swarm mode feature entirely (including its implementation file, patch registration, UI controls, and documentation) while making targeted adjustments to various patch detection regexes to accommodate newer Claude Code versions and edge cases. The contextLimit patch is simplified through a globalReplace approach. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 (3)
src/patches/systemPrompts.ts (1)
203-214: Consider making the suppression list configurable or at least tracking it via a constant.The inline hardcoded exemptions (
'Data:'prefix and'Skill: Build with Claude API') are fine for now but will silently grow as more native-only prompts appear. A named constant or comment-tagged array would make future additions more obvious.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/systemPrompts.ts` around lines 203 - 214, Extract the hardcoded exemptions into a named constant (e.g., NATIVE_ONLY_PROMPT_EXEMPTIONS) and use it in the condition instead of inline checks; specifically, replace the checks that reference prompt.name.startsWith('Data:') and prompt.name !== 'Skill: Build with Claude API' with a lookup against the new constant (supporting prefix matches and exact matches), update the surrounding comment to explain these are native-only prompts, and ensure functions referenced in this block (prompt.name, pattern, stringifyRegex) remain unchanged while you only swap the inline literals for the new constant to make future additions obvious and centralized.src/patches/userMessageDisplay.ts (1)
148-148:\bin the pattern violates the no-\bguideline for patch regexes.The pattern contains
.{0,150}?\band.{0,30}\b. Since these are in minified JS, the word boundary can be replaced with specific literal delimiters (e.g.,),",,) that always appear in those positions, which is both guideline-compliant and avoids the V8\bperformance concern.The
(?:,thinkingMetadata:[$\w]+)?change itself is correct and the existingmatch[6] ?? match[7]extraction handles the optional case cleanly.Based on learnings: "Avoid
\\bin regex patterns due to V8 performance issues; use literal character alternatives."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/userMessageDisplay.ts` at line 148, The regex in userMessageDisplay.ts that starts with /(No content found in user prompt message.{0,150}?\b)([$\w]+(?:\.default)?\.createElement... contains two \b word-boundary anchors (after .{0,150}? and .{0,30}) which violate the no-`\b` guideline; replace those \b anchors with explicit literal delimiters that appear in the minified JS (for example a character class like [\)"',] or a specific literal such as \) or " depending on the surrounding tokens) so the pattern still matches the same boundary positions without using \b, and keep the existing (?:,thinkingMetadata:[$\w]+)? optional group unchanged and the downstream extraction logic (match[6] ?? match[7]) intact.src/patches/contextLimit.ts (1)
8-8:\bin the regex violates the patch guideline — use a literal character boundary instead.
/\b200000\b/is flagged by the repo's guideline against\bin patch patterns. Since this constant appears in minified JS, it is always adjacent to a non-word character (,,;,(,), etc.). A literal alternative avoids the V8 concern:♻️ Proposed fix
- /\b200000\b/, + /(?<![.\d])200000(?!\d)/,Or if you prefer a purely literal approach using common minified-code delimiters:
- /\b200000\b/, + /([:,=(>])200000/,(then adjust the replacement to preserve the captured prefix as
'$1process.env.CLAUDE_CODE_CONTEXT_LIMIT')Based on learnings: "Avoid
\\bin regex patterns due to V8 performance issues; use literal character alternatives."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/contextLimit.ts` at line 8, The regex /\b200000\b/ in src/patches/contextLimit.ts uses \b which violates the patch guideline; replace it with a literal-boundary pattern that matches common minified delimiters (for example match preceding char set like (^|[^\w]) and following char set like ($|[^\w]) or use explicit delimiter set such as /(^|[,\;:\(\)\]\{\}\s])200000([,\;:\(\)\]\{\}\s]|$)/) and update the replacement to preserve the captured prefix so the replacement becomes '$1process.env.CLAUDE_CODE_CONTEXT_LIMIT' (or equivalent using the capture group names) where the capture before the number is kept and the number is replaced by the env var; modify the pattern and replacement in the same patch code that currently references /\b200000\b/ so minified JS delimiters are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Line 10: The changelog entry text "Fix patching errors for CC 2.1.49+ and
remove the swarm mode patch (`#528`) - `@bl-ue`" conflicts with the PR title which
references "CC 2.1.50+"; verify the actual minimum affected CC version from the
PR/commit/more detailed notes and update the CHANGELOG.md entry to use the
correct version (either change "2.1.49+" to "2.1.50+" or vice versa) so the
wording matches the authoritative source.
---
Nitpick comments:
In `@src/patches/contextLimit.ts`:
- Line 8: The regex /\b200000\b/ in src/patches/contextLimit.ts uses \b which
violates the patch guideline; replace it with a literal-boundary pattern that
matches common minified delimiters (for example match preceding char set like
(^|[^\w]) and following char set like ($|[^\w]) or use explicit delimiter set
such as /(^|[,\;:\(\)\]\{\}\s])200000([,\;:\(\)\]\{\}\s]|$)/) and update the
replacement to preserve the captured prefix so the replacement becomes
'$1process.env.CLAUDE_CODE_CONTEXT_LIMIT' (or equivalent using the capture group
names) where the capture before the number is kept and the number is replaced by
the env var; modify the pattern and replacement in the same patch code that
currently references /\b200000\b/ so minified JS delimiters are preserved.
In `@src/patches/systemPrompts.ts`:
- Around line 203-214: Extract the hardcoded exemptions into a named constant
(e.g., NATIVE_ONLY_PROMPT_EXEMPTIONS) and use it in the condition instead of
inline checks; specifically, replace the checks that reference
prompt.name.startsWith('Data:') and prompt.name !== 'Skill: Build with Claude
API' with a lookup against the new constant (supporting prefix matches and exact
matches), update the surrounding comment to explain these are native-only
prompts, and ensure functions referenced in this block (prompt.name, pattern,
stringifyRegex) remain unchanged while you only swap the inline literals for the
new constant to make future additions obvious and centralized.
In `@src/patches/userMessageDisplay.ts`:
- Line 148: The regex in userMessageDisplay.ts that starts with /(No content
found in user prompt message.{0,150}?\b)([$\w]+(?:\.default)?\.createElement...
contains two \b word-boundary anchors (after .{0,150}? and .{0,30}) which
violate the no-`\b` guideline; replace those \b anchors with explicit literal
delimiters that appear in the minified JS (for example a character class like
[\)"',] or a specific literal such as \) or " depending on the surrounding
tokens) so the pattern still matches the same boundary positions without using
\b, and keep the existing (?:,thinkingMetadata:[$\w]+)? optional group unchanged
and the downstream extraction logic (match[6] ?? match[7]) intact.
fb0fb5c to
4967a07
Compare
Summary by CodeRabbit
Bug Fixes
Removed Features