The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 11:00 UTC
type
Julius Marminge committed
Mar 3, 2026 at 09:55 UTC
93af851dc53e950673dacc1fb79c2bd95a8b6a9d
3 files changed
+27
-11
apps/web/src/components/BranchToolbar.logic.ts
+5
-3
@@ -1,10 +1,12 @@
1
import type { GitBranch } from "@t3tools/contracts";
2
3
+export type EnvMode = "local" | "worktree";
4
+
5
export function resolveDraftEnvModeAfterBranchChange(input: {
6
nextWorktreePath: string | null;
7
currentWorktreePath: string | null;
6
- effectiveEnvMode: "local" | "worktree";
7
-}): "local" | "worktree" {
8
+ effectiveEnvMode: EnvMode;
9
+}): EnvMode {
10
const { nextWorktreePath, currentWorktreePath, effectiveEnvMode } = input;
11
if (nextWorktreePath) {
12
return "worktree";
@@ -16,7 +18,7 @@ export function resolveDraftEnvModeAfterBranchChange(input: {
18
}
19
20
export function resolveBranchToolbarValue(input: {
19
- envMode: "local" | "worktree";
21
+ envMode: EnvMode;
22
activeWorktreePath: string | null;
23
activeThreadBranch: string | null;
24
currentGitBranch: string | null;
apps/web/src/components/BranchToolbar.tsx
+4
-4
@@ -5,14 +5,14 @@ import { newCommandId } from "../lib/utils";
5
import { readNativeApi } from "../nativeApi";
6
import { useComposerDraftStore } from "../composerDraftStore";
7
import { useStore } from "../store";
8
-import { resolveDraftEnvModeAfterBranchChange } from "./BranchToolbar.logic";
8
+import { EnvMode, resolveDraftEnvModeAfterBranchChange } from "./BranchToolbar.logic";
9
import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector";
10
import { Button } from "./ui/button";
11
12
interface BranchToolbarProps {
13
threadId: ThreadId;
14
- envMode: "local" | "worktree";
15
- onEnvModeChange: (mode: "local" | "worktree") => void;
14
+ envMode: EnvMode;
15
+ onEnvModeChange: (mode: EnvMode) => void;
16
envLocked: boolean;
17
onComposerFocusRequest?: () => void;
18
}
@@ -38,7 +38,7 @@ export default function BranchToolbar({
38
const activeWorktreePath = serverThread?.worktreePath ?? draftThread?.worktreePath ?? null;
39
const branchCwd = activeWorktreePath ?? activeProject?.cwd ?? null;
40
const hasServerThread = serverThread !== undefined;
41
- const effectiveEnvMode: "local" | "worktree" =
41
+ const effectiveEnvMode: EnvMode =
42
activeWorktreePath || (!hasServerThread && draftThread?.envMode === "worktree")
43
? "worktree"
44
: envMode;
apps/web/src/components/BranchToolbarBranchSelector.tsx
+18
-4
@@ -2,13 +2,22 @@ import type { GitBranch } from "@t3tools/contracts";
2
import { useQuery, useQueryClient } from "@tanstack/react-query";
3
import { useVirtualizer } from "@tanstack/react-virtual";
4
import { ChevronDownIcon } from "lucide-react";
5
-import { useCallback, useEffect, useMemo, useOptimistic, useRef, useState, useTransition } from "react";
5
+import {
6
+ useCallback,
7
+ useEffect,
8
+ useMemo,
9
+ useOptimistic,
10
+ useRef,
11
+ useState,
12
+ useTransition,
13
+} from "react";
14
15
import { gitBranchesQueryOptions, gitQueryKeys, invalidateGitQueries } from "../lib/gitReactQuery";
16
import { readNativeApi } from "../nativeApi";
17
import {
18
dedupeRemoteBranchesWithLocalMatches,
19
deriveLocalBranchNameFromRemoteRef,
20
+ EnvMode,
21
resolveBranchToolbarValue,
22
} from "./BranchToolbar.logic";
23
import { Button } from "./ui/button";
@@ -28,7 +37,7 @@ interface BranchToolbarBranchSelectorProps {
37
activeThreadBranch: string | null;
38
activeWorktreePath: string | null;
39
branchCwd: string | null;
31
- effectiveEnvMode: "local" | "worktree";
40
+ effectiveEnvMode: EnvMode;
41
envLocked: boolean;
42
onSetThreadBranch: (branch: string | null, worktreePath: string | null) => void;
43
onComposerFocusRequest?: () => void;
@@ -40,7 +49,7 @@ function toBranchActionErrorMessage(error: unknown): string {
49
50
function getBranchTriggerLabel(input: {
51
activeWorktreePath: string | null;
43
- effectiveEnvMode: "local" | "worktree";
52
+ effectiveEnvMode: EnvMode;
53
resolvedActiveBranch: string | null;
54
}): string {
55
const { activeWorktreePath, effectiveEnvMode, resolvedActiveBranch } = input;
@@ -215,7 +224,12 @@ export function BranchToolbarBranchSelector({
224
};
225
226
useEffect(() => {
218
- if (effectiveEnvMode !== "worktree" || activeWorktreePath || activeThreadBranch || !currentGitBranch) {
227
+ if (
228
+ effectiveEnvMode !== "worktree" ||
229
+ activeWorktreePath ||
230
+ activeThreadBranch ||
231
+ !currentGitBranch
232
+ ) {
233
return;
234
}
235
onSetThreadBranch(currentGitBranch, null);