Skip to content

Search scope refactor #405

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 4 commits into from
Jul 29, 2025
Merged

Search scope refactor #405

merged 4 commits into from
Jul 29, 2025

Conversation

msukkari
Copy link
Contributor

@msukkari msukkari commented Jul 28, 2025

  • Replaces demo card UI with search examples with search scope filters
  • Renames search context to search scopes
  • Adds search scopes to details card in chat message
  • Removes one search scope constraint in demo
image image image image

Summary by CodeRabbit

  • New Features

    • Added tooltips and info cards explaining search scopes and @ mentions.
    • Search scope selection now displays a count and detailed tooltip in chat details.
  • Refactor

    • Unified repository and context selection into a single "search scopes" system across chat and search features.
    • Updated all related UI components and toolbars to use the new search scope selector.
    • Simplified demo cards to use a single search scope filter.
  • Style

    • Improved iconography for search scopes and tooltips throughout the UI.
  • Documentation

    • Updated in-app explanations for search scopes and mention features.

@msukkari msukkari requested a review from brendan-kellam July 28, 2025 23:38

This comment has been minimized.

Copy link

coderabbitai bot commented Jul 28, 2025

Walkthrough

This change refactors the chat and search context selection system throughout the application. It unifies the previously separate handling of selected repositories and contexts into a single "selectedSearchScopes" array, updates all related types, schemas, and UI components, and introduces new informational components and icons to support the new model.

Changes

Cohort / File(s) Change Summary
Chat State & Panel Refactor
packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx,
packages/web/src/app/[domain]/chat/components/newChatPanel.tsx,
packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx
Refactored state management from separate selected items (repos/contexts) to unified selectedSearchScopes array; updated state initialization, effects, and prop passing accordingly.
Demo Cards & Homepage Filtering
packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx
Removed multi-selection/context logic; added single search scope filter; updated UI to reflect new selection and filtering model.
API and Backend Handler
packages/web/src/app/api/(server)/chat/route.ts
Replaced separate selectedRepos and selectedContexts with unified selectedSearchScopes parameter; updated expansion logic and handler signatures.
Chat Agent & System Prompt
packages/web/src/features/chat/agent.ts
Renamed all selectedRepos parameters to searchScopeRepoNames for clarity and consistency.
ChatBox & Toolbar Components
packages/web/src/features/chat/components/chatBox/chatBox.tsx,
packages/web/src/features/chat/components/chatBox/chatBoxToolbar.tsx
Refactored to use selectedSearchScopes instead of selectedItems; updated props, placeholder text, tooltips, and removed context-specific logic.
Search Scope Selector Component
packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx
Renamed and refactored from ContextSelector/ContextItem to SearchScopeSelector/SearchScope; updated logic, types, and icons.
Chat Thread & Details Card
packages/web/src/features/chat/components/chatThread/chatThread.tsx,
packages/web/src/features/chat/components/chatThread/detailsCard.tsx
Updated to use selectedSearchScopes throughout; details card now displays selected search scopes in a tooltip.
Search Scope Icon & Info Cards
packages/web/src/features/chat/components/searchScopeIcon.tsx,
packages/web/src/components/searchScopeInfoCard.tsx,
packages/web/src/components/atMentionInfoCard.tsx
Added new components for rendering search scope icons and informational cards for search scopes and @ mentions.
Chat Types & Schemas
packages/web/src/features/chat/types.ts
Introduced new Zod schemas and types for SearchScope, RepoSearchScope, and RepoSetSearchScope; updated message metadata and payload types to use unified selectedSearchScopes.
Chat Thread Creation Hook
packages/web/src/features/chat/useCreateNewChatThread.ts
Updated to use selectedSearchScopes in thread creation and URL state management.
Chat Utilities
packages/web/src/features/chat/utils.ts
Updated createUIMessage to use selectedSearchScopes parameter and metadata.
Demo Types & Schemas
packages/web/src/types.ts
Refactored demo search context types and schemas to use DemoSearchScope and searchScopes fields; removed obsolete context types.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Components
    participant API_Server
    participant Agent

    User->>UI_Components: Select one or more search scopes
    UI_Components->>API_Server: Send message with selectedSearchScopes[]
    API_Server->>Agent: Expand searchScopeRepoNames from selectedSearchScopes
    Agent-->>API_Server: Analyze and respond using provided repo names
    API_Server-->>UI_Components: Stream response with metadata (selectedSearchScopes)
    UI_Components-->>User: Display response, show selected search scopes in UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Possibly related PRs

Suggested labels

sourcebot-team

Suggested reviewers

  • brendan-kellam

Poem

In fields of code, a rabbit hops,
Through search scopes wide, it never stops.
Contexts and repos, now one array,
Bringing clarity to every day.
With icons and cards, the UI's bright—
Review these changes, they're a delight!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

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

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


📜 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 3b2dd51 and f0c8561.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
⏰ 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: build
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch msukkarieh/demo_card2

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

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

@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/web/src/components/searchScopeInfoCard.tsx (1)

17-30: Consider extracting the icon rendering logic for better readability.

The IIFE (Immediately Invoked Function Expression) works correctly but could be more readable as a separate function or component.

Consider extracting this logic:

const renderRepositoryIcon = () => {
  const githubIcon = getCodeHostIcon("github");
  return githubIcon ? (
    <Image
      src={githubIcon.src}
      alt="GitHub icon"
      width={16}
      height={16}
      className={cn("h-4 w-4 flex-shrink-0", githubIcon.className)}
    />
  ) : (
    <Code className="h-4 w-4 text-muted-foreground flex-shrink-0" />
  );
};

Then use: {renderRepositoryIcon()}

packages/web/src/features/chat/components/searchScopeIcon.tsx (1)

11-32: Well-implemented icon component with good fallback handling.

The component properly handles different search scope types and provides appropriate fallbacks. The logic flow is clear and the icon selection makes sense.

Consider making the size calculation more robust:

-            const size = className.includes('h-3') ? 12 : 16;
+            const size = className.match(/\bh-3\b/) ? 12 : 16;

This uses a word boundary regex to avoid false matches when 'h-3' appears as part of another class name.

packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (1)

35-66: Icon function logic is correct with a minor suggestion.

The function properly handles different search scope types and selection states. The icon inversion logic for selected badges is complex but necessary for proper contrast.

Consider extracting the size calculation to improve readability:

 const getSearchScopeIcon = (searchScope: DemoSearchScope, size: number = 20, isSelected: boolean = false) => {
-    const sizeClass = size === 12 ? "h-3 w-3" : "h-5 w-5";
+    const sizeClass = `h-${size === 12 ? '3' : '5'} w-${size === 12 ? '3' : '5'}`;
     const colorClass = isSelected ? "text-primary-foreground" : "text-muted-foreground";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be9979f and 3b2dd51.

📒 Files selected for processing (18)
  • packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (4 hunks)
  • packages/web/src/app/[domain]/chat/components/newChatPanel.tsx (4 hunks)
  • packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx (3 hunks)
  • packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (3 hunks)
  • packages/web/src/app/api/(server)/chat/route.ts (5 hunks)
  • packages/web/src/components/atMentionInfoCard.tsx (1 hunks)
  • packages/web/src/components/searchScopeInfoCard.tsx (1 hunks)
  • packages/web/src/features/chat/agent.ts (5 hunks)
  • packages/web/src/features/chat/components/chatBox/chatBox.tsx (8 hunks)
  • packages/web/src/features/chat/components/chatBox/chatBoxToolbar.tsx (3 hunks)
  • packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx (8 hunks)
  • packages/web/src/features/chat/components/chatThread/chatThread.tsx (7 hunks)
  • packages/web/src/features/chat/components/chatThread/detailsCard.tsx (2 hunks)
  • packages/web/src/features/chat/components/searchScopeIcon.tsx (1 hunks)
  • packages/web/src/features/chat/types.ts (4 hunks)
  • packages/web/src/features/chat/useCreateNewChatThread.ts (2 hunks)
  • packages/web/src/features/chat/utils.ts (3 hunks)
  • packages/web/src/types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

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

Filenames should always be camelCase. Exception: if there are filenames in the same directory with a format other than camelCase, use that format to keep things consistent.

Files:

  • packages/web/src/features/chat/components/chatThread/detailsCard.tsx
  • packages/web/src/features/chat/utils.ts
  • packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx
  • packages/web/src/components/atMentionInfoCard.tsx
  • packages/web/src/features/chat/components/chatThread/chatThread.tsx
  • packages/web/src/features/chat/components/chatBox/chatBoxToolbar.tsx
  • packages/web/src/components/searchScopeInfoCard.tsx
  • packages/web/src/features/chat/agent.ts
  • packages/web/src/app/api/(server)/chat/route.ts
  • packages/web/src/features/chat/useCreateNewChatThread.ts
  • packages/web/src/app/[domain]/chat/components/newChatPanel.tsx
  • packages/web/src/types.ts
  • packages/web/src/features/chat/components/searchScopeIcon.tsx
  • packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx
  • packages/web/src/features/chat/components/chatBox/chatBox.tsx
  • packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx
  • packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx
  • packages/web/src/features/chat/types.ts
🧬 Code Graph Analysis (11)
packages/web/src/features/chat/components/chatThread/detailsCard.tsx (2)
packages/web/src/components/ui/tooltip.tsx (3)
  • Tooltip (30-30)
  • TooltipTrigger (30-30)
  • TooltipContent (30-30)
packages/web/src/features/chat/components/searchScopeIcon.tsx (1)
  • SearchScopeIcon (11-32)
packages/web/src/features/chat/utils.ts (1)
packages/web/src/features/chat/types.ts (3)
  • MentionData (124-124)
  • SearchScope (62-62)
  • SBChatMessage (94-98)
packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (1)
packages/web/src/features/chat/types.ts (3)
  • SearchScope (62-62)
  • SET_CHAT_STATE_QUERY_PARAM (159-159)
  • SetChatStatePayload (161-164)
packages/web/src/features/chat/components/chatBox/chatBoxToolbar.tsx (3)
packages/web/src/components/atMentionInfoCard.tsx (1)
  • AtMentionInfoCard (3-15)
packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx (1)
  • SearchScopeSelector (41-243)
packages/web/src/components/searchScopeInfoCard.tsx (1)
  • SearchScopeInfoCard (5-41)
packages/web/src/components/searchScopeInfoCard.tsx (1)
packages/web/src/lib/utils.ts (2)
  • getCodeHostIcon (272-303)
  • cn (20-22)
packages/web/src/features/chat/agent.ts (1)
packages/web/src/features/chat/tools.ts (1)
  • createCodeSearchTool (138-177)
packages/web/src/features/chat/useCreateNewChatThread.ts (3)
packages/web/src/components/hooks/use-toast.ts (1)
  • useToast (194-194)
packages/web/src/features/chat/types.ts (1)
  • SearchScope (62-62)
packages/web/src/features/chat/utils.ts (3)
  • slateContentToString (122-145)
  • getAllMentionElements (147-159)
  • createUIMessage (176-212)
packages/web/src/app/[domain]/chat/components/newChatPanel.tsx (2)
packages/web/src/features/chat/types.ts (1)
  • SearchScope (62-62)
packages/web/src/features/chat/useCreateNewChatThread.ts (1)
  • useCreateNewChatThread (15-52)
packages/web/src/features/chat/components/searchScopeIcon.tsx (2)
packages/web/src/features/chat/types.ts (1)
  • SearchScope (62-62)
packages/web/src/lib/utils.ts (2)
  • cn (20-22)
  • getCodeHostIcon (272-303)
packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx (4)
packages/web/src/lib/types.ts (2)
  • RepositoryQuery (28-28)
  • SearchContextQuery (29-29)
packages/web/src/features/chat/types.ts (3)
  • SearchScope (62-62)
  • RepoSetSearchScope (56-56)
  • RepoSearchScope (48-48)
packages/web/src/lib/utils.ts (1)
  • cn (20-22)
packages/web/src/features/chat/components/searchScopeIcon.tsx (1)
  • SearchScopeIcon (11-32)
packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (4)
packages/web/src/types.ts (2)
  • DemoExamples (28-28)
  • DemoSearchScope (29-29)
packages/web/src/lib/utils.ts (2)
  • cn (20-22)
  • getCodeHostIcon (272-303)
packages/web/src/components/searchScopeInfoCard.tsx (1)
  • SearchScopeInfoCard (5-41)
packages/web/src/components/ui/card.tsx (2)
  • Card (79-79)
  • CardContent (79-79)
⏰ 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: build
🔇 Additional comments (68)
packages/web/src/components/atMentionInfoCard.tsx (1)

1-15: LGTM! Well-structured info card component.

The component follows React best practices with:

  • Clean functional component structure
  • Proper semantic HTML structure with headings and descriptions
  • Consistent styling using Tailwind CSS utility classes
  • Responsive design with max-w-[90vw] for mobile compatibility
  • Proper accessibility with semantic heading structure
packages/web/src/app/[domain]/chat/components/newChatPanel.tsx (4)

8-8: Import updated correctly for the search scope refactor.

The import change from ContextItem to SearchScope aligns with the broader refactor to unify repository and context selection.


27-27: State management correctly updated to use SearchScope[].

The local storage key and type are appropriately updated from selectedItems to selectedSearchScopes with the correct SearchScope[] type.


32-33: Function call correctly updated with new parameter.

The createNewChatThread function call properly uses the new selectedSearchScopes parameter, consistent with the updated hook signature shown in the relevant code snippets.


52-52: Props correctly updated for child components.

Both ChatBox and ChatBoxToolbar components receive the updated selectedSearchScopes prop and setter function, maintaining consistency with the refactored component interfaces.

Also applies to: 61-62

packages/web/src/components/searchScopeInfoCard.tsx (1)

1-41: LGTM! Comprehensive and user-friendly info card.

The component provides clear explanations of the two search scope types with appropriate visual indicators. The fallback logic for the GitHub icon ensures robustness across different environments.

packages/web/src/features/chat/utils.ts (3)

15-15: Import correctly added for SearchScope type.

The import addition aligns with the function signature changes and broader refactor.


176-176: Function signature correctly simplified.

The change from separate selectedRepos and selectedContexts parameters to a single selectedSearchScopes: SearchScope[] parameter simplifies the API and aligns with the unified search scope model.


209-209: Metadata structure correctly updated.

The metadata object now includes selectedSearchScopes instead of separate arrays, maintaining consistency with the new data model.

packages/web/src/features/chat/components/chatThread/detailsCard.tsx (2)

7-7: Imports correctly added for new UI functionality.

The new imports for Tooltip, ScanSearchIcon, and SearchScopeIcon are appropriate for the added search scope display functionality.

Also applies to: 9-9, 16-16


66-87: Well-implemented search scope display with tooltip.

The implementation follows good practices:

  • Properly conditional rendering based on metadata?.selectedSearchScopes
  • Consistent with other metadata displays (only shown when not streaming)
  • Uses appropriate accessibility with cursor-help class
  • Tooltip content clearly shows each search scope with icon and name
  • Proper pluralization handling for "scope" vs "scopes"
  • Uses the SearchScopeIcon component for consistent iconography
packages/web/src/features/chat/agent.ts (6)

19-19: LGTM: Clear parameter rename for better semantic clarity.

The rename from selectedRepos to searchScopeRepoNames better reflects that these are repository names derived from search scopes rather than directly selected repositories.


38-38: LGTM: Parameter rename consistent with interface.

The parameter rename aligns with the AgentOptions interface update and maintains consistency throughout the function.


43-43: LGTM: Function call updated with renamed parameter.

The function call correctly uses the renamed searchScopeRepoNames parameter.


153-157: LGTM: Interface and function signature consistently updated.

The BaseSystemPromptOptions interface and createBaseSystemPrompt function signature are properly updated to use the new searchScopeRepoNames parameter name.


179-179: LGTM: Template literal correctly uses renamed variable.

The template literal properly uses the renamed searchScopeRepoNames variable to generate the repository list.


53-53: Parameter name mismatch is cosmetic, not a runtime issue
The createCodeSearchTool function signature correctly accepts a single string[] argument (selectedRepos), and calling it with searchScopeRepoNames (another string[]) works as intended. There’s no runtime error risk—parameter names are local to the function and don’t affect invocation. Feel free to keep the current names or rename for readability, but no change is required for correctness.

Likely an incorrect or invalid review comment.

packages/web/src/features/chat/useCreateNewChatThread.ts (4)

13-13: LGTM: Import updated to reflect new type system.

The import correctly replaces ContextItem with SearchScope to align with the unified search scope model.


21-21: LGTM: Function parameter updated to use unified search scope model.

The parameter change from selectedItems: ContextItem[] to selectedSearchScopes: SearchScope[] simplifies the API and aligns with the broader refactor.


25-25: LGTM: Simplified function call with unified search scopes.

The direct pass of selectedSearchScopes to createUIMessage simplifies the logic by eliminating the need to separate repos and contexts.


40-40: LGTM: URL state simplified with unified search scopes.

The payload now uses a single selectedSearchScopes property instead of separate repo and context arrays, consistent with the SetChatStatePayload type.

packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (7)

5-5: LGTM: Import added for new SearchScope type.

The SearchScope import is correctly added to support the updated state management.


38-38: LGTM: Simplified default value derivation.

The direct use of lastUserMessage?.metadata?.selectedSearchScopes eliminates complex logic for reconstructing selected items from separate repo and context arrays.


39-39: LGTM: State variable updated to use unified search scope model.

The state variable correctly uses SearchScope[] type and the simplified default value.


48-48: LGTM: URL parameter parsing simplified.

The direct destructuring of selectedSearchScopes from the payload eliminates complex reconstruction logic.


50-50: LGTM: State setter consistent with updated state variable.

The setSelectedSearchScopes call properly uses the parsed value from the URL parameter.


59-59: LGTM: Effect dependencies correctly simplified.

Removing repos and searchContexts from the dependency array is appropriate since the effect no longer reconstructs selected items from these arrays.


75-76: LGTM: Props updated to use new search scope model.

The selectedSearchScopes and onSelectedSearchScopesChange props correctly reflect the updated component API.

packages/web/src/features/chat/components/chatBox/chatBox.tsx (9)

6-6: LGTM: Import updated for new type system.

The import correctly includes SearchScope to support the updated prop types.


31-31: LGTM: Prop type updated to unified search scope model.

The prop change from selectedItems: ContextItem[] to selectedSearchScopes: SearchScope[] aligns with the refactor.


44-44: LGTM: Prop destructuring updated consistently.

The destructuring correctly uses the renamed selectedSearchScopes prop.


55-68: LGTM: Repository extraction logic correctly updated.

The logic properly handles both 'repo' and 'reposet' types from the search scopes. The flattening approach ensures all repository names are collected into a single array.

Note: The type check uses 'reposet' instead of the previous 'context' - ensure this aligns with the SearchScope type definition.


132-132: LGTM: Validation logic updated with new variable name.

The validation correctly checks selectedSearchScopes.length to ensure at least one search scope is selected.


156-156: LGTM: Memoization dependency updated correctly.

The dependency array correctly uses selectedSearchScopes.length to maintain proper memoization.


164-164: LGTM: Toast message updated with clearer terminology.

The message now uses "search scope" terminology, which is more consistent and user-friendly than the previous "repository or context" phrasing.


286-286: LGTM: Placeholder text updated for consistency.

The placeholder correctly references "selected search scopes" providing clear guidance to users about the new terminology.


341-341: LGTM: Tooltip text consistently updated.

The tooltip message correctly uses "search scope" terminology, maintaining consistency with other user-facing messages.

packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx (3)

6-6: LGTM! Clean import update.

The import correctly replaces ContextItem with SearchScope to align with the new unified model.


36-36: LGTM! Consistent state management refactor.

The state variable and local storage key are properly updated to use the new SearchScope[] type, maintaining backwards compatibility by changing the storage key.


44-44: LGTM! Proper prop propagation.

The component correctly passes selectedSearchScopes to child components (createNewChatThread, ChatBox, and ChatBoxToolbar), maintaining consistency with the new unified model.

Also applies to: 49-49, 60-61

packages/web/src/features/chat/components/chatBox/chatBoxToolbar.tsx (3)

6-6: LGTM! Clean import updates.

The imports are correctly updated to use SearchScope instead of ContextItem and include the new info card components that provide better user experience.

Also applies to: 13-15


21-22: LGTM! Proper interface refactor.

The props interface and parameters are correctly updated to use selectedSearchScopes: SearchScope[] instead of the previous context item model, maintaining type safety.

Also applies to: 31-32


67-78: LGTM! Enhanced UI with better user experience.

The replacement of ContextSelector with SearchScopeSelector and the new SearchScopeInfoCard tooltip provides a more informative and consistent user experience. The tooltip styling with transparent background and no border creates a clean presentation.

packages/web/src/features/chat/components/chatThread/chatThread.tsx (4)

8-8: LGTM! Import properly updated.

The import correctly includes SearchScope to support the new unified selection model.


38-39: LGTM! Simplified and consistent props interface.

The props interface is correctly updated to use selectedSearchScopes: SearchScope[], eliminating the complexity of managing separate repository and context selections.

Also applies to: 50-51


118-118: LGTM! Consistent usage throughout the component.

All references to the selected items are properly updated to use selectedSearchScopes, maintaining consistency in the sendMessage callback, createUIMessage call, and dependency arrays.

Also applies to: 122-122, 238-238, 244-244


322-322: LGTM! Proper prop propagation to child components.

The component correctly passes selectedSearchScopes and the change handler to both ChatBox and ChatBoxToolbar, ensuring the unified model flows through the component hierarchy.

Also applies to: 331-332

packages/web/src/types.ts (3)

7-7: LGTM! Improved schema naming and clarity.

The schema rename from demoSearchContextSchema to demoSearchScopeSchema and the enum value change from "set" to "reposet" provides better clarity and consistency with the unified search scope model.

Also applies to: 11-11


19-19: LGTM! Consistent field naming updates.

The schema updates correctly rename searchContexts to searchScopes in both the example and root schemas, maintaining consistency throughout the type system.

Also applies to: 23-23


29-30: LGTM! Type exports properly updated.

The exported types are correctly updated to reflect the schema changes, replacing DemoSearchContext with DemoSearchScope and updating DemoSearchExample accordingly.

packages/web/src/app/api/(server)/chat/route.ts (3)

5-5: LGTM! Consistent API interface updates.

The import, request parsing, and parameter passing are all correctly updated to use the new selectedSearchScopes: SearchScope[] model, maintaining type safety throughout the API handler.

Also applies to: 67-67, 71-71, 95-95


189-212: LGTM! Well-structured scope expansion logic.

The expansion logic correctly handles both repo and reposet types, with proper async handling and database queries. The flattening approach consolidates all repository names into a single array.


220-220: LGTM! Clean parameter naming and metadata inclusion.

The parameter rename to searchScopeRepoNames better reflects its purpose, and including selectedSearchScopes in the message metadata provides valuable context for debugging and analytics.

Also applies to: 246-246

packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (5)

3-3: LGTM on import additions!

The new imports align perfectly with the refactored functionality - useState for filter state, new Lucide icons for the UI, DemoSearchScope type for filtering logic, and SearchScopeInfoCard for the tooltip component.

Also applies to: 5-5, 9-9, 12-12


22-22: Good state management simplification!

The single filter state is cleaner than the previous multi-selection approach and the typing (number | null) clearly indicates that null means "show all".


85-131: Excellent UI structure implementation!

The search scope filter section is well-designed with:

  • Clear info tooltip using the SearchScopeInfoCard component
  • Consistent badge styling for selected/unselected states
  • Proper event handling for filter state updates
  • Nice tooltip positioning with CSS arrow

134-139: Clean and correct filtering logic!

The filter implementation properly handles both the "show all" case (null filter) and specific scope filtering using array inclusion check.


140-169: Well-implemented card rendering!

The example cards properly display search scope badges with icons, maintain consistent styling, and handle user interactions correctly. The logic to filter and display relevant search scopes for each example is sound.

packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx (7)

7-7: Import updates look correct!

The new imports properly support the refactored functionality - ScanSearchIcon for the UI, cn for class utilities, the new search scope types, and the unified SearchScopeIcon component.

Also applies to: 10-10, 28-29


31-43: Interface refactoring is well-executed!

The rename to SearchScopeSelector and the prop changes to use selectedSearchScopes with unified SearchScope[] type make the component more focused and easier to understand.


61-94: State handling logic is correctly updated!

The toggle and keyboard handling logic properly works with the unified SearchScope type, maintaining the same UX behavior while using the new data structure. The scroll position preservation is a nice touch.


100-116: Item mapping logic is solid!

The transformation from separate contexts and repos into unified SearchScope items is well-implemented with proper type discriminators and field mappings.


118-142: Excellent sorting and scroll restoration logic!

The multi-level sorting (selected first, then reposets before repos) provides intuitive UX, and the scroll position restoration maintains smooth interactions during state updates.


160-225: UI updates are consistent and well-implemented!

The terminology updates, unified icon usage via SearchScopeIcon, and proper type checking for badges all align with the search scope refactoring. The UI maintains the same functionality while using the new data model.


245-245: Display name properly updated!

The component display name correctly reflects the refactored component name.

packages/web/src/features/chat/types.ts (3)

42-62: Well-designed search scope type system!

The discriminated union approach with proper type literals ('repo' vs 'reposet') provides excellent type safety. The schema fields are appropriately typed and the structure supports the unified search scope model effectively.


75-75: Metadata schema properly updated!

The selectedSearchScopes field correctly uses the new search scope schema as an optional array, maintaining backward compatibility while supporting the unified model.


163-163: Payload and request params schemas correctly updated!

Both SetChatStatePayload and additionalChatRequestParamsSchema properly use the new search scope types, with appropriate optionality for their respective contexts.

Also applies to: 180-180

@msukkari msukkari merged commit 6662d20 into main Jul 29, 2025
6 of 7 checks passed
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