Skip to content

chore: Citations loading optimization#38837

Merged
jsartisan merged 1 commit intoreleasefrom
chore/citation-loading-optimization
Jan 24, 2025
Merged

chore: Citations loading optimization#38837
jsartisan merged 1 commit intoreleasefrom
chore/citation-loading-optimization

Conversation

@jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Jan 24, 2025

/ok-to-test tags="@tag.Anvil"

Summary by CodeRabbit

  • New Features

    • Enhanced spinner component with dynamic size configuration
    • Improved type safety across multiple design system components
  • Bug Fixes

    • Refined size prop handling for various UI components
    • Updated type definitions to prevent invalid size selections
  • Refactor

    • Replaced Omit with Exclude for more precise type management
    • Updated component prop type definitions
    • Standardized size prop handling across design system widgets

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12947772391
Commit: 4043446
Cypress dashboard.
Tags: @tag.Anvil
Spec:


Fri, 24 Jan 2025 10:51:14 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Walkthrough

This pull request introduces a series of type-related modifications across multiple components in the design system. The primary change involves replacing Omit with Exclude for size property type definitions, enhancing type safety and precision in TypeScript type handling. Additionally, the Spinner component receives updates to its size prop and styling, and several components see improvements in type imports and filtering logic.

Changes

File Path Change Summary
Button/src/Button.tsx Added size prop to Spinner component
Button/src/types.ts Updated size type from Omit to Exclude
Spinner/src/index.tsx Introduced SpinnerProps with optional size prop
Spinner/src/styles.module.css Removed height and width properties from .spinner class
Multiple Component Type Files Replaced Omit<keyof typeof SIZES, ...> with Exclude<keyof typeof SIZES, ...>

Suggested labels

Enhancement, Task, skip-changelog, ok-to-test

Suggested reviewers

  • ichik
  • KelvinOm
  • ApekshaBhosale

Poem

🎨 Types dancing, sizes twirling light,
Exclude and Omit in TypeScript's might
Spinners spin with newfound grace
Code evolves at a playful pace!
Refactoring magic takes its flight 🚀

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

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

🧹 Nitpick comments (4)
app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx (1)

70-73: Type guard usage is well-implemented.
Using size is NonNullable<IconButtonProps["size"]> makes the filter logic safer, ensuring only valid size values pass through. Consider storing ["xSmall", "large"] in a constant array if these exclusions are reused elsewhere.

app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx (3)

79-83: Consistent approach
Repeating the size filter logic for mapping is consistent, but consider extracting this filtering logic into a small helper function for reusability.


91-95: Minor duplication
Again, the repetitive filter-mapping pattern for sizes suggests a DRY principle improvement opportunity.


103-107: DRY opportunity
Given the identical filter code, consider a reusable function or custom hook that returns the supported sizes for maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be2133e and 4043446.

📒 Files selected for processing (22)
  • app/client/packages/design-system/widgets/src/components/Button/src/Button.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Button/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/ComboBox/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Datepicker/src/DatepickerTrigger.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Datepicker/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Datepicker/stories/Datepicker.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx (4 hunks)
  • app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Input/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Modal/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/stories/Select.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Spinner/src/index.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Spinner/src/styles.module.css (0 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextField/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TimeField/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/packages/design-system/widgets/src/components/Spinner/src/styles.module.css
✅ Files skipped from review due to trivial changes (1)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx

[error] 36-36: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (27)
app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx (4)

1-1: LGTM! Good choice using clsx.

Using clsx for className management is a standard practice for conditional class handling in React.


11-11: Props destructuring looks good.

Clean destructuring with sensible defaults for size.


20-22: Type definition is properly handled.

Good type safety with optional className prop for the lazy-loaded component.


35-35: Consistent className handling in both render paths.

Good use of clsx to combine base styles with custom classNames.

Also applies to: 42-42

app/client/packages/design-system/widgets/src/components/Select/src/types.ts (1)

11-11: Refined type usage
Switching from Omit to Exclude provides clearer intent for removing specific keys from the type.

app/client/packages/design-system/widgets/src/components/TextField/src/types.ts (1)

9-9: Maintain type consistency
Replacing Omit with Exclude continues the trend towards more explicit type handling.

app/client/packages/design-system/widgets/src/components/TimeField/src/types.ts (1)

13-13: Refine type usage
The substitution of Omit with Exclude ensures consistent handling of omitted sizes.

app/client/packages/design-system/widgets/src/components/Spinner/src/index.tsx (3)

3-3: Spot-on import
Importing IconProps for direct reference is a neat approach for maintaining strongly typed props.


6-8: Clear and concise interface
Defining SpinnerProps with an Exclude ensures "large" is explicitly omitted, matching design constraints.


10-11: Sensible default
Defaulting the Spinner size to medium maintains uniform consistency across the design system.

app/client/packages/design-system/widgets/src/components/ComboBox/src/types.ts (1)

11-11: Use of Exclude is Appropriate for Union Types
Switching from Omit to Exclude correctly removes the specified keys from a union type. This change clarifies the intent and aligns with TypeScript best practices for union type manipulation.

app/client/packages/design-system/widgets/src/components/Datepicker/src/types.ts (1)

14-14: Consistent Type Definition Across Components
Applying Exclude here maintains consistency across the codebase. Removing "xSmall" and "large" with Exclude ensures the type precisely matches the intended valid sizes.

app/client/packages/design-system/widgets/src/components/Input/src/types.ts (1)

13-13: Appropriate Correction from Omit to Exclude
Using Exclude clarifies that you're removing the "xSmall" literal from a union, rather than omitting a property from an object type. This is a beneficial refactor.

app/client/packages/design-system/widgets/src/components/Button/src/types.ts (1)

43-43: Efficient Exclusion of "large" from Possible Sizes
The switch from Omit to Exclude cleanly removes the "large" key from the union, improving accuracy and readability of the button size type.

app/client/packages/design-system/widgets/src/components/Datepicker/src/DatepickerTrigger.tsx (1)

12-12: Use Exclude Instead of Omit

Switching from Omit to Exclude here improves precision for union types, ensuring unused sizes are skipped. This is consistent with the revised approach across the codebase.

app/client/packages/design-system/widgets/src/components/InlineButtons/src/types.ts (1)

37-37: Exclude "large" from size prop

Changing size from Omit<...> to Exclude<...> is a neat way to keep the union consistent while explicitly disallowing “large.” Looks good.

app/client/packages/design-system/widgets/src/components/Modal/src/types.ts (1)

22-22: Refine modal size type

Going from Omit to Exclude is a cleaner syntax for removing "xSmall" from the union, resulting in a clearer allowable sizes definition.

app/client/packages/design-system/widgets/src/components/ToolbarButtons/src/types.ts (1)

36-36: Consolidate size prop typing with Exclude

By excluding “large,” this aligns perfectly with the new type strategy, ensuring consistent usage of available sizes across components.

app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx (1)

9-9: Explicit type import is a good practice.
Importing IconButtonProps from @appsmith/wds clarifies the intent of the IconButton's permissible properties.

app/client/packages/design-system/widgets/src/components/Select/stories/Select.stories.tsx (1)

50-53: Type-safety improvement with a type predicate.
The use of (size): size is NonNullable<SelectProps["size"]> alongside the exclusion array helps maintain clarity and safety in the size handling.

app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx (1)

69-73: Consistent type exclusion approach.
Filtering out "xSmall" | "large" with the Exclude<keyof typeof SIZES, "xSmall" | "large"> predicate is consistent with the broader refactoring to safely define supported sizes. This is clean and readable.

app/client/packages/design-system/widgets/src/components/Datepicker/stories/Datepicker.stories.tsx (2)

7-7: Explicit type imports enhance clarity.
Importing DatePickerProps and DateValue clarifies which types are used for the DatePicker’s props, contributing to better type safety.


47-50: Robust size filtering.
Defining a type predicate inside .filter for valid DatePickerProps<DateValue>["size"]> ensures only the supported sizes are passed through, preventing accidental usage of excluded sizes.

app/client/packages/design-system/widgets/src/components/Button/src/Button.tsx (1)

60-60: Ensure type consistency for Spinner size
Passing the same size prop to the <Spinner> is consistent with the updated type definition for the button. However, confirm that the Spinner component expects the same size variants.

app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx (2)

3-3: Good import usage
Importing ButtonProps here explicitly increases type clarity for the filtering logic.


69-73: Filter logic aligns with type modifications
Excluding "large" from the size list matches the new Exclude<...,"large"> definition, ensuring consistent rendering of supported sizes.

app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx (1)

73-80: Type casting ensures consistency
Casting size as Exclude<keyof typeof SIZES, "large"> explicitly matches the updated type definition and avoids runtime confusion with unsupported sizes.

<FallbackIcon
className={styles.icon}
className={clsx(styles.icon, className)}
data-size={Boolean(size) ? size : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove redundant Boolean calls.

The Boolean calls are unnecessary as the values will be automatically coerced to boolean.

-          data-size={Boolean(size) ? size : undefined}
+          data-size={size || undefined}
-        data-size={Boolean(size) ? size : undefined}
+        data-size={size || undefined}

Also applies to: 45-45

🧰 Tools
🪛 Biome (1.9.4)

[error] 36-36: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

@jsartisan jsartisan added the ok-to-test Required label for CI label Jan 24, 2025
@jsartisan jsartisan changed the title update types chore: Citations loading optimization Jan 24, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 24, 2025
@jsartisan jsartisan merged commit cc6fafd into release Jan 24, 2025
51 checks passed
@jsartisan jsartisan deleted the chore/citation-loading-optimization branch January 24, 2025 10:53
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
/ok-to-test tags="@tag.Anvil"

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

## Summary by CodeRabbit

- **New Features**
	- Enhanced spinner component with dynamic size configuration
	- Improved type safety across multiple design system components

- **Bug Fixes**
	- Refined size prop handling for various UI components
	- Updated type definitions to prevent invalid size selections

- **Refactor**
	- Replaced `Omit` with `Exclude` for more precise type management
	- Updated component prop type definitions
	- Standardized size prop handling across design system widgets

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12947772391>
> Commit: 4043446
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12947772391&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> Spec:
> <hr>Fri, 24 Jan 2025 10:51:14 UTC
<!-- end of auto-generated comment: Cypress test results  -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants