Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented May 29, 2025

Summary by CodeRabbit

  • New Features

    • Added support for Chinese (zh) locale in the search functionality, allowing users to search and view results in Chinese.
  • Bug Fixes

    • Improved search filtering to better handle language-specific results based on the user's current language.
  • Refactor

    • Enhanced the search component to dynamically adapt to the selected language and optimize performance.
  • Chores

    • Expanded the set of recognized falsy values to include undefined.

@JounQin JounQin self-assigned this May 29, 2025
Copilot AI review requested due to automatic review settings May 29, 2025 14:09
@JounQin JounQin added the bug Something isn't working label May 29, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 29, 2025

🦋 Changeset detected

Latest commit: 420ebcb

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

This PR includes changesets to release 1 package
Name Type
@alauda/doom 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 May 29, 2025

Walkthrough

The changes introduce Chinese (zh) locale support for Algolia search by updating the Search component to use React hooks for dynamic language handling and by passing locale-specific parameters. Additionally, the set of recognized falsy values is expanded to include undefined.

Changes

File(s) Change Summary
.changeset/healthy-shirts-wink.md Adds a patch note describing the new Chinese locale support for Algolia search.
src/shared/constants.ts Updates FALSY_VALUES to include undefined as a recognized falsy value.
src/theme.tsx Refactors Search to use hooks for language detection, memoizes Algolia props, and adds zh locale support.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Search
    participant useLang
    participant AlgoliaSearch

    User->>Search: Render Search component
    Search->>useLang: Get current language
    Search->>Search: Memoize Algolia props with language filter
    Search->>AlgoliaSearch: Render with dynamic props (including zh locale)
Loading

Possibly related PRs

  • feat: add algolia search support #34: Extends Algolia search with initial integration and conditional rendering, which is further enhanced here with locale support and dynamic language-based filtering.

Suggested labels

enhancement, feature

Poem

In the land of code where changes bloom,
A rabbit hops with search in zoom—
Now Chinese queries join the dance,
With hooks and filters to enhance.
Falsy values grow, undefined’s in view,
Algolia now speaks Mandarin too!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 037496a and 420ebcb.

📒 Files selected for processing (3)
  • .changeset/healthy-shirts-wink.md (1 hunks)
  • src/shared/constants.ts (1 hunks)
  • src/theme.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/theme.tsx (1)
src/runtime/hooks/useTranslation.ts (1)
  • useLang (7-7)
🪛 ESLint
src/theme.tsx

[error] 1-1: Unable to resolve path to module '@rspress/core/runtime'.

(import-x/no-unresolved)


[error] 2-2: Unable to resolve path to module '@rspress/core/theme'.

(import-x/no-unresolved)


[error] 6-6: Unable to resolve path to module '@rspress/plugin-algolia/runtime'.

(import-x/no-unresolved)


[error] 7-7: Unable to resolve path to module 'react'.

(import-x/no-unresolved)

🔇 Additional comments (5)
src/shared/constants.ts (1)

5-5: Good consistency improvement!

Adding undefined to FALSY_VALUES makes it consistent with JS_STR_FALSY_VALUES and provides more complete falsy value handling.

src/theme.tsx (3)

1-7: LGTM! Good imports for the new functionality.

The imports correctly bring in the necessary hooks and components for language-aware Algolia search.

🧰 Tools
🪛 ESLint

[error] 1-1: Unable to resolve path to module '@rspress/core/runtime'.

(import-x/no-unresolved)


[error] 2-2: Unable to resolve path to module '@rspress/core/theme'.

(import-x/no-unresolved)


[error] 6-6: Unable to resolve path to module '@rspress/plugin-algolia/runtime'.

(import-x/no-unresolved)


[error] 7-7: Unable to resolve path to module 'react'.

(import-x/no-unresolved)


13-29: Excellent implementation of language-aware search filtering!

The refactoring successfully transforms the component to support Chinese locale filtering. Key improvements:

  1. Dependency array fixed: The past review comment about adding lang to the useMemo dependency array has been properly addressed
  2. Language filtering: Uses facetFilters: [language:${lang}] to filter search results by current language
  3. Chinese localization: Passes ZH_LOCALES to support Chinese locale
  4. Performance: Proper use of useMemo to avoid unnecessary re-renders

1-36:

Details

✅ Verification successful

Static analysis import errors are likely false positives.

The ESLint errors about unresolved module paths for @rspress/* packages and react are typical in monorepo setups where these are peer dependencies or workspace dependencies.

Verify the imports resolve correctly in the actual build environment:


🏁 Script executed:

#!/bin/bash
# Description: Check if the imported modules exist and are properly installed

# Check if the rspress packages are installed
fd -t f "package.json" --exec grep -l "@rspress" {} \;

# Check for the specific modules being imported
rg -l "useLang|AlgoliaSearch|ZH_LOCALES" --type ts --type tsx

Length of output: 162


To get definitive answers on whether those imports truly resolve, let’s broaden the search and also confirm in package.json:


🏁 Script executed:

#!/bin/bash
# 1. Check rspress and react entries in package.json
rg '"@rspress/core"' -n package.json || echo "No @rspress/core dependency found"
rg '"@rspress/plugin-algolia"' -n package.json || echo "No @rspress/plugin-algolia dependency found"
rg '"react"' -n package.json          || echo "No react dependency found"

# 2. Locate all occurrences of the imported symbols across .ts/.tsx files
rg -l -g '*.ts' -g '*.tsx' 'useLang'
rg -l -g '*.ts' -g '*.tsx' 'OriginalSearch'
rg -l -g '*.ts' -g '*.tsx' 'AlgoliaSearch'
rg -l -g '*.ts' -g '*.tsx' 'ZH_LOCALES'

Length of output: 731


Static analysis import errors are false positives – imports resolve correctly.

  • package.json declares
    • "@rspress/core": "2.0.0-beta.8"
    • "@rspress/plugin-algolia": "2.0.0-beta.8"
  • The symbols useLang, OriginalSearch, AlgoliaSearch, and ZH_LOCALES all appear in the codebase.
  • React is provided as a workspace/peer dependency, so the missing "react" entry in this package’s manifest is expected.

No further action needed.

🧰 Tools
🪛 ESLint

[error] 1-1: Unable to resolve path to module '@rspress/core/runtime'.

(import-x/no-unresolved)


[error] 2-2: Unable to resolve path to module '@rspress/core/theme'.

(import-x/no-unresolved)


[error] 6-6: Unable to resolve path to module '@rspress/plugin-algolia/runtime'.

(import-x/no-unresolved)


[error] 7-7: Unable to resolve path to module 'react'.

(import-x/no-unresolved)


[error] 33-33: Unable to resolve path to module '@rspress/core/theme'.

(import-x/no-unresolved)

.changeset/healthy-shirts-wink.md (1)

1-6: Proper changeset documentation!

The changeset correctly documents the patch with a clear description that matches the PR objective of adding Chinese locale support for Algolia search.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

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

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

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the Chinese (zh) locale to the Algolia search functionality. Key changes include:

  • Passing the new ZH_LOCALES constant to the AlgoliaSearch component.
  • Using the useLang hook and memoizing search parameters to filter results by language.
  • Updating the FALSY_VALUES set to include undefined.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/theme.tsx Updated AlgoliaSearch component to include zh locale support and language filtering
src/shared/constants.ts Added "undefined" to the FALSY_VALUES set for improved value consistency

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 29, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@alauda/doom@39

commit: 420ebcb

@JounQin JounQin force-pushed the fix/algolia_locale branch from cc98abd to 420ebcb Compare May 29, 2025 14:11
@JounQin
Copy link
Member Author

JounQin commented May 29, 2025

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented May 29, 2025

✅ Actions performed

Full review triggered.

@JounQin JounQin merged commit cdc390e into main May 29, 2025
16 checks passed
@JounQin JounQin deleted the fix/algolia_locale branch May 29, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants