Skip to content

[MISC] Centralize internal link org-prefix resolution in CustomMarkdown#1884

Merged
chandrasekharan-zipstack merged 2 commits intomainfrom
fix/logs-panel-internal-link-url
Apr 1, 2026
Merged

[MISC] Centralize internal link org-prefix resolution in CustomMarkdown#1884
chandrasekharan-zipstack merged 2 commits intomainfrom
fix/logs-panel-internal-link-url

Conversation

@chandrasekharan-zipstack
Copy link
Copy Markdown
Contributor

@chandrasekharan-zipstack chandrasekharan-zipstack commented Mar 31, 2026

What

  • Move org-name prefix resolution for internal markdown links from useExceptionHandler into CustomMarkdown

Why

  • PR [FIX] Improve platform key error with actionable link to settings #1878 added enrichMarkdownLinks in useExceptionHandler to prepend /{orgName}/ to internal markdown links. This worked for error notifications, but the logs panel renders messages via CustomMarkdown directly — bypassing useExceptionHandler entirely. Internal links in logs (e.g. "Platform Keys") navigated to /settings/platform instead of /{orgName}/settings/platform.
  • Additionally, notifications also render through CustomMarkdown (App.jsx:56), so keeping enrichment in both places would cause double-prefixing.

How

  • CustomMarkdown.jsx: Read orgName from useSessionStore. When rendering an internal RouterLink (path starting with /), prepend /{orgName} to the URL. Added orgName to useMemo dependency array.
  • useExceptionHandler.jsx: Removed enrichMarkdownLinks, useSessionStore import, and the enrichment call in buildAlert. The content is now passed through unchanged — CustomMarkdown handles 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 useExceptionHandler to render-time resolution in CustomMarkdown. All consumers of CustomMarkdown (notifications, logs panel, display logs, RJSF widgets) benefit from the fix. External links are unaffected.

Related Issues or PRs

Notes on Testing

  • Deactivate all platform keys, then test connection on any adapter
  • Verify the logs panel shows a clickable "Platform Keys" link that navigates to /{orgName}/settings/platform
  • Verify the error notification popup also links correctly (no double org prefix)
  • Verify external links in markdown still open in new tabs

Screenshots

image

Checklist

I have read and understood the Contribution Guidelines.

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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Internal markdown links now correctly include organization context, ensuring proper navigation within the application.

Walkthrough

These changes relocate the organization-name prefixing logic for internal markdown links from the useExceptionHandler hook to the CustomMarkdown component, consolidating link resolution within the rendering layer.

Changes

Cohort / File(s) Summary
Link resolution refactoring
frontend/src/components/helpers/custom-markdown/CustomMarkdown.jsx
Added useSessionStore dependency to read sessionDetails and derive orgName. Updated internal link handling to prefix routes with /${orgName} when available. Extended useMemo dependency list to include orgName.
Hook cleanup
frontend/src/hooks/useExceptionHandler.jsx
Removed useSessionStore dependency and deleted the enrichMarkdownLinks helper function. Updated buildAlert to pass content through unchanged instead of applying link transformation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: centralizing internal link org-prefix resolution in CustomMarkdown by moving logic from useExceptionHandler.
Description check ✅ Passed The PR description includes all required template sections: What, Why, How, breaking changes assessment, related issues, testing notes, and screenshots with the contribution checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/logs-panel-internal-link-url

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.

@chandrasekharan-zipstack chandrasekharan-zipstack marked this pull request as ready for review March 31, 2026 16:28
@chandrasekharan-zipstack chandrasekharan-zipstack changed the title [FIX] Centralize internal link org-prefix resolution in CustomMarkdown [MISC] Centralize internal link org-prefix resolution in CustomMarkdown Mar 31, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR centralizes org-name prefix resolution for internal markdown links by moving it from useExceptionHandler (string-level manipulation) into CustomMarkdown (render-time resolution), fixing a bug where the logs panel showed unresolved /settings/platform-style links instead of /{orgName}/settings/platform.

Key changes:

  • CustomMarkdown.jsx now reads orgName from useSessionStore and prepends /{orgName} to any internal RouterLink path (URLs starting with /). orgName is correctly added to the useMemo dependency array.
  • useExceptionHandler.jsx drops enrichMarkdownLinks, useSessionStore, and the enrichment call in buildAlert — eliminating the previously reported double-prefixing risk for notification popups.
  • All consumers of CustomMarkdown (notifications, logs panel, display-logs, RJSF widgets) now benefit uniformly from the fix without requiring per-caller changes.
  • Graceful fallback: if orgName is absent (e.g. before session is established), the original URL is used unchanged.

Confidence Score: 5/5

This PR is safe to merge — the refactoring is logically correct, removes the double-prefixing risk, and adds a graceful fallback for missing org context.

No P0 or P1 issues found. The org-prefix logic is semantically equivalent to the removed approach, all consumers benefit, and the useMemo dependency array is correctly updated.

No files require special attention.

Important Files Changed

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)"]
Loading

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/logs-panel-..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b1a343 and 38fb412.

📒 Files selected for processing (2)
  • frontend/src/components/helpers/custom-markdown/CustomMarkdown.jsx
  • frontend/src/hooks/useExceptionHandler.jsx

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Frontend Lint Report (Biome)

All checks passed! No linting or formatting issues found.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

@chandrasekharan-zipstack chandrasekharan-zipstack merged commit fd84260 into main Apr 1, 2026
8 checks passed
@chandrasekharan-zipstack chandrasekharan-zipstack deleted the fix/logs-panel-internal-link-url branch April 1, 2026 14:15
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.

3 participants