-
Notifications
You must be signed in to change notification settings - Fork 125
Add input chevron color patch #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VitalyOstanin
wants to merge
3
commits into
Piebald-AI:main
Choose a base branch
from
VitalyOstanin:feature/input-chevron-color
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { debug } from '../utils'; | ||
| import { showDiff } from './index'; | ||
|
|
||
| export const writeInputChevronColor = ( | ||
| file: string, | ||
| resolvedColor: string | ||
| ): string | null => { | ||
| const pattern = | ||
| /,\{isLoading:([$\w]+),themeColor:([$\w]+)\}=[$\w]+,([$\w]+)=\2\?\?void 0,[$\w]+;if\([$\w]+\[0\]!==\3\|\|[$\w]+\[1\]!==\1\)[$\w]+=[$\w]+\.createElement\([$\w]+,\{color:\3,dimColor:\1\}/; | ||
|
|
||
| const match = file.match(pattern); | ||
|
|
||
| if (!match || match.index === undefined) { | ||
| debug('patch: inputChevronColor: failed to find chevron component pattern'); | ||
| return null; | ||
| } | ||
|
|
||
| const isLoadingVar = match[1]; | ||
| const resolvedColorVar = match[3]; | ||
|
|
||
| const oldColorPart = `color:${resolvedColorVar},dimColor:${isLoadingVar}`; | ||
| const newColorPart = `color:${isLoadingVar}?${resolvedColorVar}:${JSON.stringify(resolvedColor)},dimColor:!1`; | ||
|
|
||
| const colorPartIndex = match[0].indexOf(oldColorPart); | ||
| const startIndex = match.index + colorPartIndex; | ||
| const endIndex = startIndex + oldColorPart.length; | ||
|
|
||
| const newFile = | ||
| file.slice(0, startIndex) + newColorPart + file.slice(endIndex); | ||
|
|
||
| showDiff(file, newFile, newColorPart, startIndex, endIndex); | ||
|
|
||
| return newFile; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Tighten the regex to include the chevron child.
This match currently stops at
{color:...,dimColor:...}, so the first memoized element with the sameisLoading/themeColorshape could be rewritten instead of the chevron. In these minified Claude Code patches, the pattern should include one more unique anchor such as the...pointer," "tail.Suggested tightening
Based on learnings, patch regexes under
src/patches/must be strict and match the minified format exactly.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai Investigated this in detail. The actual Claude Code binary uses
\xA0(non-breaking space U+00A0), not a regular space" ", in the chevron child tail. The suggested anchorpointer," "would never match the minified output.This is documented in commit 44996da: "Skip regex tightening with pointer tail: binary uses "\xA0" (non-breaking space), not " ", so the suggested anchor would not match."
The current pattern is already unique enough — it matches the specific memoized element with
{isLoading, themeColor}destructuring followed by thecreateElement({color, dimColor})call, which only appears once in the chevron component.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VitalyOstanin, thank you for the thorough investigation and the commit documenting the finding. You're correct — my suggestion was invalid. Since the minified Claude Code binary uses\xA0(U+00A0 non-breaking space) rather than a regular space in the chevron child tail, thepointer," "anchor would never match, making the suggested tightening worse than doing nothing. The current pattern's uniqueness via the{isLoading, themeColor}destructuring +createElement({color, dimColor})combination is a sound justification for leaving it as-is.I'll record this for future reviews.
✏️ Learnings added
🧠 Learnings used