Skip to content

Conversation

@bpierre
Copy link
Member

@bpierre bpierre commented Jan 9, 2026

Greptile Overview

Greptile Overview

Greptile Summary

This PR refactors the spotlight data lookup mechanism to use environment names (testnet, moderato) instead of numeric chain IDs (42429, 42431). This change aligns with the broader pattern in the codebase where VITE_TEMPO_ENV is used for environment detection.

Changes made:

  • Changed SPOTLIGHT_DATA keys from number to string type
  • Updated object keys from chain IDs to environment names (42429testnet, 42431moderato)
  • Simplified data access from Number(import.meta.env.VITE_TEMPO_CHAIN_ID) to direct string lookup using import.meta.env.VITE_TEMPO_ENV

Safety notes:

  • The code properly handles missing spotlight data (e.g., for devnet environment) through conditional checks on lines 250 and 264
  • This matches the previous behavior where devnet (chain ID 31318) also had no spotlight data
  • No other source files reference VITE_TEMPO_CHAIN_ID, so this change is isolated to this file

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it's a straightforward refactoring that maintains existing behavior
  • Score of 4 reflects a clean, well-handled refactoring. The code properly handles missing data scenarios, maintains backward compatibility with environments that lack spotlight data, and follows existing patterns in the codebase. Minor point deducted for a type safety improvement opportunity (Record<string, ...> could be more specific), but this doesn't affect runtime behavior.
  • No files require special attention - this is a single-file refactoring with proper null checks

Important Files Changed

File Analysis

Filename Score Overview
apps/explorer/src/routes/_layout/index.tsx 4/5 Changes spotlight data lookup from chain ID numbers to environment names (testnet/moderato); properly handles missing devnet data

Sequence Diagram

sequenceDiagram
    participant ENV as Environment Config
    participant DATA as SPOTLIGHT_DATA
    participant Component as SpotlightLinks
    participant UI as User Interface

    ENV->>DATA: VITE_TEMPO_ENV (testnet/moderato/devnet)
    DATA->>Component: spotlightData lookup [testnet/moderato exists, devnet → undefined]
    
    alt spotlightData exists
        Component->>UI: Render Account, Contract, Receipt pills
        Component->>UI: Render Action dropdown (Payment/Swap/Mint)
    else spotlightData is undefined
        Component->>UI: Skip spotlight-specific pills
    end
    
    Component->>UI: Always render Blocks and Tokens pills
Loading

Important Files Changed

File Analysis

Filename Score Overview
apps/explorer/src/routes/_layout/index.tsx 4/5 Changes spotlight data lookup from chain ID numbers to environment names (testnet/moderato); properly handles missing devnet data

Sequence Diagram

sequenceDiagram
    participant ENV as Environment Config
    participant DATA as SPOTLIGHT_DATA
    participant Component as SpotlightLinks
    participant UI as User Interface

    ENV->>DATA: VITE_TEMPO_ENV (testnet/moderato/devnet)
    DATA->>Component: spotlightData lookup [testnet/moderato exists, devnet → undefined]
    
    alt spotlightData exists
        Component->>UI: Render Account, Contract, Receipt pills
        Component->>UI: Render Action dropdown (Payment/Swap/Mint)
    else spotlightData is undefined
        Component->>UI: Skip spotlight-specific pills
    end
    
    Component->>UI: Always render Blocks and Tokens pills
Loading

@bpierre bpierre merged commit 41b6c1d into main Jan 9, 2026
9 checks passed
@bpierre bpierre deleted the bpierre/fix-spotlights branch January 9, 2026 18:32
@github-actions
Copy link

github-actions bot commented Jan 9, 2026

🚀 Deploying bpierre/fix-spotlights with ⚡ Cloudflare Pages

Latest commit: 53ed493e7af9819bfe01c4d691531755e8194dd4
Status: ✅ Deploy successful
Preview URL: https://3b6ed177-explorer-moderato.porto.workers.dev
Branch Preview URL:

Copy link
Contributor

@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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 24 to +25
const SPOTLIGHT_DATA: Record<
number,
string,
Copy link
Contributor

Choose a reason for hiding this comment

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

The type Record<string, {...}> is too permissive and won't catch type errors when accessing SPOTLIGHT_DATA with invalid keys. Consider using a more specific type that matches the actual keys:

Suggested change
const SPOTLIGHT_DATA: Record<
number,
string,
const SPOTLIGHT_DATA: Record<
'testnet' | 'moderato',

This would make it clear that only 'testnet' and 'moderato' have spotlight data, and TypeScript would catch any attempts to access other keys without proper undefined checks.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/explorer/src/routes/_layout/index.tsx
Line: 24:25

Comment:
The type `Record<string, {...}>` is too permissive and won't catch type errors when accessing SPOTLIGHT_DATA with invalid keys. Consider using a more specific type that matches the actual keys:

```suggestion
const SPOTLIGHT_DATA: Record<
	'testnet' | 'moderato',
```

This would make it clear that only 'testnet' and 'moderato' have spotlight data, and TypeScript would catch any attempts to access other keys without proper undefined checks.

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

gakonst pushed a commit that referenced this pull request Jan 15, 2026
gakonst pushed a commit that referenced this pull request Jan 15, 2026
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