{
+ preventTabMiddleButtonDefault(event);
+ press.onMouseDown(event);
+ }}
onMouseUp={preventTabMiddleButtonDefault}
onAuxClick={(event) => onAuxClick(event, surface)}
onContextMenu={(event) => onContextMenu(event, surface)}
+ onClick={press.onClick}
{...listeners}
+ onPointerDown={(event) => {
+ press.onPointerDown(event);
+ listeners?.onPointerDown?.(event);
+ }}
ref={setNodeRef}
style={{ transform: CSS.Translate.toString(transform), transition }}
className={cn(
@@ -1033,7 +1052,7 @@ function RightPanelTab(
props.active
? "bg-accent text-foreground"
: "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
- isDragging && "relative z-10",
+ isDragging && (inDragScope ? "opacity-50" : "relative z-10"),
)}
>
{content}
@@ -1074,12 +1093,15 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
setAddSurfaceMenuOpen(true);
}
});
+ // Inside ChatView's split view, which owns the shell and the split menu entries.
+ const pane = useRightPanelPane();
+ const takesNewSurfaceShortcut = props.open !== false && pane?.focused !== false;
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes a document keydown listener for the new surface shortcut while the panel is open
useEffect(() => {
- if (props.open === false) return;
+ if (!takesNewSurfaceShortcut) return;
document.addEventListener("keydown", onNewSurfaceKeyDown, true);
return () => document.removeEventListener("keydown", onNewSurfaceKeyDown, true);
- }, [props.open]);
+ }, [takesNewSurfaceShortcut]);
const updateTabScrollState = (viewport: HTMLDivElement) => {
const hasOverflow = viewport.scrollWidth - viewport.clientWidth > TAB_SCROLL_EDGE_TOLERANCE;
@@ -1200,7 +1222,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
const surfaceIndex = props.surfaces.findIndex((entry) => entry.id === surface.id);
if (surfaceIndex < 0) return;
- const items: ContextMenuItem
[] = [];
+ const items: ContextMenuItem[] = [];
if (surface.kind === "device" && props.onRenameDevice)
items.push({ id: "rename", label: "Rename" });
if (surface.kind === "file" && surface.attachment === undefined) {
@@ -1235,6 +1257,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
label: "Close all",
disabled: props.surfaces.length === 0,
},
+ ...(pane?.tabMenu.items(surface) ?? []),
);
const action = await api.contextMenu.show(items, { x: event.clientX, y: event.clientY });
@@ -1261,16 +1284,18 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
props.onCloseSurface(surface);
break;
case "close-others":
- props.onCloseOtherSurfaces(surface);
+ props.onCloseOtherSurfaces(surface, props.surfaces);
break;
case "close-to-right":
- props.onCloseSurfacesToRight(surface);
+ props.onCloseSurfacesToRight(surface, props.surfaces);
break;
case "close-all":
- props.onCloseAllSurfaces();
+ props.onCloseAllSurfaces(props.surfaces);
break;
case null:
break;
+ default:
+ pane?.tabMenu.select(action, surface);
}
};
const handleTabAuxClick = (event: ReactMouseEvent, surface: RightPanelSurface) => {
@@ -1336,8 +1361,11 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
};
};
+ const Frame = pane ? SplitPaneFrame : PreviewPanelShell;
+ const atLeftEdge = pane?.side !== "right";
+ const atRightEdge = pane?.side !== "left";
return (
-
@@ -1539,10 +1570,10 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
) : null}
{props.layoutControls}
- {ownsDesktopTitleBar && !props.layoutControls ? (
+ {ownsDesktopTitleBar && !props.layoutControls && atRightEdge ? (