Skip to content

(sync hot fix) : remove devconnect badge from ui#1417

Closed
kushagrasarathe wants to merge 1 commit intopeanut-wallet-devfrom
hot-fix/remove-devconnect-badge
Closed

(sync hot fix) : remove devconnect badge from ui#1417
kushagrasarathe wants to merge 1 commit intopeanut-wallet-devfrom
hot-fix/remove-devconnect-badge

Conversation

@kushagrasarathe
Copy link
Contributor

  • fixes TASK-16645

@vercel
Copy link

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Ready Ready Preview Comment Nov 7, 2025 1:18am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Walkthrough

The PR adds filtering logic to hide the 'devconnect_ba_2025' badge across multiple UI surfaces (history page, badge components, and home history) and implements URL-driven state management for the swap-currency parameter in token amount inputs and the withdraw manteca page.

Changes

Cohort / File(s) Summary
Badge Filtering
src/app/(mobile-ui)/history/page.tsx, src/components/Badges/BadgesRow.tsx, src/components/Badges/index.tsx, src/components/Home/HomeHistory.tsx
Adds filters (case-insensitive) to exclude badge with code 'devconnect_ba_2025' from being displayed in history lists and badge rendering components
Swap Currency URL State Management
src/app/(mobile-ui)/withdraw/manteca/page.tsx, src/components/Global/TokenAmountInput/index.tsx
Introduces swap-currency URL parameter reading and writing; manteca page reads the param to set initial TokenAmountInput state, while TokenAmountInput uses router hooks to persist UI state changes to URL on currency swap

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • TokenAmountInput router integration with effect logic and conditional formatting requires careful verification
  • Consistency of badge filtering pattern across four files should be validated
  • URL state management flow between withdraw/manteca page and TokenAmountInput component needs to be traced for correctness

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Zishan-7
  • jjramirezn

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description references a task (TASK-16645), indicating the work is tracked and justified, though minimal details are provided about the implementation.
Title check ✅ Passed The title clearly and specifically describes the main change: removing a devconnect badge from the UI, which is reflected across multiple files in the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hot-fix/remove-devconnect-badge

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

@notion-workspace
Copy link

@coderabbitai coderabbitai bot added the enhancement New feature or request label Nov 7, 2025
Copy link
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

♻️ Duplicate comments (3)
src/components/Home/HomeHistory.tsx (1)

103-104: LGTM - Consistent badge filtering.

The early return correctly prevents the 'devconnect_ba_2025' badge from appearing in history entries. This aligns with the filtering applied in other UI components.

Note: Same code duplication concern mentioned in src/components/Badges/index.tsx applies here.

src/app/(mobile-ui)/history/page.tsx (1)

165-166: LGTM - Consistent badge filtering in history page.

Correctly filters out the 'devconnect_ba_2025' badge from the history list, maintaining consistency with other components.

src/components/Badges/BadgesRow.tsx (1)

100-129: LGTM - Badge filtering applied before rendering.

The filter correctly excludes the 'devconnect_ba_2025' badge from the visible badges list, consistent with filtering in other components.

🧹 Nitpick comments (1)
src/components/Badges/index.tsx (1)

28-34: Consider extracting badge filtering logic to a shared utility.

The badge filtering logic b.code.toLowerCase() !== 'devconnect_ba_2025' is duplicated across 5 files (BadgesRow.tsx, HomeHistory.tsx, history/page.tsx, and two instances here). While acceptable for a hotfix, this creates maintenance overhead if the filtering criteria changes.

Consider creating a shared utility function:

// In badge.utils.ts
export function shouldDisplayBadge(badgeCode: string): boolean {
    return badgeCode.toLowerCase() !== 'devconnect_ba_2025'
}

Then use it consistently:

-        return raw
-            .filter((b) => b.code.toLowerCase() !== 'devconnect_ba_2025')
-            .map((b) => ({
+        return raw
+            .filter((b) => shouldDisplayBadge(b.code))
+            .map((b) => ({
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a097ed2 and c10b643.

📒 Files selected for processing (6)
  • src/app/(mobile-ui)/history/page.tsx (1 hunks)
  • src/app/(mobile-ui)/withdraw/manteca/page.tsx (2 hunks)
  • src/components/Badges/BadgesRow.tsx (1 hunks)
  • src/components/Badges/index.tsx (1 hunks)
  • src/components/Global/TokenAmountInput/index.tsx (4 hunks)
  • src/components/Home/HomeHistory.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (29)
📓 Common learnings
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1094
File: src/components/AddWithdraw/DynamicBankAccountForm.tsx:279-279
Timestamp: 2025-08-14T08:02:26.705Z
Learning: For hotfixes in the peanut-ui codebase, prefer generic error messages over specific validation error details until the copy can be reviewed with the team, even when the validation functions return detailed error messages.
📚 Learning: 2025-05-15T14:47:26.891Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 857
File: src/hooks/useWebSocket.ts:77-82
Timestamp: 2025-05-15T14:47:26.891Z
Learning: The useWebSocket hook in src/hooks/useWebSocket.ts is designed to provide raw history entries, while the components using it (such as HomeHistory.tsx) are responsible for implementing deduplication logic based on UUID to prevent duplicate entries when combining WebSocket data with other data sources.

Applied to files:

  • src/components/Home/HomeHistory.tsx
📚 Learning: 2025-04-11T11:33:53.245Z
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 798
File: src/components/Home/HomeHistory.tsx:138-192
Timestamp: 2025-04-11T11:33:53.245Z
Learning: In the HomeHistory component, infinite scrolling is intentionally not implemented despite the presence of useInfiniteQuery and IntersectionObserver code. The component is designed to only display the first 5 entries with a "View all transactions" link for viewing the complete history.

Applied to files:

  • src/components/Home/HomeHistory.tsx
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1230
File: src/app/(mobile-ui)/withdraw/page.tsx:92-97
Timestamp: 2025-09-18T09:30:42.901Z
Learning: In src/app/(mobile-ui)/withdraw/page.tsx, the useEffect that calls setShowAllWithdrawMethods(true) when amountFromContext exists is intentionally designed to run only on component mount (empty dependency array), not when amountFromContext changes. This is the correct behavior for the withdraw flow where showing all methods should only happen on initial load when an amount is already present.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/app/(mobile-ui)/history/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2025-05-22T15:38:48.586Z
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 869
File: src/app/(mobile-ui)/withdraw/page.tsx:82-88
Timestamp: 2025-05-22T15:38:48.586Z
Learning: The country-specific withdrawal route exists at src/app/(mobile-ui)/withdraw/[...country]/page.tsx and renders the AddWithdrawCountriesList component with flow="withdraw".

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2025-10-02T15:23:01.513Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1266
File: src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx:46-57
Timestamp: 2025-10-02T15:23:01.513Z
Learning: In the withdraw flow at src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx, the points calculation query intentionally uses crypto.randomUUID() in the queryKey dependency array to bypass React Query caching, ensuring fresh points estimates on every render. This is the intended behavior.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2025-10-29T11:27:59.248Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1368
File: src/components/Common/ActionList.tsx:109-111
Timestamp: 2025-10-29T11:27:59.248Z
Learning: In `src/components/Common/ActionList.tsx`, the `balance` from `useWallet()` hook is always in USDC (as a formatted string), making it directly comparable to USD amounts without conversion. The comparison `Number(balance) >= amountInUsd` is intentional and correct.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-07T15:25:45.170Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Views/Initial.view.tsx:76-78
Timestamp: 2024-10-07T15:25:45.170Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, both `txFee` and `utils.formatTokenAmount(...)` return strings, ensuring that `calculatedFee` consistently returns a string without the need for additional type conversion.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-07T15:28:25.280Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Views/Initial.view.tsx:76-78
Timestamp: 2024-10-07T15:28:25.280Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, both `txFee` and `utils.formatTokenAmount(estimatedGasCost, 3)` return strings, ensuring consistent return types for `calculatedFee`.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2025-10-24T13:44:39.473Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1332
File: src/components/Global/TokenAmountInput/index.tsx:141-150
Timestamp: 2025-10-24T13:44:39.473Z
Learning: In the `TokenAmountInput` component (`src/components/Global/TokenAmountInput/index.tsx`), the slider feature (controlled by `showSlider` prop) is only shown for USD input mode. When the slider is used with `maxAmount`, the `selectedAmount` is computed in USD and `isInputUsd` is always `true`, so the conversion in `onChange` handles it correctly.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-29T12:19:41.968Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 495
File: src/components/Global/TokenAmountInput/index.tsx:23-30
Timestamp: 2024-10-29T12:19:41.968Z
Learning: In the `TokenAmountInput` component (`src/components/Global/TokenAmountInput/index.tsx`), when the 'Max' button is clicked, we intentionally set the input denomination to 'TOKEN' because we are setting the value as token.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-22T18:10:56.955Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 469
File: src/app/request/pay/page.tsx:25-25
Timestamp: 2024-10-22T18:10:56.955Z
Learning: In the `src/app/request/pay/page.tsx` file, the `PreviewType` enum values are strings, so when adding `previewType` to `URLSearchParams`, there's no need to convert them to strings.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2024-10-22T18:11:36.864Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 469
File: src/app/request/pay/page.tsx:32-49
Timestamp: 2024-10-22T18:11:36.864Z
Learning: In `src/app/request/pay/page.tsx`, the `id` parameter is accessed via `searchParams.id` in the `generateMetadata` function.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2025-09-08T03:13:09.111Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:156-176
Timestamp: 2025-09-08T03:13:09.111Z
Learning: In the peanut-ui mobile app, the `/qr-pay` route is only accessed through the DirectSendQR component which always includes the qrCode parameter in the URL when redirecting users to the QR pay page after scanning MERCADO_PAGO or PIX QR codes.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2024-10-29T12:20:47.207Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 495
File: src/components/Create/Link/Input.view.tsx:244-248
Timestamp: 2024-10-29T12:20:47.207Z
Learning: In the `TokenAmountInput` component within `src/components/Global/TokenAmountInput/index.tsx`, when `balance` is undefined, the `maxValue` prop should be set to an empty string `''`.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-12-02T17:19:18.532Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 551
File: src/components/Request/Create/Views/Initial.view.tsx:151-156
Timestamp: 2024-12-02T17:19:18.532Z
Learning: In the `InitialView` component at `src/components/Request/Create/Views/Initial.view.tsx`, when setting the default chain and token in the `useEffect` triggered by `isPeanutWallet`, it's acceptable to omit the setters from the dependency array and not include additional error handling for invalid defaults.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2025-06-18T19:56:55.443Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 919
File: src/components/Withdraw/views/Initial.withdraw.view.tsx:87-87
Timestamp: 2025-06-18T19:56:55.443Z
Learning: In withdraw flows for Peanut Wallet, the PeanutActionDetailsCard should always display "USDC" as the token symbol because it shows the amount being withdrawn from the Peanut Wallet (which holds USDC), regardless of the destination token/chain selected by the user. The TokenSelector is used for choosing the withdrawal destination, not the source display.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2025-08-22T07:25:59.304Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1104
File: src/components/Payment/PaymentForm/index.tsx:596-600
Timestamp: 2025-08-22T07:25:59.304Z
Learning: The `TokenAmountInput` component in `src/components/Global/TokenAmountInput/` always returns decimal strings (e.g., "1,234.56"), not base units. When passing these values to external APIs like Daimo's `toUnits` prop, simply stripping commas with `.replace(/,/g, '')` is sufficient.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-07T13:42:00.443Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.tsx:103-111
Timestamp: 2024-10-07T13:42:00.443Z
Learning: When the token price cannot be fetched in `src/components/Request/Pay/Pay.tsx` within the `PayRequestLink` component, set `tokenPriceData.price` to 0 to ensure the UI remains functional. Since Squid uses their own price engine for x-chain fulfillment transactions, this approach will not affect the transaction computation.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-04T13:10:49.199Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 413
File: src/components/Request/Pay/Views/Initial.view.tsx:71-72
Timestamp: 2024-10-04T13:10:49.199Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, it's acceptable to use the `!` operator in TypeScript to assert that `selectedTokenData` is not `null` or `undefined`, and potential runtime errors from accessing its properties without checks can be disregarded.

Applied to files:

  • src/app/(mobile-ui)/withdraw/manteca/page.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 413
File: src/context/tokenSelector.context.tsx:118-123
Timestamp: 2024-10-08T20:13:42.967Z
Learning: In the `TokenContextProvider` component within `src/context/tokenSelector.context.tsx`, in the TypeScript React application, when data changes and before calling `fetchAndSetTokenPrice`, it is necessary to reset `selectedTokenData`, `selectedTokenPrice`, `selectedTokenDecimals`, and `inputDenomination` to discard stale data.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2025-09-05T07:31:11.396Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1185
File: src/components/Claim/useClaimLink.tsx:14-0
Timestamp: 2025-09-05T07:31:11.396Z
Learning: In the peanut-ui codebase, `window.history.replaceState` is preferred over `router.replace` when immediate/synchronous URL parameter updates are required, as `router.replace` is asynchronous and doesn't guarantee instant URL changes that subsequent code can rely on. This pattern is used consistently across usePaymentInitiator.ts, Confirm.payment.view.tsx, and useClaimLink.tsx.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-11T01:14:15.489Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 424
File: src/components/Global/TokenSelector/TokenSelector.tsx:197-211
Timestamp: 2024-10-11T01:14:15.489Z
Learning: In `src/components/Global/TokenSelector/TokenSelector.tsx`, when the calculation within functions like `byChainAndText` is not computationally expensive, it's acceptable to avoid using `useCallback` for memoization.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2025-01-16T13:14:40.363Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 631
File: src/components/Create/Create.tsx:108-112
Timestamp: 2025-01-16T13:14:40.363Z
Learning: In the Peanut UI codebase, the `resetTokenContextProvider` function from `tokenSelectorContext` is a stable function reference that doesn't change, so it doesn't need to be included in useEffect dependencies.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-03T09:57:43.885Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 404
File: src/context/tokenSelector.context.tsx:121-121
Timestamp: 2024-10-03T09:57:43.885Z
Learning: In `TokenContextProvider` within `tokenSelector.context.tsx`, when token data is loaded from preferences, it's acceptable to set `isTokenPriceFetchingComplete` to `true` because the token data is already available.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-29T16:06:38.812Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 495
File: src/components/Create/useCreateLink.tsx:647-657
Timestamp: 2024-10-29T16:06:38.812Z
Learning: In the React code for `useCreateLink` in `src/components/Create/useCreateLink.tsx`, the `switchNetwork` function used within `useCallback` hooks is stable and does not need to be included in the dependency arrays.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2025-07-05T16:58:25.340Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 0
File: :0-0
Timestamp: 2025-07-05T16:58:25.340Z
Learning: Hugo0 successfully refactored sessionStorage usage to React Context in the onramp flow, demonstrating preference for centralized state management over browser storage for component-shared state in React applications.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2025-05-19T19:40:43.138Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 868
File: src/components/Payment/PaymentForm/index.tsx:284-293
Timestamp: 2025-05-19T19:40:43.138Z
Learning: When converting between USD and token amounts, always check if the token price (divisor) is valid and non-zero before performing the division to prevent Infinity, NaN, or errors. Implementing validation like `if (!tokenPrice || isNaN(tokenPrice) || tokenPrice === 0)` before division operations is crucial for handling cases where price data might be unavailable.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.consts.ts:34-34
Timestamp: 2024-10-08T20:13:42.967Z
Learning: In `src/components/Request/Pay` components, the `tokenPrice` property in the `IPayScreenProps` interface is only relevant to these views. Other components using `IPayScreenProps` do not need to handle `tokenPriceData` when it's updated in these components.

Applied to files:

  • src/components/Global/TokenAmountInput/index.tsx
🧬 Code graph analysis (2)
src/components/Badges/BadgesRow.tsx (2)
src/components/Badges/badge.utils.ts (2)
  • getPublicBadgeDescription (36-39)
  • getBadgeIcon (29-33)
src/components/Tooltip/index.tsx (1)
  • Tooltip (18-106)
src/components/Badges/index.tsx (1)
src/components/Badges/badge.utils.ts (1)
  • getBadgeIcon (29-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (1)
src/app/(mobile-ui)/withdraw/manteca/page.tsx (1)

78-78: No issues found—logic is correct and intentional.

The swap-currency parameter and isInitialInputUsd prop are logically coherent, not inverted:

  • swap-currency=trueisInitialInputUsd=false → initial input in token/currency (not USD)
  • swap-currency=false or missing → isInitialInputUsd=true → initial input in USD

The parameter name accurately reflects its behavior: when true, it swaps away from USD to show the currency mode. No action needed.

Likely an incorrect or invalid review comment.

Comment on lines +198 to +204
if (!isInitialInputUsd) {
const value = tokenValue ? Number(tokenValue) : 0
const formattedValue = (value * (currency?.price ?? 1)).toFixed(2)
onChange(formattedValue, isInputUsd)
} else {
onChange(displayValue, isInputUsd)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify useEffect dependency safety with isInitialInputUsd prop.

This useEffect only depends on selectedTokenData?.price but references several other values including the isInitialInputUsd prop. While the comment "Seriously, this is ok" suggests this is intentional, it creates risk if:

  1. isInitialInputUsd changes value (though as an "initial" prop, it typically shouldn't)
  2. Parent components expect different formatting behavior when other dependencies change

The current implementation appears safe since isInitialInputUsd represents initial state that shouldn't change during the component's lifecycle, but this pattern can be confusing for future maintainers.

Consider verifying that isInitialInputUsd is truly immutable during component lifecycle:


🏁 Script executed:

#!/bin/bash
# Find all usages of isInitialInputUsd prop to verify it's not dynamically changed
rg -n -B3 -A3 'isInitialInputUsd=' --type=tsx --type=ts -g '!node_modules'

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Search for isInitialInputUsd usage - use broader search without tsx type
rg -n -B3 -A3 'isInitialInputUsd' --type ts -g '!node_modules'

Length of output: 3422


🏁 Script executed:

#!/bin/bash
# Also check the component file directly for prop definition and usage
cat src/components/Global/TokenAmountInput/index.tsx | head -100

Length of output: 3648


🏁 Script executed:

#!/bin/bash
# Check if isInputUsd state is used in the useEffect at lines 198-204
# This will clarify if the bug is using isInitialInputUsd instead of isInputUsd
sed -n '195,210p' src/components/Global/TokenAmountInput/index.tsx

Length of output: 653


🏁 Script executed:

#!/bin/bash
# Search for where isInputUsd state is updated to understand the flow
rg -n -B2 -A2 'setIsInputUsd' src/components/Global/TokenAmountInput/index.tsx

Length of output: 648


Fix useEffect to respond to display mode toggles—uses initial prop instead of current state.

The useEffect at line 198 checks if (!isInitialInputUsd) but should check if (!isInputUsd). Currently:

  • User toggles display mode (line 376): setIsInputUsd(!isInputUsd)
  • useEffect doesn't rerun because isInputUsd is not in dependencies
  • Formatting logic remains stuck on the initial prop value, ignoring the user's toggle

Required fix: Change line 198 from if (!isInitialInputUsd) to if (!isInputUsd), or add isInputUsd to the dependency array at line 206 (preferably both for clarity).

    useEffect(() => {
        if (!isInputUsd) {  // Changed from isInitialInputUsd
            const value = tokenValue ? Number(tokenValue) : 0
            const formattedValue = (value * (currency?.price ?? 1)).toFixed(2)
            onChange(formattedValue, isInputUsd)
        } else {
            onChange(displayValue, isInputUsd)
        }
    }, [selectedTokenData?.price, isInputUsd])  // Added isInputUsd dependency
🤖 Prompt for AI Agents
In src/components/Global/TokenAmountInput/index.tsx around lines 198 to 204, the
useEffect is checking the initial prop isInitialInputUsd which prevents it from
responding to user toggles; change the condition to check the current state
isInputUsd (replace isInitialInputUsd with isInputUsd at line 198) and add
isInputUsd to the dependency array at line 206 (so the effect re-runs when the
display mode is toggled); this ensures the formatted value is recalculated and
onChange is called with the current display mode.

@kushagrasarathe kushagrasarathe changed the base branch from peanut-wallet to peanut-wallet-dev November 7, 2025 01:17
@kushagrasarathe kushagrasarathe changed the title fix: remove devconnect badge from ui (sync hot fix) fix: remove devconnect badge from ui Nov 7, 2025
@kushagrasarathe kushagrasarathe changed the title (sync hot fix) fix: remove devconnect badge from ui (sync hot fix) : remove devconnect badge from ui Nov 7, 2025
@notion-workspace
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant