Skip to content

Conversation

@msukkari
Copy link
Contributor

@msukkari msukkari commented Jul 28, 2025

  • Adds SOURCEBOT_DEMO_EXAMPLES_PATH which points to a JSON that defines demo cards. This includes search contexts to highlight, as well as example ask sessions
  • Renders the contents of this JSON on the Ask Sourcebot homepage. Search context cards are wired into the selector system
  • TODO:
    • Need to add back a way to view search history if the user is authed from the homepage
demo_cards.mp4

Summary by CodeRabbit

  • New Features

    • Introduced interactive demo cards on the homepage, allowing users to explore search contexts and community example queries.
    • Added support for loading demo example data from a configurable JSON file, validated for correctness.
    • Homepage and search components now display demo examples when available.
  • Improvements

    • Streamlined the Agentic Search interface by removing suggestion dropdowns and recent chat history, focusing on demo-driven exploration.
    • Updated warning messages to clarify that at least one search context must be selected.
    • Enhanced chat input and context selector placeholders for clearer user guidance.
  • Configuration

    • Added a new environment variable to specify the path for demo example data.

@msukkari msukkari requested a review from brendan-kellam July 28, 2025 00:20
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Walkthrough

This change introduces a new system for loading and displaying demo search examples on the homepage. It adds a generic JSON file loader with schema validation, new types and schemas for demo data, and a React component for rendering demo cards. The homepage and agentic search components are updated to support and display these demo examples, with configuration via an environment variable. Additionally, minor UI text updates and simplifications were made in the agentic search component.

Changes

Cohort / Files Change Summary
Shared Utilities
packages/shared/src/index.server.ts, packages/shared/src/utils.ts
Added and exported a generic async function loadJsonFile for loading and validating JSON files, supporting both remote and local sources with retry and schema validation logic.
Type Definitions
packages/web/src/types.ts
Introduced new Zod schemas and TypeScript types for demo search contexts and examples, aggregating them into a demoExamplesSchema.
Environment Configuration
packages/web/src/env.mjs
Added optional environment variable SOURCEBOT_DEMO_EXAMPLES_PATH to the server schema.
Homepage Data Loading
packages/web/src/app/[domain]/page.tsx
Added logic to load demo examples from a JSON file specified via environment variable, validating with the new schema, and passing to the homepage.
Homepage Component
packages/web/src/app/[domain]/components/homepage/index.tsx
Extended HomepageProps and the Homepage component to accept and pass down demoExamples.
Agentic Search Component
packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx
Refactored to remove suggestion logic and chat history, now rendering AskSourcebotDemoCards when demo examples are present.
Demo Cards Component
packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx
Introduced new component for displaying interactive demo cards for search contexts and community examples, managing selection and interactions.
Chat UI Text Update
packages/web/src/features/chat/components/chatBox/chatBox.tsx
Updated user-facing warning message text regarding selection of search contexts.
Context Selector Placeholder Update
packages/web/src/features/chat/components/chatBox/contextSelector.tsx
Changed placeholder text to focus on "Search contexts..." instead of including repos.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomePage
    participant Env
    participant Loader
    participant Schema
    participant AgenticSearch
    participant DemoCards

    User->>HomePage: Visit homepage
    HomePage->>Env: Read SOURCEBOT_DEMO_EXAMPLES_PATH
    HomePage->>Loader: loadJsonFile(path, demoExamplesSchema)
    Loader->>Schema: Validate JSON against schema
    Schema-->>Loader: Return validated data
    Loader-->>HomePage: Return demoExamples
    HomePage->>AgenticSearch: Render with demoExamples
    AgenticSearch->>DemoCards: Render demo cards if demoExamples present
    User->>DemoCards: Interact with cards (select/search)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

sourcebot-team

Poem

A rabbit hopped in with a demo to show,
Cards on the homepage, all in a row.
JSON is loaded, schemas are tight,
Contexts and examples—pick left or right!
With a click and a hop, new features appear—
Sourcebot’s demo is finally here!
🐇✨


📜 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 3c0af96 and 0e703f5.

📒 Files selected for processing (2)
  • packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (1 hunks)
  • packages/web/src/app/[domain]/page.tsx (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web/src/app/[domain]/page.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: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch msukkarieh/demo_examples

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.

@github-actions
Copy link
Contributor

@msukkari your pull request is missing a changelog!

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: 4

🔭 Outside diff range comments (1)
packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx (1)

21-26: Interface inconsistency: chatHistory prop is declared but not used.

The AgenticSearchProps interface still declares a chatHistory prop (lines 21-25), but this prop is not used in the component function parameters (line 34) or anywhere in the component. According to the AI summary, this prop was supposed to be removed as part of the refactoring.

-    chatHistory: {
-        id: string;
-        createdAt: Date;
-        name: string | null;
-    }[];
🧹 Nitpick comments (4)
packages/shared/src/utils.ts (1)

22-22: Address the TODO: Consider consolidating with existing config loading logic.

The TODO comment highlights significant code duplication between loadJsonFile and loadConfig. Both functions implement identical retry logic for local files and similar remote file handling.

Consider extracting the common file loading logic into a shared helper function to reduce duplication and improve maintainability.

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

15-20: Consider adding URL validation for better data integrity.

The url field in demoSearchExampleSchema accepts any string, but since it's used to open links in new tabs, consider adding URL format validation for better data integrity and security.

-    url: z.string(),
+    url: z.string().url(),
packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (2)

59-101: Complex selection logic could benefit from refactoring.

The handleContextClick function contains duplicated logic for handling selection/deselection of different context types. Consider extracting the common selection logic into helper functions for better maintainability.

Consider creating helper functions like:

const toggleContextSelection = (context: DemoSearchContext, searchContext: SearchContextQuery) => {
    const isSelected = selectedItems.some(
        (selected) => selected.type === 'context' && selected.value === context.value
    );
    return isSelected
        ? selectedItems.filter(
            (selected) => !(selected.type === 'context' && selected.value === context.value)
        )
        : [...selectedItems, { 
            type: 'context', 
            value: context.value, 
            name: context.displayName, 
            repoCount: searchContext.repoNames.length 
        } as SearchContextItem];
};

const toggleRepoSelection = (context: DemoSearchContext, repo: RepositoryQuery) => {
    // Similar logic for repo selection
};

177-206: Potential performance issue: repeated array filtering in render.

The search contexts filtering inside the map function (line 178) could impact performance if the arrays are large, as it runs on every render. Consider memoizing this computation.

+import { useMemo } from 'react';

+const examplesWithContexts = useMemo(() => 
+    demoExamples.searchExamples.map(example => ({
+        ...example,
+        searchContexts: demoExamples.searchContexts.filter(context => 
+            example.searchContext.includes(context.id)
+        )
+    })), [demoExamples]
+);

-{demoExamples.searchExamples.map((example) => {
-    const searchContexts = demoExamples.searchContexts.filter((context) => example.searchContext.includes(context.id))
+{examplesWithContexts.map((example) => {
+    const { searchContexts } = example;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aebd8df and 648df84.

📒 Files selected for processing (8)
  • packages/shared/src/index.server.ts (1 hunks)
  • packages/shared/src/utils.ts (2 hunks)
  • packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx (3 hunks)
  • packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx (1 hunks)
  • packages/web/src/app/[domain]/components/homepage/index.tsx (4 hunks)
  • packages/web/src/app/[domain]/page.tsx (3 hunks)
  • packages/web/src/env.mjs (1 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/shared/src/index.server.ts
  • packages/web/src/app/[domain]/components/homepage/index.tsx
  • packages/web/src/env.mjs
  • packages/web/src/app/[domain]/page.tsx
  • packages/shared/src/utils.ts
  • packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx
  • packages/web/src/app/[domain]/components/homepage/askSourcebotDemoCards.tsx
  • packages/web/src/types.ts
⏰ 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 (9)
packages/web/src/env.mjs (1)

133-133: LGTM! Clean environment variable addition.

The new SOURCEBOT_DEMO_EXAMPLES_PATH environment variable follows the established patterns and conventions in the codebase.

packages/shared/src/utils.ts (1)

27-80: The implementation logic is solid.

The retry logic, error handling, and validation approach are all well-implemented and consistent with existing patterns in the codebase.

packages/shared/src/index.server.ts (1)

15-15: LGTM! Proper export addition.

The new loadJsonFile export is correctly placed with other utility functions.

packages/web/src/app/[domain]/page.tsx (1)

14-16: Good integration of the demo examples feature.

The imports are clean and the prop passing follows the established patterns in the component.

Also applies to: 69-69

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

13-13: LGTM! Clean integration of demo examples prop.

The interface extension, parameter handling, and prop passing all follow established patterns and are correctly implemented.

Also applies to: 25-25, 35-35, 92-92

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

74-82: LGTM! Clean conditional rendering with proper prop passing.

The conditional rendering of AskSourcebotDemoCards is well-implemented with all necessary props passed correctly. The component will only render when demo examples are available.

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

7-13: LGTM! Well-structured schema for demo search contexts.

The demoSearchContextSchema appropriately defines the structure with proper validation including the enum constraint for type and optional codeHostType.


27-31: LGTM! Comprehensive aggregation schema for demo examples.

The demoExamplesSchema properly aggregates all the individual schemas into a cohesive structure that matches the expected JSON format.

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

188-193: Missing key prop for Badge components in map.

The Badge components inside the map don't have unique keys, which could cause React rendering issues when the list changes.

The key prop uses context.value which should be unique, but verify this is always the case. If not, consider using context.id instead:

-<Badge key={context.value} variant="secondary" className="text-[10px] px-1.5 py-0.5 h-4 flex items-center gap-1">
+<Badge key={context.id} variant="secondary" className="text-[10px] px-1.5 py-0.5 h-4 flex items-center gap-1">

Likely an incorrect or invalid review comment.

@msukkari msukkari merged commit f720ec9 into main Jul 28, 2025
6 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.

1 participant