Skip to content

feat: refetching icon#288

Merged
antoncoding merged 3 commits intomasterfrom
chore/refetch
Jan 10, 2026
Merged

feat: refetching icon#288
antoncoding merged 3 commits intomasterfrom
chore/refetch

Conversation

@antoncoding
Copy link
Owner

@antoncoding antoncoding commented Jan 10, 2026

Unify refetching style

Summary by CodeRabbit

  • New Features

    • Unified refresh icon with improved loading animation used across vaults, markets, positions, rewards, history, and modals.
    • New refetching indicators exposed to surface balance and data refetch states so buttons reflect ongoing refreshes.
  • Chores

    • Replaced legacy refresh icons with the new component throughout the app for consistent behavior.
  • Documentation

    • Added developer docs describing the new refetch icon usage and loading behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Jan 10, 2026

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

Project Deployment Review Updated (UTC)
monarch Ready Ready Preview, Comment Jan 10, 2026 6:44am

@antoncoding antoncoding linked an issue Jan 10, 2026 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Jan 10, 2026

📝 Walkthrough

Walkthrough

Adds a new client React component RefetchIcon that encapsulates spin behavior driven by an isLoading prop, replaces many ReloadIcon usages with RefetchIcon, and exposes new isRefetching/isRefetchingBalance flags from several hooks and threads them into UI components.

Changes

Cohort / File(s) Summary
New UI component
src/components/ui/refetch-icon.tsx
New RefetchIcon({ isLoading, className }) component rendering ReloadIcon and managing spin via local state and an animationiteration listener to stop after one rotation.
Feature icon replacements
src/features/autovault/.../vault-settings-modal.tsx, src/features/autovault/vault-view.tsx, src/features/history/components/history-table.tsx, src/features/market-detail/components/position-stats.tsx, src/features/markets/components/table/markets-table-actions.tsx, src/features/rewards/components/reward-table.tsx
Replaced ReloadIcon imports/usages with RefetchIcon; moved from applying animate-spin via classes to passing isLoading prop. Button semantics unchanged.
Positions module updates
src/features/positions/components/rebalance/rebalance-modal.tsx, src/features/positions/components/supplied-morpho-blue-grouped-table.tsx, src/features/positions/components/user-vaults-table.tsx, src/features/positions/positions-view.tsx
Swapped ReloadIcon for RefetchIcon; positions-view.tsx now derives/passes an isRefetching value to UserVaultsTable; minor import/Fragment cleanups.
Modals and supply flow
src/modals/borrow/components/add-collateral-and-borrow.tsx, src/modals/borrow/components/withdraw-collateral-and-repay.tsx, src/modals/supply/supply-modal-content.tsx
Replaced ReloadIcon with RefetchIcon; supply-modal-content.tsx now uses isRefetchingBalance from useSupplyMarket and passes it to RefetchIcon.
Hook additions / API surface
src/hooks/useSupplyMarket.ts, src/hooks/useMorphoMarketV1Adapters.ts, src/hooks/useVaultV2.ts
useSupplyMarket exports isRefetchingBalance; useMorphoMarketV1Adapters and useVaultV2 now expose isRefetching flags in their returned objects.
Misc imports & small cleanups
various files: src/features/history/..., src/features/positions/..., src/features/markets/...
Replaced React.Fragment with Fragment imports, removed some unused locals, adjusted small JSX logic; no behavioral changes beyond icon/refetch-state wiring.
Docs
docs/DEVELOPER_GUIDE.md
Added RefetchIcon usage documentation and examples.

Sequence Diagram(s)

(Skipped — changes are UI-component replacements and small hook flag additions; no new multi-component control flow requiring a sequence diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: refetching icon' directly matches the main change: introducing a new RefetchIcon component used across multiple files to unify refetching state visualization.

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

✨ 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 chore/refetch

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ada3201 and b63fedc.

📒 Files selected for processing (3)
  • docs/DEVELOPER_GUIDE.md
  • src/features/autovault/vault-view.tsx
  • src/features/positions/positions-view.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/features/autovault/vault-view.tsx
  • src/features/positions/positions-view.tsx
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import IconSwitch from `@/components/ui/icon-switch` for switch/toggle components with optional icon

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use Button sizes: `xs`, `sm`, `md`, `lg`, `icon`

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use TooltipContent component from `@/components/shared/tooltip-content` for structured tooltip content with icon, title, detail, and secondary detail

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import TableContainerWithHeader from `@/components/common/table-container-with-header` for tables with titles and optional action buttons

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import TablePagination from `@/components/common/TablePagination` for paginated tables

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/components/layout/**/*.{ts,tsx} : Use TransactionIndicator component in navbar to show background transactions that can be restored to modal view when clicked

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/features/positions/**/*.{ts,tsx} : Import CollateralIconsDisplay from `@/features/positions/components/collateral-icons-display` for displaying collateral icons with configurable maxDisplay and iconSize

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Never use raw HTML `<table>` tags; use Table components from `@/components/ui/table`

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/components/ui/**/*.{ts,tsx} : Place pure UI primitives (Button, Badge, Table) in `src/components/ui/`

Applied to files:

  • docs/DEVELOPER_GUIDE.md
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import Checkbox from `@/components/ui/checkbox` with variants `default` or `highlighted`

Applied to files:

  • docs/DEVELOPER_GUIDE.md
🔇 Additional comments (1)
docs/DEVELOPER_GUIDE.md (1)

325-343: Documentation for RefetchIcon is clear and well-placed.

The new section follows the established pattern, with a clear import path, concise description of the spin-completion behavior, and practical examples showing both button integration and standalone usage.

Optional improvement: The Button section example (line 315) currently shows <RefreshIcon />. Consider updating it to <RefetchIcon isLoading={isRefetching} /> to showcase the new component and its primary use case, though this is a nice-to-have for consistency.


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.

@coderabbitai coderabbitai bot added feature request Specific feature ready to be implemented ui User interface labels Jan 10, 2026
Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hooks/useSupplyMarket.ts (1)

69-94: Add query.enabled guard to useBalance hook.

The useReadContract hook has query: { enabled: !!account } but useBalance is missing it. Without this guard, useBalance will attempt to fetch even when account is undefined, which can cause unnecessary requests or errors.

Diff
   const {
     data: ethBalance,
     refetch: refetchETH,
     isFetching: isRefetchingEth,
   } = useBalance({
     address: account,
     chainId: market.morphoBlue.chain.id,
+    query: {
+      enabled: !!account,
+    },
   });
🤖 Fix all issues with AI agents
In @src/features/positions/positions-view.tsx:
- Around line 38-39: Remove the leftover debug console.log call printing 'User
vaults:' in the positions view component (the console.log referencing
isVaultsLoading and vaults). Delete that statement entirely from the component
(positions-view.tsx) so no debug logging remains before merge.
🧹 Nitpick comments (3)
src/features/market-detail/components/position-stats.tsx (1)

4-5: Looks good: RefetchIcon wiring matches disabled/refresh state.

Optional: pass a className size explicitly here too (some call sites use h-4 w-4) so the icon size doesn’t depend on RefetchIcon’s internal default.

Also applies to: 199-208

src/modals/supply/supply-modal-content.tsx (1)

129-136: Disable the balance refetch button while isRefetchingBalance to avoid spamming refetch.

Proposed diff
                 <button
                   type="button"
                   onClick={() => void refetchBalance()}
                   className="opacity-50 transition hover:opacity-100"
                   aria-label="Refetch balance"
+                  disabled={isRefetchingBalance}
                 >
                     <RefetchIcon isLoading={isRefetchingBalance} />
                 </button>
src/hooks/useSupplyMarket.ts (1)

19-32: isRefetchingBalance is based on isFetching; name/semantics may be misleading.
If you intend “manual refetch in progress”, you may want a different signal (or rename to isFetchingBalance).

Also applies to: 414-427

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce4e3e6 and ad7dc12.

📒 Files selected for processing (15)
  • src/components/ui/refetch-icon.tsx
  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/autovault/vault-view.tsx
  • src/features/history/components/history-table.tsx
  • src/features/market-detail/components/position-stats.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
  • src/features/positions/components/user-vaults-table.tsx
  • src/features/positions/positions-view.tsx
  • src/features/rewards/components/reward-table.tsx
  • src/hooks/useSupplyMarket.ts
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/supply/supply-modal-content.tsx
🧰 Additional context used
🧠 Learnings (27)
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/features/positions/**/*.{ts,tsx} : Import CollateralIconsDisplay from `@/features/positions/components/collateral-icons-display` for displaying collateral icons with configurable maxDisplay and iconSize

Applied to files:

  • src/modals/supply/supply-modal-content.tsx
  • src/features/autovault/vault-view.tsx
  • src/features/market-detail/components/position-stats.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/history/components/history-table.tsx
  • src/features/rewards/components/reward-table.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
  • src/components/ui/refetch-icon.tsx
  • src/features/positions/components/user-vaults-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import MarketIdentity from `@/components/MarketIdentity` with modes: `Normal`, `Focused`, `Minimum` and focus options: `Collateral`, `Loan`

Applied to files:

  • src/modals/supply/supply-modal-content.tsx
  • src/features/market-detail/components/position-stats.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import IconSwitch from `@/components/ui/icon-switch` for switch/toggle components with optional icon

Applied to files:

  • src/modals/supply/supply-modal-content.tsx
  • src/features/autovault/vault-view.tsx
  • src/features/market-detail/components/position-stats.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/history/components/history-table.tsx
  • src/features/rewards/components/reward-table.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
  • src/components/ui/refetch-icon.tsx
  • src/features/positions/components/user-vaults-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import MarketDetailsBlock from `@/components/common/MarketDetailsBlock` for displaying market details with configurable mode and options

Applied to files:

  • src/modals/supply/supply-modal-content.tsx
  • src/features/market-detail/components/position-stats.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/components/layout/**/*.{ts,tsx} : Use TransactionIndicator component in navbar to show background transactions that can be restored to modal view when clicked

Applied to files:

  • src/modals/supply/supply-modal-content.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/history/components/history-table.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
  • src/components/ui/refetch-icon.tsx
  • src/features/positions/components/user-vaults-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use local state (useState) for single-trigger modals with depth 0-1

Applied to files:

  • src/modals/supply/supply-modal-content.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/features/*vault*/**/*.{ts,tsx} : Prefer `font-zen` for vault UI surfaces

Applied to files:

  • src/features/autovault/vault-view.tsx
  • src/features/positions/positions-view.tsx
  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/positions/components/user-vaults-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/components/shared/**/*.{ts,tsx} : Place cross-feature components (TokenIcon, AccountIdentity) in `src/components/shared/`

Applied to files:

  • src/features/autovault/vault-view.tsx
  • src/features/market-detail/components/position-stats.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/history/components/history-table.tsx
  • src/features/rewards/components/reward-table.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
  • src/components/ui/refetch-icon.tsx
  • src/features/positions/components/user-vaults-table.tsx
📚 Learning: 2024-11-25T09:39:42.148Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 87
File: app/home/HomePage.tsx:17-39
Timestamp: 2024-11-25T09:39:42.148Z
Learning: In `app/home/HomePage.tsx`, the `useEffect` hook depends on `[showCustomized]` because changing `showCustomized` triggers updates to the yield and risk terms.

Applied to files:

  • src/features/autovault/vault-view.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import AccountIdentity from `@/components/common/AccountIdentity` with variants: `badge`, `compact`, `full`

Applied to files:

  • src/features/autovault/vault-view.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/markets/components/table/markets-table-actions.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use useMemo hook for computed/derived data

Applied to files:

  • src/features/autovault/vault-view.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use useState for local UI state within a single component

Applied to files:

  • src/features/market-detail/components/position-stats.tsx
  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/modals/borrow/components/add-collateral-and-borrow.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Don't chain useEffect hooks; use useMemo instead

Applied to files:

  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/providers/**/*.{ts,tsx} : Don't fetch in Context providers; use React Query instead

Applied to files:

  • src/modals/borrow/components/withdraw-collateral-and-repay.tsx
  • src/features/rewards/components/reward-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import Modal components from `@/components/common/Modal` and use the custom Modal wrapper for consistent typography, corner radius, background, blur, and z-index

Applied to files:

  • src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx
  • src/features/positions/components/rebalance/rebalance-modal.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/components/layout/**/*.{ts,tsx} : Use GlobalTransactionModals component in layout to automatically render process modals for all tracked transactions without component-level ProcessModal

Applied to files:

  • src/features/positions/components/rebalance/rebalance-modal.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use global Zustand store pattern (Pattern 2) for nested modals to avoid Radix-UI maximum update depth errors

Applied to files:

  • src/features/positions/components/rebalance/rebalance-modal.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import TableContainerWithHeader from `@/components/common/table-container-with-header` for tables with titles and optional action buttons

Applied to files:

  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/history/components/history-table.tsx
  • src/features/rewards/components/reward-table.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Import TablePagination from `@/components/common/TablePagination` for paginated tables

Applied to files:

  • src/features/markets/components/table/markets-table-actions.tsx
  • src/features/history/components/history-table.tsx
  • src/features/rewards/components/reward-table.tsx
  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/hooks/use{Processed,Filtered,*}*.ts : Use derived hooks located in `src/hooks/use{Processed|Filtered}{Entity}.ts` for computed/derived data

Applied to files:

  • src/hooks/useSupplyMarket.ts
📚 Learning: 2024-10-07T14:38:04.384Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 57
File: src/hooks/useRebalance.ts:112-114
Timestamp: 2024-10-07T14:38:04.384Z
Learning: In `src/hooks/useRebalance.ts`, adding a delay is necessary because Rabby wallet cannot handle sequential requests.

Applied to files:

  • src/hooks/useSupplyMarket.ts
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use useStyledToast hook from `@/hooks/useStyledToast` for success and error toasts

Applied to files:

  • src/hooks/useSupplyMarket.ts
📚 Learning: 2025-12-09T10:06:39.848Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 231
File: src/hooks/useDeployMorphoMarketV1Adapter.ts:3-3
Timestamp: 2025-12-09T10:06:39.848Z
Learning: In Wagmi v3, useConnection is the correct hook to obtain the connected wallet address, chainId, and connection status (isConnected). This replaces the useAccount hook from Wagmi v2. In your code under src/hooks, use: const { address, chainId, isConnected } = useConnection() from 'wagmi' to access the connected wallet information.

Applied to files:

  • src/hooks/useSupplyMarket.ts
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/hooks/queries/use*.ts : Use React Query for fetching external data (API, blockchain) with queries located in `src/hooks/queries/use{Entity}Query.ts`

Applied to files:

  • src/features/rewards/components/reward-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Never use raw HTML `<table>` tags; use Table components from `@/components/ui/table`

Applied to files:

  • src/features/rewards/components/reward-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/src/components/ui/**/*.{ts,tsx} : Place pure UI primitives (Button, Badge, Table) in `src/components/ui/`

Applied to files:

  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
📚 Learning: 2026-01-10T04:52:06.148Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: docs/DEVELOPER_GUIDE.md:0-0
Timestamp: 2026-01-10T04:52:06.148Z
Learning: Applies to docs/**/*.{ts,tsx} : Use IconSwitch sizes: `xs`, `sm`, `md`, `lg`

Applied to files:

  • src/features/positions/components/supplied-morpho-blue-grouped-table.tsx
🧬 Code graph analysis (11)
src/modals/supply/supply-modal-content.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/positions/positions-view.tsx (1)
src/hooks/queries/useUserVaultsV2Query.ts (1)
  • useUserVaultsV2Query (106-131)
src/modals/borrow/components/withdraw-collateral-and-repay.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/modals/borrow/components/add-collateral-and-borrow.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/positions/components/rebalance/rebalance-modal.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/markets/components/table/markets-table-actions.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/history/components/history-table.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/rewards/components/reward-table.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/positions/components/supplied-morpho-blue-grouped-table.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
src/features/positions/components/user-vaults-table.tsx (1)
src/components/ui/refetch-icon.tsx (1)
  • RefetchIcon (12-40)
🔇 Additional comments (13)
src/features/positions/components/user-vaults-table.tsx (1)

4-4: Clean icon replacement.

The migration from ReloadIcon to RefetchIcon is properly implemented with the isLoading prop.

Also applies to: 72-72

src/features/positions/positions-view.tsx (1)

34-34: Proper refetching state threading.

The isVaultsRefetching state is correctly destructured and passed to UserVaultsTable.

Also applies to: 126-126

src/components/ui/refetch-icon.tsx (1)

12-32: Animation management works for common cases.

The component correctly starts spinning immediately when loading begins and waits for animation completion before stopping. The animationiteration listener ensures smooth transitions.

Note: If isLoading toggles very quickly (before the animation starts), the animationiteration event won't fire, but this is unlikely in practice.

src/modals/borrow/components/withdraw-collateral-and-repay.tsx (1)

2-2: Icon replacement looks good.

The RefetchIcon is properly integrated with the isRefreshing state.

Also applies to: 150-153

src/features/markets/components/table/markets-table-actions.tsx (1)

3-3: Consistent icon migration.

The RefetchIcon replacement follows the same pattern as other files in this PR.

Also applies to: 44-44

src/features/autovault/vault-view.tsx (1)

5-6: LGTM! Clean refactoring to unified loading indicator.

The RefetchIcon component centralizes the spin animation logic and provides a consistent API across the codebase. The isLoading prop correctly reflects vaultDataLoading state.

Also applies to: 204-204

src/features/history/components/history-table.tsx (1)

11-12: LGTM! Consistent with the refactoring pattern.

The loading state correctly combines multiple sources (history, markets, position) and is properly passed to RefetchIcon.

Also applies to: 421-421

src/features/rewards/components/reward-table.tsx (1)

4-5: LGTM! Correctly uses the prop-based loading state.

The isRefetching prop is properly forwarded to RefetchIcon, maintaining the parent-controlled loading state pattern.

Also applies to: 169-169

src/features/positions/components/rebalance/rebalance-modal.tsx (1)

2-2: LGTM! Modal header auxiliary action updated correctly.

The RefetchIcon is properly integrated into the auxiliaryAction slot with the correct loading state.

Also applies to: 243-248

src/features/autovault/components/vault-detail/modals/vault-settings-modal.tsx (1)

4-4: LGTM! Consistent refactoring in modal auxiliary action.

The RefetchIcon correctly uses vaultDataQuery.isLoading to reflect the query state, maintaining the same behavior as before.

Also applies to: 92-97

src/features/positions/components/supplied-morpho-blue-grouped-table.tsx (1)

6-8: Good swap to RefetchIcon; loading state is consistent with disabled state.

Also applies to: 169-177

src/modals/borrow/components/add-collateral-and-borrow.tsx (1)

1-4: LGTM: icon size override + isLoading/disabled are aligned.

Also applies to: 125-139

src/modals/supply/supply-modal-content.tsx (1)

35-53: Nice: balance refetch state is now exposed and used directly in the UI.

@greptile-apps
Copy link

greptile-apps bot commented Jan 10, 2026

Greptile Overview

Greptile Summary

This PR introduces a unified RefetchIcon component to replace inconsistent usage of ReloadIcon with inline animation logic across the codebase. The refactoring successfully standardizes the refetching UI pattern in 14 files.

Key Changes

New Component (refetch-icon.tsx)

  • Implements smooth animation completion: when loading stops, the icon waits for the current rotation to complete before stopping, preventing jarring mid-rotation stops
  • Uses React refs and the animationiteration event to detect when a full spin completes
  • Provides consistent default sizing (h-3 w-3) with optional className override

Hook Enhancement (useSupplyMarket.ts)

  • Adds isRefetchingBalance property that tracks the fetching state of both token and ETH balances
  • Properly combines isFetching from both useReadContract and useBalance hooks

Consistency Improvements

  • Replaces 13 instances of ReloadIcon with manual animate-spin conditional logic
  • All refetch buttons now use the same component and animation behavior
  • Most buttons properly implement the disabled state during loading

Integration Quality

The component integrates well with existing patterns:

  • Works with both Button and native button elements
  • Maintains proper accessibility (aria-labels present in most usages)
  • Consistent with modal auxiliary actions and table action patterns

Confidence Score: 4/5

  • This PR is safe to merge with minor issues that should be addressed
  • The refactoring successfully unifies the refetching icon pattern across the codebase with a well-implemented component. The core logic is sound with proper cleanup and animation handling. However, two issues prevent a higher score: (1) a debug console.log statement in production code, and (2) a missing disabled attribute that could allow duplicate refetch requests in the supply modal. Both are straightforward fixes that don't affect the overall architecture.
  • Pay attention to src/modals/supply/supply-modal-content.tsx (missing disabled attribute) and src/features/positions/positions-view.tsx (debug console.log)

Important Files Changed

File Analysis

Filename Score Overview
src/components/ui/refetch-icon.tsx 4/5 New RefetchIcon component with smooth animation completion logic. Well-implemented with proper cleanup, though could benefit from tests.
src/features/positions/positions-view.tsx 4/5 Added isRefetching prop to UserVaultsTable. Contains debug console.log that should be removed.
src/hooks/useSupplyMarket.ts 5/5 Added isRefetchingBalance property by tracking isFetching from both token and ETH balance queries. Clean implementation.
src/modals/supply/supply-modal-content.tsx 3/5 Replaced ReloadIcon with RefetchIcon and added isRefetchingBalance tracking. Missing disabled attribute on refetch button allows multiple clicks.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Jan 10, 2026

Additional Comments (1)

src/modals/supply/supply-modal-content.tsx
The refetch button is missing a disabled attribute to prevent multiple simultaneous refetch requests. While the RefetchIcon shows the loading state visually, users can still click the button repeatedly during the refetch operation, potentially causing unnecessary network requests.

                  <button
                    type="button"
                    onClick={() => void refetchBalance()}
                    disabled={isRefetchingBalance}
                    className="opacity-50 transition hover:opacity-100"
                    aria-label="Refetch balance"
                  >
                    <RefetchIcon isLoading={isRefetchingBalance} />
                  </button>
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/modals/supply/supply-modal-content.tsx
Line: 129:136

Comment:
The refetch button is missing a `disabled` attribute to prevent multiple simultaneous refetch requests. While the RefetchIcon shows the loading state visually, users can still click the button repeatedly during the refetch operation, potentially causing unnecessary network requests.

```suggestion
                  <button
                    type="button"
                    onClick={() => void refetchBalance()}
                    disabled={isRefetchingBalance}
                    className="opacity-50 transition hover:opacity-100"
                    aria-label="Refetch balance"
                  >
                    <RefetchIcon isLoading={isRefetchingBalance} />
                  </button>
```

How can I resolve this? If you propose a fix, please make it concise.

@antoncoding antoncoding merged commit 421e24f into master Jan 10, 2026
4 checks passed
@antoncoding antoncoding deleted the chore/refetch branch January 10, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Specific feature ready to be implemented ui User interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: spinning refetch

1 participant