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.

type

Julius Marminge93af851dc53e
diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts
index dd1912fb2..855b39bbb 100644
--- a/apps/web/src/components/BranchToolbar.logic.ts
+++ b/apps/web/src/components/BranchToolbar.logic.ts
@@ -1,10 +1,12 @@
import type { GitBranch } from "@t3tools/contracts";
+export type EnvMode = "local" | "worktree";
+
export function resolveDraftEnvModeAfterBranchChange(input: {
nextWorktreePath: string | null;
currentWorktreePath: string | null;
- effectiveEnvMode: "local" | "worktree";
-}): "local" | "worktree" {
+ effectiveEnvMode: EnvMode;
+}): EnvMode {
const { nextWorktreePath, currentWorktreePath, effectiveEnvMode } = input;
if (nextWorktreePath) {
return "worktree";
@@ -16,7 +18,7 @@ export function resolveDraftEnvModeAfterBranchChange(input: {
}
export function resolveBranchToolbarValue(input: {
- envMode: "local" | "worktree";
+ envMode: EnvMode;
activeWorktreePath: string | null;
activeThreadBranch: string | null;
currentGitBranch: string | null;
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx
index 9d208a32c..d4c0b4a59 100644
--- a/apps/web/src/components/BranchToolbar.tsx
+++ b/apps/web/src/components/BranchToolbar.tsx
@@ -5,14 +5,14 @@ import { newCommandId } from "../lib/utils";
import { readNativeApi } from "../nativeApi";
import { useComposerDraftStore } from "../composerDraftStore";
import { useStore } from "../store";
-import { resolveDraftEnvModeAfterBranchChange } from "./BranchToolbar.logic";
+import { EnvMode, resolveDraftEnvModeAfterBranchChange } from "./BranchToolbar.logic";
import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector";
import { Button } from "./ui/button";
interface BranchToolbarProps {
threadId: ThreadId;
- envMode: "local" | "worktree";
- onEnvModeChange: (mode: "local" | "worktree") => void;
+ envMode: EnvMode;
+ onEnvModeChange: (mode: EnvMode) => void;
envLocked: boolean;
onComposerFocusRequest?: () => void;
}
@@ -38,7 +38,7 @@ export default function BranchToolbar({
const activeWorktreePath = serverThread?.worktreePath ?? draftThread?.worktreePath ?? null;
const branchCwd = activeWorktreePath ?? activeProject?.cwd ?? null;
const hasServerThread = serverThread !== undefined;
- const effectiveEnvMode: "local" | "worktree" =
+ const effectiveEnvMode: EnvMode =
activeWorktreePath || (!hasServerThread && draftThread?.envMode === "worktree")
? "worktree"
: envMode;
diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx
index bb3170981..ba27e383d 100644
--- a/apps/web/src/components/BranchToolbarBranchSelector.tsx
+++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx
@@ -2,13 +2,22 @@ import type { GitBranch } from "@t3tools/contracts";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useVirtualizer } from "@tanstack/react-virtual";
import { ChevronDownIcon } from "lucide-react";
-import { useCallback, useEffect, useMemo, useOptimistic, useRef, useState, useTransition } from "react";
+import {
+ useCallback,
+ useEffect,
+ useMemo,
+ useOptimistic,
+ useRef,
+ useState,
+ useTransition,
+} from "react";
import { gitBranchesQueryOptions, gitQueryKeys, invalidateGitQueries } from "../lib/gitReactQuery";
import { readNativeApi } from "../nativeApi";
import {
dedupeRemoteBranchesWithLocalMatches,
deriveLocalBranchNameFromRemoteRef,
+ EnvMode,
resolveBranchToolbarValue,
} from "./BranchToolbar.logic";
import { Button } from "./ui/button";
@@ -28,7 +37,7 @@ interface BranchToolbarBranchSelectorProps {
activeThreadBranch: string | null;
activeWorktreePath: string | null;
branchCwd: string | null;
- effectiveEnvMode: "local" | "worktree";
+ effectiveEnvMode: EnvMode;
envLocked: boolean;
onSetThreadBranch: (branch: string | null, worktreePath: string | null) => void;
onComposerFocusRequest?: () => void;
@@ -40,7 +49,7 @@ function toBranchActionErrorMessage(error: unknown): string {
function getBranchTriggerLabel(input: {
activeWorktreePath: string | null;
- effectiveEnvMode: "local" | "worktree";
+ effectiveEnvMode: EnvMode;
resolvedActiveBranch: string | null;
}): string {
const { activeWorktreePath, effectiveEnvMode, resolvedActiveBranch } = input;
@@ -215,7 +224,12 @@ export function BranchToolbarBranchSelector({
};
useEffect(() => {
- if (effectiveEnvMode !== "worktree" || activeWorktreePath || activeThreadBranch || !currentGitBranch) {
+ if (
+ effectiveEnvMode !== "worktree" ||
+ activeWorktreePath ||
+ activeThreadBranch ||
+ !currentGitBranch
+ ) {
return;
}
onSetThreadBranch(currentGitBranch, null);