sourcebot icon indicating copy to clipboard operation
sourcebot copied to clipboard

feat: Added the ability to browser different branches and tag from th…

Open CyberT17 opened this issue 10 months ago • 7 comments

Added the ability to browser different branches and tag from the /browse page.

  • Added a branch/tag selector dropdown component. implements #810
Screenshot 2026-01-29 at 2 32 27 PM Screenshot 2026-01-29 at 2 32 49 PM

Fixes #810

Summary by CodeRabbit

  • New Features

    • Added branch and tag selector with search functionality to easily switch between Git references in the repository browser.
    • Improved search to intelligently handle multiple Git references for more accurate results.
  • Bug Fixes

    • Removed unnecessary tooltip on branch display in path header.

✏️ Tip: You can customize this high-level summary in your review settings.

CyberT17 avatar Jan 29 '26 20:01 CyberT17

Walkthrough

This PR introduces branch and tag selection functionality for repositories. It adds a new React component for selecting Git references, creates API endpoints to fetch refs filtered by indexed revisions, integrates the selector into the file tree panel, and updates search logic to normalize and query multiple ref variants.

Changes

Cohort / File(s) Summary
Branch/Tag Selection UI
packages/web/src/app/[domain]/components/branchTagSelector.tsx, packages/web/src/app/[domain]/components/pathHeader.tsx
Introduces BranchTagSelector component with search-enabled dropdown for branches and tags using react-query; PathHeader prop branchDisplayTitle renamed to unused variable and title attribute removed.
API Endpoints
packages/web/src/app/api/(server)/refs/getRefs.ts, packages/web/src/app/api/(server)/refs/route.ts, packages/web/src/app/api/(client)/client.ts
Adds getRefs server handler that filters Git branches and tags by indexed revisions via Prisma metadata; creates POST /api/refs route with validation; adds getRefs client function to API client.
Schema and Type Definitions
packages/web/src/lib/schemas.ts, packages/web/src/lib/types.ts
Introduces getRefsRequestSchema/getRefsResponseSchema and corresponding GetRefsRequest/GetRefsResponse types for repository reference requests.
Search Integration
packages/web/src/features/search/fileSourceApi.ts, packages/web/src/features/search/parser.ts
Refactors getFileSource to perform parallel searches across multiple ref variants; adds ref normalization in parser to produce zoekt-compatible branch patterns.
File Tree Panel Integration
packages/web/src/features/fileTree/components/fileTreePanel.tsx
Wires BranchTagSelector into file tree header with domain-aware navigation; onRefChange updates browse path with selected revision and navigates to updated path.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as BranchTagSelector Component
    participant Router as Next.js Router
    participant Client as API Client
    participant Server as /api/refs Handler
    participant Git as Git Repository
    participant Search as Search System

    User->>UI: Select branch/tag
    UI->>UI: onRefChange callback triggered
    UI->>Router: Navigate with new ref parameter
    Router->>Search: New path loaded with updated ref
    Search->>Client: Query fileSource with new ref
    Client->>Server: POST /api/refs (validate ref)
    Server->>Git: Fetch branches and tags
    Git-->>Server: Return filtered refs
    Server-->>Client: Return refs response
    Client->>Search: Parse and normalize refs
    Search-->>Search: Execute parallel searches across ref variants
    Search-->>UI: Update file tree with new ref context

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

  • sourcebot-dev/sourcebot#336: Directly modifies the same file tree explorer functionality and FileTreePanel integration introduced/changed in this PR.
  • sourcebot-dev/sourcebot#813: Modifies the same fileSourceApi and ref-handling logic that this PR enhances with multi-ref search and normalization.

Suggested reviewers

  • brendan-kellam
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is partially related to the changeset—it addresses browsing different branches and tags, a core feature added. However, it's truncated mid-word ('th…') making it incomplete and unclear, and it contains a typo ('browser' instead of 'browse'). Complete the truncated title and fix the typo. For example: 'feat: Add ability to browse different branches and tags from the browse page'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jan 29 '26 20:01 coderabbitai[bot]

@brendan-kellam lmk what your thoughts are or if you have any questions/concerns/suggestions.

CyberT17 avatar Jan 29 '26 20:01 CyberT17

thanks @CyberT17 , I'm out atm but will take a look later

brendan-kellam avatar Jan 29 '26 20:01 brendan-kellam

@claude take the review comments I have made on this PR and create a new PR with a updated CLAUDE.md file that summarizes any learnings that are not captured and could be helpful in the future.

brendan-kellam avatar Jan 30 '26 23:01 brendan-kellam

Claude encountered an error —— View job

Command failed: git fetch origin --depth=20 cybert17/browse-different-branches-and-tags

I'll analyze this and get back to you.

claude[bot] avatar Jan 30 '26 23:01 claude[bot]

Left a bunch of comments here, but overall it is looking good 🙌 heads up: I'm going to submit a PR for #574 that will change how we fetch source code. I left a comment about allowing the user to select and branch or tag (not just indexed ones) and 574 will be required for that.

Would you like to get #574 in before we merge this?

CyberT17 avatar Feb 03 '26 16:02 CyberT17

Left a bunch of comments here, but overall it is looking good 🙌 heads up: I'm going to submit a PR for #574 that will change how we fetch source code. I left a comment about allowing the user to select and branch or tag (not just indexed ones) and 574 will be required for that.

Would you like to get #574 in before we merge this?

#574 is merged so no blockers there

brendan-kellam avatar Feb 03 '26 20:02 brendan-kellam