Skip to content

OK-38195, OK-38191, OK-38159: Add dApp results to universal search #7372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 22, 2025

Conversation

originalix
Copy link
Contributor

@originalix originalix commented May 21, 2025

Summary by CodeRabbit

  • New Features

    • Added support for searching decentralized applications (Dapps) in the universal search, including a dedicated Dapp tab and section in search results.
    • Users can now view and interact with Dapp search results, including quick access to Google search if no exact match is found.
    • Added a new keyboard shortcut for global search in the shortcuts preview.
  • Improvements

    • Enhanced search result presentation with section slicing and "show more" logic for better usability.
    • Centralized common constants for search-related features to improve consistency across the app.

Copy link

codesandbox bot commented May 21, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented May 21, 2025

Walkthrough

This update adds Dapp search support to the universal search feature. It introduces types, logic, and UI for Dapp search results. The update also centralizes some constants, adds a shortcut key for universal search, and ensures search results have bottom padding.

Changes

Files/Paths Change Summary
packages/kit-bg/src/services/ServiceUniversalSearch.ts Added Dapp search logic and integrated it into the universal search method.
packages/kit/src/views/UniversalSearch/pages/UniversalSearch.tsx Added Dapp search result section, rendering, tab, and asset styles. Added bottom spacer for search results.
packages/shared/types/search.ts Added Dapp to search types and related result interfaces.
packages/shared/src/consts/discovery.ts New module for shared Dapp-related constants and utility function.
packages/kit/src/views/Discovery/hooks/useSearchModalData.ts Switched to using shared constants for Dapp search item and logo.
packages/kit/src/views/Shortcuts/pages/ShortcutsPreview.tsx Added shortcut entry for universal search.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UniversalSearchPage
    participant ServiceUniversalSearch
    participant ServiceDiscovery

    User->>UniversalSearchPage: Enter search query
    UniversalSearchPage->>ServiceUniversalSearch: universalSearch({ types: [Dapp, ...], input })
    ServiceUniversalSearch->>ServiceDiscovery: searchDapp(input)
    ServiceDiscovery-->>ServiceUniversalSearch: Dapp results
    ServiceUniversalSearch-->>UniversalSearchPage: Aggregated search results (including Dapp)
    UniversalSearchPage->>User: Display Dapp search results in section
Loading

Assessment against linked issues

Objective Addressed Explanation
Add Dapp search type and logic to universal search (OK-38195)
Integrate Dapp search results into UI section list and add asset styles (OK-38195)
Show bottom padding for search results (OK-38191)
Add universal search shortcut key to shortcuts preview (OK-38159)

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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

@originalix originalix enabled auto-merge (squash) May 21, 2025 15:59
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: 7

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between c62cf4d and 4413390.

📒 Files selected for processing (6)
  • packages/kit-bg/src/services/ServiceUniversalSearch.ts (5 hunks)
  • packages/kit/src/views/Discovery/hooks/useSearchModalData.ts (1 hunks)
  • packages/kit/src/views/Shortcuts/pages/ShortcutsPreview.tsx (1 hunks)
  • packages/kit/src/views/UniversalSearch/pages/UniversalSearch.tsx (18 hunks)
  • packages/shared/src/consts/discovery.ts (1 hunks)
  • packages/shared/types/search.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/kit-bg/src/services/ServiceUniversalSearch.ts (3)
packages/shared/types/search.ts (1)
  • IUniversalSearchDappResult (57-59)
packages/kit-bg/src/apis/BackgroundApi.ts (1)
  • serviceDiscovery (281-289)
packages/shared/src/consts/discovery.ts (2)
  • SEARCH_ITEM_ID (1-1)
  • GOOGLE_LOGO_URL (2-3)
packages/shared/types/search.ts (1)
packages/shared/types/discovery.ts (1)
  • IDApp (51-68)
🔇 Additional comments (10)
packages/kit/src/views/Shortcuts/pages/ShortcutsPreview.tsx (1)

19-22: LGTM: Global search shortcut added correctly

The global search shortcut entry fits well with existing shortcuts pattern. Good placement in the global_general section.

packages/kit/src/views/Discovery/hooks/useSearchModalData.ts (1)

7-10: Good refactoring: Constants now centralized

Moving these constants to a shared location improves code maintainability. Constants are now imported instead of being defined locally.

packages/shared/src/consts/discovery.ts (1)

1-7: Well-structured constants file

Clean organization of discovery-related constants and utility function. The Google search item identification function adds clarity to code that checks for this special case.

packages/shared/types/search.ts (6)

3-3: Proper type import

Correct import of the IDApp type needed for the new Dapp search functionality.


11-11: Good enum extension

Clean addition of Dapp to the universal search types enum.


38-41: Well-defined type structure

The IUniversalSearchDapp type properly follows the established pattern of other search types.


46-47: Correct union type integration

Properly extended the union type to include the new Dapp search type.


57-59: Consistent result type definition

The IUniversalSearchDappResult type matches the pattern used by other search result types.


65-65: Complete batch result extension

Correctly added Dapp results to the batch result interface.

packages/kit/src/views/UniversalSearch/pages/UniversalSearch.tsx (1)

31-32:

✅ Verification successful

Double-check isGoogleSearchItem export

The helper is imported from @onekeyhq/shared/src/consts/discovery, but the shared snippet only shows constants.
If the function isn’t actually exported, the build will fail.


🏁 Script executed:

#!/bin/bash
# Confirm the symbol exists in the expected module
rg --json "export .*isGoogleSearchItem" | jq -r '.data.path'

Length of output: 233


All good: isGoogleSearchItem is exported
I found three export statements for isGoogleSearchItem in packages/shared/src/consts/discovery.ts. Your import is valid—no changes needed.

@originalix originalix merged commit d81ae89 into x May 22, 2025
11 checks passed
@originalix originalix deleted the fix/search-v1 branch May 22, 2025 02:39
originalix added a commit that referenced this pull request May 22, 2025
…7372)

* fix: Add footer components for UniversalSearchList

* feat: Enhance UniversalSearch with section footer and data slicing functionality

* feat: Add UniversalSearch shortcut to ShortcutsPreview for improved accessibility

* feat: Add Dapp search functionality to UniversalSearch, enhancing search capabilities with new result type and rendering logic

* feat: Integrate DiscoveryBrowserProviderMirror into UniversalSearch for enhanced website handling

* feat: Refactor search modal data handling by centralizing constants and improving Google search item logic

* refactor: Remove console logs and clean up renderSectionFooter in UniversalSearch for improved code clarity
originalix added a commit that referenced this pull request May 22, 2025
…7372)

* fix: Add footer components for UniversalSearchList

* feat: Enhance UniversalSearch with section footer and data slicing functionality

* feat: Add UniversalSearch shortcut to ShortcutsPreview for improved accessibility

* feat: Add Dapp search functionality to UniversalSearch, enhancing search capabilities with new result type and rendering logic

* feat: Integrate DiscoveryBrowserProviderMirror into UniversalSearch for enhanced website handling

* feat: Refactor search modal data handling by centralizing constants and improving Google search item logic

* refactor: Remove console logs and clean up renderSectionFooter in UniversalSearch for improved code clarity
originalix added a commit that referenced this pull request May 22, 2025
…7372)

* fix: Add footer components for UniversalSearchList

* feat: Enhance UniversalSearch with section footer and data slicing functionality

* feat: Add UniversalSearch shortcut to ShortcutsPreview for improved accessibility

* feat: Add Dapp search functionality to UniversalSearch, enhancing search capabilities with new result type and rendering logic

* feat: Integrate DiscoveryBrowserProviderMirror into UniversalSearch for enhanced website handling

* feat: Refactor search modal data handling by centralizing constants and improving Google search item logic

* refactor: Remove console logs and clean up renderSectionFooter in UniversalSearch for improved code clarity
originalix added a commit that referenced this pull request May 23, 2025
* fix: Add footer components for UniversalSearchList

* feat: Enhance UniversalSearch with section footer and data slicing functionality

* feat: Add Dapp search functionality to UniversalSearch, enhancing search capabilities with new result type and rendering logic

* feat: Integrate DiscoveryBrowserProviderMirror into UniversalSearch for enhanced website handling

* feat: Refactor search modal data handling by centralizing constants and improving Google search item logic

* refactor: Remove console logs and clean up renderSectionFooter in UniversalSearch for improved code clarity

* feat: Add "Show More" functionality to section footer in UniversalSearch for improved user interaction

* OK-38195, OK-38191, OK-38159: Add dApp results to universal search (#7372)

* fix: Add footer components for UniversalSearchList

* feat: Enhance UniversalSearch with section footer and data slicing functionality

* feat: Add UniversalSearch shortcut to ShortcutsPreview for improved accessibility

* feat: Add Dapp search functionality to UniversalSearch, enhancing search capabilities with new result type and rendering logic

* feat: Integrate DiscoveryBrowserProviderMirror into UniversalSearch for enhanced website handling

* feat: Refactor search modal data handling by centralizing constants and improving Google search item logic

* refactor: Remove console logs and clean up renderSectionFooter in UniversalSearch for improved code clarity

* fix: Add footer components for UniversalSearchList

* feat: Enhance UniversalSearch with section footer and data slicing functionality

* feat: Add Dapp search functionality to UniversalSearch, enhancing search capabilities with new result type and rendering logic

* feat: Refactor search modal data handling by centralizing constants and improving Google search item logic

* feat: Enhance UniversalSearch with account avatar rendering and improved address validation logic

* feat: switch to select account

* feat: Add accountsValue

* feat: Introduce UniversalSearchDappItem component for improved Dapp rendering in UniversalSearch

* feat: Refactor UniversalSearchDappItem to use getSearchInput and streamline website handling logic

* feat: Add UniversalSearchAccountAssetItem component for rendering account asset details in UniversalSearch

* feat: Add UniversalSearchMarketTokenItem component for rendering market token details in UniversalSearch

* feat: Add UniversalSearchAddressItem component for rendering address details in UniversalSearch

* feat: Refactor UniversalSearchAddressItem to improve account value rendering and address shortening logic
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.

3 participants