fix(web): show previous worktree branch on second line (#13314)
This commit is contained in:
1 parent
e407f9bb09
commit
effaab94e3
3 files changed
+41
-12
No files matched your search
@@ -5,7 +5,6 @@ import {
|
||||
FolderGit2Icon,
|
||||
FolderGitIcon,
|
||||
FolderIcon,
|
||||
HistoryIcon,
|
||||
ScaleIcon,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
@@ -41,6 +40,7 @@ import {
|
||||
} from "./BranchToolbarBranchSelector";
|
||||
import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
|
||||
import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
|
||||
import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent";
|
||||
import { ComposerControl } from "./chat/ComposerControl";
|
||||
import {
|
||||
Menu,
|
||||
@@ -105,6 +105,7 @@ interface MobileRunContextSelectorProps {
|
||||
activeWorktreePath: string | null;
|
||||
onEnvModeChange: (mode: EnvMode) => void;
|
||||
previousWorktreeLabel: string | null;
|
||||
previousWorktreeBranch: string | null;
|
||||
onUsePreviousWorktree: () => void;
|
||||
}
|
||||
|
||||
@@ -123,6 +124,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
|
||||
activeWorktreePath,
|
||||
onEnvModeChange,
|
||||
previousWorktreeLabel,
|
||||
previousWorktreeBranch,
|
||||
onUsePreviousWorktree,
|
||||
}: MobileRunContextSelectorProps) {
|
||||
const composerFloatingLayerProps = useComposerMenuProps();
|
||||
@@ -217,7 +219,12 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
|
||||
{triggerContent}
|
||||
<ChevronDownIcon className="size-3 shrink-0 opacity-50" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="start" side="top" {...composerFloatingLayerProps}>
|
||||
<MenuPopup
|
||||
align="start"
|
||||
side="top"
|
||||
className={previousWorktreeLabel ? "w-[min(21rem,calc(100vw-2rem))]" : undefined}
|
||||
{...composerFloatingLayerProps}
|
||||
>
|
||||
{showEnvironmentPicker && availableEnvironments && onEnvironmentChange ? (
|
||||
<>
|
||||
<MenuGroup>
|
||||
@@ -295,10 +302,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
|
||||
</MenuRadioItem>
|
||||
{previousWorktreeLabel ? (
|
||||
<MenuRadioItem disabled={envModeLocked} value="previous-worktree" closeOnClick>
|
||||
<span className="flex min-w-0 items-center gap-1.5">
|
||||
<HistoryIcon className="size-3" />
|
||||
<MiddleTruncate value={previousWorktreeLabel} />
|
||||
</span>
|
||||
<PreviousWorktreeItemContent branch={previousWorktreeBranch} />
|
||||
</MenuRadioItem>
|
||||
) : null}
|
||||
</MenuRadioGroup>
|
||||
@@ -630,6 +634,7 @@ export const BranchToolbar = memo(function BranchToolbar({
|
||||
activeWorktreePath={activeWorktreePath}
|
||||
onEnvModeChange={onEnvModeChange}
|
||||
previousWorktreeLabel={previousWorktreeLabel}
|
||||
previousWorktreeBranch={previousWorktreeSeed?.branch ?? null}
|
||||
onUsePreviousWorktree={onUsePreviousWorktree}
|
||||
/>
|
||||
</div>
|
||||
@@ -669,6 +674,7 @@ export const BranchToolbar = memo(function BranchToolbar({
|
||||
activeWorktreePath={activeWorktreePath}
|
||||
onEnvModeChange={onEnvModeChange}
|
||||
previousWorktreeLabel={previousWorktreeLabel}
|
||||
previousWorktreeBranch={previousWorktreeSeed?.branch ?? null}
|
||||
onUsePreviousWorktree={onUsePreviousWorktree}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FolderGit2Icon, FolderGitIcon, FolderIcon, HistoryIcon } from "lucide-react";
|
||||
import { FolderGit2Icon, FolderGitIcon, FolderIcon } from "lucide-react";
|
||||
import { memo, useMemo } from "react";
|
||||
|
||||
import {
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
type EnvMode,
|
||||
} from "./BranchToolbar.logic";
|
||||
import { useComposerMenuProps } from "./chat/composerEventScope";
|
||||
import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent";
|
||||
import {
|
||||
Select,
|
||||
SelectGroup,
|
||||
@@ -28,6 +29,7 @@ interface BranchToolbarEnvModeSelectorProps {
|
||||
activeWorktreePath: string | null;
|
||||
onEnvModeChange: (mode: EnvMode) => void;
|
||||
previousWorktreeLabel?: string | null;
|
||||
previousWorktreeBranch?: string | null;
|
||||
onUsePreviousWorktree?: () => void;
|
||||
}
|
||||
|
||||
@@ -38,6 +40,7 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
|
||||
activeWorktreePath,
|
||||
onEnvModeChange,
|
||||
previousWorktreeLabel,
|
||||
previousWorktreeBranch = null,
|
||||
onUsePreviousWorktree,
|
||||
}: BranchToolbarEnvModeSelectorProps) {
|
||||
const composerFloatingLayerProps = useComposerMenuProps();
|
||||
@@ -142,7 +145,11 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
|
||||
: resolveCurrentWorkspaceLabel(activeWorktreePath)}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
<SelectPopup alignItemWithTrigger={false} {...composerFloatingLayerProps}>
|
||||
<SelectPopup
|
||||
alignItemWithTrigger={false}
|
||||
className={showPreviousWorktree ? "w-[min(21rem,calc(100vw-2rem))]" : undefined}
|
||||
{...composerFloatingLayerProps}
|
||||
>
|
||||
<SelectGroup>
|
||||
<SelectGroupLabel>Workspace</SelectGroupLabel>
|
||||
<SelectItem value="local">
|
||||
@@ -163,10 +170,7 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
|
||||
</SelectItem>
|
||||
{showPreviousWorktree && previousWorktreeLabel ? (
|
||||
<SelectItem value={PREVIOUS_WORKTREE_SELECT_VALUE}>
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<HistoryIcon className="size-3" />
|
||||
{previousWorktreeLabel}
|
||||
</span>
|
||||
<PreviousWorktreeItemContent branch={previousWorktreeBranch} />
|
||||
</SelectItem>
|
||||
) : null}
|
||||
</SelectGroup>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { HistoryIcon } from "lucide-react";
|
||||
|
||||
import { MiddleTruncate } from "./ui/middle-truncate";
|
||||
|
||||
export function PreviousWorktreeItemContent({ branch }: { branch: string | null }) {
|
||||
return (
|
||||
<span className="flex min-w-0 items-start gap-1.5">
|
||||
<HistoryIcon className="mt-1 size-3" />
|
||||
<span className="flex min-w-0 flex-col">
|
||||
<span>Previous worktree</span>
|
||||
{branch ? (
|
||||
<span className="min-w-0 text-xs text-muted-foreground">
|
||||
<MiddleTruncate value={branch} />
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user