diff --git a/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts b/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts index 943d75af8bd..c7ae685f837 100644 --- a/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts +++ b/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts @@ -14,8 +14,8 @@ beforeEach(() => { openHttpLinkMock.mockReset() }) -// Why: markdown-preview-links.test.ts pins the preview half with the same options -// shape, so together they stop one file's link routing two ways. +// Why: the preview deliberately routes differently; this pins the editor side so a +// future "make them consistent" change cannot land silently. function clickExternalLinkWithShift(sourceOwner: HttpLinkSourceOwner, isMac = true): boolean { const href = 'https://example.com/docs' const view = { @@ -52,11 +52,12 @@ function clickExternalLinkWithShift(sourceOwner: HttpLinkSourceOwner, isMac = tr } describe('rich markdown editor Shift+modifier click on external links', () => { - it('defers the destination to openHttpLink instead of forcing the system browser', () => { + // Why: intentionally NOT the preview's behavior — this path hands the link to the + // client OS, so it must keep forcing the system browser even when inverting is on. + it('forces the system browser rather than following the invert setting', () => { expect(clickExternalLinkWithShift({ kind: 'local' })).toBe(true) expect(openHttpLinkMock).toHaveBeenCalledWith('https://example.com/docs', { - worktreeId: 'wt-1', - modifierHeld: true, + forceSystemBrowser: true, sourceOwner: { kind: 'local' } }) }) @@ -66,21 +67,18 @@ describe('rich markdown editor Shift+modifier click on external links', () => { it('uses the Ctrl chord off macOS', () => { expect(clickExternalLinkWithShift({ kind: 'local' }, false)).toBe(true) expect(openHttpLinkMock).toHaveBeenCalledWith('https://example.com/docs', { - worktreeId: 'wt-1', - modifierHeld: true, + forceSystemBrowser: true, sourceOwner: { kind: 'local' } }) }) - // Why: the owner has to survive the hop; openHttpLink is what then refuses to put - // a non-local source in Orca (enforced in http-link-routing.test.ts, not here). it('forwards a non-local source owner untouched', () => { const sourceOwner = { kind: 'ssh', connectionId: 'conn-1' } as HttpLinkSourceOwner expect(clickExternalLinkWithShift(sourceOwner)).toBe(true) expect(openHttpLinkMock).toHaveBeenCalledWith( 'https://example.com/docs', - expect.objectContaining({ modifierHeld: true, sourceOwner }) + expect.objectContaining({ forceSystemBrowser: true, sourceOwner }) ) }) }) diff --git a/src/renderer/src/components/editor/rich-markdown-editor-click-routing.ts b/src/renderer/src/components/editor/rich-markdown-editor-click-routing.ts index 87289fbdbbd..9078f0e769d 100644 --- a/src/renderer/src/components/editor/rich-markdown-editor-click-routing.ts +++ b/src/renderer/src/components/editor/rich-markdown-editor-click-routing.ts @@ -129,7 +129,6 @@ export function handleRichMarkdownEditorClick({ runtimeEnvironmentId, sourceOwner, settings, - worktreeId, worktreeRoot }) return true @@ -185,7 +184,6 @@ function getClickedLinkHref(view: EditorView, pos: number): string { function openMarkdownLinkInClientOs({ href, filePath, - worktreeId, worktreeRoot, runtimeEnvironmentId, sourceOwner, @@ -193,7 +191,6 @@ function openMarkdownLinkInClientOs({ }: { href: string filePath: string - worktreeId: string worktreeRoot: string | null runtimeEnvironmentId?: string | null sourceOwner: HttpLinkSourceOwner @@ -207,9 +204,9 @@ function openMarkdownLinkInClientOs({ return } if (classified.kind === 'external') { - // Why: same escape hatch as the markdown preview of this very file — routing must - // not depend on which of the two views the link was clicked in. - openHttpLink(classified.url, { worktreeId, modifierHeld: true, sourceOwner }) + // Why: deliberate divergence from the preview — this path hands the link to the + // client OS unconditionally, so it does not follow the invert setting. + openHttpLink(classified.url, { forceSystemBrowser: true, sourceOwner }) return } if (classified.kind === 'anchor') {