Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

helper

Julius Marminge760fe643e857
diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts
index 855b39bbb..1b48970bb 100644
--- a/apps/web/src/components/BranchToolbar.logic.ts
+++ b/apps/web/src/components/BranchToolbar.logic.ts
@@ -2,6 +2,17 @@ import type { GitBranch } from "@t3tools/contracts";
export type EnvMode = "local" | "worktree";
+export function resolveEffectiveEnvMode(input: {
+ activeWorktreePath: string | null;
+ hasServerThread: boolean;
+ draftThreadEnvMode: EnvMode | undefined;
+}): EnvMode {
+ const { activeWorktreePath, hasServerThread, draftThreadEnvMode } = input;
+ return activeWorktreePath || (!hasServerThread && draftThreadEnvMode === "worktree")
+ ? "worktree"
+ : "local";
+}
+
export function resolveDraftEnvModeAfterBranchChange(input: {
nextWorktreePath: string | null;
currentWorktreePath: string | null;
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx
index d4c0b4a59..929a0572c 100644
--- a/apps/web/src/components/BranchToolbar.tsx
+++ b/apps/web/src/components/BranchToolbar.tsx
@@ -5,7 +5,11 @@ import { newCommandId } from "../lib/utils";
import { readNativeApi } from "../nativeApi";
import { useComposerDraftStore } from "../composerDraftStore";
import { useStore } from "../store";
-import { EnvMode, resolveDraftEnvModeAfterBranchChange } from "./BranchToolbar.logic";
+import {
+ EnvMode,
+ resolveDraftEnvModeAfterBranchChange,
+ resolveEffectiveEnvMode,
+} from "./BranchToolbar.logic";
import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector";
import { Button } from "./ui/button";
@@ -38,10 +42,11 @@ export default function BranchToolbar({
const activeWorktreePath = serverThread?.worktreePath ?? draftThread?.worktreePath ?? null;
const branchCwd = activeWorktreePath ?? activeProject?.cwd ?? null;
const hasServerThread = serverThread !== undefined;
- const effectiveEnvMode: EnvMode =
- activeWorktreePath || (!hasServerThread && draftThread?.envMode === "worktree")
- ? "worktree"
- : envMode;
+ const effectiveEnvMode = resolveEffectiveEnvMode({
+ activeWorktreePath,
+ hasServerThread,
+ draftThreadEnvMode: draftThread?.envMode,
+ });
const setThreadBranch = useCallback(
(branch: string | null, worktreePath: string | null) => {