Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/web/src/components/PaneNotch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import { holdEndCornerWhileSliding } from "../motion/paneMotion";
* tooltips keep working in Electron. The focus ring is inset because the tab
* sits on the pane edge, where the pane clip would cut an outer ring.
*/
export const PANE_TAB_CLASS =
"inline-flex h-7 min-w-0 max-w-80 items-center gap-1.75 rounded-control surface-pane-tab px-2.5 text-control text-strong-foreground outline-none [-webkit-app-region:no-drag] focus-visible:inset-ring-2 focus-visible:inset-ring-ring";
export const PANE_TAB_SHAPE_CLASS =
"inline-flex h-7 min-w-0 max-w-80 items-center gap-1.75 rounded-control px-2.5 text-control text-strong-foreground outline-none [-webkit-app-region:no-drag] focus-visible:inset-ring-2 focus-visible:inset-ring-ring";
export const PANE_TAB_CLASS = `${PANE_TAB_SHAPE_CLASS} surface-pane-tab`;

export const PANE_TAB_TITLE_CLASS = "max-w-68 truncate";
/** The connected pane tabs widen it to the active title's, so activating a tab moves nothing. */
Expand Down
20 changes: 17 additions & 3 deletions apps/web/src/components/ThreadStatusIndicators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ import {
visibleThreadPullRequests,
} from "@t3tools/client-runtime/thread-pull-requests";
import { useRender } from "@base-ui/react/use-render";
import { type ReactNode, type AnimationEvent, type MouseEvent, type ReactElement } from "react";
import {
type ReactNode,
type AnimationEvent,
type MouseEvent,
type PointerEvent,
type ReactElement,
} from "react";
import { cn } from "../lib/utils";
import { revealThreadTerminal } from "../lib/revealThreadTerminal";

Expand Down Expand Up @@ -254,6 +260,7 @@ export function ThreadPullRequestBadgeControl({
status,
onOpenList,
onOpenPullRequest,
onPress,
appearance = "glyph",
}: {
render: ReactElement<{ render?: useRender.RenderProp }>;
Expand All @@ -264,6 +271,7 @@ export function ThreadPullRequestBadgeControl({
status: PrStatusIndicator | null;
onOpenList: () => void;
onOpenPullRequest: (event: MouseEvent<HTMLElement>, url?: string) => void;
onPress: (event: PointerEvent<HTMLElement>, opensList: boolean) => void;
appearance?: ThreadPullRequestBadgeAppearance;
}) {
const presentation = resolveThreadPullRequestBadgePresentation({ badge, number, url, status });
Expand All @@ -280,6 +288,7 @@ export function ThreadPullRequestBadgeControl({
pullRequests={pullRequests}
onOpenList={onOpenList}
onOpenPullRequest={onOpenPullRequest}
onPress={onPress}
/>
);
}
Expand All @@ -295,6 +304,7 @@ function PullRequestBadge({
pullRequests,
onOpenList,
onOpenPullRequest,
onPress,
}: {
render: ReactElement<{ render?: useRender.RenderProp }>;
appearance: ThreadPullRequestBadgeAppearance;
Expand All @@ -306,6 +316,7 @@ function PullRequestBadge({
pullRequests: ReadonlyArray<ThreadPullRequestLink>;
onOpenList: () => void;
onOpenPullRequest: (event: MouseEvent<HTMLElement>, url?: string) => void;
onPress: (event: PointerEvent<HTMLElement>, opensList: boolean) => void;
}) {
const onClick = opensList
? (event: MouseEvent<HTMLElement>) => {
Expand All @@ -317,14 +328,17 @@ function PullRequestBadge({
const element = opensList ? (
<button type="button" />
) : (
<a href={url} target="_blank" rel="noopener noreferrer" />
<a href={url} target="_blank" rel="noopener noreferrer" draggable={false} />
);
const control = useRender({
render,
props: {
render: element,
"aria-label": presentation.label,
onPointerDown: (event: MouseEvent<HTMLElement>) => event.stopPropagation(),
onPointerDown: (event: PointerEvent<HTMLElement>) => {
event.stopPropagation();
onPress(event, opensList);
},
onClick,
},
});
Expand Down
15 changes: 13 additions & 2 deletions apps/web/src/components/sidebar/SidebarChrome.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArrowLeftIcon, ChartNoAxesColumnIcon, SettingsIcon } from "lucide-react";
import type { ReactNode } from "react";
import type { PointerEvent as ReactPointerEvent, ReactNode } from "react";
import { memo } from "react";
import { Link, useLocation, useNavigate } from "@tanstack/react-router";

Expand All @@ -25,6 +25,7 @@ import {
useSidebar,
} from "../ui/sidebar";
import { PullRequestGlyph } from "../pullRequest/pullRequestIcons";
import { beginLayoutContentDrag } from "../../layout/layoutDrag";
import { useOpenLayoutPage } from "../../layout/pageNavigation";
import { isSidebarUtilityPage, useNavigateToMainApp } from "./mainAppLocation";
import { SidebarHeaderIconButton } from "./SidebarThreadHeader";
Expand Down Expand Up @@ -154,13 +155,20 @@ function SidebarUtilityItem({
icon,
label,
onClick,
onPointerDown,
}: {
icon: ReactNode;
label: string;
onClick: () => void;
onPointerDown?: ((event: ReactPointerEvent) => void) | undefined;
}) {
return (
<SidebarHeaderIconButton label={label} size="footer" onClick={onClick}>
<SidebarHeaderIconButton
label={label}
size="footer"
onClick={onClick}
onPointerDown={onPointerDown}
>
{icon}
</SidebarHeaderIconButton>
);
Expand Down Expand Up @@ -225,6 +233,9 @@ const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
icon={<PullRequestGlyph.pullRequest className="size-4" />}
label="Pull Requests"
onClick={handlePullRequestsClick}
onPointerDown={(event) =>
beginLayoutContentDrag(event, { kind: "pull-requests" })
}
/>
) : null}
<SidebarUtilityItem
Expand Down
13 changes: 12 additions & 1 deletion apps/web/src/components/sidebar/SidebarThreadRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ import {
} from "react";

import { useRightPanelStore } from "../../rightPanelStore";
import { useOpenPrLink } from "../../lib/openPullRequestLink";
import { beginLayoutContentDrag } from "../../layout/layoutDrag";
import { readThreadPullRequestSurface, useOpenPrLink } from "../../lib/openPullRequestLink";
import { useUiStateStore } from "../../uiStateStore";
import { useThreadSelectionStore } from "../../threadSelectionStore";
import { useNowMinute } from "../../hooks/useNowMinute";
Expand Down Expand Up @@ -1125,6 +1126,15 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
useRightPanelStore.getState().open(threadRef, "pull-requests");
if (!props.isRouteThread) onThreadActivate(threadRef);
};
const handlePrPress = (event: ReactPointerEvent<HTMLElement>, opensList: boolean) => {
const url = pr?.url ?? currentLinkedPr?.url;
const surface = opensList
? ({ id: "pull-requests", kind: "pull-requests" } as const)
: url
? readThreadPullRequestSurface(threadRef, url)
: null;
if (surface) beginLayoutContentDrag(event, { kind: "surface", threadRef, surface });
};
const prBadge =
prBadgeShape?.kind === "stack" || pr || currentLinkedPr ? (
<ThreadPullRequestBadgeControl
Expand All @@ -1143,6 +1153,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
status={prStatus}
onOpenList={handlePrListClick}
onOpenPullRequest={handlePrClick}
onPress={handlePrPress}
/>
) : null;
const terminalStatusIcon = (
Expand Down
65 changes: 54 additions & 11 deletions apps/web/src/layout/DropZones.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { AppWindowIcon, AtSignIcon, Columns2Icon, Layers2Icon, Rows2Icon } from
import type { ReactNode } from "react";
import { createPortal } from "react-dom";

import { PANE_TAB_CLASS } from "../components/PaneNotch";
import { PANE_TAB_SHAPE_CLASS } from "../components/PaneNotch";
import { ThreadSurfaceTabIcon } from "../components/SurfaceTabIcon";
import { useScrollingWorkspacesEnabled } from "../hooks/useSettings";
import { cn } from "../lib/utils";
import {
LAYOUT_DROP_CHROME_HEIGHT,
layoutDropLabel,
useLayoutDragState,
type LayoutDragContentSource,
type LayoutDragPane,
type LayoutDragRect,
type LayoutDragState,
Expand All @@ -17,6 +19,7 @@ import {
import { findLayoutTab, type LayoutTab } from "./layoutModel";
import { useLayoutStore } from "./layoutStore";
import { useLayoutTabLabel } from "./PaneTabs";
import { surfaceTabTitle } from "./surfaceTabLabels";

/** Pen C4fxiA: drop zones sit 8px inside the pane, 7.5px each side of its middle. */
const ZONE_INSET = 8;
Expand Down Expand Up @@ -90,10 +93,9 @@ function targetZone(state: LayoutDragState, target: LayoutDropTarget): Box | nul
function intoTabs(state: LayoutDragState, target: LayoutDropTarget) {
if (target.kind !== "into") return null;
const tabs = state.panes.find((pane) => pane.paneId === target.paneId)?.tabs ?? [];
const sourceTabId = state.source.kind === "tab" ? state.source.tabId : null;
return {
tabs: tabs.filter((tab) => tab.id !== sourceTabId),
reorder: tabs.some((tab) => tab.id === sourceTabId),
tabs: tabs.filter((tab) => tab.id !== state.sourceTabId),
reorder: tabs.some((tab) => tab.id === state.sourceTabId),
index: target.index,
};
}
Expand Down Expand Up @@ -235,22 +237,59 @@ function DraggedTabGhost({ tabId, point }: { tabId: string; point: { x: number;
(state) => findLayoutTab(state.layout, (candidate) => candidate.id === tabId)?.tab ?? null,
);
if (!tab) return null;
return <DraggedTabGhostBody tab={tab} point={point} />;
return (
<DraggedTabGhostBody point={point}>
<LayoutTabGhostLabel tab={tab} />
</DraggedTabGhostBody>
);
}

function DraggedTabGhostBody({ tab, point }: { tab: LayoutTab; point: { x: number; y: number } }) {
const label = useLayoutTabLabel(tab);
function DraggedTabGhostBody({
point,
children,
}: {
point: { x: number; y: number };
children: ReactNode;
}) {
return (
<div
className={cn(PANE_TAB_CLASS, "absolute left-0 top-0 surface-popover")}
className={cn(PANE_TAB_SHAPE_CLASS, "absolute left-0 top-0 surface-popover")}
style={{ transform: `translate(${point.x - 24}px, ${point.y - 14}px) rotate(-2deg)` }}
>
{label.icon}
<span className="min-w-0 truncate">{label.title}</span>
{children}
</div>
);
}

function GhostLabel({ icon, title }: { icon: ReactNode; title: string }) {
return (
<>
{icon}
<span className="min-w-0 truncate">{title}</span>
</>
);
}

function LayoutTabGhostLabel({ tab }: { tab: LayoutTab }) {
const label = useLayoutTabLabel(tab);
return <GhostLabel icon={label.icon} title={label.title} />;
}

const PULL_REQUESTS_PAGE_TAB: LayoutTab = {
id: "pull-requests",
content: { kind: "pull-requests" },
};

function DraggedContentLabel({ source }: { source: LayoutDragContentSource }) {
if (source.kind === "pull-requests") return <LayoutTabGhostLabel tab={PULL_REQUESTS_PAGE_TAB} />;
return (
<GhostLabel
icon={<ThreadSurfaceTabIcon threadRef={source.threadRef} surface={source.surface} />}
title={surfaceTabTitle(source.surface, null)}
/>
);
}

/** Cuts the composers out of the zones, so a composer reads as above them. */
function zonesClipPath(composers: readonly LayoutDragRect[]): string | undefined {
if (composers.length === 0) return undefined;
Expand Down Expand Up @@ -299,7 +338,11 @@ export function LayoutDropZones() {
</div>
{state.source.kind === "tab" ? (
<DraggedTabGhost tabId={state.source.tabId} point={state.point} />
) : null}
) : state.source.kind === "thread" ? null : (
<DraggedTabGhostBody point={state.point}>
<DraggedContentLabel source={state.source} />
</DraggedTabGhostBody>
)}
{into ? <InsertionMarker tabs={into.tabs} index={into.index} /> : null}
{zone && state.target ? (
<DropPill x={zone.left + zone.width / 2} y={zone.top + zone.height / 2}>
Expand Down
Loading
Loading