Skip to content

fix(code): route all markdown link clicks through openExternal#2381

Closed
annikaschmid wants to merge 1 commit into
mainfrom
posthog-code/fix-markdown-link-clicks
Closed

fix(code): route all markdown link clicks through openExternal#2381
annikaschmid wants to merge 1 commit into
mainfrom
posthog-code/fix-markdown-link-clicks

Conversation

@annikaschmid
Copy link
Copy Markdown
Contributor

Summary

External https:// links rendered inside chat / agent messages were inert when clicked — they appeared correctly (with the external-link glyph), but did nothing. The regression was introduced in #2241, which added an onClick handler to the markdown <a> renderer for posthog-code:// deeplinks and short-circuited every other URL:

onClick={(event) => {
  if (!isDeeplink || !href) return;   // ← bails for normal http(s) URLs
  event.preventDefault();
  void trpcClient.os.openExternal.mutate({ url: href });
}}

For non-deeplink URLs the click was left to target="_blank" + the main process's setWindowOpenHandler fallback, which on at least some setups was not actually opening the URL in the system browser.

This change drops the isDeeplink guard so every link with a real href is routed through trpcClient.os.openExternal — the same path the deeplink branch already uses. setupExternalLinkHandlers in apps/code/src/main/window.ts remains as a defensive safety net for any stray navigations from elsewhere in the renderer.

The isPostHogCodeDeeplink import is still in use for markdownUrlTransform (so defaultUrlTransform doesn't strip the custom scheme); only the unused local in the a renderer was removed.

Test plan

  • In a session, send a prompt that yields a markdown message containing a plain https:// link (e.g. ask the agent for a PostHog insight URL). Click the link → opens in the default system browser.
  • Click a posthog-code:// deeplink (e.g. via Inbox → Discuss). Deeplink still routes correctly.
  • Click a GitHub issue/PR URL in chat. GithubRefChip path is unaffected (returns before the modified onClick).
  • Right-click a link → "Open link in new window" still does not spawn an Electron child window (setWindowOpenHandler returns action: "deny").

Created with PostHog Code

PR #2241 added explicit handling for `posthog-code://` deeplinks in the
chat markdown renderer, but the new `onClick` short-circuited for every
other URL — leaving plain `https://` links inert when clicked. Drop the
`isDeeplink` guard so any link with an `href` is sent through
`trpcClient.os.openExternal`, the same path the deeplink branch already
uses.

Generated-By: PostHog Code
Task-Id: 893f622d-2bda-4581-9498-200848518353
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 26, 2026

Reviews (1): Last reviewed commit: "fix(code): route all markdown link click..." | Re-trigger Greptile

@annikaschmid annikaschmid requested a review from a team May 26, 2026 15:39
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.

1 participant