Skip to content

Conversation

@kingston
Copy link
Collaborator

@kingston kingston commented Jul 25, 2025

Summary by CodeRabbit

  • New Features

    • Loader component now includes a customizable delay (default 300ms) before showing the loading animation to prevent flashing on quick operations.
  • Tests

    • Added tests verifying the Loader's delayed visibility, class name application, and timer cleanup.

@changeset-bot
Copy link

changeset-bot bot commented Jul 25, 2025

🦋 Changeset detected

Latest commit: 1e577ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@baseplate-dev/react-generators Patch
@baseplate-dev/ui-components Patch
@baseplate-dev/project-builder-server Patch
@baseplate-dev/plugin-auth Patch
@baseplate-dev/plugin-storage Patch
@baseplate-dev/project-builder-lib Patch
@baseplate-dev/project-builder-web Patch
@baseplate-dev/project-builder-cli Patch
@baseplate-dev/project-builder-common Patch
@baseplate-dev/project-builder-test Patch
@baseplate-dev/code-morph Patch
@baseplate-dev/core-generators Patch
@baseplate-dev/create-project Patch
@baseplate-dev/fastify-generators Patch
@baseplate-dev/sync Patch
@baseplate-dev/tools Patch
@baseplate-dev/utils Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

A 300ms delay feature was added to the Loader component in both @baseplate-dev/react-generators and @baseplate-dev/ui-components packages. The Loader now accepts an optional delay prop, defaults to 300ms, and only displays the loading animation after this delay. Corresponding unit tests were introduced to verify the new behavior. Additionally, a test verifying loader display during version info fetching was removed from the project-builder-web package.

Changes

File(s) Change Summary
packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx
packages/ui-components/src/components/ui/loader/loader.tsx
Loader component updated to support optional delay prop (default 300ms); uses state/effect to manage visibility.
packages/ui-components/src/components/ui/loader/loader.unit.test.tsx Added tests for Loader delay logic, className application, and timer cleanup.
packages/project-builder-web/src/app/client-version-provider/client-version-provider.test.tsx Removed test case verifying loader display while fetching version info.
.changeset/clever-signs-tickle.md Changeset documenting patch version updates for affected packages.

Sequence Diagram(s)

sequenceDiagram
    participant Parent as Parent Component
    participant Loader as Loader
    Note over Loader: Receives optional delay prop (default 300ms)
    Parent->>Loader: Mounts Loader
    Loader->>Loader: Sets isVisible = false
    Loader->>Loader: Starts timer for delay
    Note over Loader: Renders empty container
    Loader->>Loader: After delay, sets isVisible = true
    Note over Loader: Renders loading animation
    Parent-->>Loader: Unmounts Loader
    Loader->>Loader: Clears timer
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a34ad98 and 1e577ba.

📒 Files selected for processing (1)
  • packages/project-builder-web/src/app/client-version-provider/client-version-provider.test.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/project-builder-web/src/app/client-version-provider/client-version-provider.test.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). (1)
  • GitHub Check: Test E2E
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch eng-817-add-500ms-delay-to-loader-component

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

Documentation and Community

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

@vercel
Copy link

vercel bot commented Jul 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baseplate-project-builder-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 11:58am

Copy link

@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)
packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx (1)

6-6: Verify import order follows guidelines.

The React imports should be grouped together. Consider moving the useState and useEffect import to be grouped with the React type import.

 import type React from 'react';
+import { useEffect, useState } from 'react';
 
 import { cn } from '$cn';
-import { useEffect, useState } from 'react';
packages/ui-components/src/components/ui/loader/loader.unit.test.tsx (2)

1-3: Fix import sorting to follow coding guidelines.

The imports should be sorted according to the perfectionist rules: external libraries first, then properly ordered named imports.

-import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { render, screen } from '@testing-library/react';
-import { act } from '@testing-library/react';
+import { act, render, screen } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';

77-85: Fix global reference to use globalThis.

Use globalThis instead of global as recommended by the unicorn/prefer-global-this ESLint rule.

-    const clearTimeoutSpy = vi.spyOn(global, 'clearTimeout');
+    const clearTimeoutSpy = vi.spyOn(globalThis, 'clearTimeout');
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc6cd6c and d9c32e8.

📒 Files selected for processing (4)
  • .changeset/clever-signs-tickle.md (1 hunks)
  • packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx (1 hunks)
  • packages/ui-components/src/components/ui/loader/loader.tsx (1 hunks)
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
.changeset/*.md

📄 CodeRabbit Inference Engine (CLAUDE.md)

When adding a new feature or changing an existing feature, add a new Changeset in the .changeset/ directory in the specified markdown format.

Files:

  • .changeset/clever-signs-tickle.md
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{ts,tsx}: Import UI components from the @baseplate-dev/ui-components package as shown in the provided examples.
Use both standalone and React Hook Form controller variants for form components from @baseplate-dev/ui-components as appropriate.
If a particular interface or type is not exported, change the file so it is exported.

**/*.{ts,tsx}: TypeScript with strict type checking
Always include return types on top-level functions including React components (React.ReactElement)
Include absolute paths in import statements via tsconfig paths (@src/ is the alias for src/)
If a particular interface or type is not exported, change the file so it is exported

Files:

  • packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
**/*.tsx

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.tsx: When using form components, integrate them with React Hook Form by passing the control prop from useForm().
Use layout components such as SidebarLayout, Card, and Breadcrumb from @baseplate-dev/ui-components to structure pages as shown in the example.
Use interactive dialog components like Dialog, ConfirmDialog, and useConfirmDialog from @baseplate-dev/ui-components for modal interactions.

Files:

  • packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/code-style.mdc)

Node 16 module resolution - include file extensions in imports (.js)

Files:

  • packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
**/*.{ts,tsx,js}

📄 CodeRabbit Inference Engine (.cursor/rules/code-style.mdc)

**/*.{ts,tsx,js}: Sort imports by group: external libs first, then local imports
Use camelCase for variables/functions, PascalCase for types/classes
Order functions such that functions are placed below the variables/functions they use
We use the prefer using nullish coalescing operator (??) ESLint rule instead of a logical or (||), as it is a safer operator
Use console.info/warn/error instead of console.log

Files:

  • packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
**/*

📄 CodeRabbit Inference Engine (.cursor/rules/code-style.mdc)

Use kebab-case for file names

Files:

  • packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
{packages/project-builder-web/**,packages/ui-components/**}/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/ui-rules.mdc)

{packages/project-builder-web/**,packages/ui-components/**}/*.tsx: Use ShadCN-based components from @baseplate-dev/ui-components and always prefer these components over creating custom ones
Use Tailwind CSS utilities exclusively for styling; avoid writing custom CSS classes and use Tailwind's utility classes for all styling needs
In plugins, prefix all Tailwind classes with the plugin name (e.g., auth-, storage-)
Use icons from react-icons/md (Material Design icons) and import them like import { MdAdd, MdDelete } from 'react-icons/md'; avoid using other icon libraries

Files:

  • packages/ui-components/src/components/ui/loader/loader.tsx
  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
**/*.test.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/testing.mdc)

**/*.test.{ts,tsx}: Use descriptive test names that explain what is being tested
Structure tests with clear setup, execution, and verification phases (Arrange-Act-Assert)
Always mock external API calls and file system operations in tests
Each test should be independent and not rely on others
Leverage TypeScript for type-safe mocking in tests
Focus on testing public methods and behaviors, not implementation details
Each test should verify one specific behavior to keep tests simple
For file system operations in tests, use memfs and mock 'node:fs' and 'node:fs/promises'
When using globby in tests, pass the mocked fs adapter

Files:

  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
**/*.{test,test-helper}.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/testing.mdc)

Extract repeated logic into reusable helper functions

Files:

  • packages/ui-components/src/components/ui/loader/loader.unit.test.tsx
🪛 ESLint
packages/ui-components/src/components/ui/loader/loader.tsx

[error] 2-2: Missed spacing between "react" and "react".

(perfectionist/sort-imports)

packages/ui-components/src/components/ui/loader/loader.unit.test.tsx

[error] 1-1: Expected "expect" to come before "it".

(perfectionist/sort-named-imports)


[error] 1-1: Expected "beforeEach" to come before "vi".

(perfectionist/sort-named-imports)


[error] 2-2: Expected "@testing-library/react" to come before "vitest".

(perfectionist/sort-imports)


[error] 78-78: Prefer globalThis over global.

(unicorn/prefer-global-this)

⏰ 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: Lint
  • GitHub Check: test
  • GitHub Check: Test E2E
🔇 Additional comments (10)
packages/ui-components/src/components/ui/loader/loader.tsx (4)

8-8: LGTM: Delay prop addition is well-designed.

The optional delay prop with a sensible default of 300ms follows good API design principles.


15-26: LGTM: Timer implementation is correct and properly handles cleanup.

The useEffect implementation correctly:

  • Sets up the timer with the specified delay
  • Updates visibility state after delay
  • Cleans up the timer on unmount or delay change
  • Includes delay in the dependency array

This prevents memory leaks and ensures proper behavior when the delay prop changes.


28-34: LGTM: Empty container maintains layout consistency.

The initial empty container uses the same styling classes as the final loader, ensuring consistent layout and preventing layout shifts during the transition.


2-2: Fix import sorting to follow coding guidelines.

The React imports should be grouped together according to the ESLint perfectionist/sort-imports rule.

-import { useEffect, useState } from 'react';
+import { useEffect, useState } from 'react';

Actually, let me provide the correct fix by reordering the imports:

 import type React from 'react';
-import { useEffect, useState } from 'react';
+import { useEffect, useState } from 'react';

Wait, the imports are already correctly placed. The static analysis hint appears to be a false positive since the React imports are properly grouped together.

.changeset/clever-signs-tickle.md (1)

1-7: LGTM: Changeset follows proper format and versioning.

The changeset correctly:

  • Uses patch version increments for both affected packages
  • Provides a clear, descriptive title
  • Follows the standard changeset markdown format
packages/react-generators/src/generators/core/react-components/templates/components/ui/loader.tsx (1)

17-36: LGTM: Template implementation matches main component perfectly.

The delay functionality is implemented identically to the main component, ensuring consistency across generated code. The logic correctly handles:

  • Timer setup and cleanup
  • State management for visibility
  • Proper dependency tracking
packages/ui-components/src/components/ui/loader/loader.unit.test.tsx (4)

12-22: LGTM: Initial state test is thorough and correct.

The test properly verifies that:

  • The loader container is rendered initially
  • No progressbar role is present (indicating hidden state)
  • The container has no children (empty state)

This ensures the delay functionality starts in the correct hidden state.


24-41: LGTM: Default delay test covers the core functionality well.

The test correctly verifies:

  • Initial hidden state (no progressbar role)
  • Proper timing with fake timers
  • Visibility after 300ms delay
  • Correct DOM structure after becoming visible

43-64: LGTM: Custom delay test provides excellent edge case coverage.

The test validates custom delay values by:

  • Testing intermediate timing (400ms when delay is 500ms)
  • Confirming the loader remains hidden until full delay
  • Verifying visibility after exact delay period

This ensures the delay prop works correctly with any value.


77-85: LGTM: Timer cleanup test ensures no memory leaks.

This test is crucial for verifying that timers are properly cleaned up on component unmount, preventing memory leaks and unexpected behavior.

@kingston kingston merged commit 541db59 into main Jul 25, 2025
10 checks passed
@kingston kingston deleted the eng-817-add-500ms-delay-to-loader-component branch July 25, 2025 12:00
@github-actions github-actions bot mentioned this pull request Jul 25, 2025
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