[MISC] Centralize internal link org-prefix resolution in CustomMarkdown#1884
Conversation
Move org-name prefix logic from useExceptionHandler into CustomMarkdown so it applies to all rendering contexts (logs panel, notifications, etc.) and prevents double-prefixing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary by CodeRabbit
WalkthroughThese changes relocate the organization-name prefixing logic for internal markdown links from the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
| Filename | Overview |
|---|---|
| frontend/src/components/helpers/custom-markdown/CustomMarkdown.jsx | Adds org-name prefix resolution at render time for internal RouterLink paths; reads orgName from session store and prepends it to any URL starting with '/'; correctly adds orgName to useMemo deps. |
| frontend/src/hooks/useExceptionHandler.jsx | Removes enrichMarkdownLinks helper, useSessionStore import, and its call in buildAlert; content now passes through unchanged as CustomMarkdown handles resolution at render time. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Markdown text\ne.g. [Platform Keys](/settings/platform)"] --> B["CustomMarkdown.jsx"]
B --> C{"URL starts with '/'?"}
C -- Yes --> D{"orgName available?"}
D -- Yes --> E["resolvedUrl = /{orgName}{url}"]
D -- No --> F["Use original url"]
E --> G["RouterLink to=resolvedUrl"]
F --> G
C -- No --> H["Link href=url target=_blank (external)"]
Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/logs-panel-..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/src/components/helpers/custom-markdown/CustomMarkdown.jsx`:
- Around line 57-60: The internal-link check in CustomMarkdown.jsx incorrectly
treats protocol-relative URLs (//host) as internal and may double-prefix already
org-prefixed paths; modify the isInternal logic (used where isInternal,
resolvedUrl, RouterLink, orgName, and url are referenced) to only treat a link
as internal when url starts with a single slash (e.g. url.startsWith("/") &&
!url.startsWith("//")), and when constructing resolvedUrl only prefix with
`/${orgName}` if orgName exists AND the url is not already org-prefixed (e.g.
not url.startsWith(`/${orgName}`)); return RouterLink to the original url
otherwise.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fe741a0e-214a-48d8-9e9b-82e07f95460e
📒 Files selected for processing (2)
frontend/src/components/helpers/custom-markdown/CustomMarkdown.jsxfrontend/src/hooks/useExceptionHandler.jsx
Frontend Lint Report (Biome)✅ All checks passed! No linting or formatting issues found. |
|



What
useExceptionHandlerintoCustomMarkdownWhy
enrichMarkdownLinksinuseExceptionHandlerto prepend/{orgName}/to internal markdown links. This worked for error notifications, but the logs panel renders messages viaCustomMarkdowndirectly — bypassinguseExceptionHandlerentirely. Internal links in logs (e.g. "Platform Keys") navigated to/settings/platforminstead of/{orgName}/settings/platform.CustomMarkdown(App.jsx:56), so keeping enrichment in both places would cause double-prefixing.How
CustomMarkdown.jsx: ReadorgNamefromuseSessionStore. When rendering an internalRouterLink(path starting with/), prepend/{orgName}to the URL. AddedorgNametouseMemodependency array.useExceptionHandler.jsx: RemovedenrichMarkdownLinks,useSessionStoreimport, and the enrichment call inbuildAlert. Thecontentis now passed through unchanged —CustomMarkdownhandles resolution at render time.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
No. The org-prefix logic is preserved — it just moved from string manipulation in
useExceptionHandlerto render-time resolution inCustomMarkdown. All consumers ofCustomMarkdown(notifications, logs panel, display logs, RJSF widgets) benefit from the fix. External links are unaffected.Related Issues or PRs
Notes on Testing
/{orgName}/settings/platformScreenshots
Checklist
I have read and understood the Contribution Guidelines.