Skip to content

Fix patching errors for CC 2.1.50+ and remove the swarm mode patch#532

Merged
bl-ue merged 2 commits intomainfrom
fix-cc-2.1.50-patching-errors
Feb 21, 2026
Merged

Fix patching errors for CC 2.1.50+ and remove the swarm mode patch#532
bl-ue merged 2 commits intomainfrom
fix-cc-2.1.50-patching-errors

Conversation

@bl-ue
Copy link
Copy Markdown
Member

@bl-ue bl-ue commented Feb 21, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed patching errors on Claude Code 2.1.49+
    • Improved context limit patching reliability
    • Enhanced pattern matching accuracy for various features
    • Refined system prompt warning handling
  • Removed Features

    • Removed swarm mode functionality from the application and UI

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Swarm Mode Removal
src/patches/index.ts, src/patches/swarmMode.ts, src/ui/components/MiscView.tsx, README.md, CHANGELOG.md
Removes all swarm mode functionality: deletes the writeSwarmMode implementation, unregisters the patch definition, removes UI toggle in MiscView, deletes feature documentation, and documents removal in changelog.
Patch Pattern Adjustments
src/patches/agentsMd.ts, src/patches/opusplan1m.ts, src/patches/userMessageDisplay.ts, src/patches/toolsets.ts
Broadens regex patterns to handle edge cases and variable version strings: agentsMd includes "Skipping non-text file" text, opusplan1m matches flexible Opus/Sonnet versions, userMessageDisplay makes thinkingMetadata optional, and toolsets simplifies function-signature and mode-detection patterns.
Patch Logic Refactoring
src/patches/contextLimit.ts, src/patches/systemPrompts.ts
Replaces complex regex-based location logic with direct globalReplace in contextLimit; adds conditional warning suppression in systemPrompts for Data: and Skill: Build with Claude API prompts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 The swarm flies home, its nest now bare,
While patterns bend to match with care,
From regex webs to simpler ways,
The patcher hops through cleaner days! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes in the PR: fixing patching errors for CC 2.1.50+ and removing the swarm mode feature, which are reflected across multiple files (contextLimit.ts, agentsMd.ts, opusplan1m.ts, userMessageDisplay.ts, index.ts, swarmMode.ts, MiscView.tsx, systemPrompts.ts, and CHANGELOG.md).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-cc-2.1.50-patching-errors

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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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: \b in the pattern violates the no-\b guideline for patch regexes.

The pattern contains .{0,150}?\b and .{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 \b performance concern.

The (?:,thinkingMetadata:[$\w]+)? change itself is correct and the existing match[6] ?? match[7] extraction handles the optional case cleanly.

Based on learnings: "Avoid \\b in 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: \b in the regex violates the patch guideline — use a literal character boundary instead.

/\b200000\b/ is flagged by the repo's guideline against \b in 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 \\b in 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.

@bl-ue bl-ue force-pushed the fix-cc-2.1.50-patching-errors branch from fb0fb5c to 4967a07 Compare February 21, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant