Skip to content

Commit 3c1be11

Browse files
fix(web): middle-clicking empty chat space on Linux no longer pastes into the composer (#36436)
1 parent b537916 commit 3c1be11

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ import { orchestrationV2WorktreePending } from "@t3tools/shared/orchestrationV2T
123123
import { resolveThreadReferenceCopyTarget } from "@t3tools/client-runtime/thread-reference";
124124
import { resolveTerminalSessionLabel } from "@t3tools/shared/terminalLabels";
125125
import { useAtomValue } from "@effect/atom-react";
126-
import { type SetStateAction, use, useEffect, useLayoutEffect, useRef, useState } from "react";
126+
import {
127+
type MouseEvent as ReactMouseEvent,
128+
type SetStateAction,
129+
use,
130+
useEffect,
131+
useLayoutEffect,
132+
useRef,
133+
useState,
134+
} from "react";
127135
import { BackgroundThreadContext } from "./chat/backgroundThread";
128136
import { WorkspaceMutationIdContext } from "./chat/ChatMarkdownMedia";
129137
import { useLocation, useNavigate } from "@tanstack/react-router";
@@ -3318,6 +3326,7 @@ export default function ChatView(props: ChatViewProps) {
33183326
data-chat-column-maximized-away={rightPanelMaximized ? "true" : "false"}
33193327
data-chat-column
33203328
inert={rightPanelMaximized}
3329+
onMouseUp={preventMiddleClickPasteOutsideEditable}
33213330
>
33223331
{embedded ? null : (
33233332
<header
@@ -4045,6 +4054,12 @@ export default function ChatView(props: ChatViewProps) {
40454054
);
40464055
}
40474056

4057+
// Chromium on Linux pastes PRIMARY into the focused editable unless the middle mouseup is cancelled.
4058+
function preventMiddleClickPasteOutsideEditable(event: ReactMouseEvent) {
4059+
if (event.button !== 1 || isEditableFocused(event.target)) return;
4060+
event.preventDefault();
4061+
}
4062+
40484063
function PreviewSessionSync(props: { readonly threadRef: ScopedThreadRef }) {
40494064
usePreviewSession(props.threadRef);
40504065
return null;

0 commit comments

Comments
 (0)