Skip to content

fix: open coder_app links in new tab when open_in is tab#23000

Merged
angrycub merged 4 commits intomainfrom
fix/open-in-tab-new-tab
Mar 17, 2026
Merged

fix: open coder_app links in new tab when open_in is tab#23000
angrycub merged 4 commits intomainfrom
fix/open-in-tab-new-tab

Conversation

@angrycub
Copy link
Copy Markdown
Contributor

@angrycub angrycub commented Mar 12, 2026

Fixes #18573

Changes

When a coder_app resource sets open_in = "tab", clicking the app link now opens in a new browser tab instead of navigating in the same tab.

target="_blank" and rel="noopener noreferrer" are set inline on the <a> elements in AppLink.tsx, gated on app.open_in === "tab". This follows the codebase convention of co-locating target and rel at the render site.

noopener prevents tabnabbing — without it, the opened page can redirect the Coder dashboard tab via window.opener. This is especially relevant for same-origin path-based apps, which would otherwise have full DOM access to the dashboard. noreferrer suppresses the Referer header to avoid leaking workspace IDs to destination servers.

Future enhancement: template admins could opt into sending the referrer via a coder_app setting, enabling feedback pages built around workspace context.

Tests

A vitest case is added in AppLink.test.tsx (rather than a Storybook story, since the assertions are purely behavioral with no visual component):

  • sets target=_blank and rel=noopener noreferrer when open_in is tab — renders the app link with open_in: "tab" and asserts target="_blank" and rel="noopener noreferrer" are present on the anchor.

Slim-window behavior

The slim-window test case and the openAppInNewWindow() comment in apps.ts have been split out into a follow-up PR for separate review, since the window.open() / noopener tradeoffs there deserve dedicated discussion.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 12, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@angrycub angrycub force-pushed the fix/open-in-tab-new-tab branch 6 times, most recently from 1a53985 to dc17261 Compare March 13, 2026 13:34
@angrycub angrycub force-pushed the fix/open-in-tab-new-tab branch from 6e2e79c to 0645839 Compare March 13, 2026 20:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes workspace app link behavior so that coder_app.open_in = "tab" opens the app in a new browser tab (instead of navigating the current tab), aligning with expected UX and improving safety for _blank links.

Changes:

  • Add target="_blank" and rel="noopener noreferrer" to AppLink anchors when app.open_in === "tab".
  • Add Vitest regression coverage asserting correct target/rel behavior for open_in="tab" vs open_in="slim-window".
  • Document why openAppInNewWindow() intentionally omits "noopener" in window.open() features.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
site/src/modules/resources/AppLink/AppLink.tsx Conditionally sets anchor target/rel when open_in is "tab" to open in a new tab safely.
site/src/modules/resources/AppLink/AppLink.test.tsx Adds regression tests verifying anchor attributes for "tab" and absence for "slim-window".
site/src/modules/apps/apps.ts Adds explanatory comment about omitting "noopener" in window.open() features for popup-block detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

When a coder_app resource sets open_in = "tab", clicking the app
link now opens in a new browser tab instead of navigating in the
same tab.

The fix adds target="_blank" and rel="noopener noreferrer" inline
on the anchor elements in AppLink.tsx, gated on app.open_in === "tab".
This matches the codebase convention of co-locating target and rel at
the render site rather than returning HTML attributes from the hook.

noopener prevents tabnabbing — an opened page must not be able to
redirect the Coder dashboard via window.opener, which is especially
important for same-origin path-based apps that would otherwise have
full DOM access. noreferrer suppresses the Referer header to avoid
leaking workspace IDs to destination servers. A future enhancement
could allow template admins to opt into sending the referrer via a
coder_app setting, enabling feedback pages based on workspace context.

Vitest tests are added in AppLink.test.tsx asserting target and rel
are set correctly for open_in="tab", and absent for open_in="slim-window".
The slim-window path uses window.open() in onClick rather than anchor
attributes — adding "noopener" to window.open() features would cause it
to always return null per the WHATWG spec, making popup-blocked detection
impossible. The omission is intentional and documented in apps.ts.

Fixes #18573
…out slim-window

- Remove redundant <ProxyProvider> wrapper in test (renderWithAuth
  already provides one via RequireAuth)
- Remove slim-window test case and apps.ts comment to be reviewed
  separately in a follow-up PR
@angrycub angrycub force-pushed the fix/open-in-tab-new-tab branch from 0c8d4f8 to f8213f2 Compare March 16, 2026 15:27
Copy link
Copy Markdown
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

sorry, I just realized I didn't actually submit this review on friday 🤦‍♀️

current browsers are expected to include the noopener behavior when noreferrer is set. ref: https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer

Co-authored-by: Kayla はな <kayla@tree.camp>
@angrycub angrycub merged commit d3c9469 into main Mar 17, 2026
25 of 26 checks passed
@angrycub angrycub deleted the fix/open-in-tab-new-tab branch March 17, 2026 19:32
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: coder_app open_in = "tab" opens link in same tab

3 participants