Skip to content

feat: add same deployment link util#2546

Open
wassimoo wants to merge 4 commits intomasterfrom
feat/add-same-deployment-link-util
Open

feat: add same deployment link util#2546
wassimoo wants to merge 4 commits intomasterfrom
feat/add-same-deployment-link-util

Conversation

@wassimoo
Copy link
Copy Markdown
Contributor

@wassimoo wassimoo commented May 6, 2026

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact security@ory.com) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

Summary by CodeRabbit

  • New Features

    • Introduced deployment-aware links that maintain consistent navigation across network, OEL, and OSS documentation sections with automatic path resolution.
  • Documentation

    • Updated documentation to reflect new Shared content structure and paths; adjusted guidance for component location references and import patterns.

@wassimoo wassimoo self-assigned this May 6, 2026
@wassimoo wassimoo changed the title Feat/add same deployment link util feat: add same deployment link util May 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Walkthrough

This pull request introduces path-based deployment resolution for documentation navigation. It adds utilities to infer deployment segments (network, oel, oss) from URLs, a new SameDeploymentLink component for preserving navigation within deployment contexts, and wires deployment awareness through the context system. Documentation and ownership references are also updated.

Changes

Path-Based Deployment Infrastructure

Layer / File(s) Summary
Deployment Detection Utilities
src/utils/docsDeploymentFromPathname.ts
New module defines DocsDeploymentId type and introduces docsDeploymentFromPathname() to infer deployment (network/oel/oss) from URL pathname, plus isExplicitDocsDeploymentPath() to detect explicit segment presence.
Context Synchronization
src/contexts/QuickstartsDeploymentContext.tsx
Adds useEffect hook to sync internal deployment state with initialDeployment prop when not "network"; reformats React import to multi-line style.
DocRoot Integration
src/theme/DocRoot/index.js
Imports docsDeploymentFromPathname and passes deployment resolved from current pathname as initialDeployment to QuickstartsDeploymentProvider.

Deployment-Aware Navigation Component

Layer / File(s) Summary
Component Implementation
src/components/SameDeploymentLink.tsx
New React component that preserves navigation within the current deployment segment; computes segment from pathname, applies optional per-segment overrides, normalizes paths, validates target docs exist, and logs warnings for missing docs.
MDX Integration
src/theme/MDXComponents.js
Imports SameDeploymentLink and exposes it in the MDXComponents default export mapping, making it available for use in documentation content.

Documentation and Configuration Updates

Layer / File(s) Summary
Documentation Structure
AGENTS.md
Updates all references from /src/components/shared/ (lowercase) to /src/components/Shared/ (capitalized) to reflect migration to new Shared path structure; adds guidance to consult Docs before structural changes.
Ownership Configuration
.github/CODEOWNERS
Adds @wassimoo as additional owner to top-level and /code-examples/ path entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ory/docs#2522: Introduces AGENTS.md documentation; this PR updates the same file with Shared path casing changes and structural guidance.

Suggested reviewers

  • aeneasr

Poem

🐰 Hopping through paths with deployment care,
A link that keeps us just right there—
Network, OEL, OSS in view,
Context flows and docs ring true,
Shared structure capitalized bright!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is entirely empty except for the template placeholder comments; no substantive content, issue references, or checklist items were filled in. Provide a clear description of the changes, link a related issue or design document, and complete the checklist items to indicate what has been done.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a same deployment link utility and component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-same-deployment-link-util

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/SameDeploymentLink.tsx`:
- Around line 51-55: overrideForCurrentDeployment is only normalized and
therefore bypasses deployment-scoped rewriting; change the href computation so
that when overrideForCurrentDeployment is present you pass the normalized
override through rewriteToCurrentDeployment (e.g. href =
rewriteToCurrentDeployment(normalizePath(overrideForCurrentDeployment))) instead
of using normalizePath(...) alone, keeping the existing fallback to
rewriteToCurrentDeployment(to) when no override exists; use the same symbols
overrideForCurrentDeployment, normalizePath, and rewriteToCurrentDeployment so
the override resolves to a deployment-scoped docs route and avoids broken links.

In `@src/theme/DocRoot/index.js`:
- Around line 83-90: docsDeploymentFromPathname currently returns "network" for
both explicit "/docs/network/..." URLs and default non-segmented routes, which
loses routing intent when only that value is passed to
QuickstartsDeploymentProvider; update the call site in DocRoot (where
docsDeploymentFromPathname(pathname) is computed) to also derive an explicit
flag (e.g. const isNetworkExplicit = pathname.includes('/docs/network/')) and
pass that flag to QuickstartsDeploymentProvider as syncFromInitialDeployment (in
addition to initialDeployment), and then update QuickstartsDeploymentProvider to
gate its useEffect sync on the syncFromInitialDeployment prop (instead of
checking initialDeployment === "network") so picker/sidebar state preserves
explicit-vs-default routing intent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6fcb5101-f222-4f0b-be18-5d2ac0b8ee17

📥 Commits

Reviewing files that changed from the base of the PR and between 9ac94e6 and 9c5be3a.

⛔ Files ignored due to path filters (1)
  • src/components/Shared/kratos/index.mdx is excluded by !**/*.mdx
📒 Files selected for processing (7)
  • .github/CODEOWNERS
  • AGENTS.md
  • src/components/SameDeploymentLink.tsx
  • src/contexts/QuickstartsDeploymentContext.tsx
  • src/theme/DocRoot/index.js
  • src/theme/MDXComponents.js
  • src/utils/docsDeploymentFromPathname.ts

Comment on lines +51 to +55
const overrideForCurrentDeployment = { network, oel, oss }[segment]
const href = overrideForCurrentDeployment
? normalizePath(overrideForCurrentDeployment)
: rewriteToCurrentDeployment(to)
const allDocs = useAllDocsData()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Override targets bypass deployment rewrite and can produce broken doc links.

overrideForCurrentDeployment is only normalized, not deployment-rewritten. For values like oel="kratos/self-hosted/intro", href becomes /kratos/self-hosted/intro instead of a deployment-scoped docs route. This can silently navigate to non-existent pages.

Proposed fix
-  const href = overrideForCurrentDeployment
-    ? normalizePath(overrideForCurrentDeployment)
-    : rewriteToCurrentDeployment(to)
+  const href = overrideForCurrentDeployment
+    ? rewriteToCurrentDeployment(overrideForCurrentDeployment)
+    : rewriteToCurrentDeployment(to)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const overrideForCurrentDeployment = { network, oel, oss }[segment]
const href = overrideForCurrentDeployment
? normalizePath(overrideForCurrentDeployment)
: rewriteToCurrentDeployment(to)
const allDocs = useAllDocsData()
const overrideForCurrentDeployment = { network, oel, oss }[segment]
const href = overrideForCurrentDeployment
? rewriteToCurrentDeployment(overrideForCurrentDeployment)
: rewriteToCurrentDeployment(to)
const allDocs = useAllDocsData()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/SameDeploymentLink.tsx` around lines 51 - 55,
overrideForCurrentDeployment is only normalized and therefore bypasses
deployment-scoped rewriting; change the href computation so that when
overrideForCurrentDeployment is present you pass the normalized override through
rewriteToCurrentDeployment (e.g. href =
rewriteToCurrentDeployment(normalizePath(overrideForCurrentDeployment))) instead
of using normalizePath(...) alone, keeping the existing fallback to
rewriteToCurrentDeployment(to) when no override exists; use the same symbols
overrideForCurrentDeployment, normalizePath, and rewriteToCurrentDeployment so
the override resolves to a deployment-scoped docs route and avoids broken links.

Comment on lines +83 to +90
const deploymentFromPath = docsDeploymentFromPathname(pathname)
const versionMetadata = useDocsVersion() ?? {}
const docsSidebars = versionMetadata.docsSidebars ?? {}

return (
<div id="route-identifier" data-route={pathname}>
<HtmlClassNameProvider className={clsx(ThemeClassNames.page.docsDocPage)}>
<QuickstartsDeploymentProvider>
<QuickstartsDeploymentProvider initialDeployment={deploymentFromPath}>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Explicit vs implicit “network” context is currently collapsed.

docsDeploymentFromPathname() returns "network" for both explicit /docs/network/... and default non-segmented paths, but only that value is passed to the provider. This loses routing intent and can desync picker/sidebar state across navigations.

Suggested direction
-import { docsDeploymentFromPathname } from "@site/src/utils/docsDeploymentFromPathname"
+import {
+  docsDeploymentFromPathname,
+  isExplicitDocsDeploymentPath,
+} from "@site/src/utils/docsDeploymentFromPathname"

  const pathname = props.location?.pathname ?? ""
  const deploymentFromPath = docsDeploymentFromPathname(pathname)
+ const explicitDeploymentPath = isExplicitDocsDeploymentPath(pathname)

- <QuickstartsDeploymentProvider initialDeployment={deploymentFromPath}>
+ <QuickstartsDeploymentProvider
+   initialDeployment={deploymentFromPath}
+   syncFromInitialDeployment={explicitDeploymentPath}
+ >

Then gate the useEffect sync in QuickstartsDeploymentProvider on syncFromInitialDeployment instead of checking initialDeployment === "network".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/theme/DocRoot/index.js` around lines 83 - 90, docsDeploymentFromPathname
currently returns "network" for both explicit "/docs/network/..." URLs and
default non-segmented routes, which loses routing intent when only that value is
passed to QuickstartsDeploymentProvider; update the call site in DocRoot (where
docsDeploymentFromPathname(pathname) is computed) to also derive an explicit
flag (e.g. const isNetworkExplicit = pathname.includes('/docs/network/')) and
pass that flag to QuickstartsDeploymentProvider as syncFromInitialDeployment (in
addition to initialDeployment), and then update QuickstartsDeploymentProvider to
gate its useEffect sync on the syncFromInitialDeployment prop (instead of
checking initialDeployment === "network") so picker/sidebar state preserves
explicit-vs-default routing intent.

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