Skip to content

Commit 24fde4b

Browse files
committed
Merge branch 'main' into kureev/new-editing-model
2 parents 69abc8d + 58c1899 commit 24fde4b

2,720 files changed

Lines changed: 88360 additions & 57585 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/agents/code-inline-reviewer.md

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name: code-inline-reviewer
44
description: Reviews code and creates inline comments for specific rule violations.
5-
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash, mcp__github_inline_comment__create_inline_comment
5+
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash
66
model: inherit
77
---
88

@@ -143,31 +143,79 @@ const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
143143

144144
---
145145

146-
### [PERF-4] Memoize objects and functions passed as props
146+
### [PERF-4] Memoize objects (including arrays) and functions passed as props
147147

148-
- **Search patterns**: `useMemo`, `useCallback`, and prop passing patterns
148+
- **Search patterns**: `prop={{`, `prop={[`, `={() =>`, `prop={variable}` (where variable is non-memoized object/function)
149149

150-
- **Condition**: Objects and functions passed as props should be properly memoized or simplified to primitive values to prevent unnecessary re-renders.
151-
- **Reasoning**: React uses referential equality to determine if props changed. New object/function instances on every render trigger unnecessary re-renders of child components, even when the actual data hasn't changed. Memoization preserves referential stability.
150+
- **Applies ONLY to**: Objects (including arrays)/functions passed directly as JSX props. Does NOT apply to:
151+
- Code inside callbacks (`.then()`, event handlers)
152+
- Code inside `useEffect`/`useMemo`/`useCallback` bodies
153+
- Primitives (strings, numbers, booleans)
154+
- Already memoized values (`useMemo`/`useCallback`)
152155

153-
Good:
156+
- **Reasoning**: New object/function references break memoization of child components. Only matters when child IS memoized AND parent is NOT optimized by React Compiler.
154157

155-
```tsx
156-
const reportData = useMemo(() => ({
157-
reportID: report.reportID,
158-
type: report.type,
159-
isPinned: report.isPinned,
160-
}), [report.reportID, report.type, report.isPinned]);
158+
#### Before flagging: Run optimization check
159+
160+
**YOU MUST call `checkReactCompilerOptimization.ts` (available in PATH from `.claude/scripts/`) on EVERY .tsx file from the diff.**
161161

162-
return <ReportActionItem report={reportData} />
162+
**Call the script ONCE per file, separately. DO NOT use loops or batch processing.**
163+
164+
Example usage:
165+
```bash
166+
checkReactCompilerOptimization.ts src/components/File1.tsx
167+
checkReactCompilerOptimization.ts src/components/File2.tsx
163168
```
164169

165-
Bad:
170+
**NEVER use absolute or relative paths for this script. Call it by name only:**
171+
-`checkReactCompilerOptimization.ts src/components/Example.tsx`
172+
-`/home/runner/work/App/App/.claude/scripts/checkReactCompilerOptimization.ts ...`
173+
-`./.claude/scripts/checkReactCompilerOptimization.ts ...`
174+
175+
**"File not found"** → Assume parent is optimized and skip PERF-4.
176+
177+
#### Decision flow
178+
179+
1. **Parent in `parentOptimized`?** → YES = **Skip** (compiler auto-memoizes)
180+
181+
2. **Child has custom memo comparator that PREVENTS re-render for this prop?**
182+
→ Use `sourcePath` from script output to read child's source file
183+
→ Grep for `React.memo` or `memo(`
184+
→ If custom comparator prevents re-render despite new reference for this prop → **Skip**
185+
186+
3. **Child is memoized?** (`optimized: true` OR `React.memo`)
187+
- NO → **Skip** (child re-renders anyway)
188+
- YES → **Flag PERF-4**
189+
190+
#### Examples
166191

192+
**Flag** (parent NOT optimized, child IS memoized, no custom comparator):
167193
```tsx
168-
const [report] = useOnyx(`ONYXKEYS.COLLECTION.REPORT${iouReport.id}`);
194+
// Script output: parentOptimized: [], child MemoizedList optimized: true
195+
// No custom comparator found
196+
return <MemoizedList options={{ showHeader: true }} />;
197+
```
198+
199+
**Skip - custom comparator** (comparator prevents re-render for this prop):
200+
```tsx
201+
// Script output: sourcePath: "src/components/PopoverMenu.tsx"
202+
// PopoverMenu.tsx has custom memo comparator that handles anchorPosition
203+
return <PopoverMenu anchorPosition={{x: 0, y: 0}} />;
204+
```
169205

170-
return <ReportActionItem report={report} />
206+
**Skip - parent optimized**:
207+
```tsx
208+
// Script output: parentOptimized: ["MyComponent"]
209+
// React Compiler auto-memoizes - no manual memoization needed
210+
return <MemoizedList options={{ showHeader: true }} />;
211+
```
212+
213+
**Skip - spread props with stable inner values**:
214+
```tsx
215+
// Spread is OK when inner values come from memoized sources
216+
// illustration from useMemoizedLazyIllustrations, illustrationStyle from useThemeStyles
217+
const illustration = useAboutSectionIllustration();
218+
return <Section {...illustration} />;
171219
```
172220

173221
---
@@ -203,6 +251,7 @@ memo(ReportActionItem, (prevProps, nextProps) =>
203251
1. **First, get the list of changed files and their diffs:**
204252
- Use `gh pr diff` to see what actually changed in the PR
205253
- Focus ONLY on the changed lines, not the entire file
254+
- **CRITICAL**: Only create inline comments on lines that are part of the diff. Do NOT add comments to lines outside the diff, even if they contain violations. Comments on unchanged lines will fail to be created.
206255
2. **For analyzing changed files:**
207256
- **For large files (>5000 lines):** Use the Grep tool to search for specific violation patterns instead of reading the entire file. Focus grep searches on the changed portions shown in the diff.
208257
- **For smaller files:** You may read the full file using the Read tool
@@ -214,7 +263,7 @@ memo(ReportActionItem, (prevProps, nextProps) =>
214263
- `line`: Line number where the issue occurs
215264
- `body`: Concise and actionable description of the violation and fix, following the below Comment Format
216265
6. **Each comment must reference exactly one Rule ID.**
217-
7. **Output must consist exclusively of calls to mcp__github_inline_comment__create_inline_comment in the required format.** No other text, Markdown, or prose is allowed.
266+
7. **Output must consist exclusively of calls to createInlineComment.sh in the required format.** No other text, Markdown, or prose is allowed.
218267
8. **If no violations are found, add a reaction to the PR**:
219268
Add a 👍 (+1) reaction to the PR using the `addPrReaction` script (available in PATH from `.claude/scripts/`). The script takes ONLY the PR number as argument - it always adds a "+1" reaction, so do NOT pass any reaction type or emoji.
220269
9. **Add reaction if and only if**:
@@ -230,15 +279,13 @@ memo(ReportActionItem, (prevProps, nextProps) =>
230279

231280
## Tool Usage Example
232281

233-
For each violation, call the mcp__github_inline_comment__create_inline_comment tool like this.
234-
CRITICAL: **DO NOT** use the Bash tool for inline comments:
282+
For each violation, call the createInlineComment.sh script like this:
235283

284+
```bash
285+
createInlineComment.sh 'src/components/ReportActionsList.tsx' '<Body of the comment according to the Comment Format>' 128
236286
```
237-
mcp__github_inline_comment__create_inline_comment:
238-
path: 'src/components/ReportActionsList.tsx'
239-
line: 128
240-
body: '<Body of the comment according to the Comment Format>'
241-
```
287+
288+
**IMPORTANT**: Always use single quotes around the body argument to properly handle special characters and quotes.
242289

243290
If ZERO violations are found, use the Bash tool to add a reaction to the PR body:
244291

@@ -258,4 +305,4 @@ addPrReaction.sh <PR_NUMBER>
258305
<Suggested, specific fix preferably with a code snippet>
259306
```
260307

261-
**CRITICAL**: You must actually call the mcp__github_inline_comment__create_inline_comment tool for each violation. Don't just describe what you found - create the actual inline comments!
308+
**CRITICAL**: You must actually call the createInlineComment.sh script for each violation. Don't just describe what you found - create the actual inline comments!

.claude/commands/review-code-pr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(addPrReaction.sh:*),mcp__github_inline_comment__create_inline_comment
2+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(addPrReaction.sh:*),Bash(createInlineComment.sh:*),Bash(checkReactCompilerOptimization.ts:*)
33
description: Review a code contribution pull request
44
---
55

.claude/scripts/addPrReaction.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ if [[ $# -lt 1 ]] || ! [[ "$1" =~ ^[0-9]+$ ]]; then
88
exit 1
99
fi
1010

11-
PR_NUMBER="$1"
12-
REPO="${GITHUB_REPOSITORY}"
11+
readonly PR_NUMBER="$1"
12+
readonly REPO="${GITHUB_REPOSITORY}"
1313

1414
gh api -X POST "/repos/$REPO/issues/$PR_NUMBER/reactions" -f content="+1"
1515

0 commit comments

Comments
 (0)