Split open-in editor controls into panel and toolbar variants
- Move Open in editor shortcut handling into a shared hook - Show Open in picker inside the thread details panel and restyle PR actions - Tighten popover positioning for the panel layout
This commit is contained in:
1 parent
97736c47a5
commit
a39d2fda26
12 files changed
+228
-602
No files matched your search
@@ -620,14 +620,8 @@ export function BranchToolbarBranchSelector({
|
||||
startFromOrigin,
|
||||
});
|
||||
|
||||
// PR pill shown next to the branch selector when the active branch has one.
|
||||
const branchPr = resolveThreadPr({
|
||||
threadBranch: resolveBranchToolbarPrBranch({
|
||||
activeThreadBranch,
|
||||
resolvedActiveBranch,
|
||||
}),
|
||||
gitStatus: branchStatusQuery.data ?? null,
|
||||
});
|
||||
// Change request state is compact in the composer and gets a dedicated row in the panel.
|
||||
const branchPr = resolveThreadPr(resolvedActiveBranch, branchStatusQuery.data ?? null);
|
||||
const branchPrStatus = prStatusIndicator(branchPr, branchStatusQuery.data?.sourceControlProvider);
|
||||
// Action-oriented tooltip (the pill opens the PR), distinct from the sidebar's
|
||||
// state-description tooltip.
|
||||
@@ -635,6 +629,12 @@ export function BranchToolbarBranchSelector({
|
||||
? `Open ${sourceControlPresentation.terminology.singular} #${branchPr.number} (${branchPr.state})`
|
||||
: "";
|
||||
const openPrLink = useOpenPrLink(threadRef);
|
||||
const panelPrStateClass =
|
||||
branchPr?.state === "open"
|
||||
? "bg-emerald-500/10 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-300"
|
||||
: branchPr?.state === "merged"
|
||||
? "bg-violet-500/10 text-violet-700 dark:bg-violet-400/10 dark:text-violet-300"
|
||||
: "bg-muted text-muted-foreground";
|
||||
|
||||
function renderPickerItem(itemValue: string, index: number) {
|
||||
if (checkoutPullRequestItemValue && itemValue === checkoutPullRequestItemValue) {
|
||||
@@ -735,12 +735,12 @@ export function BranchToolbarBranchSelector({
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex min-w-0 items-center gap-1",
|
||||
displayMode === "panel" && "w-full",
|
||||
"flex min-w-0",
|
||||
displayMode === "panel" ? "w-full flex-col items-stretch" : "items-center gap-1",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{branchPr && branchPrStatus ? (
|
||||
{displayMode !== "panel" && branchPr && branchPrStatus ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
@@ -788,6 +788,39 @@ export function BranchToolbarBranchSelector({
|
||||
</span>
|
||||
<ChevronDownIcon className="size-3 shrink-0 opacity-50" />
|
||||
</ComboboxTrigger>
|
||||
{displayMode === "panel" && branchPr && branchPrStatus ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={THREAD_DETAILS_PANEL_ROW_CLASS}
|
||||
aria-label={branchPrTooltip}
|
||||
onClick={(event) => openPrLink(event, branchPrStatus.url)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ChangeRequestStatusIcon
|
||||
className={cn(THREAD_DETAILS_PANEL_ICON_CLASS, branchPrStatus.colorClass)}
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate text-left">
|
||||
View {sourceControlPresentation.terminology.shortLabel} #{branchPr.number}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium capitalize leading-4",
|
||||
panelPrStateClass,
|
||||
)}
|
||||
>
|
||||
<span className="size-1.5 rounded-full bg-current opacity-75" aria-hidden="true" />
|
||||
{branchPr.state}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{branchPrStatus.tooltip}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
</div>
|
||||
<ComboboxPopup
|
||||
align={displayMode === "panel" ? "start" : "end"}
|
||||
|
||||
@@ -246,6 +246,8 @@ import { PullRequestThreadDialog } from "./PullRequestThreadDialog";
|
||||
import { MessagesTimeline } from "./chat/MessagesTimeline";
|
||||
import { resolveTimelineIsAtEnd } from "./chat/MessagesTimeline.logic";
|
||||
import { ChatHeader } from "./chat/ChatHeader";
|
||||
import { shouldShowOpenInPicker } from "./chat/OpenInPicker.logic";
|
||||
import { useOpenFavoriteEditorShortcut } from "./chat/OpenInPickerShortcut";
|
||||
import {
|
||||
PanelLayoutControls,
|
||||
type PanelLayoutControlsProps,
|
||||
@@ -2029,172 +2031,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
hasMultipleRegisteredEnvironments && activeThread
|
||||
? `${environmentById.get(activeThread.environmentId)?.label ?? serverConfig?.environment.label ?? activeThread.environmentId} server`
|
||||
: "server";
|
||||
const serverUpdateEnvironmentId = activeThread?.environmentId ?? null;
|
||||
const versionMismatchSelfUpdate = resolveServerSelfUpdateCapability(serverConfig);
|
||||
const serverUpdateState = useAtomValue(
|
||||
serverEnvironment.updateStateAtom(serverUpdateEnvironmentId),
|
||||
);
|
||||
const systemComposerBannerItems = useMemo<ComposerBannerStackItem[]>(() => {
|
||||
const items: ComposerBannerStackItem[] = [];
|
||||
const updateRunning = serverUpdateState.status === "running";
|
||||
const unavailableConnection = activeEnvironmentUnavailableState?.connection ?? null;
|
||||
const environmentReconnecting =
|
||||
unavailableConnection !== null &&
|
||||
(unavailableConnection.phase === "connecting" ||
|
||||
unavailableConnection.phase === "reconnecting");
|
||||
// Reconnecting to a version-skewed server with no update in flight
|
||||
// usually means the server is restarting mid-update and a refresh wiped
|
||||
// the in-memory update state. Fold the reconnect and version banners
|
||||
// into one calm line instead of stacking "Failed to connect" on
|
||||
// "versions differ". A failed update never folds: its error and retry
|
||||
// action must stay visible.
|
||||
const reconnectingThroughVersionSkew =
|
||||
serverUpdateState.status === "idle" && environmentReconnecting && versionMismatch !== null;
|
||||
// While an update runs, transient connect blips are expected (the server
|
||||
// restarts) and the update banner already shows progress. Hard failure
|
||||
// phases still surface so the Reconnect action stays reachable.
|
||||
const suppressUnavailableBanner =
|
||||
environmentReconnecting &&
|
||||
(updateRunning || (!reconnectingThroughVersionSkew && !reconnectWarningGraceElapsed));
|
||||
if (activeEnvironmentUnavailableState && unavailableConnection && !suppressUnavailableBanner) {
|
||||
if (reconnectingThroughVersionSkew) {
|
||||
items.push({
|
||||
id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`,
|
||||
variant: "default",
|
||||
// Live connection status: calm styling, but it must front the stack.
|
||||
urgent: true,
|
||||
icon: (
|
||||
<span
|
||||
className="size-1.5 animate-status-pulse rounded-full bg-foreground"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
),
|
||||
title: `${unavailableConnection.phase === "connecting" ? "Connecting" : "Reconnecting"} to ${activeEnvironmentUnavailableState.label}`,
|
||||
description: "It may be finishing an update. One moment.",
|
||||
});
|
||||
} else {
|
||||
items.push({
|
||||
id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`,
|
||||
variant: unavailableConnection.phase === "error" ? "error" : "warning",
|
||||
icon: <WifiOffIcon />,
|
||||
title: `${activeEnvironmentUnavailableState.label}: ${connectionStatusTitle(unavailableConnection)}`,
|
||||
description:
|
||||
unavailableConnection.error ??
|
||||
"Reconnect this environment before sending messages or running actions.",
|
||||
actions: (
|
||||
<>
|
||||
<Button
|
||||
size="xs"
|
||||
disabled={environmentReconnecting}
|
||||
onClick={() =>
|
||||
void handleReconnectActiveEnvironment(
|
||||
activeEnvironmentUnavailableState.environmentId,
|
||||
)
|
||||
}
|
||||
>
|
||||
{environmentReconnecting ? "Reconnecting..." : "Reconnect"}
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
onClick={() => void navigate({ to: "/settings/connections" })}
|
||||
>
|
||||
Connections
|
||||
</Button>
|
||||
</>
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (
|
||||
serverUpdateEnvironmentId &&
|
||||
!reconnectingThroughVersionSkew &&
|
||||
(serverUpdateState.status !== "idle" ||
|
||||
(showVersionMismatchBanner && versionMismatch && versionMismatchDismissKey))
|
||||
) {
|
||||
const updateInProgress = serverUpdateState.status === "running";
|
||||
const updateFailed = serverUpdateState.status === "failed";
|
||||
items.push({
|
||||
id: `server-version:${serverUpdateEnvironmentId}`,
|
||||
variant: updateFailed ? "error" : "default",
|
||||
// A running update is live progress the user is waiting on; only the
|
||||
// idle "update available" offer is calm enough to stack behind.
|
||||
urgent: updateInProgress,
|
||||
// In-flight and failed states carry their own status dot inside
|
||||
// ServerUpdateProgress; only the idle offer needs an icon.
|
||||
icon:
|
||||
updateInProgress || updateFailed ? null : (
|
||||
<span
|
||||
className="size-1.5 rounded-full border border-muted-foreground/40"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
),
|
||||
title:
|
||||
updateInProgress || updateFailed ? (
|
||||
`${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`
|
||||
) : versionMismatch ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button type="button" className="cursor-help rounded-sm text-left">
|
||||
Server update available
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">
|
||||
{versionMismatchServerLabel} {versionMismatch.serverVersion}{" "}
|
||||
<span aria-hidden="true">→</span> {versionMismatch.clientVersion}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : (
|
||||
"Server update available"
|
||||
),
|
||||
description:
|
||||
updateInProgress || updateFailed ? (
|
||||
<ServerUpdateProgress state={serverUpdateState} />
|
||||
) : versionMismatchSelfUpdate === "desktop-managed" ? (
|
||||
serverUpdateGuidance(versionMismatchSelfUpdate, versionMismatchServerLabel)
|
||||
) : null,
|
||||
// The desktop-managed guidance is already the description; the action
|
||||
// slot would only repeat it.
|
||||
actions:
|
||||
updateInProgress ||
|
||||
!versionMismatch ||
|
||||
versionMismatchSelfUpdate === "desktop-managed" ? undefined : (
|
||||
<ServerUpdateAction
|
||||
environmentId={serverUpdateEnvironmentId}
|
||||
serverLabel={versionMismatchServerLabel}
|
||||
selfUpdate={versionMismatchSelfUpdate}
|
||||
targetVersion={versionMismatch.clientVersion}
|
||||
label={updateFailed ? "Retry" : "Update"}
|
||||
/>
|
||||
),
|
||||
...(updateInProgress || updateFailed || !versionMismatchDismissKey
|
||||
? {}
|
||||
: {
|
||||
dismissLabel: "Dismiss update notice",
|
||||
onDismiss: () => {
|
||||
dismissVersionMismatch(versionMismatchDismissKey);
|
||||
setDismissedVersionMismatchKey(versionMismatchDismissKey);
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}, [
|
||||
activeEnvironmentUnavailableState,
|
||||
reconnectWarningGraceElapsed,
|
||||
handleReconnectActiveEnvironment,
|
||||
navigate,
|
||||
setDismissedVersionMismatchKey,
|
||||
showVersionMismatchBanner,
|
||||
serverUpdateState,
|
||||
versionMismatch,
|
||||
versionMismatchDismissKey,
|
||||
serverUpdateEnvironmentId,
|
||||
versionMismatchSelfUpdate,
|
||||
versionMismatchServerLabel,
|
||||
]);
|
||||
const reconnectActiveEnvironment = useCallback(() => {
|
||||
if (!activeEnvironmentUnavailableState) return;
|
||||
void handleReconnectActiveEnvironment(activeEnvironmentUnavailableState.environmentId);
|
||||
@@ -2643,6 +2479,18 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
);
|
||||
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||
const availableEditors = useAtomValue(primaryServerAvailableEditorsAtom);
|
||||
const showOpenInPicker = shouldShowOpenInPicker({
|
||||
activeProjectName: activeProject?.title,
|
||||
activeThreadEnvironmentId: activeThread?.environmentId ?? environmentId,
|
||||
primaryEnvironmentId,
|
||||
});
|
||||
useOpenFavoriteEditorShortcut({
|
||||
enabled: showOpenInPicker,
|
||||
environmentId: activeThread?.environmentId ?? environmentId,
|
||||
keybindings,
|
||||
availableEditors,
|
||||
openInCwd: gitCwd,
|
||||
});
|
||||
// Prefer an instance-id match so a custom Codex instance (e.g.
|
||||
// `codex_personal`) surfaces its own status/message in the banner rather
|
||||
// than the default Codex's. Falls back to first-match-by-kind when no
|
||||
@@ -6331,6 +6179,8 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
? (lastInvokedScriptByProjectId[activeProject.id] ?? null)
|
||||
: null,
|
||||
keybindings,
|
||||
availableEditors,
|
||||
showOpenInPicker,
|
||||
gitCwd,
|
||||
isGitRepo,
|
||||
envLocked,
|
||||
@@ -6461,19 +6311,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
? panelLayoutControls
|
||||
: null}
|
||||
<ChatHeader
|
||||
{...(!supportsPullRequests || threadRepository === null
|
||||
? {}
|
||||
: { onOpenPullRequest: openThreadPullRequest })}
|
||||
activeThreadEnvironmentId={activeThread.environmentId}
|
||||
activeThreadTitle={activeThread.title}
|
||||
isServerThread={isServerThread}
|
||||
changeRequestState={activeThreadPr?.state ?? null}
|
||||
activeProjectName={activeProject?.title}
|
||||
activeProjectCwd={activeProject?.workspaceRoot ?? null}
|
||||
activeProjectFaviconPath={activeProject?.faviconPath ?? null}
|
||||
openInCwd={gitCwd}
|
||||
keybindings={keybindings}
|
||||
availableEditors={availableEditors}
|
||||
rightPanelOpen={inlineRightPanelOwnsTitleBar}
|
||||
/>
|
||||
</header>
|
||||
|
||||
@@ -1,287 +1,24 @@
|
||||
import {
|
||||
type EnvironmentId,
|
||||
type EditorId,
|
||||
type ResolvedKeybindingsConfig,
|
||||
} from "@t3tools/contracts";
|
||||
import { memo } from "react";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import { SidebarTrigger } from "../ui/sidebar";
|
||||
import { OpenInPicker } from "./OpenInPicker";
|
||||
import { useRemoteOpenState, type RemoteOpenMode } from "../../remoteOpen";
|
||||
import { usePrimaryEnvironmentId } from "../../state/environments";
|
||||
import { useT3ProjectFileScripts } from "~/hooks/useT3ProjectFileScripts";
|
||||
import { useThreadActionMenu } from "~/hooks/useThreadActionMenu";
|
||||
import { threadEnvironment } from "../../state/threads";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import { ProjectFavicon } from "../ProjectFavicon";
|
||||
import {
|
||||
WorkspaceBreadcrumb,
|
||||
WorkspaceBreadcrumbItem,
|
||||
WorkspaceBreadcrumbSeparator,
|
||||
} from "../WorkspaceBreadcrumb";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
interface ChatHeaderProps {
|
||||
activeThreadEnvironmentId: EnvironmentId;
|
||||
activeThreadTitle: string;
|
||||
/** Drafts have no server thread yet, so the title carries no action menu. */
|
||||
isServerThread: boolean;
|
||||
/** PR state feeding the settled classification, resolved by ChatView. */
|
||||
changeRequestState: ChangeRequestStateLike | null;
|
||||
activeProjectName: string | undefined;
|
||||
activeProjectCwd: string | null;
|
||||
activeProjectFaviconPath: string | null;
|
||||
openInCwd: string | null;
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
availableEditors: ReadonlyArray<EditorId>;
|
||||
rightPanelOpen: boolean;
|
||||
<<<<<<< HEAD
|
||||
gitCwd: string | null;
|
||||
readonly onOpenPullRequest?: ((number: number) => void) | undefined;
|
||||
onNewThreadInProject: () => void;
|
||||
onRunProjectScript: (script: ProjectScript) => void;
|
||||
onAddProjectScript: (input: NewProjectScriptInput) => Promise<ProjectScriptActionResult>;
|
||||
onUpdateProjectScript: (
|
||||
scriptId: string,
|
||||
input: NewProjectScriptInput,
|
||||
) => Promise<ProjectScriptActionResult>;
|
||||
onDeleteProjectScript: (scriptId: string) => Promise<ProjectScriptActionResult>;
|
||||
=======
|
||||
>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename commit rule shared with the sidebar's inline rename: trim, reject
|
||||
* empty (the caller toasts), and skip the mutation when nothing changed.
|
||||
*/
|
||||
export function resolveRenameCommit(input: {
|
||||
readonly title: string;
|
||||
readonly originalTitle: string;
|
||||
}): { action: "commit"; title: string } | { action: "reject-empty" } | { action: "noop" } {
|
||||
const trimmed = input.title.trim();
|
||||
if (trimmed.length === 0) return { action: "reject-empty" };
|
||||
if (trimmed === input.originalTitle) return { action: "noop" };
|
||||
return { action: "commit", title: trimmed };
|
||||
}
|
||||
|
||||
export function shouldShowOpenInPicker(input: {
|
||||
readonly activeProjectName: string | undefined;
|
||||
readonly activeThreadEnvironmentId: EnvironmentId;
|
||||
readonly primaryEnvironmentId: EnvironmentId | null;
|
||||
readonly remoteOpenMode: RemoteOpenMode;
|
||||
}): boolean {
|
||||
if (!input.activeProjectName) return false;
|
||||
if (
|
||||
input.primaryEnvironmentId !== null &&
|
||||
input.activeThreadEnvironmentId === input.primaryEnvironmentId
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
// Remote environments get the picker in deep-link mode (or its explicit
|
||||
// "no SSH route" state). Non-primary local backends (e.g. WSL) keep it
|
||||
// hidden, matching pre-remote behavior.
|
||||
return input.remoteOpenMode !== "local-exec";
|
||||
}
|
||||
|
||||
export const ChatHeader = memo(function ChatHeader({
|
||||
activeThreadEnvironmentId,
|
||||
activeThreadTitle,
|
||||
isServerThread,
|
||||
changeRequestState,
|
||||
activeProjectName,
|
||||
activeProjectCwd,
|
||||
activeProjectFaviconPath,
|
||||
openInCwd,
|
||||
keybindings,
|
||||
availableEditors,
|
||||
rightPanelOpen,
|
||||
<<<<<<< HEAD
|
||||
gitCwd,
|
||||
onOpenPullRequest,
|
||||
onNewThreadInProject,
|
||||
onRunProjectScript,
|
||||
onAddProjectScript,
|
||||
onUpdateProjectScript,
|
||||
onDeleteProjectScript,
|
||||
=======
|
||||
>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
|
||||
}: ChatHeaderProps) {
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
const fileScripts = useT3ProjectFileScripts(
|
||||
activeThreadEnvironmentId,
|
||||
activeProjectScripts ? activeProjectCwd : null,
|
||||
);
|
||||
const remoteOpenState = useRemoteOpenState(activeThreadEnvironmentId);
|
||||
const showOpenInPicker = shouldShowOpenInPicker({
|
||||
activeProjectName,
|
||||
activeThreadEnvironmentId,
|
||||
primaryEnvironmentId,
|
||||
remoteOpenMode: remoteOpenState.mode,
|
||||
});
|
||||
const activeThreadRef = useMemo(
|
||||
() => scopeThreadRef(activeThreadEnvironmentId, activeThreadId),
|
||||
[activeThreadEnvironmentId, activeThreadId],
|
||||
);
|
||||
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
|
||||
reportFailure: false,
|
||||
});
|
||||
// Inline rename, keyed by thread: navigating away drops an in-progress
|
||||
// rename instead of committing stale text. Cleared on thread change (not
|
||||
// just hidden) so returning to the thread doesn't revive the old draft.
|
||||
const [renaming, setRenaming] = useState<{ threadId: ThreadId; title: string } | null>(null);
|
||||
if (renaming !== null && renaming.threadId !== activeThreadId) {
|
||||
setRenaming(null);
|
||||
}
|
||||
const renamingTitle = renaming?.threadId === activeThreadId ? renaming.title : null;
|
||||
const renameCommittedRef = useRef(false);
|
||||
const startRename = useCallback(() => {
|
||||
renameCommittedRef.current = false;
|
||||
setRenaming({ threadId: activeThreadId, title: activeThreadTitle });
|
||||
}, [activeThreadId, activeThreadTitle]);
|
||||
const commitRename = useCallback(
|
||||
(title: string) => {
|
||||
setRenaming(null);
|
||||
const resolution = resolveRenameCommit({ title, originalTitle: activeThreadTitle });
|
||||
if (resolution.action === "reject-empty") {
|
||||
toastManager.add({ type: "warning", title: "Thread title cannot be empty" });
|
||||
return;
|
||||
}
|
||||
if (resolution.action === "noop") return;
|
||||
void updateThreadMetadata({
|
||||
environmentId: activeThreadEnvironmentId,
|
||||
input: { threadId: activeThreadId, title: resolution.title },
|
||||
}).then((result) => {
|
||||
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
|
||||
const error = squashAtomCommandFailure(result);
|
||||
toastManager.add({
|
||||
type: "error",
|
||||
title: "Failed to rename thread",
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
[activeThreadEnvironmentId, activeThreadId, activeThreadTitle, updateThreadMetadata],
|
||||
);
|
||||
const { openMenu } = useThreadActionMenu({
|
||||
threadRef: isServerThread ? activeThreadRef : null,
|
||||
projectCwd: activeProjectCwd,
|
||||
changeRequestState,
|
||||
onStartRename: startRename,
|
||||
});
|
||||
const titleButtonRef = useRef<HTMLButtonElement | null>(null);
|
||||
const openMenuFromTitle = useCallback(() => {
|
||||
const rect = titleButtonRef.current?.getBoundingClientRect();
|
||||
if (!rect) return;
|
||||
openMenu({ x: rect.left, y: rect.bottom + 4 });
|
||||
}, [openMenu]);
|
||||
const handleHeaderContextMenu = useCallback(
|
||||
(event: ReactMouseEvent) => {
|
||||
if (!isServerThread || renamingTitle !== null) return;
|
||||
// The right-side controls (git, scripts, open-in) keep their own
|
||||
// behavior; only the breadcrumb area opens the thread menu.
|
||||
if ((event.target as HTMLElement).closest("[data-chat-header-actions]")) return;
|
||||
event.preventDefault();
|
||||
openMenu({ x: event.clientX, y: event.clientY });
|
||||
},
|
||||
[isServerThread, openMenu, renamingTitle],
|
||||
);
|
||||
const handleRenameKeyDown = useCallback(
|
||||
(event: ReactKeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === "Enter") {
|
||||
renameCommittedRef.current = true;
|
||||
commitRename(event.currentTarget.value);
|
||||
} else if (event.key === "Escape") {
|
||||
renameCommittedRef.current = true;
|
||||
setRenaming(null);
|
||||
}
|
||||
},
|
||||
[commitRename],
|
||||
);
|
||||
return (
|
||||
<div
|
||||
className="@container/header-actions flex min-w-0 flex-1 items-center gap-2 sm:gap-3"
|
||||
onContextMenu={handleHeaderContextMenu}
|
||||
className={cn(
|
||||
"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",
|
||||
rightPanelOpen ? "pr-10" : "pr-24",
|
||||
)}
|
||||
>
|
||||
<<<<<<< HEAD
|
||||
<WorkspaceBreadcrumb ariaLabel="Thread breadcrumb" className="flex-1">
|
||||
{/* The project always leads the header: knowing which project a
|
||||
thread lives in is priority zero, and the thread title alone
|
||||
doesn't answer it. */}
|
||||
{activeProjectName ? (
|
||||
<>
|
||||
<WorkspaceBreadcrumbItem>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`New thread in ${activeProjectName}`}
|
||||
onClick={onNewThreadInProject}
|
||||
className="inline-flex min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ProjectFavicon
|
||||
environmentId={activeThreadEnvironmentId}
|
||||
cwd={activeProjectCwd ?? ""}
|
||||
faviconPath={activeProjectFaviconPath}
|
||||
className="size-3.5"
|
||||
/>
|
||||
<span className="max-w-40 truncate">{activeProjectName}</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">New thread in {activeProjectName}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</WorkspaceBreadcrumbItem>
|
||||
<WorkspaceBreadcrumbSeparator />
|
||||
</>
|
||||
) : null}
|
||||
<WorkspaceBreadcrumbItem current className="flex-1">
|
||||
{renamingTitle !== null ? (
|
||||
<input
|
||||
autoFocus
|
||||
aria-label="Thread title"
|
||||
className="min-w-0 flex-1 rounded-sm bg-transparent text-sm font-medium text-foreground outline-none ring-1 ring-ring/50 focus:ring-ring"
|
||||
defaultValue={renamingTitle}
|
||||
onBlur={(event) => {
|
||||
if (renameCommittedRef.current) return;
|
||||
commitRename(event.currentTarget.value);
|
||||
}}
|
||||
onFocus={(event) => event.currentTarget.select()}
|
||||
onKeyDown={handleRenameKeyDown}
|
||||
/>
|
||||
) : isServerThread ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
ref={titleButtonRef}
|
||||
type="button"
|
||||
aria-label={`Thread actions for ${activeThreadTitle}`}
|
||||
aria-haspopup="menu"
|
||||
onClick={openMenuFromTitle}
|
||||
className="group/thread-title inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-sm text-left focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<h2 className="min-w-0 truncate">{activeThreadTitle}</h2>
|
||||
<ChevronDownIcon
|
||||
aria-hidden
|
||||
className="size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/thread-title:opacity-100 group-focus-visible/thread-title:opacity-100"
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{activeThreadTitle}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<h2 aria-label={activeThreadTitle} className="min-w-0 flex-1 truncate">
|
||||
{activeThreadTitle}
|
||||
</h2>
|
||||
}
|
||||
=======
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-3">
|
||||
<SidebarTrigger className="size-7 shrink-0 md:hidden" />
|
||||
<Tooltip>
|
||||
@@ -296,39 +33,27 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
<ChevronDownIcon
|
||||
aria-hidden
|
||||
className="size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/thread-title:opacity-100 group-focus-visible/thread-title:opacity-100"
|
||||
>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
|
||||
/>
|
||||
<TooltipPopup side="top">{activeThreadTitle}</TooltipPopup>
|
||||
</Tooltip>
|
||||
)}
|
||||
</WorkspaceBreadcrumbItem>
|
||||
</WorkspaceBreadcrumb>
|
||||
<div
|
||||
data-chat-header-actions
|
||||
className={cn(
|
||||
"flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3",
|
||||
rightPanelOpen ? "pr-10" : "pr-24",
|
||||
)}
|
||||
>
|
||||
{showOpenInPicker && (
|
||||
<OpenInPicker
|
||||
environmentId={activeThreadEnvironmentId}
|
||||
keybindings={keybindings}
|
||||
availableEditors={availableEditors}
|
||||
openInCwd={openInCwd}
|
||||
/>
|
||||
)}
|
||||
<<<<<<< HEAD
|
||||
{activeProjectName && (
|
||||
<GitActionsControl
|
||||
gitCwd={gitCwd}
|
||||
activeThreadRef={scopeThreadRef(activeThreadEnvironmentId, activeThreadId)}
|
||||
onOpenPullRequest={onOpenPullRequest}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
/>
|
||||
)}
|
||||
=======
|
||||
>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{activeThreadTitle}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<h2
|
||||
aria-label={activeThreadTitle}
|
||||
className="min-w-0 flex-1 truncate text-sm font-medium text-foreground"
|
||||
>
|
||||
{activeThreadTitle}
|
||||
</h2>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{activeThreadTitle}</TooltipPopup>
|
||||
</Tooltip>
|
||||
)}
|
||||
>>>>>>> 3e9701fff3 (Split open-in editor controls into panel and toolbar variants)
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
|
||||
export function shouldShowOpenInPicker(input: {
|
||||
readonly activeProjectName: string | undefined;
|
||||
readonly activeThreadEnvironmentId: EnvironmentId;
|
||||
readonly primaryEnvironmentId: EnvironmentId | null;
|
||||
}): boolean {
|
||||
return (
|
||||
Boolean(input.activeProjectName) &&
|
||||
input.primaryEnvironmentId !== null &&
|
||||
input.activeThreadEnvironmentId === input.primaryEnvironmentId
|
||||
);
|
||||
}
|
||||
+4
@@ -1,7 +1,11 @@
|
||||
import { EnvironmentId } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
<<<<<<< HEAD:apps/web/src/components/chat/ChatHeader.test.ts
|
||||
import { resolveRenameCommit, shouldShowOpenInPicker } from "./ChatHeader";
|
||||
=======
|
||||
import { shouldShowOpenInPicker } from "./OpenInPicker.logic";
|
||||
>>>>>>> 786f5c5767 (Split open-in editor controls into panel and toolbar variants):apps/web/src/components/chat/OpenInPicker.test.ts
|
||||
|
||||
describe("shouldShowOpenInPicker", () => {
|
||||
const primaryEnvironmentId = EnvironmentId.make("environment-primary");
|
||||
@@ -1,19 +1,7 @@
|
||||
import {
|
||||
buildRemoteOpenUrl,
|
||||
EditorId,
|
||||
type EnvironmentId,
|
||||
type ResolvedKeybindingsConfig,
|
||||
} from "@t3tools/contracts";
|
||||
import { memo, useCallback, useEffect, useMemo } from "react";
|
||||
import { isOpenFavoriteEditorShortcut, shortcutLabelForCommand } from "../../keybindings";
|
||||
import { EditorId, type EnvironmentId, type ResolvedKeybindingsConfig } from "@t3tools/contracts";
|
||||
import { memo, useCallback, useMemo } from "react";
|
||||
import { shortcutLabelForCommand } from "../../keybindings";
|
||||
import { usePreferredEditor } from "../../editorPreferences";
|
||||
import {
|
||||
openRemoteEditorUrl,
|
||||
useRemoteCapableEditors,
|
||||
useRemoteOpenHint,
|
||||
useRemoteOpenState,
|
||||
} from "../../remoteOpen";
|
||||
import { useEnvironment } from "../../state/environments";
|
||||
import { ChevronDownIcon, FolderClosedIcon } from "lucide-react";
|
||||
import { Button } from "../ui/button";
|
||||
import { Group, GroupSeparator } from "../ui/group";
|
||||
@@ -46,6 +34,13 @@ import {
|
||||
import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils";
|
||||
import { shellEnvironment } from "~/state/shell";
|
||||
import { useAtomCommand } from "~/state/use-atom-command";
|
||||
import {
|
||||
THREAD_DETAILS_PANEL_ICON_CLASS,
|
||||
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
|
||||
THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
|
||||
THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS,
|
||||
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
|
||||
} from "./threadDetailsPanelStyles";
|
||||
|
||||
type OpenInOption = {
|
||||
label: string;
|
||||
@@ -201,27 +196,22 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
availableEditors,
|
||||
openInCwd,
|
||||
compact = false,
|
||||
enableShortcut = true,
|
||||
displayMode = "toolbar",
|
||||
}: {
|
||||
environmentId: EnvironmentId;
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
availableEditors: ReadonlyArray<EditorId>;
|
||||
openInCwd: string | null;
|
||||
compact?: boolean;
|
||||
enableShortcut?: boolean;
|
||||
displayMode?: "toolbar" | "panel";
|
||||
}) {
|
||||
const isPanel = displayMode === "panel";
|
||||
const ActionGroup = isPanel ? "div" : Group;
|
||||
const openInEditorMutation = useAtomCommand(shellEnvironment.openInEditor, "open in editor");
|
||||
const remote = useRemoteOpenState(environmentId);
|
||||
const remoteCapableEditors = useRemoteCapableEditors();
|
||||
const [remoteHintSeen, markRemoteHintSeen] = useRemoteOpenHint();
|
||||
const environmentLabel = useEnvironment(environmentId)?.label ?? "this machine";
|
||||
// Remote mode ignores the server's PATH probe: what matters is what runs on
|
||||
// the viewing machine, which only the desktop app can probe.
|
||||
const effectiveEditors = remote.mode === "local-exec" ? availableEditors : remoteCapableEditors;
|
||||
const [preferredEditor, setPreferredEditor] = usePreferredEditor(effectiveEditors);
|
||||
const [preferredEditor, setPreferredEditor] = usePreferredEditor(availableEditors);
|
||||
const options = useMemo(
|
||||
() => resolveOptions(navigator.platform, effectiveEditors),
|
||||
[effectiveEditors],
|
||||
() => resolveOptions(navigator.platform, availableEditors),
|
||||
[availableEditors],
|
||||
);
|
||||
const primaryOption = options.find(({ value }) => value === preferredEditor) ?? null;
|
||||
|
||||
@@ -230,23 +220,6 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
if (!openInCwd) return;
|
||||
const editor = editorId ?? preferredEditor;
|
||||
if (!editor) return;
|
||||
if (remote.mode === "remote-unavailable") return;
|
||||
if (remote.mode === "remote-links") {
|
||||
const url = buildRemoteOpenUrl({
|
||||
editor,
|
||||
host: remote.host.host,
|
||||
absolutePath: openInCwd,
|
||||
});
|
||||
if (url === undefined) return;
|
||||
// Only record hint-seen/preferred when the shell actually accepted
|
||||
// the URL (an older desktop build can refuse the editor scheme).
|
||||
void openRemoteEditorUrl(url).then((opened) => {
|
||||
if (!opened) return;
|
||||
markRemoteHintSeen();
|
||||
setPreferredEditor(editor);
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = openInEditorMutation({
|
||||
environmentId,
|
||||
input: {
|
||||
@@ -257,97 +230,77 @@ export const OpenInPicker = memo(function OpenInPicker({
|
||||
setPreferredEditor(editor);
|
||||
return result;
|
||||
},
|
||||
[
|
||||
environmentId,
|
||||
markRemoteHintSeen,
|
||||
openInCwd,
|
||||
openInEditorMutation,
|
||||
preferredEditor,
|
||||
remote,
|
||||
setPreferredEditor,
|
||||
],
|
||||
[environmentId, openInCwd, openInEditorMutation, preferredEditor, setPreferredEditor],
|
||||
);
|
||||
|
||||
const openFavoriteEditorShortcutLabel = useMemo(
|
||||
() => shortcutLabelForCommand(keybindings, "editor.openFavorite"),
|
||||
[keybindings],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enableShortcut) return;
|
||||
const handler = (e: globalThis.KeyboardEvent) => {
|
||||
if (!isOpenFavoriteEditorShortcut(e, keybindings)) return;
|
||||
if (!openInCwd) return;
|
||||
if (!preferredEditor) return;
|
||||
|
||||
e.preventDefault();
|
||||
void openInEditor(preferredEditor);
|
||||
};
|
||||
window.addEventListener("keydown", handler);
|
||||
return () => window.removeEventListener("keydown", handler);
|
||||
}, [enableShortcut, keybindings, openInCwd, openInEditor, preferredEditor]);
|
||||
const primaryLabel = isPanel ? `Open in ${primaryOption?.label ?? "editor"}` : "Open";
|
||||
|
||||
return (
|
||||
<Group aria-label="Open in editor">
|
||||
<ActionGroup
|
||||
aria-label="Open in editor"
|
||||
role="group"
|
||||
{...(isPanel ? { className: THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS } : {})}
|
||||
>
|
||||
<Button
|
||||
aria-label={compact ? "Open file in preferred editor" : undefined}
|
||||
className="ps-[8.5px]"
|
||||
size="xs"
|
||||
aria-label={compact ? "Open file in preferred editor" : primaryLabel}
|
||||
size={isPanel ? "sm" : "xs"}
|
||||
variant="outline"
|
||||
disabled={!preferredEditor || !openInCwd || remote.mode === "remote-unavailable"}
|
||||
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS : undefined}
|
||||
disabled={!preferredEditor || !openInCwd}
|
||||
onClick={() => openInEditor(preferredEditor)}
|
||||
>
|
||||
{primaryOption?.Icon && (
|
||||
<primaryOption.Icon
|
||||
aria-hidden="true"
|
||||
className={cn("size-3.5", getOpenInIconClass(primaryOption.kind))}
|
||||
className={isPanel ? THREAD_DETAILS_PANEL_ICON_CLASS : "size-3.5"}
|
||||
/>
|
||||
)}
|
||||
<span
|
||||
className={
|
||||
className={cn(
|
||||
compact
|
||||
? "sr-only"
|
||||
: "sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5"
|
||||
}
|
||||
: "sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
|
||||
isPanel && "not-sr-only ml-0.5 min-w-0 truncate",
|
||||
)}
|
||||
>
|
||||
Open
|
||||
{primaryLabel}
|
||||
</span>
|
||||
</Button>
|
||||
<GroupSeparator {...(!compact ? { className: "hidden @3xl/header-actions:block" } : {})} />
|
||||
{isPanel ? (
|
||||
<span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
|
||||
) : (
|
||||
<GroupSeparator {...(!compact ? { className: "hidden @3xl/header-actions:block" } : {})} />
|
||||
)}
|
||||
<Menu>
|
||||
<MenuTrigger
|
||||
render={
|
||||
<Button
|
||||
aria-label={compact ? "Choose editor" : "Copy options"}
|
||||
size="icon-xs"
|
||||
aria-label="Choose editor"
|
||||
size={isPanel ? "sm" : "icon-xs"}
|
||||
variant="outline"
|
||||
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS : undefined}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ChevronDownIcon aria-hidden="true" className="size-4" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end">
|
||||
{remote.mode === "remote-unavailable" ? (
|
||||
<MenuItem disabled>No SSH route to {environmentLabel}</MenuItem>
|
||||
) : (
|
||||
<>
|
||||
{options.length === 0 && <MenuItem disabled>No installed editors found</MenuItem>}
|
||||
{options.map(({ label, Icon, value, kind }) => (
|
||||
<MenuItem key={value} onClick={() => openInEditor(value)}>
|
||||
<Icon aria-hidden="true" className={getOpenInIconClass(kind)} />
|
||||
{label}
|
||||
{value === preferredEditor && openFavoriteEditorShortcutLabel && (
|
||||
<MenuShortcut>{openFavoriteEditorShortcutLabel}</MenuShortcut>
|
||||
)}
|
||||
</MenuItem>
|
||||
))}
|
||||
{remote.mode === "remote-links" && !remoteHintSeen && (
|
||||
<MenuItem disabled>Opens over SSH. Needs your key on {environmentLabel}</MenuItem>
|
||||
{options.length === 0 && <MenuItem disabled>No installed editors found</MenuItem>}
|
||||
{options.map(({ label, Icon, value, kind }) => (
|
||||
<MenuItem key={value} onClick={() => openInEditor(value)}>
|
||||
<Icon aria-hidden="true" className={getOpenInIconClass(kind)} />
|
||||
{label}
|
||||
{value === preferredEditor && openFavoriteEditorShortcutLabel && (
|
||||
<MenuShortcut>{openFavoriteEditorShortcutLabel}</MenuShortcut>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
</Group>
|
||||
</ActionGroup>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { EditorId, EnvironmentId, ResolvedKeybindingsConfig } from "@t3tools/contracts";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { usePreferredEditor } from "../../editorPreferences";
|
||||
import { isOpenFavoriteEditorShortcut } from "../../keybindings";
|
||||
import { shellEnvironment } from "../../state/shell";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
|
||||
export function useOpenFavoriteEditorShortcut({
|
||||
enabled,
|
||||
environmentId,
|
||||
keybindings,
|
||||
availableEditors,
|
||||
openInCwd,
|
||||
}: {
|
||||
enabled: boolean;
|
||||
environmentId: EnvironmentId;
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
availableEditors: ReadonlyArray<EditorId>;
|
||||
openInCwd: string | null;
|
||||
}) {
|
||||
const openInEditorMutation = useAtomCommand(shellEnvironment.openInEditor, "open in editor");
|
||||
const [preferredEditor] = usePreferredEditor(availableEditors);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
const handler = (event: globalThis.KeyboardEvent) => {
|
||||
if (!isOpenFavoriteEditorShortcut(event, keybindings)) return;
|
||||
if (!openInCwd || !preferredEditor) return;
|
||||
|
||||
event.preventDefault();
|
||||
void openInEditorMutation({
|
||||
environmentId,
|
||||
input: {
|
||||
cwd: openInCwd,
|
||||
editor: preferredEditor,
|
||||
},
|
||||
});
|
||||
};
|
||||
window.addEventListener("keydown", handler);
|
||||
return () => window.removeEventListener("keydown", handler);
|
||||
}, [enabled, environmentId, keybindings, openInCwd, openInEditorMutation, preferredEditor]);
|
||||
}
|
||||
@@ -114,12 +114,13 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({
|
||||
<PopoverPopup
|
||||
anchor={threadPanelPopoverAnchor}
|
||||
align="end"
|
||||
alignOffset={8}
|
||||
alignOffset={0}
|
||||
collisionAvoidance={{ side: "shift", align: "shift", fallbackAxisSide: "none" }}
|
||||
side="bottom"
|
||||
sideOffset={8}
|
||||
positionerClassName="w-[min(20rem,calc(var(--anchor-width)-1rem))]"
|
||||
className="w-full border-0 bg-transparent shadow-none before:hidden [--viewport-inline-padding:0]"
|
||||
viewportClassName="p-0"
|
||||
sideOffset={0}
|
||||
positionerClassName="w-[min(21rem,var(--anchor-width))] !transition-none"
|
||||
className="w-full !overflow-visible rounded-none border-0 bg-transparent shadow-none before:hidden [--viewport-inline-padding:0]"
|
||||
viewportClassName="!overflow-visible p-2"
|
||||
>
|
||||
{threadPanelPopoverContent}
|
||||
</PopoverPopup>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
EditorId,
|
||||
EnvironmentId,
|
||||
ProjectScript,
|
||||
ResolvedKeybindingsConfig,
|
||||
@@ -18,6 +19,7 @@ import ProjectScriptsControl, {
|
||||
} from "../ProjectScriptsControl";
|
||||
import { Button } from "../ui/button";
|
||||
import { cn } from "../../lib/utils";
|
||||
import { OpenInPicker } from "./OpenInPicker";
|
||||
import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl";
|
||||
|
||||
interface VersionMismatchIssue {
|
||||
@@ -37,6 +39,8 @@ export interface ThreadDetailsPanelProps {
|
||||
activeProjectScripts: ReadonlyArray<ProjectScript> | undefined;
|
||||
preferredScriptId: string | null;
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
availableEditors: ReadonlyArray<EditorId>;
|
||||
showOpenInPicker: boolean;
|
||||
gitCwd: string | null;
|
||||
isGitRepo: boolean;
|
||||
envLocked: boolean;
|
||||
@@ -132,20 +136,20 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
|
||||
const card = (
|
||||
<div
|
||||
className={cn(
|
||||
"floating-glass-surface overflow-x-hidden rounded-[20px] border border-border/75",
|
||||
"floating-glass-surface overflow-x-hidden rounded-[20px] border border-border",
|
||||
props.mode === "inline"
|
||||
? "max-h-full overflow-y-auto overscroll-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
|
||||
: "overflow-y-hidden",
|
||||
)}
|
||||
data-thread-details-card
|
||||
>
|
||||
<section aria-labelledby="thread-details-project-heading">
|
||||
<section aria-labelledby="thread-details-workspace-heading">
|
||||
<div className="flex min-h-10 items-center justify-between gap-3 px-3.5 pb-1 pt-3">
|
||||
<h3
|
||||
id="thread-details-project-heading"
|
||||
id="thread-details-workspace-heading"
|
||||
className="text-[11px] font-medium text-muted-foreground"
|
||||
>
|
||||
Project / environment
|
||||
Workspace
|
||||
</h3>
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
<span className="inline-flex items-center gap-1.5 text-[11px] text-muted-foreground">
|
||||
@@ -232,6 +236,16 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
|
||||
|
||||
<BranchToolbar layout="panel" panelSection="workspace" {...branchToolbarProps} />
|
||||
|
||||
{props.showOpenInPicker ? (
|
||||
<OpenInPicker
|
||||
environmentId={props.environmentId}
|
||||
keybindings={props.keybindings}
|
||||
availableEditors={props.availableEditors}
|
||||
openInCwd={props.gitCwd}
|
||||
displayMode="panel"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{props.activeProjectScripts ? (
|
||||
<ProjectScriptsControl
|
||||
displayMode="panel"
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
* The core control variants intentionally become denser at the `sm` breakpoint. The panel has
|
||||
* its own fixed density, so every size and type override here includes its desktop counterpart.
|
||||
*/
|
||||
export const THREAD_DETAILS_PANEL_ROW_CLASS =
|
||||
"h-9 w-full justify-start gap-2.5 rounded-lg border-transparent bg-transparent px-2.5 text-[13px] font-medium text-foreground/80 shadow-none before:shadow-none sm:h-9 sm:text-[13px]";
|
||||
const THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS =
|
||||
"shadow-none before:shadow-none not-disabled:not-active:not-data-pressed:before:shadow-none dark:not-disabled:before:shadow-none dark:not-disabled:not-active:not-data-pressed:before:shadow-none";
|
||||
|
||||
export const THREAD_DETAILS_PANEL_ROW_CLASS = `h-9 w-full justify-start gap-2.5 rounded-lg border-transparent bg-transparent px-2.5 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px] ${THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS}`;
|
||||
|
||||
export const THREAD_DETAILS_PANEL_LOCKED_ROW_CLASS =
|
||||
"h-9 w-full justify-start gap-2.5 rounded-lg border border-transparent px-2.5 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px]";
|
||||
@@ -15,10 +17,8 @@ export const THREAD_DETAILS_PANEL_ICON_CLASS = "size-4 shrink-0 text-muted-foreg
|
||||
export const THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS =
|
||||
"group/thread-details-action flex w-full items-center rounded-lg transition-colors hover:bg-muted/65 focus-within:bg-muted/65";
|
||||
|
||||
export const THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS =
|
||||
"h-9 min-w-0 flex-1 justify-start gap-2.5 rounded-e-none border-transparent bg-transparent px-2.5 pr-2 text-[13px] font-medium text-foreground/80 shadow-none before:shadow-none sm:h-9 sm:text-[13px] [&:hover]:bg-transparent [&[data-pressed]]:bg-transparent";
|
||||
export const THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS = `h-9 min-w-0 flex-1 justify-start gap-2.5 rounded-e-none border-transparent bg-transparent px-2.5 pr-2 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px] [&:hover]:bg-transparent [&[data-pressed]]:bg-transparent ${THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS}`;
|
||||
|
||||
export const THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS =
|
||||
"h-9 w-8 rounded-s-none border-transparent bg-transparent px-0 shadow-none before:shadow-none sm:h-9 sm:w-8 [&:hover]:bg-transparent [&[data-pressed]]:bg-transparent";
|
||||
export const THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS = `h-9 w-8 rounded-s-none border-transparent bg-transparent px-0 sm:h-9 sm:w-8 [&:hover]:bg-transparent [&[data-pressed]]:bg-transparent ${THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS}`;
|
||||
|
||||
export const THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS = "h-4 w-px shrink-0 bg-border/65";
|
||||
@@ -903,7 +903,6 @@ export default function FilePreviewPanel({
|
||||
availableEditors={availableEditors}
|
||||
openInCwd={absolutePath}
|
||||
compact
|
||||
enableShortcut={false}
|
||||
/>
|
||||
) : null}
|
||||
{isMarkdown ? (
|
||||
|
||||
@@ -25,6 +25,7 @@ function PopoverPopup({
|
||||
align = "center",
|
||||
sideOffset = 4,
|
||||
alignOffset = 0,
|
||||
collisionAvoidance,
|
||||
tooltipStyle = false,
|
||||
anchor,
|
||||
...props
|
||||
@@ -35,6 +36,7 @@ function PopoverPopup({
|
||||
align?: PopoverPrimitive.Positioner.Props["align"];
|
||||
sideOffset?: PopoverPrimitive.Positioner.Props["sideOffset"];
|
||||
alignOffset?: PopoverPrimitive.Positioner.Props["alignOffset"];
|
||||
collisionAvoidance?: PopoverPrimitive.Positioner.Props["collisionAvoidance"];
|
||||
tooltipStyle?: boolean;
|
||||
anchor?: PopoverPrimitive.Positioner.Props["anchor"];
|
||||
}) {
|
||||
@@ -44,6 +46,7 @@ function PopoverPopup({
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
anchor={anchor}
|
||||
collisionAvoidance={collisionAvoidance}
|
||||
className={cn(
|
||||
"z-[130] h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none",
|
||||
positionerClassName,
|
||||
|
||||
Reference in new issue
Block a user