| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | import type { ThreadId } from "@t3tools/contracts"; | 1 | import type { ThreadId } from "@t3tools/contracts"; |
| | 2 | import { FolderIcon, GitForkIcon } from "lucide-react"; |
| 2 | import { useCallback } from "react"; | 3 | import { useCallback } from "react"; |
| 3 | | 4 | |
| 4 | import { newCommandId } from "../lib/utils"; | 5 | import { newCommandId } from "../lib/utils"; |
| ... | @@ -11,8 +12,14 @@ import { | ... | @@ -11,8 +12,14 @@ import { |
| 11 | resolveEffectiveEnvMode, | 12 | resolveEffectiveEnvMode, |
| 12 | } from "./BranchToolbar.logic"; | 13 | } from "./BranchToolbar.logic"; |
| 13 | import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector"; | 14 | import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector"; |
| | 15 | import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select"; |
| 14 | import { Button } from "./ui/button"; | 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 | interface BranchToolbarProps { | 23 | interface BranchToolbarProps { |
| 17 | threadId: ThreadId; | 24 | threadId: ThreadId; |
| 18 | onEnvModeChange: (mode: EnvMode) => void; | 25 | onEnvModeChange: (mode: EnvMode) => void; |
| ... | @@ -104,23 +111,50 @@ export default function BranchToolbar({ | ... | @@ -104,23 +111,50 @@ export default function BranchToolbar({ |
| 104 | | 111 | |
| 105 | return ( | 112 | return ( |
| 106 | <div className="mx-auto flex w-full max-w-3xl items-center justify-between px-5 pb-3 pt-1"> | 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"> | 114 | {envLocked || activeWorktreePath ? ( |
| 108 | {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"> |
| 109 | <span className="border border-transparent px-[calc(--spacing(2)-1px)] text-sm font-medium text-muted-foreground/70 sm:text-xs"> | 116 | {activeWorktreePath ? ( |
| 110 | {activeWorktreePath ? "Worktree" : "Local"} | 117 | <> |
| 111 | </span> | 118 | <GitForkIcon className="size-3" /> |
| 112 | ) : ( | 119 | Worktree |
| 113 | <Button | 120 | </> |
| 114 | type="button" | 121 | ) : ( |
| 115 | variant="ghost" | 122 | <> |
| 116 | className="text-muted-foreground/70 hover:text-foreground/80" | 123 | <FolderIcon className="size-3" /> |
| 117 | size="xs" | 124 | Local |
| 118 | onClick={() => onEnvModeChange(effectiveEnvMode === "local" ? "worktree" : "local")} | 125 | </> |
| 119 | > | 126 | )} |
| 120 | {effectiveEnvMode === "worktree" ? "New worktree" : "Local"} | 127 | </span> |
| 121 | </Button> | 128 | ) : ( |
| 122 | )} | 129 | <Select |
| 123 | </div> | 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 | <BranchToolbarBranchSelector | 159 | <BranchToolbarBranchSelector |
| 126 | activeProjectCwd={activeProject.cwd} | 160 | activeProjectCwd={activeProject.cwd} |