You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): middle-clicking a file link no longer opens a broken tab - #47125
When middle-clicking a web chat file link chip, the browser opens a new tab at http://<origin>/<file-path> showing "Thread unavailable" instead of staying on the thread. MarkdownFileLink renders <a href={href} /> and cancels onClick, but middle-click fires auxclick.
Change
Added onAuxClick to the anchor chip in apps/web/src/components/chat/MarkdownFileLink.tsx to cancel middle-click (event.button === 1) with event.preventDefault() so middle-clicking does nothing (no tab opens, thread stays), matching ChatMarkdown.tsx's guard for editor/localhost links and desktop's no-op.
Added a browser regression test in apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx.
Scope
Web chat file chip middle-click bug fix (single web surface, obvious bug, no issue needed).
Verification
Linux repro: Add /tmp/t3-demo-repo (src/module0..3.ts) to an isolated dev server (T3CODE_DEV_SEED=0, T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD=false), pair Chromium, run window.t3dev.replay("bench-heavy"), middle-click module0.ts.
Setup. Ubuntu 26.04, headless Chromium (Playwright; input sent through the debugging port), dark theme, 1280x800, fresh data per commit (/tmp/t3-demo-repo, Replay (dev)bench-heavy).
Steps. Open Replay: bench-heavy → middle-click module0.ts.
Opens a new tab showing Thread unavailable (http://localhost:8384/tmp/t3-demo-repo/src/module0.ts).
Opens no new tab; thread stays unchanged.
Controls unchanged (e903c8517a5e, be9f9e9debf0): left-click, Shift+click, Enter open file panel; Ctrl+click triggers editor open (no tab); right-click opens context menu.
Links. Base e903c8517a5e, candidate be9f9e9debf0 (linked above).
Not shown.
Desktop (Electron): read only, not run; DesktopWindow.ts (setWindowOpenHandler) denies non-http:/https: popups on t3code://app/ (t3code-dev://app/), so middle-click is already a no-op.
Mobile: SelectableMarkdownText.tsx uses native MobileEnrichedMarkdownText (no HTML <a> chips or middle-click).
Firefox and Safari: not run; relies on auxclickpreventDefault(), as ChatMarkdown.tsx does.
File link chips render an anchor whose href is a local file path. Left-clicks cancel default navigation in onClick, but middle-clicking an anchor fires auxclick instead of click, letting the browser open a new tab at a nonexistent app route showing Thread unavailable.
Add an onAuxClick handler on the anchor chip to cancel middle-click navigation with event.preventDefault() so the thread stays unchanged, matching desktop behavior.
Macroscope's review found this PR approvable — Middle-clicking actionable Markdown file links will no longer open a broken browser tab. The change is limited to that interaction and leaves existing primary-click actions and context menus unchanged.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between be9f9e9 and 685ca2e.
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
No actionable comments were generated in the recent review.
Walkthrough
The anchor-rendered file link chip now prevents the browser’s default action on middle-click. A browser test verifies that the event’s default action is prevented.
Changes: File link middle-click handling
Layer / File(s)
Summary
Middle-click behavior and browser test apps/web/src/components/chat/MarkdownFileLink.tsx, apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx
The anchor-rendered primary-action chip prevents the default action when an auxclick event has button === 1. The browser test verifies that the event’s default action is prevented.
Middle-clicking a file link chip no longer opens a broken tab. The change is narrow, reversible, and covered by a regression test, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: middle-clicking a file link chip no longer opens a broken tab. It follows the conventional commit form and matches the added onAuxClick guard in MarkdownFileLink.tsx.
Description check
The description covers the problem, the change, scope, and verification. It follows the template sections, gives the middle-click reproduction, and includes before/after screenshots and test results. …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description covers the problem, the change, scope, and verification. It follows the template sections, gives the middle-click reproduction, and includes before/after screenshots and test results. The Problem and Change sections are clear. The Scope section links no issue but explains why none is needed for an obvious bug. The Verification section is detailed and lists untested platforms.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Environment: real web client in headless Chromium, 1280×800, light theme; isolated fresh databases and identical synthetic replay data.
On each commit, seed a fresh synthetic demo-repo with src/module0.ts–module3.ts through t3.project; open the paired web app; wait for replay discovery; run window.t3dev.replay("bench-heavy"); wait for the completed answer; middle-click the module0.ts file chip with Playwright click({button:"middle"}); observe tabs and the current thread URL. On base, inspect the new tab's “Thread unavailable” page.
Scenario: Middle-clicking a chat file chip opens no broken tab
Base opened a second tab; head kept one tab and the original thread URL. Recordings follow the original tab; the extra base tab is shown in the separate capture above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When middle-clicking a web chat file link chip, the browser opens a new tab at
http://<origin>/<file-path>showing "Thread unavailable" instead of staying on the thread.MarkdownFileLinkrenders<a href={href} />and cancelsonClick, but middle-click firesauxclick.Change
onAuxClickto the anchor chip inapps/web/src/components/chat/MarkdownFileLink.tsxto cancel middle-click (event.button === 1) withevent.preventDefault()so middle-clicking does nothing (no tab opens, thread stays), matchingChatMarkdown.tsx's guard for editor/localhost links and desktop's no-op.apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx.Scope
Web chat file chip middle-click bug fix (single web surface, obvious bug, no issue needed).
Verification
Linux repro: Add
/tmp/t3-demo-repo(src/module0..3.ts) to an isolated dev server (T3CODE_DEV_SEED=0,T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD=false), pair Chromium, runwindow.t3dev.replay("bench-heavy"), middle-clickmodule0.ts.Setup. Ubuntu 26.04, headless Chromium (Playwright; input sent through the debugging port), dark theme,
1280x800, fresh data per commit (/tmp/t3-demo-repo,Replay (dev)bench-heavy).Steps. Open
Replay: bench-heavy→ middle-clickmodule0.ts.e903c8517a5e)be9f9e9debf0)Opens a new tab showing Thread unavailable (
http://localhost:8384/tmp/t3-demo-repo/src/module0.ts).Opens no new tab; thread stays unchanged.
Controls unchanged (
e903c8517a5e,be9f9e9debf0): left-click, Shift+click, Enter open file panel; Ctrl+click triggers editor open (no tab); right-click opens context menu.Links. Base
e903c8517a5e, candidatebe9f9e9debf0(linked above).Not shown.
DesktopWindow.ts(setWindowOpenHandler) denies non-http:/https:popups ont3code://app/(t3code-dev://app/), so middle-click is already a no-op.SelectableMarkdownText.tsxuses nativeMobileEnrichedMarkdownText(no HTML<a>chips or middle-click).auxclickpreventDefault(), asChatMarkdown.tsxdoes.Automated checks on be9f9e9
e903c8517a5e(expected false to be trueonmiddle.defaultPrevented) and passed onbe9f9e9debf0.vp test run apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx: 12/12 passed.vp test run apps/web/src/components/chat/MarkdownFileLink.logic.test.ts: 1/1 passed.ChatMarkdown.permissions.browser.test.tsx): 200/200 passed, 0 failures.vp run check:changed e903c8517a5e4546ac6b4f4e0e817a6266360644: format pass, lint pass (0 warnings, 0 errors), knip pass, typecheck pass (2 packages), test pass (2 files, 13 tests), react compiler pass (1 file).test-delta.cjs:{"kinds":{"browser":1,"server":0,"unit":0},"net":1,"newBrowserFiles":[]} quiet.Generated with Gemini 4 Neon in T3 Code Nightly