[No QA] New AI PR reviewer prompt#71655
Conversation
|
|
||
| **Conditions**: Flag ONLY when ALL of these are true: | ||
|
|
||
| - Using .every(), .some(), .find(), .filter() or similar function |
There was a problem hiding this comment.
Updated PERF-1 & PERF-2 as I was getting inconsistent results. Checking if making rule more specific can help.
There was a problem hiding this comment.
same here, let's not break the structure that is very strict and allows an llm to navigate more easily
|
Claude still adds a short summary sometimes :( But it's non invasive so IMO should be fine to test with this version |
.claude/utils/test-review-prompt.sh
Outdated
| REVIEW_REQUEST="$REVIEW_OUTPUT_DIR/review-request-${TIMESTAMP}.txt" | ||
|
|
||
| { | ||
| echo "Below you will see output for automated code review. For the purpose of this prompt: Instead of calling github actions output all comments to the console here, in the same format as if they were comments in GH. Follow the same rules as mentioned below, no unwanted output, only rules comments." |
There was a problem hiding this comment.
I'm not sure this helps us 'rate' the prompt in any way given how it can change the output:
Follow the same rules as mentioned below, no unwanted output, only rules comments.
There was a problem hiding this comment.
I'd leave it to internal engineers if this is helpful as EApp's source code
There was a problem hiding this comment.
ok, changed this a bit, removed parts with instruction from to not mention anything apart from "Run it locally" context + updated the actual prompt to be more liberal.
.claude/utils/test-review-prompt.sh
Outdated
| echo "- Analyze the provided diff and file contents directly" | ||
| echo "- The files are ready for your review - proceed with the analysis" | ||
| echo "" | ||
| sed 's/Read each changed file carefully using the Read tool/Carefully analyze each changed file from the complete content provided below/g; s/using the available GitHub inline comment tool/as console output in GitHub comment format/g' "$PROMPT_FILE" |
There was a problem hiding this comment.
same as above, changes the overall prompt
| - `path`: Full file path (e.g., "src/components/ReportActionsList.tsx") | ||
| - `line`: Line number where the issue occurs | ||
| - `body`: Concise and actionable description of the violation and fix, following the below Comment Format | ||
| 4. **Each comment must reference exactly one Rule ID.** |
encourage Claude to leave comments if uncertain
| - **Condition**: When passing data to components in renderItem functions, avoid using spread operators to extend objects. Instead, pass the base object and additional properties as separate props to prevent unnecessary object creation on each render. | ||
| - **Reasoning**: `renderItem` functions execute for every visible list item on each render. Creating new objects with spread operators forces React to treat each item as changed, preventing reconciliation optimizations and causing unnecessary re-renders of child components. | ||
|
|
||
| **Conditions**: Flag ONLY when ALL of these are true: |
There was a problem hiding this comment.
I'm afraid this addition breaks formatting of Conditions + Reasoning that is defined at the top. Do you see how we can break it down so both these are under this 'conditions' block?
There was a problem hiding this comment.
| **Conditions**: Flag ONLY when ALL of these are true: | |
| **Conditions**: | |
| Flag ONLY when ALL of these are true: | |
| - a | |
| - b | |
| DO NOT flag if: | |
| - c | |
| - d | |
| **Reasoning**: ... | |
| If you found even ONE violation or have ANY uncertainty do NOT output LGTM - create inline comments instead. | ||
| 8. **DO NOT invent new rules, stylistic preferences, or commentary outside the listed rules.** | ||
| 9. **DO NOT describe what you are doing, output any summaries, explanations, extra content, comments on rules that are NOT violated or ANYTHING ELSE except from rules violations or LGTM message.** | ||
| EXCEPTION: If you believe something MIGHT be a Rule violation but are uncertain, err on the side of creating an inline comment with your concern rather than skipping it. |
There was a problem hiding this comment.
Can you give an example for that?
err on the side of creating an inline comment with your concern rather than skipping it.
There was a problem hiding this comment.
The issue was that sometimes the prompt was not giving comments when there were clear violations. Sometimes is a keyword here as I was getting correct comments on one execution and then only some on another teminal for the same branch. adding EXCEPTION stabilized that
Mostly tested on PR: Expensify card page uses navigation for magic code.
.claude/utils/test-review-prompt.sh
Outdated
There was a problem hiding this comment.
my only concern is if this belong to the source code
There was a problem hiding this comment.
The idea behind adding it to provide consistent way to test prompts in the future. Can delete it though
There was a problem hiding this comment.
I think we can propose some utils separately, with docs and more structure on the directory 👍🏼
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
mountiny
left a comment
There was a problem hiding this comment.
All the changes look good to me, I think we do not have to wait much for other reviewers here as its iterative approach so lets test this and improve on it
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.2.24-0 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.2.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.2.26-7 🚀
|
Explanation of Change
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/521398
PROPOSAL:
Tests
Pre requisite:
must have
claude CLIwith at least pro plan. If you do not you can use--manualon the testing script and copy result to web claude.chmod +xfor.claude/utils/test-review-prompt.shCheckout the branch you want to test locally
Run
./test-review-prompt.sh mainSee the output in the console
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Run against following branches with results:
Prompt testing
PR: Expensify card page uses navigation for magic code ✅
❌ [PERF-6]
Passing entire objects as dependencies causes hooks to re-execute whenever any property changes, even unrelated ones. Specifying individual properties creates more granular dependency tracking, reducing unnecessary hook executions.
In
src/pages/settings/Wallet/ExpensifyCardPage/ExpensifyCardContextProvider.tsxline 40, theuseMemodepends on the entire setter functions instead of just the state values. The memoization dependencies should only includecardsDetails,isCardDetailsLoading, andcardsDetailsErrors:PR: Delay emoji modal opening when keyboard is closing ✅
LGTM
. Thank you for your hard work!
PR: Navigation initialization console errors fix ✅
LGTM
. Thank you for your hard work!
PR Feat/update ai review prompt - test branch with violations ✅
❌ [PERF-4] Memoize objects and functions passed as props
Line: 40-49 in src/components/SubStepForms/YesNoStep.tsx
Objects passed as props should be properly memoized to prevent unnecessary re-renders. The
optionsarray was previously memoized withuseMemobut has been changed to a regular array that gets recreated on every render.Reasoning: React uses referential equality to determine if props changed. Creating a new array instance on every render triggers unnecessary re-renders of child components, even when the actual data hasn't changed. The previous memoization preserved referential stability.
Fix: Restore the
useMemowrapper:❌ [PERF-2] Use early returns in array iteration methods
Line: 71-98 in src/libs/PaginationUtils.ts
The code performs expensive operations (function calls like
findFirstItem,findLastItem, array slicing, and mapping) before checking simple null conditions.Reasoning: The null checks for
firstItemandlastItemare simple property checks that can eliminate items early, but they're being performed after expensive operations have already executed. This wastes computation when items are null.Fix: Perform null checks immediately after getting the items:
❌ [PERF-5] Use shallow comparisons instead of deep comparisons
Line: 324 in src/pages/iou/request/MoneyRequestAttendeeSelector.tsx
The memo comparison is using
deepEqual(prevProps, nextProps)which performs a deep equality check on all props instead of comparing only specific relevant properties.Reasoning: Deep equality checks recursively compare all nested properties, creating performance overhead that often exceeds the re-render cost they aim to prevent. Shallow comparisons of specific relevant properties provide the same optimization benefits with minimal computational cost.
Fix: Compare only specific relevant properties:
❌ [PERF-6] Use specific properties as hook dependencies
Line: 70 in src/pages/settings/Wallet/ReportVirtualCardFraudPage.tsx
The
useEffectdependency array includes entire objects (formData,virtualCard,validateCodeAction) instead of specifying individual properties.Reasoning: Passing entire objects as dependencies causes hooks to re-execute whenever any property changes, even unrelated ones. Specifying individual properties creates more granular dependency tracking, reducing unnecessary hook executions and improving performance predictability.
Fix: Specify individual object properties as dependencies:
❌ [PERF-1] No spread in list item's renderItem
Line: 57-60 in tests/ui/ReportActionAvatarsTest.tsx
A spread operator is being used on an object (
...rest) that is being passed as props within what appears to be a mock component's render function.Reasoning: Creating new objects with spread operators in render contexts forces React to treat each render as changed, preventing reconciliation optimizations and causing unnecessary re-renders.
Fix: Pass individual properties explicitly:
PR: Add F1 Custom Avatars SVGs ✅
LGTM
. Thank you for your hard work!
PR: WIP - Add card fraud alert ✅
LGTM
. Thank you for your hard work!