Skip to content

Dashboard: Fix Import Contract Modal submit button loading state#7970

Merged
graphite-app[bot] merged 1 commit into
mainfrom
09-03-dashboard_fix_import_contract_modal_submit_button_loading_state
Sep 3, 2025
Merged

Dashboard: Fix Import Contract Modal submit button loading state#7970
graphite-app[bot] merged 1 commit into
mainfrom
09-03-dashboard_fix_import_contract_modal_submit_button_loading_state

Conversation

@MananTank

@MananTank MananTank commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

PR-Codex overview

This PR updates the conditional rendering logic in the modal.tsx file to reflect the form submission state instead of the contract addition state. This change improves the user experience by providing accurate feedback during the import process.

Detailed summary

  • Changed the condition from addContractToProject.isPending to form.formState.isSubmitting for rendering the Spinner and the button text.
  • Ensured the button displays "Importing" when the form is submitting, enhancing clarity for users.

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

Summary by CodeRabbit

  • Bug Fixes
    • Import Contract modal: The submit button now reflects the form submission state. While submitting it shows a spinner and the label changes to “Importing”; when idle it shows the standard icon and “Import”. This improves user feedback, reduces confusion, and helps prevent duplicate submissions by clearly indicating when an import is in progress.

@vercel

vercel Bot commented Sep 3, 2025

Copy link
Copy Markdown

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 3, 2025 8:23pm
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Sep 3, 2025 8:23pm
nebula Skipped Skipped Sep 3, 2025 8:23pm
thirdweb_playground Skipped Skipped Sep 3, 2025 8:23pm
wallet-ui Skipped Skipped Sep 3, 2025 8:23pm

@changeset-bot

changeset-bot Bot commented Sep 3, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 18b7f91

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 vercel Bot temporarily deployed to Preview – thirdweb_playground September 3, 2025 13:59 Inactive
@vercel vercel Bot temporarily deployed to Preview – wallet-ui September 3, 2025 13:59 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs-v2 September 3, 2025 13:59 Inactive
@MananTank MananTank marked this pull request as ready for review September 3, 2025 13:59
@coderabbitai

coderabbitai Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Update the import-contract modal’s submit button to use form.formState.isSubmitting for its loading state and label, replacing reliance on addContractToProject.isPending. The button now shows a spinner and “Importing” during submission; otherwise, it shows the ArrowDownToLineIcon and “Import.” No exported/public APIs changed.

Changes

Cohort / File(s) Summary of Changes
Dashboard Contract Import Modal
apps/dashboard/src/@/components/contracts/import-contract/modal.tsx
Submit button loading state and label now derive from form.formState.isSubmitting instead of addContractToProject.isPending; spinner and text updated accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 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.

📜 Recent 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 7a79585 and 18b7f91.

📒 Files selected for processing (1)
  • apps/dashboard/src/@/components/contracts/import-contract/modal.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/src/@/components/contracts/import-contract/modal.tsx
⏰ 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). (7)
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 09-03-dashboard_fix_import_contract_modal_submit_button_loading_state

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

@MananTank MananTank requested review from a team as code owners September 3, 2025 13:59
@vercel vercel Bot temporarily deployed to Preview – nebula September 3, 2025 13:59 Inactive
@github-actions github-actions Bot added the Dashboard Involves changes to the Dashboard. label Sep 3, 2025

MananTank commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov

codecov Bot commented Sep 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.54%. Comparing base (82be4fa) to head (18b7f91).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7970   +/-   ##
=======================================
  Coverage   56.54%   56.54%           
=======================================
  Files         904      904           
  Lines       58626    58626           
  Branches     4148     4148           
=======================================
  Hits        33149    33149           
  Misses      25371    25371           
  Partials      106      106           
Flag Coverage Δ
packages 56.54% <ø> (ø)
🚀 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

github-actions Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.01 KB (0%) 1.3 s (0%) 238 ms (+183.09% 🔺) 1.6 s
thirdweb (cjs) 357.32 KB (0%) 7.2 s (0%) 704 ms (+18.37% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 88 ms (+1938.54% 🔺) 202 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 88 ms (+5485.6% 🔺) 99 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 93 ms (+808.2% 🔺) 476 ms

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/dashboard/src/@/components/contracts/import-contract/modal.tsx (1)

161-186: Consider awaiting the mutation for RHF’s loading state
Switch to await addContractToProject.mutateAsync(...) so React Hook Form’s isSubmitting covers the entire import; this changes the fire-and-forget UX used elsewhere—confirm it’s desired.

📜 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 b8f4966 and 7a79585.

📒 Files selected for processing (1)
  • apps/dashboard/src/@/components/contracts/import-contract/modal.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/import-contract/modal.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/import-contract/modal.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/import-contract/modal.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/import-contract/modal.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/import-contract/modal.tsx
🧠 Learnings (2)
📓 Common learnings
Learnt from: MananTank
PR: thirdweb-dev/js#7434
File: apps/dashboard/src/app/(app)/team/~/~/contract/[chain]/[contractAddress]/components/project-selector.tsx:62-76
Timestamp: 2025-06-24T21:38:03.155Z
Learning: In the project-selector.tsx component for contract imports, the addToProject.mutate() call is intentionally not awaited (fire-and-forget pattern) to allow immediate navigation to the contract page while the import happens in the background. This is a deliberate design choice to prioritize user experience.
📚 Learning: 2025-06-24T21:38:03.155Z
Learnt from: MananTank
PR: thirdweb-dev/js#7434
File: apps/dashboard/src/app/(app)/team/~/~/contract/[chain]/[contractAddress]/components/project-selector.tsx:62-76
Timestamp: 2025-06-24T21:38:03.155Z
Learning: In the project-selector.tsx component for contract imports, the addToProject.mutate() call is intentionally not awaited (fire-and-forget pattern) to allow immediate navigation to the contract page while the import happens in the background. This is a deliberate design choice to prioritize user experience.

Applied to files:

  • apps/dashboard/src/@/components/contracts/import-contract/modal.tsx
⏰ 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). (7)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)

Comment on lines 233 to 241
<Button className="gap-2" type="submit">
{addContractToProject.isPending ? (
{form.formState.isSubmitting ? (
<Spinner className="size-4" />
) : (
<ArrowDownToLineIcon className="size-4" />
)}

{addContractToProject.isPending ? "Importing" : "Import"}
{form.formState.isSubmitting ? "Importing" : "Import"}
</Button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Loading state regresses: formState.isSubmitting ends before the mutation finishes (spinner can stop while import still runs).

Because addContractToProject.mutate is fire-and-forget, RHF flips isSubmitting to false as soon as onSubmit returns, while the mutation remains in-flight. This can show “Import” with no spinner during the import and also allow rapid re-submits. Combine both states and disable the button to prevent double-submits. (Used retrieved learning about the deliberate non-awaited pattern for contract imports.)

Apply this diff:

-            <Button className="gap-2" type="submit">
-              {form.formState.isSubmitting ? (
+            <Button
+              className="gap-2"
+              type="submit"
+              disabled={form.formState.isSubmitting || addContractToProject.isPending}
+              aria-busy={form.formState.isSubmitting || addContractToProject.isPending}
+            >
+              {form.formState.isSubmitting || addContractToProject.isPending ? (
                 <Spinner className="size-4" />
               ) : (
                 <ArrowDownToLineIcon className="size-4" />
               )}
 
-              {form.formState.isSubmitting ? "Importing" : "Import"}
+              {(form.formState.isSubmitting || addContractToProject.isPending) ? "Importing" : "Import"}
             </Button>

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/dashboard/src/@/components/contracts/import-contract/modal.tsx around
lines 233 to 241, the submit button currently relies only on
form.formState.isSubmitting which can become false before the
addContractToProject mutation finishes; update the button to derive a single
loading state (e.g. const loading = form.formState.isSubmitting ||
addContractToProject.isLoading), use loading to choose between Spinner vs Icon
and "Importing" vs "Import", and set the Button disabled when loading to prevent
double-submits.

@graphite-app

graphite-app Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Merge activity

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the conditional rendering logic in the `modal.tsx` file to use the `form.formState.isSubmitting` state instead of `addContractToProject.isPending`. This change ensures that the button reflects the correct submission state during the import process.

### Detailed summary
- Changed the conditional check for displaying the loading spinner from `addContractToProject.isPending` to `form.formState.isSubmitting`.
- Updated the button text from "Importing" to reflect the new state condition.

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

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Import Contract modal: The submit button now accurately reflects the submission state. It shows a spinner and the label changes to “Importing” while the form is submitting, and reverts to the standard icon with “Import” when idle. This improves user feedback, reduces confusion, and helps prevent duplicate submissions by clearly indicating when an import is in progress.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app Bot force-pushed the 09-03-dashboard_fix_import_contract_modal_submit_button_loading_state branch from 7a79585 to 18b7f91 Compare September 3, 2025 20:15
@vercel vercel Bot temporarily deployed to Preview – nebula September 3, 2025 20:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – wallet-ui September 3, 2025 20:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – thirdweb_playground September 3, 2025 20:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs-v2 September 3, 2025 20:15 Inactive
@graphite-app graphite-app Bot merged commit 18b7f91 into main Sep 3, 2025
24 checks passed
@graphite-app graphite-app Bot deleted the 09-03-dashboard_fix_import_contract_modal_submit_button_loading_state branch September 3, 2025 20:25
@vercel vercel Bot temporarily deployed to Production – nebula September 3, 2025 20:25 Inactive
@vercel vercel Bot temporarily deployed to Production – wallet-ui September 3, 2025 20:25 Inactive
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.

2 participants