Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Sep 17, 2025


PR-Codex overview

This PR enhances the ImportEngineButton component by introducing a dialog for importing engine instances. It improves state management, updates the UI layout, and modifies the form submission process.

Detailed summary

  • Added useState to manage dialog open state.
  • Changed routing from push to refresh after import.
  • Updated dialog structure and styling.
  • Improved link for setup guidance.
  • Enhanced input fields with consistent background styling.
  • Removed DialogFooter and replaced with a styled div.

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

Summary by CodeRabbit

  • New Features

    • Import dialog now closes automatically after a successful import and refreshes the current page.
    • Prefilled import URL still respected on open.
    • Updated “Get started” / “Get help” link destination.
  • Style

    • Redesigned import dialog with improved layout, spacing, rounded content, and a bottom action bar; inputs use card-style appearance.
    • Added a visible warning beneath the URL field and refined labels/placeholders and header padding.

@vercel
Copy link

vercel bot commented Sep 17, 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 17, 2025 4:07pm
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Sep 17, 2025 4:07pm
nebula Skipped Skipped Sep 17, 2025 4:07pm
thirdweb_playground Skipped Skipped Sep 17, 2025 4:07pm
wallet-ui Skipped Skipped Sep 17, 2025 4:07pm

@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2025

⚠️ No Changeset found

Latest commit: 552f702

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 – wallet-ui September 17, 2025 14:31 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground September 17, 2025 14:32 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 September 17, 2025 14:32 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula September 17, 2025 14:32 Inactive
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 17, 2025

Walkthrough

Refactors the ImportEngine dialog to a controlled component using isOpen/onOpenChange, restructures dialog layout and styling, adds a URL warning area, updates the Get Started link, and changes post-import behavior to close the dialog and call router.refresh(). No public API changes.

Changes

Cohort / File(s) Summary
Import Engine Dialog refactor
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
Adds useState for isOpen and converts Dialog to controlled (open={isOpen}/onOpenChange), removes DialogTrigger/DialogFooter, restructures DialogContent/DialogHeader/spacing, styles inputs with bg-card, adds URL warning area with CircleAlertIcon, updates Get Started/Get Help URL and surrounding layout, moves submit into a bottom bar, switches success handling from router.push to router.refresh() and closes dialog via setIsOpen(false), preserves prefillImportUrl.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant B as ImportEngineButton
  participant D as ControlledDialog
  participant F as ImportForm
  participant S as ImportService
  participant R as Router

  U->>B: Click "Import engine"
  B->>D: setIsOpen(true)
  D-->>U: Dialog opens

  U->>F: Fill fields and Submit
  F->>S: call import(...)
  S-->>F: success
  F->>B: signal success
  B->>D: setIsOpen(false)
  B->>R: router.refresh()

  note over F,S: on error -> dialog stays open for correction
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR includes a useful PR-Codex overview summarizing the changes, but the repository's required template fields were left as the original placeholders; the formatted PR title/issue tag, "Notes for the reviewer", and "How to test" sections are not filled out. Because those template sections are required by the repo template and are currently missing or incomplete, the description does not satisfy the template requirements. This prevents a full review of testing steps and reviewer guidance. Please complete the repository PR template: add the formatted PR title or issue tag at the top, populate "Notes for the reviewer" with any important context or decisions, and provide a "How to test" section containing explicit reproduction and verification steps (unit/playground steps, expected outcomes, and any required credentials or setup). After those sections are filled the description should meet the repository's template requirements and be ready for review.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Dashboard: Fix Import Engine form submit not working" concisely and accurately describes the primary change — fixing the import engine form submit and related dialog behavior — and maps to the ImportEngineButton updates in the changeset. It is specific, relevant to the code changes, and clear for a reviewer scanning history. The phrasing avoids unnecessary noise and highlights the main fix.
✨ 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-17-dashboard_fix_import_engine_form_submit_not_working

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.

Comment @coderabbitai help to get the list of available commands and usage tips.

@MananTank MananTank marked this pull request as ready for review September 17, 2025 14:32
@MananTank MananTank requested review from a team as code owners September 17, 2025 14:32
@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Sep 17, 2025
Copy link
Member 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
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8064   +/-   ##
=======================================
  Coverage   56.53%   56.53%           
=======================================
  Files         904      904           
  Lines       58873    58873           
  Branches     4165     4165           
=======================================
  Hits        33283    33283           
  Misses      25484    25484           
  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 17, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.96 KB (0%) 1.3 s (0%) 590 ms (+126.55% 🔺) 1.9 s
thirdweb (cjs) 361.44 KB (0%) 7.3 s (0%) 2.5 s (-2.65% 🔽) 9.8 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 105 ms (+553.56% 🔺) 219 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 63 ms (+986.13% 🔺) 73 ms
thirdweb/react (minimal + tree-shaking) 19.14 KB (-0.01% 🔽) 383 ms (-0.01% 🔽) 92 ms (+680.69% 🔺) 475 ms

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

Caution

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

⚠️ Outside diff range comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (1)

44-48: Add explicit return types (guideline).

Make component and async util explicit.

-async function importEngine({
+async function importEngine({
   teamIdOrSlug,
   ...data
-}: ImportEngineParams & { teamIdOrSlug: string }) {
+}: ImportEngineParams & { teamIdOrSlug: string }): Promise<void> {
-export function ImportEngineButton(props: {
+export function ImportEngineButton(props: {
   prefillImportUrl: string | undefined;
   teamSlug: string;
   projectSlug: string;
-}) {
+}): JSX.Element {

Also applies to: 68-72

🧹 Nitpick comments (6)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (6)

75-81: Prefer defaultValues to avoid unintended controlled resets.

Using values can reset on re-renders; defaultValues is sufficient here.

-  const form = useForm<ImportEngineParams>({
-    resolver: zodResolver(formSchema),
-    values: {
+  const form = useForm<ImportEngineParams>({
+    resolver: zodResolver(formSchema),
+    defaultValues: {
       name: "",
       url: props.prefillImportUrl || "",
     },
   });

37-40: Tighten validation (trim + enforce http/https).

Prevents whitespace and non-web schemes.

-const formSchema = z.object({
-  name: z.string().min(1, "Name is required"),
-  url: z.string().url("Please enter a valid URL").min(1, "URL is required"),
-});
+const formSchema = z.object({
+  name: z.string().trim().min(1, "Name is required"),
+  url: z
+    .string()
+    .trim()
+    .url("Please enter a valid URL")
+    .refine((v) => /^https?:\/\//i.test(v), "URL must start with http:// or https://")
+    .min(1, "URL is required"),
+});

48-55: Trailing slash logic breaks URLs with query/hash. Use URL API.

Current concatenation can produce ...?x=1/. Safer to adjust pathname.

-  // Instance URLs should end with a /.
-  const url = data.url.endsWith("/") ? data.url : `${data.url}/`;
+  // Ensure trailing slash on pathname without breaking query/hash.
+  const u = new URL(data.url);
+  if (!u.pathname.endsWith("/")) {
+    u.pathname = `${u.pathname}/`;
+  }
+  const url = u.toString();

96-103: Provide a fallback message on unknown errors.

Avoid empty toasts.

-      const message = e instanceof Error ? e.message : undefined;
+      const message =
+        e instanceof Error && e.message ? e.message : "Unknown error";

107-117: Optional: drop DialogTrigger when using controlled open.

Simplifies state; open via button click.

-    <Dialog open={isOpen} onOpenChange={setIsOpen}>
-      <DialogTrigger asChild>
-        <Button
-          className="gap-2 rounded-full bg-card"
-          size="sm"
-          variant="outline"
-        >
-          <ArrowDownToLineIcon className="size-3.5" />
-          Import Engine
-        </Button>
-      </DialogTrigger>
+    <Dialog open={isOpen} onOpenChange={setIsOpen}>
+      <Button
+        className="gap-2 rounded-full bg-card"
+        size="sm"
+        variant="outline"
+        onClick={() => setIsOpen(true)}
+      >
+        <ArrowDownToLineIcon className="size-3.5" />
+        Import Engine
+      </Button>

Note: Remove DialogTrigger from the imports as well.


68-72: Optional: expose className per apps/dashboard guideline.

Pass through to the trigger button (lightweight, no extra wrapper).

-export function ImportEngineButton(props: {
+export function ImportEngineButton(props: {
   prefillImportUrl: string | undefined;
   teamSlug: string;
   projectSlug: string;
+  className?: string;
 }): JSX.Element {
-        <Button
-          className="gap-2 rounded-full bg-card"
+        <Button
+          className={cn("gap-2 rounded-full bg-card", props.className)}
           size="sm"
           variant="outline"
         >

Add import (outside the shown hunk):

import { cn } from "@/lib/utils";

Also applies to: 109-116

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • 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 15f0839 and d82ab78.

📒 Files selected for processing (1)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (7 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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
🧠 Learnings (4)
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to 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

Applied to files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
📚 Learning: 2025-06-18T04:30:04.326Z
Learnt from: jnsdls
PR: thirdweb-dev/js#7365
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectFTUX/ProjectFTUX.tsx:16-17
Timestamp: 2025-06-18T04:30:04.326Z
Learning: Next.js Link component fully supports both internal and external URLs and works appropriately with all standard anchor attributes including target="_blank", rel="noopener noreferrer", etc. Using Link for external URLs is completely appropriate and recommended.

Applied to files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
📚 Learning: 2025-06-18T04:27:16.172Z
Learnt from: jnsdls
PR: thirdweb-dev/js#7365
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectFTUX/ProjectFTUX.tsx:16-17
Timestamp: 2025-06-18T04:27:16.172Z
Learning: Next.js Link component supports external URLs without throwing errors. When used with absolute URLs (like https://...), it behaves like a regular anchor tag without client-side routing, but does not cause runtime crashes or errors as previously believed.

Applied to files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
📚 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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
🧬 Code graph analysis (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (2)
apps/playground-web/src/components/ui/dialog.tsx (6)
  • Dialog (112-112)
  • DialogTrigger (116-116)
  • DialogContent (117-117)
  • DialogHeader (118-118)
  • DialogTitle (120-120)
  • DialogDescription (121-121)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Link (44-62)
⏰ 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). (3)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (1)

83-88: Verify router.refresh() sufficiency.

Ensure the page derives engine list from server data so refresh reflects the import; otherwise consider invalidating relevant React Query keys instead.

Comment on lines 83 to 88
const importMutation = useMutation({
mutationFn: async (importParams: ImportEngineParams) => {
await importEngine({ ...importParams, teamIdOrSlug: props.teamSlug });
router.push(`/team/${props.teamSlug}/${props.projectSlug}/engine`);
router.refresh();
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Prevent duplicate submissions; disable UI while pending.

Multiple clicks can create duplicate imports. Guard submit and disable inputs/button during mutation.

-  const importMutation = useMutation({
+  const importMutation = useMutation({
     mutationFn: async (importParams: ImportEngineParams) => {
       await importEngine({ ...importParams, teamIdOrSlug: props.teamSlug });
       router.refresh();
     },
   });

-  const onSubmit = async (data: ImportEngineParams) => {
+  const onSubmit = async (data: ImportEngineParams) => {
+    if (importMutation.isPending) return;
     try {
       await importMutation.mutateAsync(data);
       toast.success("Engine imported successfully");
       setIsOpen(false);
     } catch (e) {
       const message = e instanceof Error ? e.message : undefined;
       toast.error(
         "Error importing Engine. Please check if the details are correct.",
         {
           description: message,
         },
       );
     }
   };
-                        <Input
+                        <Input
                           className="bg-card"
+                          disabled={importMutation.isPending}
                           autoFocus
                           placeholder="Enter a descriptive label"
                           {...field}
                         />
-                        <Input
+                        <Input
                           className="bg-card"
+                          disabled={importMutation.isPending}
                           placeholder="Enter your Engine URL"
                           type="url"
                           {...field}
                         />
-              <Button className="gap-2 rounded-full" type="submit">
+              <Button
+                className="gap-2 rounded-full"
+                type="submit"
+                disabled={importMutation.isPending}
+                aria-busy={importMutation.isPending}
+              >

Also applies to: 90-104, 148-153, 167-173, 187-196

🤖 Prompt for AI Agents
In
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
around lines 83-88 (and similarly for 90-104, 148-153, 167-173, 187-196): the
mutation allows multiple clicks causing duplicate imports; use the useMutation
status (isLoading/isPending) to guard submissions and disable the form controls
and submit button while the mutation is in flight. Update handlers to return
early if the mutation is already loading, await mutateAsync (or check isLoading)
to ensure a single in-flight request, and pass the mutation state to the UI so
inputs/buttons have disabled={isLoading} and show a loading indicator.

@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 17, 2025

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 introduces a dialog for importing engine instances in the `ImportEngineButton` component, enhancing user interaction by managing the dialog state and updating UI elements.

### Detailed summary
- Added `useState` to manage the dialog's open state.
- Changed navigation from `router.push` to `router.refresh` after import.
- Wrapped the dialog in a conditional open state.
- Updated the layout and styling of the dialog content and links.
- Modified form field styles for better UI consistency.

> ✨ 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

* New Features
  * Import dialog now closes automatically after a successful import and refreshes the current page.
  * Added an in-dialog warning beneath the URL field for clearer guidance.
  * Updated “Get started” link destination.

* Style
  * Redesigned import dialog with improved layout, spacing, rounded content, and a bottom action bar; inputs use card styling.
  * Refined labels, placeholders, and header padding for clearer readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app bot force-pushed the 09-17-dashboard_fix_import_engine_form_submit_not_working branch from d82ab78 to 552f702 Compare September 17, 2025 15:58
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground September 17, 2025 15:58 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula September 17, 2025 15:58 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 September 17, 2025 15:58 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui September 17, 2025 15:58 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

Caution

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

⚠️ Outside diff range comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (1)

75-81: Use defaultValues instead of values to avoid unintended form resets

Passing a new object to useForm.values each render can reset user input on re-renders (e.g., while a mutation is pending). Switch to defaultValues and explicitly reset when the dialog opens.

-  const form = useForm<ImportEngineParams>({
-    resolver: zodResolver(formSchema),
-    values: {
-      name: "",
-      url: props.prefillImportUrl || "",
-    },
-  });
+  const form = useForm<ImportEngineParams>({
+    resolver: zodResolver(formSchema),
+    defaultValues: {
+      name: "",
+      url: props.prefillImportUrl || "",
+    },
+  });
♻️ Duplicate comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (1)

90-104: Prevent duplicate submissions; disable UI while pending

Guard submit and disable inputs/button during the mutation. This avoids duplicate imports and improves a11y with aria-busy.

   const onSubmit = async (data: ImportEngineParams) => {
+    if (importMutation.isPending) return;
     try {
       await importMutation.mutateAsync(data);
       toast.success("Engine imported successfully");
       setIsOpen(false);
-                        <Input
+                        <Input
                           className="bg-card"
+                          disabled={importMutation.isPending}
                           autoFocus
                           placeholder="Enter a descriptive label"
                           {...field}
                         />
-                        <Input
+                        <Input
                           className="bg-card"
+                          disabled={importMutation.isPending}
                           placeholder="Enter your Engine URL"
                           type="url"
                           {...field}
                         />
-              <Button className="gap-2 rounded-full" type="submit">
+              <Button
+                className="gap-2 rounded-full"
+                type="submit"
+                disabled={importMutation.isPending}
+                aria-busy={importMutation.isPending}
+              >

Also applies to: 148-153, 168-172, 188-195

🧹 Nitpick comments (4)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (4)

107-108: Reset form when opening the dialog to honor prefill and start clean

Resetting on open ensures prefillImportUrl is applied and stale input isn’t carried over between sessions.

-    <Dialog open={isOpen} onOpenChange={setIsOpen}>
+    <Dialog
+      open={isOpen}
+      onOpenChange={(open) => {
+        setIsOpen(open);
+        if (open) {
+          form.reset({ name: "", url: props.prefillImportUrl || "" });
+        }
+      }}
+    >

44-66: Add explicit return types and type the mutation for stronger TS guarantees

Conforms to repo guidelines and improves DX.

-async function importEngine({
+async function importEngine({
   teamIdOrSlug,
   ...data
-}: ImportEngineParams & { teamIdOrSlug: string }) {
+}: ImportEngineParams & { teamIdOrSlug: string }): Promise<void> {
-export function ImportEngineButton(props: {
+export function ImportEngineButton(props: {
   prefillImportUrl: string | undefined;
   teamSlug: string;
   projectSlug: string;
-}) {
+}): JSX.Element {
-  const importMutation = useMutation({
+  const importMutation = useMutation<void, Error, ImportEngineParams>({
     mutationFn: async (importParams: ImportEngineParams) => {
       await importEngine({ ...importParams, teamIdOrSlug: props.teamSlug });
       router.refresh();
     },
   });
-  const onSubmit = async (data: ImportEngineParams) => {
+  const onSubmit = async (data: ImportEngineParams): Promise<void> => {

Also applies to: 68-72, 83-88, 90-90


68-72: Expose className on the component root (apps/ guideline)*

Allow styling from callers by forwarding a className to the root wrapper.

-export function ImportEngineButton(props: {
+export function ImportEngineButton(props: {
   prefillImportUrl: string | undefined;
   teamSlug: string;
   projectSlug: string;
-}) {
+  className?: string;
+}) {
-  return (
-    <Dialog
+  return (
+    <div className={cn(props.className)}>
+      <Dialog
         open={isOpen}
         onOpenChange={(open) => {
           setIsOpen(open);
           if (open) {
             form.reset({ name: "", url: props.prefillImportUrl || "" });
           }
         }}
       >
         ...
-      </Dialog>
-    </Dialog>
+      </Dialog>
+    </div>

Additional change (outside selected ranges): add cn import at top.

import { cn } from "@/lib/utils";

Also applies to: 106-201


37-40: Trim inputs in schema to avoid whitespace-only values

Prevents " " passing min(1) and normalizes url/name.

-const formSchema = z.object({
-  name: z.string().min(1, "Name is required"),
-  url: z.string().url("Please enter a valid URL").min(1, "URL is required"),
-});
+const formSchema = z.object({
+  name: z.string().trim().min(1, "Name is required"),
+  url: z.string().trim().url("Please enter a valid URL").min(1, "URL is required"),
+});
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • 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 d82ab78 and 552f702.

📒 Files selected for processing (1)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (7 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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
🧠 Learnings (3)
📚 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/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
📚 Learning: 2025-06-18T04:27:16.172Z
Learnt from: jnsdls
PR: thirdweb-dev/js#7365
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectFTUX/ProjectFTUX.tsx:16-17
Timestamp: 2025-06-18T04:27:16.172Z
Learning: Next.js Link component supports external URLs without throwing errors. When used with absolute URLs (like https://...), it behaves like a regular anchor tag without client-side routing, but does not cause runtime crashes or errors as previously believed.

Applied to files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx
📚 Learning: 2025-06-18T04:30:04.326Z
Learnt from: jnsdls
PR: thirdweb-dev/js#7365
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectFTUX/ProjectFTUX.tsx:16-17
Timestamp: 2025-06-18T04:30:04.326Z
Learning: Next.js Link component fully supports both internal and external URLs and works appropriately with all standard anchor attributes including target="_blank", rel="noopener noreferrer", etc. Using Link for external URLs is completely appropriate and recommended.

Applied to files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.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). (5)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx (2)

86-87: LGTM: router.refresh + closing dialog on success

Post‑import refresh and explicit close align with the PR goals and improve UX.

Also applies to: 94-94


107-118: LGTM: Controlled Dialog conversion and layout cleanup

Controlled open/onOpenChange, trigger-as-child, and content structure look consistent with our UI primitives.

Also applies to: 119-121

@graphite-app graphite-app bot merged commit 552f702 into main Sep 17, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 09-17-dashboard_fix_import_engine_form_submit_not_working branch September 17, 2025 16:07
@vercel vercel bot temporarily deployed to Production – thirdweb_playground September 17, 2025 16:07 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.

3 participants