Skip to content

fix: confirm intercepted external links#2515

Open
janburzinski wants to merge 2 commits into
mainfrom
emdash/link-click-modal-ckkmv
Open

fix: confirm intercepted external links#2515
janburzinski wants to merge 2 commits into
mainfrom
emdash/link-click-modal-ckkmv

Conversation

@janburzinski

Copy link
Copy Markdown
Collaborator

Description

  • fixes external links from the main electron window opening immediately
  • routes intercepted window.open,target=_blank
Checklist
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for commit
    messages and, when possible, the PR title

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a confirmation dialog before opening external links intercepted by the main Electron process — both window.open/target="_blank" calls and will-navigate events now route through an IPC event to the renderer, where the existing confirmOpenExternalLink modal is shown.

  • externalLinks.ts: Replaces direct shell.openExternal() calls with requestExternalLinkOpen(), which emits an IPC event to the renderer; falls back to direct-open with a warning log when the main window is unavailable.
  • external-link-requests.ts (new): Wires the renderer-side IPC listener that calls confirmOpenExternalLink; the deregistration handle is returned but discarded at the call site in main.tsx, consistent with the other wire* helpers.
  • appEvents.ts: Adds the externalLinkOpenRequestedChannel event definition carrying { url: string }.

Confidence Score: 5/5

Safe to merge — the change narrows a gap where external links bypassed the existing confirmation modal, and the fallback path is explicitly logged.

The new IPC flow correctly threads intercepted links through the renderer's existing confirmation modal without introducing new code paths that could break existing behavior. The fallback to direct shell.openExternal when the main window is absent preserves the previous behavior for that narrow edge case and logs a warning. No logic errors or data-loss risks were identified in the changed files.

No files require special attention.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/main/utils/externalLinks.ts Adds requestExternalLinkOpen() helper that routes intercepted links through an IPC event to the renderer instead of calling shell.openExternal() directly; includes a fallback to direct-open when the main window is unavailable.
apps/emdash-desktop/src/renderer/lib/external-link-requests.ts New file wiring the renderer-side IPC listener; calls confirmOpenExternalLink on incoming events and returns the deregistration callback (which the caller in main.tsx currently discards).
apps/emdash-desktop/src/renderer/main.tsx Calls wireExternalLinkRequests() during bootstrap alongside the other wire* helpers; minimal and consistent with the existing pattern.
apps/emdash-desktop/src/shared/events/appEvents.ts Adds externalLinkOpenRequestedChannel event definition with { url: string } payload; straightforward addition following existing channel conventions.

Sequence Diagram

sequenceDiagram
    participant R as Renderer
    participant M as Main Process
    participant D as Dialog (Renderer)
    participant B as Default Browser

    R->>M: window.open() / navigation
    M->>M: setWindowOpenHandler / will-navigate
    alt main window available
        M->>R: "IPC: externalLinkOpenRequestedChannel { url }"
        R->>D: confirmOpenExternalLink(url)
        D->>R: user confirms
        alt open in default browser
            R->>M: rpc.app.openExternal(url)
            M->>B: shell.openExternal(url)
        else open in emdash browser
            R->>R: taskView.tabGroupManager.openBrowser(url)
        end
    else main window unavailable (fallback)
        M->>B: shell.openExternal(url) - no confirmation
    end
Loading

Reviews (2): Last reviewed commit: "fix(app): harden external link requests" | Re-trigger Greptile

Comment thread apps/emdash-desktop/src/renderer/lib/external-link-requests.ts Outdated
@janburzinski

Copy link
Copy Markdown
Collaborator Author

@greptileai

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