Skip to content

Conversation

prateek041
Copy link
Contributor

Closes #538

Description

This pull request addresses the issue where the browser tab title remained generic ("Sourcebot") while navigating the code browser. The goal was to make the title dynamic and context-aware, displaying the current file or folder name to improve user experience and navigability.

Solution

This PR implements the recommended Next.js approach for dynamic metadata by using the server-side generateMetadata function within the browse/[...path]/page.tsx file.

The core changes include:

  1. generateMetadata Export: Added the async function generateMetadata({ params }) to src/app/[domain]/browse/[...path]/page.tsx. This allows Next.js to set the page title on the server during the rendering process.

  2. parsePathForTitle Helper Function: A robust, provider-agnostic parsing function was created to interpret the URL path array. This function:

    • Parses the base repository and revision information (e.g., owner/repo @ HEAD).
    • Intelligently detects whether the user is viewing a file (blob), a directory (tree), or the repository root.
    • Constructs a descriptive title based on the context:
      • File View: filename.ts - owner/repo @ revision
      • Folder View: folder/path/ - owner/repo @ revision
      • Repo Root: owner/repo @ revision

How to Test

  1. Navigate to a repository's root page (e.g., /~/browse/github.com/sourcebot-dev/sourcebot@HEAD).
    • Verify: The browser tab title should be sourcebot-dev/sourcebot @ HEAD | Sourcebot.
  2. Navigate to a directory within the repository (e.g., ~/browse/github.com/sourcebot-dev/sourcebot@HEAD/-/tree/packages%2Fweb).
    • Verify: The browser tab title should be packages/web/ - sourcebot-dev/sourcebot @ HEAD | Sourcebot.
  3. Navigate to a specific file (e.g., ~/browse/github.com/sourcebot-dev/sourcebot@HEAD/-/blob/packages%2Fweb%2Fsrc%2Fauth.ts).
    • Verify: The browser tab title should be auth.ts - sourcebot-dev/sourcebot @ HEAD | Sourcebot.
  4. Confirm that the title updates correctly as you navigate between files and folders.

feat(utils): Add parseRepoPath function to extract repository name and revision from URL path
Copy link

coderabbitai bot commented Oct 13, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 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.

@prateek041
Copy link
Contributor Author

Want me to fix the changelog thing? I think I just need to add an entry in the CHANGELOG.md and list my PR there right?

brendan-kellam
brendan-kellam previously approved these changes Oct 13, 2025
Copy link
Contributor

@brendan-kellam brendan-kellam left a comment

Choose a reason for hiding this comment

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

LGTM! If you could add a Changelog entry, that will unblock the changelog gate that is failing.

brendan-kellam
brendan-kellam previously approved these changes Oct 15, 2025
@brendan-kellam brendan-kellam merged commit 5b09757 into sourcebot-dev:main Oct 15, 2025
5 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.

[FR] Sourcebot Tab Title in code-browser should be filename / folder name

2 participants