Skip to content

feat(browser): open clicked links in the pane to the side - #13392

Closed
dcieslak19973 wants to merge 5 commits into
stablyai:mainfrom
dcieslak19973:dcieslak19973/link-open-to-side
Closed

dcieslak19973 wants to merge 5 commits into
stablyai:mainfrom
dcieslak19973:dcieslak19973/link-open-to-side

Conversation

@dcieslak19973

Copy link
Copy Markdown
Contributor

Summary

Closes #13390.

Clicking an in-app link always opened another tab in the worktree's active group, even with a browser pane sitting right beside the source — the handler passed no group at all:

store.createBrowserTab(sourcePage.worktreeId, url, { title: url })

This adds an opt-in setting (Settings → Browser → Open Links Beside, nested under Link Routing) that instead reuses the source pane's layout sibling, or splits right when there is no sibling yet. That is the behavior Open Preview to the Side already provides for previews; this PR makes it available for links and has both paths share one implementation.

Default is off, so nobody's current behavior changes silently.

Shape

  • src/renderer/src/lib/side-group-placement.ts — the placement primitive, lifted out of file-preview.ts now that it has two callers: resolve the source group (requested → active → first), then reuse the layout sibling or ask for a right split. Pure, so the rules are testable without a store.
  • src/renderer/src/lib/link-target-group.ts — link-specific policy: a pure planner plus a thin store adapter that performs the split.
  • file-preview.ts now delegates to the shared helper; openFilePreviewToSide behavior is unchanged.

Two decisions worth calling out, both pinned by tests:

  1. The source group is the clicked page's own group, not the focused one. A link clicked in an unfocused pane opens beside itself, which is what makes the behavior predictable under split layouts.
  2. Every failure path degrades to the previous behavior rather than failing to open — setting off, no resolvable group, or createEmptySplitGroup returning null all fall back to a new tab in the active group.

The existing remote/SSH early return (getRuntimeEnvironmentIdForWorktree) is untouched.

Screenshots

No new UI surface beyond one settings switch; the behavior change is where an existing tab appears. With Agent | Browser split and a link clicked in the left pane, the page now opens in the right pane instead of as another left-pane tab. With a single pane, a right split is created and the link opens there.

Testing

  • pnpm lint — oxlint, type-aware audit, react-doctor, max-lines ratchet, reliability gates, and all three localization gates (catalog / extraction / coverage) pass individually for these changes. New user-facing strings were added via pnpm run sync:localization-catalog. The full chain's verify:skill-bundle-manifest step fails identically on an untouched main checkout (stale generated skill artifacts — pre-existing, unrelated).
  • pnpm typecheck — clean (all three projects)
  • pnpm test — 3,839 passed / 1 skipped across the full src/renderer/src/lib suite, which includes the existing file-preview tests exercising the refactor. 16 of those are new.
  • pnpm build — not run.
  • Added 16 tests, written test-first: source-group precedence, sibling reuse from either pane, nested-split sibling resolution, subtree siblings, split-right when single-pane or when the source group is missing from the layout, setting-off passthrough, and the unfocused-pane case.

Not manually verified in a running app. The logic is unit-tested and the store calls are the same ones openFilePreviewToSide already uses in production, but I have not watched a click land in the right pane. Worth a manual check before merge.

AI Review Report

Reviewed with Claude (Opus 5), TDD throughout — each test watched fail before implementation.

Risks checked:

  • Silent behavior change for existing users — mitigated by defaulting the setting off; the passthrough case is a test.
  • Regressing "Open Preview to the Side" — the refactor is behavior-preserving, and the full existing lib suite (3,839 tests) passes unchanged.
  • Broken opens on failure paths — audited every path that can fail to produce a group; all return null and fall back to the historical behavior rather than dropping the link.
  • Wrong pane under nested splits — "to the side" resolves as the layout sibling via the existing findSiblingGroupId; tested with (a | (b | c)) for both the nearest-sibling and subtree cases. This is deliberate but is not always the visually rightmost pane.
  • Index-coupled settings search entries — BrowserPane selects search entries positionally, so the new entry is appended rather than inserted, with a comment recording why. Inserting would have silently mis-mapped every later setting's visibility.

Cross-platform (macOS / Linux / Windows): checked. No shortcuts, accelerators, shortcut labels, path handling, or shell invocation are touched. The change is layout-state logic plus one settings switch; nothing platform-conditional. Developed and tested on Windows.

Forge/provider and remote considerations: no source-control provider surface touched. No wire-format change — the placement decision is made entirely in the renderer from local layout state, so there is no client/host contract impact per docs/reference/remote-wire-compatibility.md. Remote/SSH worktrees keep their existing early return and are unaffected.

Security Audit

  • Input handling: the URL path is unchanged — main still validates and normalizes before sending, and this PR only adds a destination group id resolved from local layout state. No rule, URL, or guest-supplied content influences the placement decision.
  • Command execution / path handling / IPC: none added. No new IPC channels; the existing browser:open-link-in-orca-tab payload is unchanged.
  • Secrets / auth: untouched.
  • Settings surface: one boolean, defaulting off, persisted through the existing GlobalSettings path.
  • Follow-up: none identified.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cded04e-16ee-432f-b553-6eafe3b5f16e

📥 Commits

Reviewing files that changed from the base of the PR and between 991a3fe and c323fe65727ef95208e185d92f8b89afdc5f7519.

📒 Files selected for processing (12)
  • src/renderer/src/components/settings/BrowserLinkSidePaneSetting.tsx
  • src/renderer/src/components/settings/BrowserPane.tsx
  • src/renderer/src/components/settings/browser-search.test.ts
  • src/renderer/src/components/settings/browser-search.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/file-preview.ts
  • src/renderer/src/lib/link-target-group.test.ts
  • src/renderer/src/lib/link-target-group.ts
  • src/renderer/src/lib/side-group-placement.test.ts
  • src/renderer/src/lib/side-group-placement.ts
  • src/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/shared/types.ts
  • src/renderer/src/components/settings/browser-search.ts
  • src/renderer/src/lib/link-target-group.test.ts
  • src/renderer/src/components/settings/BrowserPane.tsx
  • src/renderer/src/components/settings/browser-search.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/components/settings/BrowserLinkSidePaneSetting.tsx
  • src/renderer/src/lib/link-target-group.ts
  • src/renderer/src/lib/side-group-placement.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/side-group-placement.test.ts
  • src/renderer/src/lib/file-preview.ts

📝 Walkthrough

Walkthrough

Adds the optional openLinksInSidePane preference and a searchable browser setting with translated content. Adds helpers that resolve the source group, reuse an adjacent group, or create a right-side split. Applies the resolution to in-app browser links and file previews. Adds tests for disabled settings, fallback behavior, existing sibling groups, nested layouts, single-pane layouts, and split creation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: routing clicked browser links to a side pane.
Description check ✅ Passed The description covers the change, testing, AI review, security audit, screenshots, and platform considerations; only the optional Notes heading is absent.
Linked Issues check ✅ Passed The implementation satisfies issue #13390, including opt-in behavior, sibling reuse, right-side splitting, clicked-page targeting, fallbacks, and remote handling.
Out of Scope Changes check ✅ Passed All code changes support issue #13390 or its required shared placement refactor, settings UI, localization, and regression tests.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f77fe1d2-a6da-4a45-9426-303bdaa37ef7

📥 Commits

Reviewing files that changed from the base of the PR and between a1f61ef and d577651125b7a688696f456a43a938e829139106.

📒 Files selected for processing (11)
  • src/renderer/src/components/settings/BrowserLinkSidePaneSetting.tsx
  • src/renderer/src/components/settings/BrowserPane.tsx
  • src/renderer/src/components/settings/browser-search.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/file-preview.ts
  • src/renderer/src/lib/link-target-group.test.ts
  • src/renderer/src/lib/link-target-group.ts
  • src/renderer/src/lib/side-group-placement.test.ts
  • src/renderer/src/lib/side-group-placement.ts
  • src/shared/types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/i18n/locales/en.json (1)

5746-5746: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Preserve the Kagi brand capitalization.

"kagi" is a user-facing provider label. Use "Kagi" to match the product name.

Proposed fix
-          "4af9a17947": "kagi"
+          "4af9a17947": "Kagi"

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9bfa5368-e119-4acf-a471-5196666f35c3

📥 Commits

Reviewing files that changed from the base of the PR and between d577651125b7a688696f456a43a938e829139106 and e1a04bb5921c0cc9e1ee26b4c51ad2c6d6c06a27.

📒 Files selected for processing (3)
  • src/renderer/src/components/settings/BrowserLinkSidePaneSetting.tsx
  • src/renderer/src/components/settings/browser-search.test.ts
  • src/renderer/src/i18n/locales/en.json

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from f69a9d3 to c323fe6 Compare August 12, 2026 01:29
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from c323fe6 to b48bc88 Compare August 13, 2026 02:19
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from b48bc88 to 63ead44 Compare August 13, 2026 23:32
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from 63ead44 to 32036bc Compare August 14, 2026 00:23
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from 32036bc to be9473f Compare August 15, 2026 00:25
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from be9473f to 5a1345c Compare August 15, 2026 16:00
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from 5a1345c to 168def1 Compare August 19, 2026 01:39
@nwparker nwparker removed the P2 label Aug 19, 2026
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch 3 times, most recently from 464d014 to c271e61 Compare August 28, 2026 04:49
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch 4 times, most recently from 2e4249a to d9e7bc6 Compare September 10, 2026 13:00
@dcieslak19973
dcieslak19973 force-pushed the dcieslak19973/link-open-to-side branch from 88f6228 to 20c3289 Compare September 11, 2026 13:37
@nwparker

nwparker commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Closing this PR as orphaned: #13390 was closed as completed on 2026-10-23 by merged PR #31844 (feat(browser): open links beside their pane, focus link tabs, honor window.close()). Thanks for the contribution!

@nwparker nwparker closed this Dec 1, 2026
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.

[Feature]: Open clicked links in the pane to the side, splitting if none exists

4 participants