| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | import type { ThreadId } from "@t3tools/contracts"; |
| 2 | import { FolderIcon, GitForkIcon } from "lucide-react"; |
| 2 | 3 | import { useCallback } from "react"; |
| 3 | 4 | |
| 4 | 5 | import { newCommandId } from "../lib/utils"; |
| ... | ... | @@ -11,8 +12,14 @@ import { |
| 11 | 12 | resolveEffectiveEnvMode, |
| 12 | 13 | } from "./BranchToolbar.logic"; |
| 13 | 14 | import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector"; |
| 15 | import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select"; |
| 14 | 16 | import { Button } from "./ui/button"; |
| 15 | 17 | |
| 18 | const envModeItems = [ |
| 19 | { value: "local", label: "Local" }, |
| 20 | { value: "worktree", label: "New worktree" }, |
| 21 | ] as const; |
| 22 | |
| 16 | 23 | interface BranchToolbarProps { |
| 17 | 24 | threadId: ThreadId; |
| 18 | 25 | onEnvModeChange: (mode: EnvMode) => void; |
| ... | ... | @@ -104,23 +111,50 @@ export default function BranchToolbar({ |
| 104 | 111 | |
| 105 | 112 | return ( |
| 106 | 113 | <div className="mx-auto flex w-full max-w-3xl items-center justify-between px-5 pb-3 pt-1"> |
| 107 | | <div className="flex items-center gap-2"> |
| 108 | | {envLocked || activeWorktreePath ? ( |
| 109 | | <span className="border border-transparent px-[calc(--spacing(2)-1px)] text-sm font-medium text-muted-foreground/70 sm:text-xs"> |
| 110 | | {activeWorktreePath ? "Worktree" : "Local"} |
| 111 | | </span> |
| 112 | | ) : ( |
| 113 | | <Button |
| 114 | | type="button" |
| 115 | | variant="ghost" |
| 116 | | className="text-muted-foreground/70 hover:text-foreground/80" |
| 117 | | size="xs" |
| 118 | | onClick={() => onEnvModeChange(effectiveEnvMode === "local" ? "worktree" : "local")} |
| 119 | | > |
| 120 | | {effectiveEnvMode === "worktree" ? "New worktree" : "Local"} |
| 121 | | </Button> |
| 122 | | )} |
| 123 | | </div> |
| 114 | {envLocked || activeWorktreePath ? ( |
| 115 | <span className="inline-flex items-center gap-1 border border-transparent px-[calc(--spacing(3)-1px)] text-sm font-medium text-muted-foreground/70 sm:text-xs"> |
| 116 | {activeWorktreePath ? ( |
| 117 | <> |
| 118 | <GitForkIcon className="size-3" /> |
| 119 | Worktree |
| 120 | </> |
| 121 | ) : ( |
| 122 | <> |
| 123 | <FolderIcon className="size-3" /> |
| 124 | Local |
| 125 | </> |
| 126 | )} |
| 127 | </span> |
| 128 | ) : ( |
| 129 | <Select |
| 130 | value={effectiveEnvMode} |
| 131 | onValueChange={(value) => onEnvModeChange(value as EnvMode)} |
| 132 | items={envModeItems} |
| 133 | > |
| 134 | <SelectTrigger variant="ghost" size="xs" className="font-medium"> |
| 135 | {effectiveEnvMode === "worktree" ? ( |
| 136 | <GitForkIcon className="size-3" /> |
| 137 | ) : ( |
| 138 | <FolderIcon className="size-3" /> |
| 139 | )} |
| 140 | <SelectValue /> |
| 141 | </SelectTrigger> |
| 142 | <SelectPopup> |
| 143 | <SelectItem value="local"> |
| 144 | <span className="inline-flex items-center gap-1.5"> |
| 145 | <FolderIcon className="size-3" /> |
| 146 | Local |
| 147 | </span> |
| 148 | </SelectItem> |
| 149 | <SelectItem value="worktree"> |
| 150 | <span className="inline-flex items-center gap-1.5"> |
| 151 | <GitForkIcon className="size-3" /> |
| 152 | New worktree |
| 153 | </span> |
| 154 | </SelectItem> |
| 155 | </SelectPopup> |
| 156 | </Select> |
| 157 | )} |
| 124 | 158 | |
| 125 | 159 | <BranchToolbarBranchSelector |
| 126 | 160 | activeProjectCwd={activeProject.cwd} |