Repository navigation
Resolve cross-space repository page URLs when rendering sites - #4619
Conversation
🦋 Changeset detectedLatest commit: f6f9c48 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Style invalidation on a large API referenceElements restyled by opening one popup on the Snyk API reference. A share near or above 100% means the insertion restyles the whole document.
|
… links Use the matcher the editor uses, which treats an omitted project directory as the repository root, decodes anchors, accepts the www host and resolves spaces whose Git Sync was removed. Links to other hosts no longer scan every site space, and paths that cannot be pages no longer read a revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n' into taran/cross-space-page-resolution
jpreynat
left a comment
There was a problem hiding this comment.
One remaining issue with links to version folders.
…ders Whether a path is a page folder or a file can only be told from the target revision: guessing from its name skipped folders like `11.8`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6f9c48f25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
URL-kind loss and inconsistent path normalization can resolve assets or ambiguous encoded paths to incorrect pages.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Resolves repository page URLs to matching pages across spaces in a published site.
Changes:
- Adds Git repository URL and page-path matching.
- Fetches revision metadata with space-aware cache invalidation.
- Renders resolved URLs as internal links with comprehensive tests.
| File | Description |
|---|---|
.changeset/cross-space-repository-links.md |
Records the user-facing feature. |
packages/gitbook/src/lib/gitPageURL.ts |
Implements repository URL matching. |
packages/gitbook/src/lib/gitPageURL.test.ts |
Tests URL and page-path matching. |
packages/gitbook/src/lib/references.tsx |
Resolves repository URLs across site spaces. |
packages/gitbook/src/lib/references.test.ts |
Tests cross-space resolution behavior. |
packages/gitbook/src/lib/data/types.ts |
Adds the revision metadata option. |
packages/gitbook/src/lib/data/api.ts |
Fetches and caches revision metadata. |
packages/gitbook/src/lib/context.ts |
Propagates metadata-fetch requests. |
packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx |
Treats resolved URLs as internal links. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Proposed changes
Resolve repository URLs left by parallel Git Sync imports to pages in the same published site. API/import companion: https://github.com/GitbookIO/gitbook-x/pull/25900.
@gitbook/app-content-refs). A space syncing from the repository root counts too, and so does a space whose Git Sync was removed, through its remembered project URL. Anchors are decoded; the original URL is kept for ambiguous, missing, draft, or forbidden targets.Relies on the API's
Space.gitSync.installationProjectDirectory(omitted for the repository root) andSpace.previousGitSync. Main revisions are intentional for now, with comments for future Site CR selection. Export path repair and published Markdown rewriting are outside this PR.Validation: 82 focused tests passed, including a 500-space site that reads only one target space/revision, permissions denial, ambiguous matches, and resolving a previously missing target. Package typecheck passed. A production build passed before the final metadata-fetch wiring; the final wiring passed focused tests and typecheck.
Draft pending browser verification/demo. Includes the required separate changeset commit.
Changelog