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
2 changes: 1 addition & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,7 @@ export default function ChatView(props: ChatViewProps) {
)
? gt("Available once the thread's worktree is set up.")
: null;
const openSideChatStable = useStableCallback(() => void sideChat.open());
const openSideChatStable = useStableCallback(() => sideChat.open());
const openSurfaceInMainView = useOpenSurfaceInMainView(activeThreadRef);
const sendSideChatStable = useStableCallback(sideChat.open);
const { onConfirmRevertStable, onForkFromRunStable, onRevertTimelineTurnStable } =
Expand Down
23 changes: 19 additions & 4 deletions apps/web/src/components/RightPanelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import {
} from "~/fork/dashboard/dashboardSurface";
import {
AllMenuItemsHidden,
type SurfaceActionDrag,
useArrangedSurfaceActions,
useSurfaceActionDrag,
} from "~/fork/rightPanelMenu/rightPanelMenu";
import {
displayTitle,
Expand Down Expand Up @@ -168,7 +170,11 @@ export interface RightPanelTabsProps<Entry extends WorkAreaEntry = RightPanelSur
onMoveSurface?: (surfaceId: string, toIndex: number) => void;
onCopyFilePath: (relativePath: string) => void;
onDuplicateBrowser?: (surface: Entry) => void;
onAddBrowser: () => void;
/**
* Opens a browser tab. A returned promise lets a drop wait for the open, so a user action before
* it settles wins over the drop's place.
*/
onAddBrowser: () => void | Promise<unknown>;
/** Keep separate from the DOM click handler so a MouseEvent cannot become a profile id. */
onAddBrowserInProfile: (profileId: string) => void;
onAddTerminal: () => void;
Expand All @@ -178,7 +184,7 @@ export interface RightPanelTabsProps<Entry extends WorkAreaEntry = RightPanelSur
onAddPullRequests: () => void;
onAddDevice: () => void;
/** Absent where side chats are not offered. */
onAddSideChat?: (() => void) | undefined;
onAddSideChat?: (() => void | Promise<unknown>) | undefined;
/** Items that open the tabs of the thread's display mode and Dashboard switch, such as Replies. */
modeSurfaceActions?: ReadonlyArray<ModeSurfaceAction> | undefined;
browserAvailable: boolean;
Expand Down Expand Up @@ -338,10 +344,12 @@ function SurfaceMenuItem(props: {
disabledReason?: string;
shortcut: string;
onClick: () => void;
drag: ReturnType<SurfaceActionDrag>;
children: ReactNode;
}) {
const item = (
<MenuItem
{...props.drag}
className={!props.available ? "data-disabled:pointer-events-auto" : undefined}
onClick={props.onClick}
disabled={!props.available}
Expand All @@ -356,7 +364,7 @@ function SurfaceMenuItem(props: {
}

function RightPanelEmptyState(props: {
onAddBrowser: () => void;
onAddBrowser: () => void | Promise<unknown>;
onAddBrowserInProfile: (profileId: string) => void;
browserProfiles: ReadonlyArray<{ readonly id: string; readonly name: string }>;
onAddTerminal: () => void;
Expand All @@ -366,8 +374,9 @@ function RightPanelEmptyState(props: {
onAddPullRequests: () => void;
onAddDevice: () => void;
/** Absent where side chats are not offered. */
onAddSideChat?: (() => void) | undefined;
onAddSideChat?: (() => void | Promise<unknown>) | undefined;
modeSurfaceActions?: ReadonlyArray<ModeSurfaceAction> | undefined;
actionDrag: SurfaceActionDrag;
browserAvailable: boolean;
terminalAvailable: boolean;
diffAvailable: boolean;
Expand Down Expand Up @@ -559,6 +568,7 @@ function RightPanelEmptyState(props: {
}
>
<button
{...props.actionDrag(action)}
type="button"
onClick={action.onClick}
className={cn(
Expand Down Expand Up @@ -1199,6 +1209,8 @@ export function RightPanelTabs<Entry extends WorkAreaEntry>(props: RightPanelTab
const addSurfaceTriggerRef = useRef<HTMLButtonElement>(null);
const [renamingDevice, setRenamingDevice] = useState<string | null>(null);
const [addSurfaceMenuOpen, setAddSurfaceMenuOpen] = useState(false);
const actionDrag = useSurfaceActionDrag(props.environmentId);
const closeAddSurfaceMenu = () => setAddSurfaceMenuOpen(false);
const [tabScrollState, setTabScrollState] = useState({
hasOverflow: false,
canScrollLeft: false,
Expand Down Expand Up @@ -1662,6 +1674,7 @@ export function RightPanelTabs<Entry extends WorkAreaEntry>(props: RightPanelTab
return (
<MenuSub key={action.label}>
<MenuSubTrigger
{...actionDrag(action, closeAddSurfaceMenu)}
className="[&>svg:last-child]:ms-0"
aria-keyshortcuts={action.shortcut || undefined}
onClick={(event) => {
Expand Down Expand Up @@ -1702,6 +1715,7 @@ export function RightPanelTabs<Entry extends WorkAreaEntry>(props: RightPanelTab
disabledReason={action.disabledReason}
shortcut={action.shortcut}
onClick={action.onClick}
drag={actionDrag(action, closeAddSurfaceMenu)}
>
<Icon />
{messages(action.label)}
Expand Down Expand Up @@ -1787,6 +1801,7 @@ export function RightPanelTabs<Entry extends WorkAreaEntry>(props: RightPanelTab
onAddDevice={props.onAddDevice}
onAddSideChat={props.onAddSideChat}
modeSurfaceActions={props.modeSurfaceActions}
actionDrag={actionDrag}
browserAvailable={props.browserAvailable}
terminalAvailable={props.terminalAvailable}
diffAvailable={props.diffAvailable}
Expand Down
11 changes: 10 additions & 1 deletion apps/web/src/components/chat/ThreadDetailsIssueRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { threadIssueKeyOf, type ScopedThreadRef, type ThreadIssueLink } from "@t
import { scopedThreadKey } from "@t3tools/client-runtime/environment";
import { useGT } from "gt-react";
import { MessageSquareIcon } from "lucide-react";
import { useState, type MouseEvent } from "react";
import { useState, type DragEvent, type MouseEvent } from "react";

import { issueRowPanelLink, useWebPanelLink } from "~/fork/workArea/chatAnchorLink";
import { startPanelLinkDrag } from "~/fork/workArea/panelLinkDrag";
import { cn } from "~/lib/utils";
import { useRightPanelStore } from "~/rightPanelStore";
import { useServerConfigs } from "~/state/entities";
Expand Down Expand Up @@ -39,6 +41,7 @@ function LinkedIssueRow({
const gt = useGT();
const configs = useServerConfigs();
const detail = useLinkedIssueDetail(threadRef.environmentId, link, mountScope);
const webPanelLink = useWebPanelLink(threadRef);
const trackerPresentation = issueTrackerPresentation(link.tracker);
const state = detail === null ? null : issueStatePresentation(detail.state);
const Icon = state?.Icon ?? IssueGlyph.issue;
Expand All @@ -56,6 +59,12 @@ function LinkedIssueRow({
useRightPanelStore.getState().openIssue(threadRef, link);
onOpen?.();
},
// A row drags to a pane, except in the sidebar tooltip, whose click also opens its thread.
onDragStart:
mountScope !== "sidebar-tooltip"
? (event: DragEvent<HTMLElement>) =>
startPanelLinkDrag(event, issueRowPanelLink(link, threadRef, webPanelLink))
: undefined,
};
const glyph = (
<Icon
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/components/chat/ThreadDetailsPrRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useState, type MouseEvent as ReactMouseEvent } from "react";
import type { ComposerThreadTarget } from "~/composerDraftStore";
import { useLiveRefresh } from "~/hooks/useLiveRefresh";
import { usePullRequestChecksRefresh } from "~/hooks/usePullRequestChecksRefresh";
import { type PanelLink, panelDragProps } from "~/fork/workArea/panelLinkDrag";
import { cn } from "~/lib/utils";
import { useServerConfigs } from "~/state/entities";
import { pullRequestEnvironment } from "~/state/pullRequests";
Expand Down Expand Up @@ -94,6 +95,7 @@ export function ThreadDetailsPrRow({
project,
label,
onOpen,
panelLink,
onActed,
onStopWatching,
composerTarget,
Expand All @@ -106,6 +108,7 @@ export function ThreadDetailsPrRow({
project: EnvironmentProject | null;
label: string;
onOpen: (event: ReactMouseEvent<HTMLElement>) => void;
panelLink?: (() => PanelLink | null) | undefined;
onActed?: () => void;
onStopWatching?: (() => void) | undefined;
/** Fix and Resolve write here instead of checking the pull request out in a new thread. */
Expand Down Expand Up @@ -505,6 +508,7 @@ export function ThreadDetailsPrRow({
aria-label={openAriaLabel}
onClick={onOpen}
onAuxClick={onOpen}
{...(panelLink ? panelDragProps(panelLink) : {})}
/>
}
>
Expand Down
8 changes: 8 additions & 0 deletions apps/web/src/components/chat/ThreadDetailsPrRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useProjects, useQuietThreadShell } from "~/state/entities";
import { threadEnvironment } from "~/state/threads";
import { useAtomCommand } from "~/state/use-atom-command";

import { usePullRequestRowPanelLink } from "../../fork/workArea/chatAnchorLink";
import { useOpenPrLink } from "../../lib/openPullRequestLink";
import {
linkedPullRequestSnapshotStatus,
Expand All @@ -40,13 +41,15 @@ function ThreadDetailsPrLinkRow({
environmentId,
link,
onOpen,
panelLink,
onActed,
onStopWatching,
composerTarget,
}: {
environmentId: EnvironmentId;
link: ThreadPullRequestLink;
onOpen: (event: ReactMouseEvent<HTMLElement>) => void;
panelLink: ComponentProps<typeof ThreadDetailsPrRow>["panelLink"];
onActed?: (() => void) | undefined;
onStopWatching?: (() => void) | undefined;
composerTarget?: ComposerThreadTarget | undefined;
Expand All @@ -73,6 +76,7 @@ function ThreadDetailsPrLinkRow({
project={project}
label={`#${link.number}${link.snapshot === null ? "" : `: ${link.snapshot.title}`}`}
onOpen={onOpen}
panelLink={panelLink}
onStopWatching={onStopWatching}
composerTarget={composerTarget}
{...(onActed ? { onActed } : {})}
Expand All @@ -93,6 +97,7 @@ function ThreadDetailsPrRows({
onOpenLink: (event: ReactMouseEvent<HTMLElement>, url: string) => void;
}) {
const [expanded, setExpanded] = useState(false);
const rowPanelLink = usePullRequestRowPanelLink(threadRef);
const watch = useAtomCommand(threadEnvironment.watchPullRequest, { reportFailure: true });
const stopWatching = (link: ThreadPullRequestLink | null) =>
link?.watch === undefined
Expand Down Expand Up @@ -128,6 +133,7 @@ function ThreadDetailsPrRows({
environmentId={row.environmentId}
link={link}
onOpen={(event) => onOpenLink(event, link.url)}
panelLink={() => rowPanelLink(link.url)}
onActed={row.onActed}
onStopWatching={stopWatching(link)}
composerTarget={row.composerTarget}
Expand Down Expand Up @@ -168,6 +174,7 @@ export function ThreadDetailsThreadPrRows({
branchSourceControlProvider,
);
const openPrLink = useOpenPrLink(threadRef);
const rowPanelLink = usePullRequestRowPanelLink(threadRef);
const { currentLink, pr, number, url } = displayed;
const projects = useProjects();
const parsed =
Expand Down Expand Up @@ -197,6 +204,7 @@ export function ThreadDetailsThreadPrRows({
project={rowProject}
label={`#${number}${pr?.title.trim() ? `: ${pr.title}` : ""}`}
onOpen={(event) => openPrLink(event, url)}
panelLink={() => rowPanelLink(url)}
composerTarget={composerTarget}
{...(onActed ? { onActed } : {})}
/>
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/components/chat/useRightPanelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
import type { ChatShortcutCommands } from "./useChatShortcuts";
import { closeFocusedTab, toggleDiff, togglePreview } from "../../fork/workArea/workAreaCommands";
import { fromPrimaryChat } from "../../fork/workArea/chatFileOpener";
import { deviceOpensSetup } from "../../fork/rightPanelMenu/menu.logic";
interface RightPanelActionsInput {
readonly activeThreadRef: ScopedThreadRef | null;
readonly activeProject: EnvironmentProject | null;
Expand Down Expand Up @@ -115,7 +116,7 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
const onToggleDiffStable = useStableCallback(onToggleDiff);
const createBrowserSurface = (profileId?: string, duplicateFrom?: PreviewSessionSnapshot) => {
if (!activeThreadRef || !canOperatePreview) return;
void addBrowserSurface({
return addBrowserSurface({
threadRef: activeThreadRef,
openPreview,
...(profileId === undefined ? {} : { profileId }),
Expand Down Expand Up @@ -164,7 +165,7 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
const addPullRequestsSurfaceStable = useStableCallback(addPullRequestsSurface);
const addDeviceSurface = () => {
if (!activeThreadRef) return;
if (!deviceState.onboardingCompleted || deviceState.hostStatus === "disabled") {
if (deviceOpensSetup(deviceState)) {
openDeviceSetupDialog(scopedThreadKey(activeThreadRef));
return;
}
Expand Down
39 changes: 21 additions & 18 deletions apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import {
import { writeTextToClipboard } from "~/hooks/useCopyToClipboard";
import { findProjectForChangeRequest } from "@t3tools/client-runtime/change-request-links";
import { pullRequestLinkPanelTarget, useOpenPrLink } from "~/lib/openPullRequestLink";
import { usePullRequestRowPanelLink } from "~/fork/workArea/chatAnchorLink";
import { startPanelLinkDrag } from "~/fork/workArea/panelLinkDrag";
import { useClientSettings } from "~/hooks/useSettings";
import { usePrimaryEnvironmentId } from "~/state/environments";
import { usePullRequestIntentPrefetch } from "./usePullRequestIntentPrefetch";
Expand Down Expand Up @@ -116,6 +118,7 @@ function LinkRowImpl({
const gt = useGT();
const resolve = useMessages();
const openPrLink = useOpenPrLink(threadRef);
const rowPanelLink = usePullRequestRowPanelLink(threadRef);
const [menuOpen, setMenuOpen] = useState(false);
const [menuPosition, setMenuPosition] = useState<{ x: number; y: number } | null>(null);
const menuAnchor = menuPosition
Expand Down Expand Up @@ -179,24 +182,24 @@ function LinkRowImpl({
<a
href={link.url}
onClick={(event) => openPrLink(event, link.url, threadRef)}
// Outside drops use the URL; the composer uses this context-chip payload.
onDragStart={
snapshot === null
? undefined
: (event) =>
event.dataTransfer.setData(
COMPOSER_PULL_REQUEST_DRAG_TYPE,
encodePullRequestDragPayload({
number: link.number,
title: snapshot.title,
url: link.url,
headBranch: snapshot.headBranch,
baseBranch: snapshot.baseBranch,
state: snapshot.state,
isDraft: snapshot.isDraft,
}),
)
}
// Outside drops use the URL, the composer this context-chip payload; a pane opens its tab.
onDragStart={(event) => {
if (snapshot !== null) {
event.dataTransfer.setData(
COMPOSER_PULL_REQUEST_DRAG_TYPE,
encodePullRequestDragPayload({
number: link.number,
title: snapshot.title,
url: link.url,
headBranch: snapshot.headBranch,
baseBranch: snapshot.baseBranch,
state: snapshot.state,
isDraft: snapshot.isDraft,
}),
);
}
startPanelLinkDrag(event, rowPanelLink(link.url));
}}
className="flex min-w-0 flex-1"
>
<PullRequestRowLines
Expand Down
Loading
Loading