Skip to content

Feature: Implement Algo Insights Tile with PnL & Risk Analysis#471

Merged
RanaBug merged 4 commits intostagingfrom
feature/algo-insights-tile
Dec 4, 2025
Merged

Feature: Implement Algo Insights Tile with PnL & Risk Analysis#471
RanaBug merged 4 commits intostagingfrom
feature/algo-insights-tile

Conversation

@aldin4u
Copy link
Collaborator

@aldin4u aldin4u commented Dec 3, 2025

Description

Homefeed tile:

image image

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features

    • Algorithmic Insights tile added to the home feed with performance metrics, risk indicator, PnL breakdown, and an Algo Insights logo.
    • Multiple timeframe controls (1w, 1m, 3m, 6m) with interactive chart, filled gradient area, and current-value indicator.
    • Responsive layouts: compact mobile view with metric cards and CTA; desktop view with detailed chart, donut PnL status, and legend.
  • Chores

    • Tile registered in the component map and sample tile injected into the feed; new data/layout support added.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • src/apps/pillarx-app/components/TokensWithMarketDataTile/test/__snapshots__/TokensWithMarketDataTile.test.tsx.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds a new Algo Insights feature: UI components (AlgoInsightsTile, AlgoInsightsLogo), a new AlgoInsightsData type and ApiLayout.ALGO_INSIGHTS enum entry, registers the tile in the component map, and injects a mock Algo Insights projection into the home feed.

Changes

Cohort / File(s) Summary
UI Components
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsLogo.tsx, src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
Added AlgoInsightsLogo (simple image component) and AlgoInsightsTile (default export) implementing responsive mobile/desktop layouts, SVG cumulative PnL chart with smooth line and filled gradient, timeframe tabs, metric cards, risk gauge/donut visuals, and styled-components styles.
App bootstrap / Mock data
src/apps/pillarx-app/index.tsx
Imported ApiLayout, constructed and prepended a mock Projection with layout ApiLayout.ALGO_INSIGHTS (id: algo-insights-mock) into home feed API data when building initial feed.
Component registration
src/apps/pillarx-app/utils/configComponent.ts
Registered AlgoInsightsTile in the public component map keyed by ApiLayout.ALGO_INSIGHTS.
Types & API
src/types/api.ts
Added ALGO_INSIGHTS = 'ALGO_INSIGHTS' to ApiLayout, introduced exported AlgoInsightsData type (pnl_1m/pnl_3m/pnl_6m, risk_level, pnl_status, cumulative_pnl with time windows and histories), and extended Projection["data"] union to include AlgoInsightsData.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention points:
    • SVG path generation and cubic Bézier smoothing (scaling, edge cases with short histories).
    • Y-axis/X-axis label calculations and timeframe-specific date spacing.
    • Donut stroke-dasharray math (normalization to 100%) and legend mapping.
    • Mock projection structure vs. new AlgoInsightsData type and injection logic (duplicate prevention).
    • Styled-components responsiveness and CSS class/size consistency.

Suggested reviewers

  • IAmKio

Poem

🐰 I hopped in with pixels bright and new,
Curves and donuts dancing into view,
Tabs that flip, a tiny logo gleams,
Charts that hum with number-laden dreams,
Hop—insights sprout from code and streams! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete: it lacks a detailed summary of changes, provides no testing information, and does not specify the type of change (all checkboxes are unchecked). Only screenshots are partially provided. Complete the Description section with a summary of changes, add testing details covering environment and test cases, and check the appropriate Types of changes checkbox (likely 'New feature').
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: implementing a new Algo Insights Tile component with PnL and risk analysis functionality, which aligns with the comprehensive feature addition across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 3, 2025

Deploying pillarx-debug with  Cloudflare Pages  Cloudflare Pages

Latest commit: b4819ee
Status: ✅  Deploy successful!
Preview URL: https://cc818579.pillarx-debug.pages.dev
Branch Preview URL: https://feature-algo-insights-tile.pillarx-debug.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 3, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: b4819ee
Status: ✅  Deploy successful!
Preview URL: https://e1ac2291.x-e62.pages.dev
Branch Preview URL: https://feature-algo-insights-tile.x-e62.pages.dev

View logs

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: 5

Caution

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

⚠️ Outside diff range comments (1)
src/apps/pillarx-app/index.tsx (1)

119-125: Use id property for duplicate checking instead of reference equality.

The condition !prevData.includes(item) uses reference equality. Since homeFeed.projection items are new object instances on each fetch, this check will always fail for previously loaded items. This can cause duplicates to be added repeatedly. The Projection type (defined in src/types/api.ts) includes a required id: string property, so compare by id instead:

         homeFeed.projection.forEach((item) => {
-          if (!prevData.includes(item)) {
+          if (!prevData.some(existing => existing.id === item.id)) {
             newApiData.push(item);
           }
         });
🧹 Nitpick comments (5)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsLogo.tsx (1)

6-12: Logo dimensions may not match mobile container.

The logo is rendered at a fixed 60x60 size, but LogoContainerMobile in AlgoInsightsTile.tsx expects a 48x48 container and overrides the img to 48x48 via CSS. While this works due to the CSS override, consider making the logo responsive or accepting size props to avoid relying on parent CSS overrides.

-const AlgoInsightsLogo: React.FC = () => {
+type AlgoInsightsLogoProps = {
+  size?: number;
+};
+
+const AlgoInsightsLogo: React.FC<AlgoInsightsLogoProps> = ({ size = 60 }) => {
     return (
         <img
             src={logoImage}
             alt="Algo Insights Logo"
-            width="60"
-            height="60"
+            width={size}
+            height={size}
             style={{ display: 'block' }}
         />
     );
 };
src/apps/pillarx-app/index.tsx (1)

127-222: Extract mock data to a separate file and add TODO for removal.

The inline mock data object is ~90 lines and clutters the component logic. Additionally, the 6m history contains future timestamps (Dec 9, 16, 23, 2025) which is inconsistent for historical data.

Consider:

  1. Extract the mock data to a dedicated file (e.g., utils/mockAlgoInsightsData.ts)
  2. Add a TODO comment to remove mock injection before production
  3. Fix future timestamps in the history data
+        // TODO: Remove mock tile injection before production release
         // Inject Algo Insights Tile (Mock Data)
-        const algoTile: Projection = {
-          id: 'algo-insights-mock',
-          layout: ApiLayout.ALGO_INSIGHTS,
-          // ... 90 lines of data
-        };
+        const algoTile: Projection = getMockAlgoInsightsTile();
src/types/api.ts (1)

180-220: Consider extracting repeated history entry type to reduce duplication.

The { value: number; history: { timestamp: number; value: number; }[]; } structure is repeated 4 times for each timeframe.

+type PnLTimeframeData = {
+  value: number;
+  history: {
+    timestamp: number;
+    value: number;
+  }[];
+};
+
 export type AlgoInsightsData = {
   pnl_1m: number;
   pnl_3m: number;
   pnl_6m: number;
   risk_level: 'Low Risk' | 'Medium Risk' | 'High Risk';
   pnl_status: {
     winning: number;
     losing: number;
     neutral: number;
   };
   cumulative_pnl: {
-    '1w': {
-      value: number;
-      history: {
-        timestamp: number;
-        value: number;
-      }[];
-    };
-    '1m': {
-      value: number;
-      history: {
-        timestamp: number;
-        value: number;
-      }[];
-    };
-    '3m': {
-      value: number;
-      history: {
-        timestamp: number;
-        value: number;
-      }[];
-    };
-    '6m': {
-      value: number;
-      history: {
-        timestamp: number;
-        value: number;
-      }[];
-    };
+    '1w': PnLTimeframeData;
+    '1m': PnLTimeframeData;
+    '3m': PnLTimeframeData;
+    '6m': PnLTimeframeData;
   };
 };
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (2)

62-73: Simplify redundant conditional branches.

The first three branches (1w, 1m, 3m) produce the same output format.

   const formatDateLabel = (timestamp: number, timeframe: string): string => {
     const date = new Date(timestamp * 1000);
-    if (timeframe === '1w') {
-      return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
-    } else if (timeframe === '1m') {
-      return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
-    } else if (timeframe === '3m') {
+    if (timeframe === '6m') {
+      return date.toLocaleDateString('en-US', { month: 'short', year: 'numeric' });
+    } else {
       return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
-    } else {
-      return date.toLocaleDateString('en-US', { month: 'short', year: 'numeric' });
     }
   };

649-658: Use semantic button element for accessibility.

BuyButton is styled as a div but functions as a button. This lacks keyboard navigation and screen reader support. Use a button element for better accessibility.

-const BuyButton = styled.div`
+const BuyButton = styled.button`
   height: 40px;
   background: #8A77FF;
   border-radius: 8px;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   padding: 0 24px;
+  border: none;
+  
+  &:focus-visible {
+    outline: 2px solid #FFFFFF;
+    outline-offset: 2px;
+  }
 `;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e14ade9 and 3d147da.

⛔ Files ignored due to path filters (2)
  • src/apps/pillarx-app/components/AlgoInsightsTile/algo-insights-logo.png is excluded by !**/*.png
  • src/assets/algo-insights-logo.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsLogo.tsx (1 hunks)
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1 hunks)
  • src/apps/pillarx-app/index.tsx (2 hunks)
  • src/apps/pillarx-app/utils/configComponent.ts (2 hunks)
  • src/types/api.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-04-23T15:04:20.826Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 290
File: src/apps/pillarx-app/components/TileTitle/TitleTitle.tsx:6-10
Timestamp: 2025-04-23T15:04:20.826Z
Learning: In this repository, TileTitleProps and TileTitle are different types that serve different purposes. TileTitleProps is used for the TileTitle component and has optional fields (title?, leftDecorator?, rightDecorator?), while TileTitle in api.ts has a required text field. The TileTitleProps interface aligns with the TokensMarketData.title type in api.ts which also has optional fields.

Applied to files:

  • src/apps/pillarx-app/utils/configComponent.ts
  • src/apps/pillarx-app/index.tsx
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
📚 Learning: 2025-04-23T15:04:20.826Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 290
File: src/apps/pillarx-app/components/TileTitle/TitleTitle.tsx:6-10
Timestamp: 2025-04-23T15:04:20.826Z
Learning: In this repository, TileTitleProps and TileTitle are different types that serve different purposes. TileTitleProps is used for the TileTitle component and has optional fields (title?, leftDecorator?, rightDecorator?), while TileTitle in api.ts has a required title field. The TileTitleProps structure aligns with how it's used in the TokensMarketData type in api.ts.

Applied to files:

  • src/apps/pillarx-app/utils/configComponent.ts
  • src/apps/pillarx-app/index.tsx
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
📚 Learning: 2025-08-20T14:01:31.715Z
Learnt from: IAmKio
Repo: pillarwallet/x PR: 387
File: src/apps/leaderboard/components/LeaderboardTab/LeaderboardTab.tsx:118-125
Timestamp: 2025-08-20T14:01:31.715Z
Learning: In src/apps/leaderboard/components/LeaderboardTab/LeaderboardTab.tsx, the "My rank" calculation uses 'trading' context while the list uses 'migration' context when calling calculateFinalPxPoints. This is intentional design to control where the 200-point bonus is applied - the 'trading' context with 'all' timeTab bypasses the bonus while 'migration' context allows it, preventing points from being added in the wrong place.

Applied to files:

  • src/types/api.ts
📚 Learning: 2025-08-20T09:14:16.888Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 374
File: src/apps/pillarx-app/index.tsx:12-12
Timestamp: 2025-08-20T09:14:16.888Z
Learning: In this codebase, Transaction Kit providers are set up at the container level (src/containers/Authorized.tsx), not at individual app component levels. App components like src/apps/pillarx-app/index.tsx are children that consume the context through the provider tree.

Applied to files:

  • src/apps/pillarx-app/index.tsx
🧬 Code graph analysis (2)
src/apps/pillarx-app/index.tsx (1)
src/types/api.ts (1)
  • Projection (222-235)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1)
src/types/api.ts (2)
  • Projection (222-235)
  • AlgoInsightsData (180-220)
⏰ 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). (4)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages: pillarx-debug
🔇 Additional comments (3)
src/apps/pillarx-app/utils/configComponent.ts (1)

13-13: LGTM!

The import and component mapping follow the established pattern for tile components in this file.

Also applies to: 28-28

src/types/api.ts (1)

10-10: LGTM!

The new enum value and union type extension are correctly implemented and consistent with the existing patterns.

Also applies to: 226-232

src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1)

181-181: No action needed—this navigation pattern is intentional.

window.location.href = '/insights' is appropriate here. The /insights route does not exist in the application's React Router setup, and AlgoInsightsTile is a dumb presentational component without Router context. This navigation is either to an external destination or a full-page reload is intentionally desired. Converting to useNavigate() would require both the route to exist and the component to have access to Router context, neither of which applies in this case.

Likely an incorrect or invalid review comment.

- Implement runtime type guard for AlgoInsightsData validation
- Add guards for empty history arrays and min/max calculations
- Add conditional up/down arrows for mobile PnL badges
- Implement dynamic donut chart calculations using useMemo
@github-actions github-actions bot temporarily deployed to Preview (feature/algo-insights-tile) December 3, 2025 09:18 Inactive
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: 2

♻️ Duplicate comments (2)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (2)

392-397: Graph header still hardcodes 6m value instead of using selected timeframe

The header value is currently:

<GraphValue>{algoData.cumulative_pnl['6m'].value}%</GraphValue>

so it always shows the 6‑month cumulative PnL, regardless of which timeframe tab is selected. This is misleading for users and was already raised in a prior review; the issue appears to have regressed.

Since you already compute currentTimeframeData from selectedTimeframe (Line 90), you can simply bind the header to that:

-              <GraphValue>{algoData.cumulative_pnl['6m'].value}%</GraphValue>
+              <GraphValue>{currentTimeframeData.value}%</GraphValue>

This keeps the header in sync with the active timeframe and matches the chart data.


264-291: Desktop PnL indicators don’t reflect negative direction (only show positive icon)

In the desktop Performance section (Lines 264‑291), each metric always shows a green PolygonIcon, even when algoData.pnl_1m, pnl_3m, or pnl_6m are negative. Mobile metrics already use SmallArrowUp / SmallArrowDown to reflect direction, but desktop remains misleading. This is conceptually the same issue that was previously flagged for always‑up indicators.

You can reuse the existing SmallArrowUp / SmallArrowDown from the mobile section for desktop metrics:

                 {/* 1 Month PnL */}
                 <PerformanceMetric>
                   <PerformanceMetricTitle>1 Month PnL</PerformanceMetricTitle>
                   <PerformanceMetricValueContainer>
-                    <PerformanceMetricValue>{algoData.pnl_1m}%</PerformanceMetricValue>
-                    <PolygonIcon />
+                    <PerformanceMetricValue>{algoData.pnl_1m}%</PerformanceMetricValue>
+                    {algoData.pnl_1m >= 0
+                      ? <SmallArrowUp>▲</SmallArrowUp>
+                      : <SmallArrowDown>▼</SmallArrowDown>}
                   </PerformanceMetricValueContainer>
                 </PerformanceMetric>
@@
                 {/* 3 Month PnL */}
@@
-                    <PerformanceMetricValue>{algoData.pnl_3m}%</PerformanceMetricValue>
-                    <PolygonIcon />
+                    <PerformanceMetricValue>{algoData.pnl_3m}%</PerformanceMetricValue>
+                    {algoData.pnl_3m >= 0
+                      ? <SmallArrowUp>▲</SmallArrowUp>
+                      : <SmallArrowDown>▼</SmallArrowDown>}
@@
                 {/* 6 Month PnL */}
@@
-                    <PerformanceMetricValue>{algoData.pnl_6m}%</PerformanceMetricValue>
-                    <PolygonIcon />
+                    <PerformanceMetricValue>{algoData.pnl_6m}%</PerformanceMetricValue>
+                    {algoData.pnl_6m >= 0
+                      ? <SmallArrowUp>▲</SmallArrowUp>
+                      : <SmallArrowDown>▼</SmallArrowDown>}

This aligns desktop with mobile behaviour and gives users a clear visual cue when returns are negative.

Also applies to: 586-593

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d147da and ccaf77b.

📒 Files selected for processing (1)
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-04-23T15:04:20.826Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 290
File: src/apps/pillarx-app/components/TileTitle/TitleTitle.tsx:6-10
Timestamp: 2025-04-23T15:04:20.826Z
Learning: In this repository, TileTitleProps and TileTitle are different types that serve different purposes. TileTitleProps is used for the TileTitle component and has optional fields (title?, leftDecorator?, rightDecorator?), while TileTitle in api.ts has a required text field. The TileTitleProps interface aligns with the TokensMarketData.title type in api.ts which also has optional fields.

Applied to files:

  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
📚 Learning: 2025-04-23T15:04:20.826Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 290
File: src/apps/pillarx-app/components/TileTitle/TitleTitle.tsx:6-10
Timestamp: 2025-04-23T15:04:20.826Z
Learning: In this repository, TileTitleProps and TileTitle are different types that serve different purposes. TileTitleProps is used for the TileTitle component and has optional fields (title?, leftDecorator?, rightDecorator?), while TileTitle in api.ts has a required title field. The TileTitleProps structure aligns with how it's used in the TokensMarketData type in api.ts.

Applied to files:

  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
🧬 Code graph analysis (1)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1)
src/types/api.ts (2)
  • Projection (222-235)
  • AlgoInsightsData (180-220)
🪛 Biome (2.1.2)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx

[error] 138-138: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.

Hooks should not be called after an early return.

For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level

(lint/correctness/useHookAtTopLevel)

⏰ 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). (4)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages: pillarx-debug

@github-actions github-actions bot temporarily deployed to Preview (feature/algo-insights-tile) December 3, 2025 15:57 Inactive
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: 0

♻️ Duplicate comments (1)
src/apps/pillarx-app/index.tsx (1)

17-223: Mock Algo Insights tile injection should be gated or moved out of core home feed logic

The mock algoTile injection is functionally correct (added once, deduped by id, always at the top), but hard‑coding this Projection inside the main home feed effect makes it easy for test data to leak into production and diverge from the API contract over time.

Consider one of:

  • Guarding this with an explicit feature flag / environment check (e.g. only on staging/dev).
  • Moving the mock construction into a small helper (e.g. buildMockAlgoInsightsProjection()) to centralize the data contract.
  • Wiring the tile from backend once the API is ready and dropping the injection entirely.

This keeps the feed assembly closer to the real API surface and avoids future confusion around where this tile actually comes from.

🧹 Nitpick comments (3)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (3)

120-179: Chart math correctly matches the guaranteed data shape; just be aware of history-length assumptions

The cumulative PnL chart logic (min/max + 10% padding, smooth path, last-point marker, date labels) is coherent and will behave well with the provided mock data: all four timeframes have multi‑point histories, so divisions by (length - 1) and indexing are safe, and the padding avoids a flat line when values are constant.

If this tile is ever wired to dynamic or partially populated backend data, you’ll likely want to add guards for history.length <= 1 before computing xStep, lastIndex, and date labels to avoid NaNs and out‑of‑range indexing. Given the current contract that histories are always present and complete, this implementation is fine as is. Based on learnings, the hardcoded dataset guarantees non‑empty, multi‑point histories for every timeframe.


381-413: Desktop PnL indicators are always styled as “up/positive” even if values go negative

On desktop, the 1m/3m/6m PnL metrics always use the green PolygonIcon and a positive‑styled badge, regardless of whether algoData.pnl_* might be negative in future dynamic data. You already handle sign correctly in the mobile view with SmallArrowUp/SmallArrowDown; mirroring that behaviour (e.g., different color/icon for negative values) on desktop would avoid showing an “up” marker next to negative PnL.

Not urgent with the current positive mock values, but worth aligning once this is driven by real data.


366-373: Use semantic buttons (or add keyboard handlers) for clickable desktop controls

BuyButton and TimeframeButton are styled divs with onClick handlers, which makes them mouse‑only by default and less accessible than the mobile CTA (which uses a button element):

  • Lines 366–373: BuyButton click navigates to /insights.
  • Lines 494–517: TimeframeButton toggles selectedTimeframe.
  • Lines 903–912 and 1146–1155 define these as divs, not buttons.

For better a11y and keyboard support, consider:

  • Switching these to styled.button with type="button", or
  • Adding role="button", tabIndex={0}, and onKeyDown handlers (Enter/Space) if you want to keep them as divs.

This keeps the UX consistent with the mobile CTA and improves accessibility without changing behaviour.

Also applies to: 494-517, 903-912, 1146-1155

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccaf77b and 6c3cbfc.

⛔ Files ignored due to path filters (2)
  • src/apps/pillarx-app/components/TokenMarketDataRow/tests/__snapshots__/LeftColumnTokenMarketDataRow.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensWithMarketDataTile/test/__snapshots__/TokensWithMarketDataTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsLogo.tsx (1 hunks)
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1 hunks)
  • src/apps/pillarx-app/index.tsx (2 hunks)
  • src/types/api.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsLogo.tsx
  • src/types/api.ts
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: aldin4u
Repo: pillarwallet/x PR: 471
File: src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx:36-48
Timestamp: 2025-12-03T10:01:15.789Z
Learning: In the AlgoInsightsTile component (src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx), the data is always hardcoded and guaranteed to be present with complete history arrays for all timeframes, so edge case handling for empty or sparse history data is not required.
📚 Learning: 2025-12-03T10:01:15.789Z
Learnt from: aldin4u
Repo: pillarwallet/x PR: 471
File: src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx:36-48
Timestamp: 2025-12-03T10:01:15.789Z
Learning: In the AlgoInsightsTile component (src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx), the data is always hardcoded and guaranteed to be present with complete history arrays for all timeframes, so edge case handling for empty or sparse history data is not required.

Applied to files:

  • src/apps/pillarx-app/index.tsx
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
📚 Learning: 2025-04-23T15:04:20.826Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 290
File: src/apps/pillarx-app/components/TileTitle/TitleTitle.tsx:6-10
Timestamp: 2025-04-23T15:04:20.826Z
Learning: In this repository, TileTitleProps and TileTitle are different types that serve different purposes. TileTitleProps is used for the TileTitle component and has optional fields (title?, leftDecorator?, rightDecorator?), while TileTitle in api.ts has a required text field. The TileTitleProps interface aligns with the TokensMarketData.title type in api.ts which also has optional fields.

Applied to files:

  • src/apps/pillarx-app/index.tsx
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
📚 Learning: 2025-04-23T15:04:20.826Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 290
File: src/apps/pillarx-app/components/TileTitle/TitleTitle.tsx:6-10
Timestamp: 2025-04-23T15:04:20.826Z
Learning: In this repository, TileTitleProps and TileTitle are different types that serve different purposes. TileTitleProps is used for the TileTitle component and has optional fields (title?, leftDecorator?, rightDecorator?), while TileTitle in api.ts has a required title field. The TileTitleProps structure aligns with how it's used in the TokensMarketData type in api.ts.

Applied to files:

  • src/apps/pillarx-app/index.tsx
  • src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx
📚 Learning: 2025-08-20T09:14:16.888Z
Learnt from: RanaBug
Repo: pillarwallet/x PR: 374
File: src/apps/pillarx-app/index.tsx:12-12
Timestamp: 2025-08-20T09:14:16.888Z
Learning: In this codebase, Transaction Kit providers are set up at the container level (src/containers/Authorized.tsx), not at individual app component levels. App components like src/apps/pillarx-app/index.tsx are children that consume the context through the provider tree.

Applied to files:

  • src/apps/pillarx-app/index.tsx
🧬 Code graph analysis (2)
src/apps/pillarx-app/index.tsx (1)
src/types/api.ts (1)
  • Projection (222-235)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1)
src/types/api.ts (2)
  • Projection (222-235)
  • AlgoInsightsData (180-220)
⏰ 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). (4)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages: pillarx-debug
🔇 Additional comments (1)
src/apps/pillarx-app/components/AlgoInsightsTile/AlgoInsightsTile.tsx (1)

14-43: Core props, loading guard, and AlgoInsightsData type narrowing look solid

The component boundary (Projection + isDataLoading), early return on loading, and isAlgoInsightsData guard give you a safe, explicit narrowing of the data union before any chart logic runs. This removes the earlier unsafe cast and avoids runtime crashes if a wrong layout slips through. No changes needed here.

@vignesha22 vignesha22 self-requested a review December 4, 2025 11:36
@RanaBug RanaBug merged commit 7ede244 into staging Dec 4, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants