-
Notifications
You must be signed in to change notification settings - Fork 120
Implement universal docs routing feature #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
516564f
Implement universal docs routing feature
softmarshmallow 87cad57
mv
softmarshmallow bbd035d
Enhance documentation with universal routing guidelines
softmarshmallow 794b0cb
pnpm dlx shadcn@latest add item
softmarshmallow 3760149
chore: style
softmarshmallow 283e838
feat: add new project and document route configurations
softmarshmallow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| --- | ||
| title: Universal Docs Routing (WG) | ||
| --- | ||
|
|
||
| # Universal Docs Routing | ||
|
|
||
| ## Summary | ||
|
|
||
| We need a **universal routing system** for user-facing docs and links where the | ||
| actual path depends on the user’s **org**, **project**, and sometimes the | ||
| **document context** (id + type). Docs should be written with a stable, concise | ||
| path like: | ||
|
|
||
| ``` | ||
| https://grida.co/_/connect/share | ||
| ``` | ||
|
|
||
| and resolved at runtime to the user-specific canonical path, for example: | ||
|
|
||
| ``` | ||
| https://grida.co/acme/project/00000000-0000-0000-0000-000000001234/connect/share | ||
| ``` | ||
|
|
||
| This keeps documentation readable while preserving correct routing for any | ||
| tenant and document. | ||
|
|
||
| --- | ||
|
|
||
| ## Terminology | ||
|
|
||
| - **Context path**: the org/project/doc portion of the URL. | ||
| - **Canonical path**: the fully expanded, tenant-specific path. | ||
| - **Universal route**: a shorthand path that starts with `/_/`. | ||
| - **Route registry**: the explicit list of shorthand routes and how they expand. | ||
|
|
||
| --- | ||
|
|
||
| ## Canonical path model | ||
|
|
||
| Canonical paths include the full tenant and document context: | ||
|
|
||
| - Project-level pages: | ||
| - `/:org/:project/dash` | ||
| - `/:org/:project/ciam` | ||
| - Document-level pages (example: forms): | ||
| - `/:org/:project/:docId/connect/share` | ||
|
|
||
| The doc type is **not** encoded in the universal path; it is resolved from | ||
| document context (id + type) at runtime. | ||
|
|
||
| --- | ||
|
|
||
| ## Universal path model | ||
|
|
||
| Universal routes replace the context path with a single reserved segment: | ||
|
|
||
| ``` | ||
| /_/<path> | ||
| ``` | ||
|
|
||
| Examples: | ||
|
|
||
| - `/_/dash` → `/:org/:project/dash` | ||
| - `/_/ciam` → `/:org/:project/ciam` | ||
| - `/_/connect/share` → `/:org/:project/:docId/connect/share` | ||
|
|
||
| `/_/` is **never canonical**. It is only an alias for documentation and | ||
| context-aware navigation. | ||
|
|
||
| --- | ||
|
|
||
| ## Resolution algorithm (runtime) | ||
|
|
||
| 1. Detect the universal prefix (`/_/`). | ||
| 2. Resolve **current context**: | ||
| - `org`, `project` from the active workspace/session. | ||
| - `docId` + `docType` from the active document (if required). | ||
| 3. Match the remainder against the **route registry**. | ||
| 4. Expand to the canonical path using the resolved context. | ||
| 5. Route/redirect to the canonical path. | ||
|
|
||
| If a required context is missing, the router must halt with a context selection | ||
| flow (or a clear error) instead of guessing. | ||
|
|
||
| --- | ||
|
|
||
| ## Invariants | ||
|
|
||
| - `_` is a **reserved segment** and must never be used as an org or project id. | ||
| - Universal routes are **explicitly registered**, not inferred. | ||
| - Doc type must **not** be encoded into `/_/` paths (no `/forms/`, no query | ||
| params like `?doctype=forms`). | ||
| - Any universal path must resolve to **exactly one** canonical route. | ||
|
|
||
| --- | ||
|
|
||
| ## Uniqueness test (collision prevention) | ||
|
|
||
| Because routing is **not strictly rule-based**, shorthand names can collide. | ||
| We must enforce uniqueness with a looped test over the route registry. | ||
|
|
||
| **Requirement** | ||
|
|
||
| For every defined shorthand route, the matcher must return **exactly one** | ||
| result (itself). | ||
|
|
||
| **Sketch** | ||
|
|
||
| ``` | ||
| for (const route of universalRoutes) { | ||
| const matches = matchUniversalRoute(route.samplePath) | ||
| assert(matches.length === 1) | ||
| assert(matches[0].id === route.id) | ||
| } | ||
| ``` | ||
|
|
||
| Notes: | ||
|
|
||
| - Each route definition must include a `samplePath` that exercises its matcher. | ||
| - The test must run in CI to catch collisions early. | ||
|
|
||
| --- | ||
|
|
||
| ## Examples | ||
|
|
||
| | universal path | canonical path (example) | | ||
| | ----------------------- | ----------------------------------------------------------------------- | | ||
| | `/_/dash` | `/acme/project/dash` | | ||
| | `/_/ciam` | `/acme/project/ciam` | | ||
| | `/_/connect/share` | `/acme/project/00000000-0000-0000-0000-000000001234/connect/share` | | ||
|
|
||
| --- | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - No implicit guessing or inference beyond the route registry. | ||
| - No alternate universal prefixes (`/_/_/`, `/__/`). | ||
| - No doc type leakage in the universal path. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| # `editor` | ||
|
|
||
| ## Universal routing (docs-friendly links) | ||
|
|
||
| Grida supports **universal routing** so documentation can link to stable, tenant-agnostic URLs like `https://grida.co/_/<path>` and have them resolved to canonical tenant/document routes at runtime. | ||
|
|
||
| - When you add a **new user-facing page** that should be referenced from docs, ensure it is registered in **universal routing**. | ||
| - When debugging docs links that point to the editor, start from the universal routing spec: `docs/wg/platform/universal-docs-routing.md`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Universal routing links in docs — verify they work for readers without auth context.
These links use the new
/_/universal routing prefix (https://grida.co/_/connectandhttps://grida.co/_/connect/channels). Per the PR's routing spec, universal routes require context resolution (org/project), and theUniversalRoutePickerpage redirects unauthenticated users to sign-in.For documentation readers who aren't logged in or land on this page externally, these links will redirect to sign-in rather than showing the referenced UI. Consider whether plain text navigation steps (the previous approach) or a mix of both would be more user-friendly for docs that are publicly accessible.
🤖 Prompt for AI Agents