Skip to content

Conversation

@Yash094
Copy link
Member

@Yash094 Yash094 commented Sep 4, 2025


PR-Codex overview

This PR updates the ContractFunctionInner component by changing the initial state value of environment from "javascript" to "api".

Detailed summary

  • Updated the initial state of environment in ContractFunctionInner from "javascript" to "api".

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Refactor
    • Default code example environment in contract function views now starts with the API variant. Users can still switch to JavaScript, cURL, and other options as before.

@Yash094 Yash094 requested review from a team as code owners September 4, 2025 07:23
@changeset-bot
Copy link

changeset-bot bot commented Sep 4, 2025

⚠️ No Changeset found

Latest commit: fddc4a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Sep 4, 2025

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

Project Deployment Preview Comments Updated (UTC)
thirdweb-www Ready Ready Preview Comment Sep 4, 2025 7:31am
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Sep 4, 2025 7:31am
nebula Skipped Skipped Sep 4, 2025 7:31am
thirdweb_playground Skipped Skipped Sep 4, 2025 7:31am
wallet-ui Skipped Skipped Sep 4, 2025 7:31am

@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 4, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Initial code environment for the ContractFunctionInner component is changed from "javascript" to "api". The initial state now selects the API snippet variant on first render. Snippet assembly logic, environment toggling, and data fetching remain unchanged.

Changes

Cohort / File(s) Summary of Changes
Contracts UI Component
apps/dashboard/src/@/components/contracts/functions/contract-function.tsx
Updated initial state to set CodeSegment environment to "api" instead of "javascript"; no other logic changes to snippet construction or toggling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant ContractFunctionInner as ContractFunctionInner (React)
  participant CodeSegment as CodeSegment

  User->>ContractFunctionInner: Mount component
  activate ContractFunctionInner
  ContractFunctionInner->>ContractFunctionInner: init state: environment = "api"
  ContractFunctionInner->>CodeSegment: Render with environment = "api"
  deactivate ContractFunctionInner

  User-->>CodeSegment: Toggle environment (optional)
  CodeSegment-->>User: Display selected snippet
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yash/fix-default-code-selection

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Sep 4, 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: 0

🧹 Nitpick comments (3)
apps/dashboard/src/@/components/contracts/functions/contract-function.tsx (3)

6-11: Add useEffect import for fallback handling (see next comment).

If you adopt the fallback effect below, include useEffect here.

 import {
   type Dispatch,
   lazy,
   type SetStateAction,
   useMemo,
-  useState,
+  useState,
+  useEffect,
 } from "react";

151-156: Graceful fallback when API snippet is unavailable.

With "api" as the initial environment, functions lacking an API snippet could render an empty panel unless CodeSegment guards this. Add a minimal fallback to switch to the first available snippet.

   const codeSnippet = {
     ...baseSnippet,
     ...apiSnippet,
     ...curlSnippet,
   };
+
+  // Fallback: if selected environment isn't available for this function, pick the first available
+  useEffect(() => {
+    const available = Object.keys(codeSnippet) as CodeEnvironment[];
+    if (!available.includes(environment)) {
+      const preference: CodeEnvironment[] = [
+        "api",
+        "javascript",
+        "typescript",
+        "react",
+        "react-native",
+        "dotnet",
+        "unity",
+        "curl",
+      ];
+      const next =
+        preference.find((e) => available.includes(e)) ?? available[0];
+      if (next) setEnvironment(next);
+    }
+  }, [environment, codeSnippet]);

224-224: Fix stray brace in list key.

Minor typo in key string.

-                  <TableRow key={`${input.name}+${idx}}`}>
+                  <TableRow key={`${input.name}-${idx}`}>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f47eda6 and fddc4a3.

📒 Files selected for processing (1)
  • apps/dashboard/src/@/components/contracts/functions/contract-function.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/dashboard/src/@/components/contracts/functions/contract-function.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/@/components/contracts/functions/contract-function.tsx
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/@/components/contracts/functions/contract-function.tsx
apps/{dashboard,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/_ (e.g., Button, Input, Tabs, Card)
Use NavLink for internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names with cn() from @/lib/utils for conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start with import "server-only"; use next/headers, server‑only env, heavy data fetching, and redirect() where appropriate
Client Components must start with 'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: call getAuthToken() from cookies, send Authorization: Bearer <token> header, and return typed results (avoid any)
Client-side data fetching: wrap calls in React Query with descriptive, stable queryKeys and set sensible staleTime/cacheTime (≥ 60s default); keep tokens secret via internal routes or server actions
Do not import posthog-js in server components (client-side only)

Files:

  • apps/dashboard/src/@/components/contracts/functions/contract-function.tsx
apps/{dashboard,playground}/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Expose a className prop on the root element of every component

Files:

  • apps/dashboard/src/@/components/contracts/functions/contract-function.tsx
🧬 Code graph analysis (1)
apps/dashboard/src/@/components/contracts/functions/contract-function.tsx (1)
apps/dashboard/src/@/components/blocks/code/code-segment.client.tsx (1)
  • CodeEnvironment (9-17)
⏰ 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). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apps/dashboard/src/@/components/contracts/functions/contract-function.tsx (3)

71-71: Default to API by default — LGTM.

This directly satisfies the PR goal; CodeEnvironment already includes "api".


69-76: Confirm desired persistence across function switches.

environment state is preserved when selecting different functions (same component instance). If product wants “API by default per function,” reset on fn change; otherwise keep as-is.

Option to reset per function:

-  const [environment, setEnvironment] = useState<CodeEnvironment>("api");
+  const [environment, setEnvironment] = useState<CodeEnvironment>("api");
+  useEffect(() => {
+    setEnvironment("api");
+  }, [fn]);

187-193: CodeSegment handles missing env keys correctly; no changes required.
It gracefully falls back to the first available snippet (via Object.keys(snippet)[0]) when the requested environment key is missing and renders without error.

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.53%. Comparing base (f47eda6) to head (fddc4a3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7980   +/-   ##
=======================================
  Coverage   56.53%   56.53%           
=======================================
  Files         904      904           
  Lines       58626    58626           
  Branches     4146     4146           
=======================================
  Hits        33145    33145           
  Misses      25375    25375           
  Partials      106      106           
Flag Coverage Δ
packages 56.53% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.01 KB (0%) 1.3 s (0%) 261 ms (+121.81% 🔺) 1.6 s
thirdweb (cjs) 357.32 KB (0%) 7.2 s (0%) 931 ms (+2.21% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 76 ms (+1186.55% 🔺) 191 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 29 ms (+1275.72% 🔺) 40 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 68 ms (+377.37% 🔺) 451 ms

@0xFirekeeper 0xFirekeeper merged commit bc6309d into main Sep 4, 2025
25 checks passed
@0xFirekeeper 0xFirekeeper deleted the yash/fix-default-code-selection branch September 4, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dashboard Involves changes to the Dashboard.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants