From cce0ae35eb3b02d73e1b1fed8dc8059f45212626 Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Mon, 2 Nov 2026 16:57:31 +0530 Subject: [PATCH 1/9] fix(web): branch pickers highlight one row after refs load Co-Authored-By: Claude Opus 5.5 --- .../components/BranchPicker.browser.test.tsx | 54 +++++++++++++++++++ apps/web/src/components/BranchPicker.tsx | 2 + 2 files changed, 56 insertions(+) create mode 100644 apps/web/src/components/BranchPicker.browser.test.tsx diff --git a/apps/web/src/components/BranchPicker.browser.test.tsx b/apps/web/src/components/BranchPicker.browser.test.tsx new file mode 100644 index 0000000000000..b4fc0200b3042 --- /dev/null +++ b/apps/web/src/components/BranchPicker.browser.test.tsx @@ -0,0 +1,54 @@ +import { describe, expect, it } from "vite-plus/test"; +import { page, userEvent } from "vite-plus/test/browser"; + +import "~/index.css"; +import { render } from "../../test/render"; +import { BranchPicker } from "./BranchPicker"; +import { ComboboxItem, ComboboxTrigger } from "./ui/combobox"; + +function picker(items: string[]) { + return ( + {}} + open + onOpenChange={() => {}} + onSelectItem={() => {}} + hasNextPage={false} + isFetchingNextPage={false} + onLoadNext={() => {}} + statusText={null} + popupProps={{}} + renderItem={(item, index) => ( + + {item} + + )} + > + Refs + + ); +} + +describe("BranchPicker", () => { + it("highlights one row when refs arrive above a row that was already listed", async () => { + // The create row shows alone until the server answers the query. + await using screen = await render(picker(["Create dev"])); + await userEvent.click(page.getByPlaceholder("Search refs...")); + await userEvent.keyboard("{ArrowDown}"); + await expect + .element(page.getByRole("option", { name: "Create dev" })) + .toHaveAttribute("data-highlighted"); + await screen.rerender(picker(["origin/dev", "Create dev"])); + + await expect + .element(page.getByRole("option", { name: "origin/dev" })) + .toHaveAttribute("data-highlighted"); + await expect + .element(page.getByRole("option", { name: "Create dev" })) + .not.toHaveAttribute("data-highlighted"); + }); +}); diff --git a/apps/web/src/components/BranchPicker.tsx b/apps/web/src/components/BranchPicker.tsx index cfa082368a974..f909abc1652f8 100644 --- a/apps/web/src/components/BranchPicker.tsx +++ b/apps/web/src/components/BranchPicker.tsx @@ -179,6 +179,8 @@ export function BranchPicker({ ref={attachBranchList} data={filteredItems} + // Rows whose item is unchanged keep their render, and with it a stale index. + extraData={filteredItems} keyExtractor={(item) => item} {...(getItemType ? { getItemType } : {})} renderItem={({ item, index }) => renderItem(item, index)} From 1da9784ce77668062163c4f266c6dc27d8ef3349 Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Tue, 27 Oct 2026 18:07:57 +0530 Subject: [PATCH 2/9] feat(settings): new worktrees can start from a configured base branch Projects whose work branches from something other than the repository default, such as dev, had to pick that base by hand on every new worktree thread. Settings -> Worktrees -> Base branch sets it per environment or per project; empty keeps the repository default. Web and mobile drafts use it wherever they used the default branch. Switching a draft from the current checkout to a new worktree drops the branch synced from the checkout so the configured base applies; a branch the user picked still wins. Co-Authored-By: Claude Opus 5.5 --- ...SettingsServerControlsRouteScreen.test.tsx | 3 ++ .../SettingsServerControlsRouteScreen.tsx | 8 +++ .../components/WorktreeBaseBranchSetting.tsx | 50 +++++++++++++++++ .../new-task-context-presentation.test.ts | 44 +++++++++++++++ .../threads/new-task-context-presentation.ts | 29 +++++++--- .../threads/new-task-flow-provider.tsx | 13 ++++- .../features/threads/thread-list-v2-items.tsx | 1 + .../src/state/pending-new-tasks-model.test.ts | 9 ++++ .../src/state/pending-new-tasks-model.ts | 2 + .../components/BranchToolbar.logic.test.ts | 39 ++++++++++++++ .../web/src/components/BranchToolbar.logic.ts | 11 ++++ .../BranchToolbarBranchSelector.tsx | 23 ++++++-- .../components/chat/useComposerSelection.ts | 18 ++++++- .../components/settings/WorktreesSettings.tsx | 53 ++++++++++++++++++- .../src/components/settings/settingsSearch.ts | 7 +++ apps/web/src/lib/chatThreadActions.test.ts | 28 +++++++++- apps/web/src/lib/chatThreadActions.ts | 15 ++++++ docs/user/project-settings.md | 8 +++ packages/contracts/src/settings.ts | 5 ++ packages/shared/src/projectSettings.test.ts | 12 +++++ 20 files changed, 362 insertions(+), 16 deletions(-) create mode 100644 apps/mobile/src/features/settings/components/WorktreeBaseBranchSetting.tsx diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx index 698536b9ec1b6..45b8d749b988e 100644 --- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx +++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx @@ -122,6 +122,9 @@ vi.mock("./components/BranchNamingSettings", () => ({ return null; }, })); +vi.mock("./components/WorktreeBaseBranchSetting", () => ({ + WorktreeBaseBranchSetting: () => null, +})); vi.mock("./settings-environment-filter", () => ({ useSettingsEnvironmentFilter: () => ({ selectedTargets: mocks.targets, diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx index f35c6a29bd846..37da9e3b05779 100644 --- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx @@ -33,6 +33,7 @@ import { SettingsSection } from "./components/SettingsSection"; import { SettingsSwitchRow } from "./components/SettingsSwitchRow"; import { SourceControlSignInSection } from "./components/SourceControlSignInSection"; import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection"; +import { WorktreeBaseBranchSetting } from "./components/WorktreeBaseBranchSetting"; import { useSettingsEnvironmentFilter } from "./settings-environment-filter"; import { useSettingsWriter } from "./useSettingsWriter"; import { @@ -67,6 +68,7 @@ const PAGE_PROJECT_KEYS: Record + void; +}) { + // Save on exit too: Android Back hides the keyboard without ending editing. + const draft = useRef<{ text: string; over: string | null } | null>(null); + const save = () => { + const current = draft.current; + draft.current = null; + // Drop a draft typed over an older saved value: the updated value has already remounted the input. + if (current === null || current.over !== props.value) return; + const value = current.text.trim(); + if (props.value === null || value !== props.value) { + props.onChange({ newWorktreesBaseBranch: value }); + } + }; + const saveOnExit = useEffectEvent(save); + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- saves an unsent base branch draft to server settings when the setting unmounts + useEffect(() => () => saveOnExit(), []); + return ( + + Base branch + + The branch, tag, or commit new worktrees start from, such as dev. Leave empty to use the + repository’s default branch. + + { + draft.current = { text, over: props.value }; + }} + defaultValue={props.value ?? ""} + placeholder={props.value === null ? "Mixed" : "Repository default"} + editable={!props.disabled} + autoCapitalize="none" + autoCorrect={false} + className="min-h-10 rounded-xl px-3 py-2 text-base text-foreground" + onEndEditing={save} + /> + + ); +} diff --git a/apps/mobile/src/features/threads/new-task-context-presentation.test.ts b/apps/mobile/src/features/threads/new-task-context-presentation.test.ts index 2bb2659dc6d76..1f97230d89dbc 100644 --- a/apps/mobile/src/features/threads/new-task-context-presentation.test.ts +++ b/apps/mobile/src/features/threads/new-task-context-presentation.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vite-plus/test"; import { fillNewTaskWorkspaceBranch, + resolveWorktreeSwitchBranch, resolveNewTaskBranchLabel, resolveNewTaskBranchWorktreePath, resolveNewTaskLocalWorkspaceSelection, @@ -116,6 +117,7 @@ describe("fillNewTaskWorkspaceBranch", () => { branches, projectCwd: "/repo", worktreeDefaultSettled: true, + worktreeBaseBranch: "", }; it("bases a new worktree on the default branch, even when only the remote has it", () => { @@ -127,6 +129,32 @@ describe("fillNewTaskWorkspaceBranch", () => { ).toEqual({ mode: "worktree", branch: "origin/main", worktreePath: null }); }); + it("bases a new worktree on the configured branch, even when refs have not listed it", () => { + expect( + fillNewTaskWorkspaceBranch({ + ...base, + branches: [], + worktreeBaseBranch: "dev", + selection: { mode: "worktree", branch: null, worktreePath: null }, + }), + ).toEqual({ mode: "worktree", branch: "dev", worktreePath: null }); + }); + + it("keeps a configured base out of local selections", () => { + expect( + fillNewTaskWorkspaceBranch({ + ...base, + worktreeBaseBranch: "dev", + selection: { + mode: "local", + branch: null, + worktreePath: null, + followsCurrentCheckout: true, + }, + }), + ).toMatchObject({ branch: "feature" }); + }); + it("waits for the workspace default to settle before picking a base", () => { const selection = { mode: "worktree", branch: null, worktreePath: null } as const; expect(fillNewTaskWorkspaceBranch({ ...base, selection, worktreeDefaultSettled: false })).toBe( @@ -167,5 +195,21 @@ describe("fillNewTaskWorkspaceBranch", () => { it("keeps an explicit branch", () => { const selection = { mode: "worktree", branch: "release", worktreePath: null } as const; expect(fillNewTaskWorkspaceBranch({ ...base, selection })).toBe(selection); + expect(fillNewTaskWorkspaceBranch({ ...base, worktreeBaseBranch: "dev", selection })).toBe( + selection, + ); + }); +}); + +describe("resolveWorktreeSwitchBranch", () => { + const input = { selectedBranch: "feature", checkoutBranch: "feature", worktreeBaseBranch: "dev" }; + + it("drops the checkout branch so the configured base applies", () => { + expect(resolveWorktreeSwitchBranch(input)).toBeNull(); + }); + + it("keeps another branch the user chose, and today's behavior without a base", () => { + expect(resolveWorktreeSwitchBranch({ ...input, selectedBranch: "release" })).toBe("release"); + expect(resolveWorktreeSwitchBranch({ ...input, worktreeBaseBranch: "" })).toBe("feature"); }); }); diff --git a/apps/mobile/src/features/threads/new-task-context-presentation.ts b/apps/mobile/src/features/threads/new-task-context-presentation.ts index 44efe4cf04843..3e85a08e7836c 100644 --- a/apps/mobile/src/features/threads/new-task-context-presentation.ts +++ b/apps/mobile/src/features/threads/new-task-context-presentation.ts @@ -72,6 +72,17 @@ export function resolveNewTaskLocalWorkspaceSelection(input: { }; } +/** Leaving the checkout for a new worktree drops the checkout's branch when a base is configured. */ +export function resolveWorktreeSwitchBranch(input: { + readonly selectedBranch: string | null; + readonly checkoutBranch: string | null; + readonly worktreeBaseBranch: string; +}): string | null { + return input.worktreeBaseBranch !== "" && input.selectedBranch === input.checkoutBranch + ? null + : input.selectedBranch; +} + export function resolveNewTaskBranchLabel(input: { readonly branchName: string | null; readonly startFromOrigin: boolean; @@ -113,10 +124,9 @@ export function filterNewTaskBranches( } /** - * A worktree with no chosen base starts from the default branch, and a local - * selection the user just switched to follows the current checkout until refs - * load. Both are derived, never written back, so a late ref list or t3.json - * default still wins. + * A worktree with no chosen base starts from the configured base, else the default branch, + * and a local selection the user just switched to follows the current checkout until refs + * load. Both are derived, never written back, so a late ref list or t3.json default still wins. */ export function fillNewTaskWorkspaceBranch(input: { readonly selection: ComposerDraftWorkspaceSelection; @@ -129,17 +139,18 @@ export function fillNewTaskWorkspaceBranch(input: { }>; readonly projectCwd: string | null; readonly worktreeDefaultSettled: boolean; + readonly worktreeBaseBranch: string; }): ComposerDraftWorkspaceSelection { const { selection } = input; if (selection.branch !== null) return selection; if (selection.mode === "worktree") { // The default may only exist as origin/, so search remote refs too. - const base = + const fallback = input.branches.find((branch) => branch.isDefault) ?? - input.branches.find((branch) => !branch.isRemote && branch.current) ?? - null; + input.branches.find((branch) => !branch.isRemote && branch.current); + const base = input.worktreeBaseBranch || fallback?.name; return input.worktreeDefaultSettled && base - ? { ...selection, branch: base.name, worktreePath: null } + ? { ...selection, branch: base, worktreePath: null } : selection; } if (!selection.followsCurrentCheckout || input.projectCwd === null) return selection; @@ -166,6 +177,7 @@ export function resolveNewTaskDraftWorkspace(input: { readonly isGitRepo: boolean; readonly branches: Parameters[0]["branches"]; readonly projectCwd: string | null; + readonly worktreeBaseBranch: string; }): ComposerDraftWorkspaceSelection { const selection = input.canChooseWorkspace ? input.selection : undefined; return fillNewTaskWorkspaceBranch({ @@ -177,5 +189,6 @@ export function resolveNewTaskDraftWorkspace(input: { branches: input.branches, projectCwd: input.projectCwd, worktreeDefaultSettled: selection?.mode !== undefined || input.defaultModeSettled, + worktreeBaseBranch: input.worktreeBaseBranch, }); } diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsx index 3876fd2f83dbb..907418c16309e 100644 --- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx +++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx @@ -90,6 +90,7 @@ import { import { useLegacyPlanModeState } from "./use-legacy-plan-mode-enabled"; import { resolveNewTaskDraftWorkspace, + resolveWorktreeSwitchBranch, resolveNewTaskBranchWorktreePath, resolveNewTaskLocalWorkspaceSelection, } from "./new-task-context-presentation"; @@ -406,6 +407,7 @@ export function NewTaskFlowProvider( isGitRepo, branches: allBranchRefs, projectCwd: selectedProject?.workspaceRoot ?? null, + worktreeBaseBranch: projectSettings.settings.newWorktreesBaseBranch, }); const workspaceSelection = resolveWorkspaceSelection(selectedProjectDraft.workspaceSelection); const workspaceMode = workspaceSelection.mode; @@ -649,7 +651,16 @@ export function NewTaskFlowProvider( updateComposerDraftSettings(selectedProjectDraftKey, { workspaceSelection: { mode, - branch: mode === "local" ? localSelection.branch : selectedBranchName, + branch: + mode === "local" + ? localSelection.branch + : workspaceMode === "local" + ? resolveWorktreeSwitchBranch({ + selectedBranch: selectedBranchName, + checkoutBranch: localSelection.branch, + worktreeBaseBranch: projectSettings.settings.newWorktreesBaseBranch, + }) + : selectedBranchName, worktreePath: mode === "local" ? localSelection.worktreePath : selectedWorktreePath, ...(draftStartFromOrigin !== undefined ? { startFromOrigin: draftStartFromOrigin } : {}), // Refs have not named the current branch yet; the selection follows it. diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index 84e9494759cad..9a22f7ab3a63f 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -404,6 +404,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props canChooseWorkspace: !projectDefaults.isScratch, defaultMode: projectDefaults.defaultWorkspaceMode, defaultModeSettled: projectDefaults.defaultWorkspaceModeSettled, + worktreeBaseBranch: projectDefaults.projectSettings.settings.newWorktreesBaseBranch, }; const draftBranchRefs = useBranches({ environmentId: pendingTask.environmentId, diff --git a/apps/mobile/src/state/pending-new-tasks-model.test.ts b/apps/mobile/src/state/pending-new-tasks-model.test.ts index 6c039d7254c07..d35df7d701ff9 100644 --- a/apps/mobile/src/state/pending-new-tasks-model.test.ts +++ b/apps/mobile/src/state/pending-new-tasks-model.test.ts @@ -13,6 +13,7 @@ const localDefault: PendingDraftProjectDefaults = { canChooseWorkspace: true, defaultMode: "local", defaultModeSettled: true, + worktreeBaseBranch: "", }; const worktreeDefault: PendingDraftProjectDefaults = { ...localDefault, defaultMode: "worktree" }; const resolve = ( @@ -63,6 +64,14 @@ describe("resolvePendingDraftBranch", () => { const worktree = draft({ mode: "worktree", branch: null, worktreePath: null }); expect(pendingDraftBranchNeedsRefs(worktree, localDefault)).toBe(true); expect(resolve({ draft: worktree, branches, projectCwd })).toBe("origin/main"); + expect( + resolve({ + draft: worktree, + defaults: { ...localDefault, worktreeBaseBranch: "dev" }, + branches, + projectCwd, + }), + ).toBe("dev"); }); it("shows the current branch for a local draft that follows the checkout", () => { diff --git a/apps/mobile/src/state/pending-new-tasks-model.ts b/apps/mobile/src/state/pending-new-tasks-model.ts index ce8923ce62ee1..7add8f1281447 100644 --- a/apps/mobile/src/state/pending-new-tasks-model.ts +++ b/apps/mobile/src/state/pending-new-tasks-model.ts @@ -52,6 +52,7 @@ export interface PendingDraftProjectDefaults { readonly canChooseWorkspace: boolean; readonly defaultMode: "local" | "worktree"; readonly defaultModeSettled: boolean; + readonly worktreeBaseBranch: string; } /** @@ -82,6 +83,7 @@ export function resolvePendingDraftBranch(input: { isGitRepo: input.isGitRepo, branches: input.branches, projectCwd: input.projectCwd, + worktreeBaseBranch: input.defaults.worktreeBaseBranch, }).branch; } diff --git a/apps/web/src/components/BranchToolbar.logic.test.ts b/apps/web/src/components/BranchToolbar.logic.test.ts index 08e6f7633dee3..8c4422e0f544f 100644 --- a/apps/web/src/components/BranchToolbar.logic.test.ts +++ b/apps/web/src/components/BranchToolbar.logic.test.ts @@ -8,6 +8,7 @@ import { resolveEffectiveEnvMode, resolveBranchToolbarPrBranch, resolveLocalCheckoutBranchMismatch, + resolveWorktreeBaseBranchCandidate, sanitizeNewRefName, shouldIncludeBranchPickerItem, } from "./BranchToolbar.logic"; @@ -45,6 +46,44 @@ describe("resolveBranchToolbarPrBranch", () => { }); }); +describe("resolveWorktreeBaseBranchCandidate", () => { + const input = { + configuredBaseBranch: "", + isRepo: true, + defaultBranchName: "main", + currentGitBranch: "feature/open-thread", + }; + + it("uses the repository default, not the open thread's branch, when no base is configured", () => { + expect(resolveWorktreeBaseBranchCandidate(input)).toBe("main"); + expect(resolveWorktreeBaseBranchCandidate({ ...input, defaultBranchName: null })).toBe( + "feature/open-thread", + ); + }); + + it("uses the configured base even when the loaded refs do not include it", () => { + expect( + resolveWorktreeBaseBranchCandidate({ + ...input, + configuredBaseBranch: "dev", + defaultBranchName: null, + currentGitBranch: null, + }), + ).toBe("dev"); + }); + + it("ignores a configured base outside a Git repository", () => { + expect( + resolveWorktreeBaseBranchCandidate({ + configuredBaseBranch: "dev", + isRepo: false, + defaultBranchName: null, + currentGitBranch: null, + }), + ).toBeNull(); + }); +}); + describe("resolveLocalCheckoutBranchMismatch", () => { it("detects when a local thread is associated with a different branch than the checkout", () => { expect( diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts index e22dcfaddedeb..2998ef5ccea9a 100644 --- a/apps/web/src/components/BranchToolbar.logic.ts +++ b/apps/web/src/components/BranchToolbar.logic.ts @@ -196,6 +196,17 @@ export function resolveBranchToolbarValue(input: { return currentGitBranch ?? activeThreadBranch; } +/** A configured base is used as typed; it may sit outside the loaded ref page or exist only on a remote. */ +export function resolveWorktreeBaseBranchCandidate(input: { + configuredBaseBranch: string; + isRepo: boolean; + defaultBranchName: string | null; + currentGitBranch: string | null; +}): string | null { + if (input.isRepo && input.configuredBaseBranch !== "") return input.configuredBaseBranch; + return input.defaultBranchName ?? input.currentGitBranch; +} + export function resolveBranchTriggerLabel(input: { activeWorktreePath: string | null; effectiveEnvMode: EnvMode; diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx index fab250f6adaf8..8b3227812d772 100644 --- a/apps/web/src/components/BranchToolbarBranchSelector.tsx +++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx @@ -1,3 +1,5 @@ +import { useAtomValue } from "@effect/atom-react"; +import { resolveProjectSettings } from "@t3tools/shared/projectSettings"; import { ThreadDetailsControl } from "./chat/ThreadDetailsControl"; import { ComposerContextLabel } from "./ComposerContextLabel"; import { useSupportsMultiplePullRequests } from "~/hooks/useSupportsMultiplePullRequests"; @@ -35,6 +37,7 @@ import { usePaginatedBranches } from "../state/queries"; import { useProject, useQuietThreadShell } from "../state/entities"; import { useEnvironmentQuery } from "../state/query"; import { readEnvironmentScope, useEnvironmentScope } from "~/state/session"; +import { serverEnvironment } from "~/state/server"; import { threadEnvironment } from "../state/threads"; import { useAtomCommand } from "../state/use-atom-command"; import { vcsEnvironment } from "../state/vcs"; @@ -52,6 +55,7 @@ import { resolveBranchToolbarValue, resolveDraftEnvModeAfterBranchChange, resolveEffectiveEnvMode, + resolveWorktreeBaseBranchCandidate, sanitizeNewRefName, shouldIncludeBranchPickerItem, } from "./BranchToolbar.logic"; @@ -145,6 +149,9 @@ export function BranchToolbarBranchSelector({ ? scopeProjectRef(draftThread.environmentId, draftThread.projectId) : null; const activeProject = useProject(activeProjectRef); + const environmentServerSettings = useAtomValue( + serverEnvironment.settingsValueAtom(environmentId), + ); const activeThreadId = serverThread?.id ?? (draftThread ? threadId : undefined); const activeThreadBranch = @@ -475,9 +482,19 @@ export function BranchToolbarBranchSelector({ }); }; - const worktreeBaseBranchCandidate = isInitialBranchesLoadPending - ? null - : (defaultBranchName ?? currentGitBranch); + // Wait for settings too, so the repository default cannot claim the draft before a configured base arrives. + const worktreeBaseBranchCandidate = + isInitialBranchesLoadPending || environmentServerSettings === null + ? null + : resolveWorktreeBaseBranchCandidate({ + configuredBaseBranch: resolveProjectSettings( + environmentServerSettings, + activeProject?.id ?? null, + ).settings.newWorktreesBaseBranch, + isRepo: branchRefState.data?.isRepo ?? false, + defaultBranchName, + currentGitBranch, + }); // The server sets started threads' branches; defaulting here would detach the agent from its worktree. const threadStarted = serverSession !== null; diff --git a/apps/web/src/components/chat/useComposerSelection.ts b/apps/web/src/components/chat/useComposerSelection.ts index a6312466d9747..bbab3419a1eff 100644 --- a/apps/web/src/components/chat/useComposerSelection.ts +++ b/apps/web/src/components/chat/useComposerSelection.ts @@ -18,7 +18,10 @@ import { type SetStateAction } from "react"; import { useNavigate } from "@tanstack/react-router"; import { toastManager } from "../ui/toast"; import { resolveAppModelSelectionForInstance } from "../../modelSelection"; -import { resolveNewDraftStartFromOrigin } from "../../lib/chatThreadActions"; +import { + resolveNewDraftStartFromOrigin, + shouldClearSyncedDraftBranch, +} from "../../lib/chatThreadActions"; import { type DraftThreadEnvMode, useComposerDraftStore } from "../../composerDraftStore"; import { getStartedThreadModelChangeBlockReason, @@ -32,7 +35,10 @@ interface ComposerSelectionInput { readonly activeThread: EnvironmentThreadShell | undefined; readonly activeRuntime: ReturnType; readonly activeProjectSettings: { - readonly settings: { readonly newWorktreesStartFromOrigin: boolean }; + readonly settings: { + readonly newWorktreesStartFromOrigin: boolean; + readonly newWorktreesBaseBranch: string; + }; }; readonly settings: UnifiedSettings; readonly providerStatuses: ReadonlyArray; @@ -229,6 +235,14 @@ export function useComposerSelection(input: ComposerSelectionInput) { newWorktreesStartFromOrigin: activeProjectSettings.settings.newWorktreesStartFromOrigin, }), ...(mode === "worktree" && draftThread?.worktreePath ? { worktreePath: null } : {}), + ...(shouldClearSyncedDraftBranch({ + nextEnvMode: mode, + worktreeBaseBranch: activeProjectSettings.settings.newWorktreesBaseBranch, + draftBranch: draftThread?.branch ?? null, + environmentSelection: draftThread?.environmentSelection, + }) + ? { branch: null } + : {}), }); } scheduleComposerFocus(); diff --git a/apps/web/src/components/settings/WorktreesSettings.tsx b/apps/web/src/components/settings/WorktreesSettings.tsx index a771e92ceca43..0d643643e8374 100644 --- a/apps/web/src/components/settings/WorktreesSettings.tsx +++ b/apps/web/src/components/settings/WorktreesSettings.tsx @@ -1,5 +1,7 @@ +import { useRef } from "react"; import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; +import { Input } from "../ui/input"; import { AdvancedSettings } from "./AdvancedSettings"; import { BranchNamingSettings } from "./BranchNamingSettings"; import { WorktreeSubmodulesRow } from "./ProjectDefaultsSettings"; @@ -13,7 +15,55 @@ import { } from "./settingsLayout"; import { searchableSetting } from "./settingsSearch"; import { WorktreeCleanupSection, WorktreesDirectoryRow } from "./StorageSettings"; -import { useScopedSettings, useUpdateScopedSettings } from "./useScopedSettings"; +import { + useScopedSettings, + useScopedSettingsMixed, + useUpdateScopedSettings, +} from "./useScopedSettings"; + +function BaseBranchRow() { + const settings = useScopedSettings(); + const { targets } = useSettingsScope(); + const scopeKey = targets.map((target) => `${target.environmentId}:${target.projectId}`).join(","); + const edited = useRef(false); + const updateSettings = useUpdateScopedSettings(); + const mixed = useScopedSettingsMixed(["newWorktreesBaseBranch"]); + return ( + updateSettings({ newWorktreesBaseBranch: "" })} + /> + ) : null + } + control={ + { + edited.current = true; + }} + placeholder={mixed ? "Mixed" : "Repository default"} + defaultValue={mixed ? "" : settings.newWorktreesBaseBranch} + onBlur={(event) => { + const value = event.target.value.trim(); + if (edited.current && (mixed || value !== settings.newWorktreesBaseBranch)) + updateSettings({ newWorktreesBaseBranch: value }); + edited.current = false; + }} + /> + } + /> + ); +} function StartFromRemoteRow() { const settings = useScopedSettings(); @@ -59,6 +109,7 @@ export function WorktreesSettingsPanel() { {!isProjectScope && } + diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts index d28e467b0cf70..917bfc62fd716 100644 --- a/apps/web/src/components/settings/settingsSearch.ts +++ b/apps/web/src/components/settings/settingsSearch.ts @@ -639,6 +639,13 @@ export const SETTINGS_SEARCH_ITEMS = [ scope: "project-defaults", searchTerms: ["git submodule init recursive top-level none worktree t3.json"], }, + { + id: "worktree-base-branch", + title: "Base branch", + to: "/settings/worktrees", + scope: "project-defaults", + searchTerms: ["new worktrees start from default branch dev main base ref"], + }, { id: "start-from-origin", title: "Start from remote", diff --git a/apps/web/src/lib/chatThreadActions.test.ts b/apps/web/src/lib/chatThreadActions.test.ts index ad465cd06b2bf..6ef132bfc533d 100644 --- a/apps/web/src/lib/chatThreadActions.test.ts +++ b/apps/web/src/lib/chatThreadActions.test.ts @@ -1,6 +1,9 @@ import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; -import { resolveNewThreadModelSelectionOverride } from "./chatThreadActions"; +import { + resolveNewThreadModelSelectionOverride, + shouldClearSyncedDraftBranch, +} from "./chatThreadActions"; const PROJECT_DEFAULT_SELECTION: ModelSelection = { instanceId: ProviderInstanceId.make("codex"), @@ -34,3 +37,26 @@ describe("chatThreadActions", () => { ).toEqual(PROJECT_DEFAULT_SELECTION); }); }); + +describe("shouldClearSyncedDraftBranch", () => { + const input = { + nextEnvMode: "worktree", + worktreeBaseBranch: "dev", + draftBranch: "feature/checked-out", + environmentSelection: "auto", + } as const; + + it("drops the checkout branch so a new worktree starts from the configured base", () => { + expect(shouldClearSyncedDraftBranch(input)).toBe(true); + expect(shouldClearSyncedDraftBranch({ ...input, environmentSelection: undefined })).toBe(true); + }); + + it("keeps a branch the user picked", () => { + expect(shouldClearSyncedDraftBranch({ ...input, environmentSelection: "manual" })).toBe(false); + }); + + it("keeps today's behavior without a configured base or outside worktree mode", () => { + expect(shouldClearSyncedDraftBranch({ ...input, worktreeBaseBranch: "" })).toBe(false); + expect(shouldClearSyncedDraftBranch({ ...input, nextEnvMode: "local" })).toBe(false); + }); +}); diff --git a/apps/web/src/lib/chatThreadActions.ts b/apps/web/src/lib/chatThreadActions.ts index ac5412c239753..a4188fd415268 100644 --- a/apps/web/src/lib/chatThreadActions.ts +++ b/apps/web/src/lib/chatThreadActions.ts @@ -43,6 +43,21 @@ export function resolveNewDraftStartFromOrigin(input: { return input.envMode === "worktree" && input.newWorktreesStartFromOrigin; } +/** A configured base replaces the branch a draft synced from its checkout, never one the user picked. */ +export function shouldClearSyncedDraftBranch(input: { + nextEnvMode: DraftThreadEnvMode; + worktreeBaseBranch: string; + draftBranch: string | null; + environmentSelection: "auto" | "manual" | undefined; +}): boolean { + return ( + input.nextEnvMode === "worktree" && + input.worktreeBaseBranch !== "" && + input.draftBranch !== null && + input.environmentSelection !== "manual" + ); +} + export function resolveNewThreadModelSelectionOverride(input: { readonly projectDefaultSelection: ModelSelection | null; readonly carrySelection: ModelSelection | null; diff --git a/docs/user/project-settings.md b/docs/user/project-settings.md index ba481be9f5b00..a8b754e820db6 100644 --- a/docs/user/project-settings.md +++ b/docs/user/project-settings.md @@ -62,6 +62,14 @@ back. On mobile, both are in **Settings → Projects → Organize**. A project on several machines must have every machine connected to pin or archive it. +## Worktree base branch + +New worktrees start from the repository's default branch. If a project's work branches +from somewhere else, such as `dev`, select the project and enter that branch, tag, or +commit in **Settings → Worktrees → Base branch**. Leave it empty to go back to the +repository default. You can still choose a different base for any single thread +from the branch picker. + ## Worktree branch names In **Settings → Worktrees → Worktree branch naming**, choose a static prefix, diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index f291cec115f73..d448a2410f61b 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -1027,6 +1027,7 @@ export const PROJECT_SCOPED_SERVER_SETTING_KEYS = [ "defaultRuntimeMode", "defaultThreadEnvMode", "newWorktreesStartFromOrigin", + "newWorktreesBaseBranch", "worktreeSubmodules", "defaultAutoPull", "defaultProjectScripts", @@ -1064,6 +1065,7 @@ export const ProjectSettingsOverrides = Schema.Struct({ defaultRuntimeMode: Schema.optionalKey(RuntimeMode), defaultThreadEnvMode: Schema.optionalKey(ThreadEnvMode), newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean), + newWorktreesBaseBranch: Schema.optionalKey(TrimmedString), worktreeSubmodules: ForwardCompatibleOptional(WorktreeSubmodules), defaultAutoPull: Schema.optionalKey(Schema.Boolean), defaultProjectScripts: Schema.optionalKey(Schema.Array(ProjectScript)), @@ -1306,6 +1308,8 @@ export const ServerSettings = Schema.Struct({ newWorktreesStartFromOrigin: Schema.Boolean.pipe( Schema.withDecodingDefault(Effect.succeed(true)), ), + /** Empty uses the repository's default branch. */ + newWorktreesBaseBranch: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))), /** Null inherits t3.json, then recursive; unknown values decode to null for older clients. */ worktreeSubmodules: ForwardCompatibleNullable(WorktreeSubmodules).pipe( Schema.withDecodingDefault(Effect.succeed(null)), @@ -1669,6 +1673,7 @@ export const ServerSettingsPatch = Schema.Struct({ environmentIcon: Schema.optionalKey(Schema.NullOr(EnvironmentMachineKind)), defaultThreadEnvMode: Schema.optionalKey(Schema.NullOr(ThreadEnvMode)), newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean), + newWorktreesBaseBranch: Schema.optionalKey(TrimmedString), worktreeSubmodules: Schema.optionalKey(Schema.NullOr(WorktreeSubmodules)), addProjectBaseDirectory: Schema.optionalKey(TrimmedString), textGenerationModelSelection: Schema.optionalKey(ModelSelectionPatch), diff --git a/packages/shared/src/projectSettings.test.ts b/packages/shared/src/projectSettings.test.ts index 67aaf2186e7a2..2b53214187820 100644 --- a/packages/shared/src/projectSettings.test.ts +++ b/packages/shared/src/projectSettings.test.ts @@ -34,6 +34,18 @@ describe("resolveSendEnvMode", () => { }); describe("resolveProjectSettings", () => { + it("lets a project return to the repository default when its environment sets a base branch", () => { + const settings = { + ...DEFAULT_SERVER_SETTINGS, + newWorktreesBaseBranch: "dev", + projectSettingsOverrides: { [projectId]: { newWorktreesBaseBranch: "" } }, + }; + expect(resolveProjectSettings(settings, projectId).settings.newWorktreesBaseBranch).toBe(""); + expect(resolveProjectSettings(settings, otherProjectId).settings.newWorktreesBaseBranch).toBe( + "dev", + ); + }); + it("ignores an override left undefined by a forward-compatible decode", () => { const resolved = resolveProjectSettings( { From e3165d77ed7f16b7064a49aa49d9bdf9509982fb Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Tue, 27 Oct 2026 18:29:53 +0530 Subject: [PATCH 3/9] fix(settings): a configured base always applies when leaving the checkout Leaving Current checkout for New worktree guessed whether the draft's branch was synced or picked: web read environmentSelection, which machine picks also set, and mobile compared branch names, which a checked-out pick also matches. In Current checkout the picker checks a branch out rather than choosing a worktree base, so with a base configured the switch now always starts from it, shown in the picker before sending. Re-selecting New worktree keeps a base already picked there. Co-Authored-By: Claude Opus 5.5 --- .../new-task-context-presentation.test.ts | 15 +++++----- .../threads/new-task-context-presentation.ts | 7 ++--- .../threads/new-task-flow-provider.tsx | 1 - .../components/chat/useComposerSelection.ts | 7 ++--- apps/web/src/lib/chatThreadActions.test.ts | 28 +++++++++++-------- apps/web/src/lib/chatThreadActions.ts | 12 ++++---- 6 files changed, 34 insertions(+), 36 deletions(-) diff --git a/apps/mobile/src/features/threads/new-task-context-presentation.test.ts b/apps/mobile/src/features/threads/new-task-context-presentation.test.ts index 1f97230d89dbc..a373b4010613d 100644 --- a/apps/mobile/src/features/threads/new-task-context-presentation.test.ts +++ b/apps/mobile/src/features/threads/new-task-context-presentation.test.ts @@ -202,14 +202,15 @@ describe("fillNewTaskWorkspaceBranch", () => { }); describe("resolveWorktreeSwitchBranch", () => { - const input = { selectedBranch: "feature", checkoutBranch: "feature", worktreeBaseBranch: "dev" }; - - it("drops the checkout branch so the configured base applies", () => { - expect(resolveWorktreeSwitchBranch(input)).toBeNull(); + it("starts a new worktree from the configured base, not the checkout's branch", () => { + expect( + resolveWorktreeSwitchBranch({ selectedBranch: "release", worktreeBaseBranch: "dev" }), + ).toBeNull(); }); - it("keeps another branch the user chose, and today's behavior without a base", () => { - expect(resolveWorktreeSwitchBranch({ ...input, selectedBranch: "release" })).toBe("release"); - expect(resolveWorktreeSwitchBranch({ ...input, worktreeBaseBranch: "" })).toBe("feature"); + it("keeps today's behavior without a configured base", () => { + expect(resolveWorktreeSwitchBranch({ selectedBranch: "release", worktreeBaseBranch: "" })).toBe( + "release", + ); }); }); diff --git a/apps/mobile/src/features/threads/new-task-context-presentation.ts b/apps/mobile/src/features/threads/new-task-context-presentation.ts index 3e85a08e7836c..f246bf45a89e2 100644 --- a/apps/mobile/src/features/threads/new-task-context-presentation.ts +++ b/apps/mobile/src/features/threads/new-task-context-presentation.ts @@ -72,15 +72,12 @@ export function resolveNewTaskLocalWorkspaceSelection(input: { }; } -/** Leaving the checkout for a new worktree drops the checkout's branch when a base is configured. */ +/** A checkout's branch is not a worktree base, so leaving it for a new worktree starts from the configured base. */ export function resolveWorktreeSwitchBranch(input: { readonly selectedBranch: string | null; - readonly checkoutBranch: string | null; readonly worktreeBaseBranch: string; }): string | null { - return input.worktreeBaseBranch !== "" && input.selectedBranch === input.checkoutBranch - ? null - : input.selectedBranch; + return input.worktreeBaseBranch === "" ? input.selectedBranch : null; } export function resolveNewTaskBranchLabel(input: { diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsx index 907418c16309e..ea9360009958f 100644 --- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx +++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx @@ -657,7 +657,6 @@ export function NewTaskFlowProvider( : workspaceMode === "local" ? resolveWorktreeSwitchBranch({ selectedBranch: selectedBranchName, - checkoutBranch: localSelection.branch, worktreeBaseBranch: projectSettings.settings.newWorktreesBaseBranch, }) : selectedBranchName, diff --git a/apps/web/src/components/chat/useComposerSelection.ts b/apps/web/src/components/chat/useComposerSelection.ts index bbab3419a1eff..1c204dda2eb37 100644 --- a/apps/web/src/components/chat/useComposerSelection.ts +++ b/apps/web/src/components/chat/useComposerSelection.ts @@ -20,7 +20,7 @@ import { toastManager } from "../ui/toast"; import { resolveAppModelSelectionForInstance } from "../../modelSelection"; import { resolveNewDraftStartFromOrigin, - shouldClearSyncedDraftBranch, + shouldResetBranchForNewWorktree, } from "../../lib/chatThreadActions"; import { type DraftThreadEnvMode, useComposerDraftStore } from "../../composerDraftStore"; import { @@ -235,11 +235,10 @@ export function useComposerSelection(input: ComposerSelectionInput) { newWorktreesStartFromOrigin: activeProjectSettings.settings.newWorktreesStartFromOrigin, }), ...(mode === "worktree" && draftThread?.worktreePath ? { worktreePath: null } : {}), - ...(shouldClearSyncedDraftBranch({ + ...(shouldResetBranchForNewWorktree({ + currentEnvMode: draftThread?.envMode, nextEnvMode: mode, worktreeBaseBranch: activeProjectSettings.settings.newWorktreesBaseBranch, - draftBranch: draftThread?.branch ?? null, - environmentSelection: draftThread?.environmentSelection, }) ? { branch: null } : {}), diff --git a/apps/web/src/lib/chatThreadActions.test.ts b/apps/web/src/lib/chatThreadActions.test.ts index 6ef132bfc533d..b6e99f8c70a05 100644 --- a/apps/web/src/lib/chatThreadActions.test.ts +++ b/apps/web/src/lib/chatThreadActions.test.ts @@ -2,7 +2,7 @@ import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; import { resolveNewThreadModelSelectionOverride, - shouldClearSyncedDraftBranch, + shouldResetBranchForNewWorktree, } from "./chatThreadActions"; const PROJECT_DEFAULT_SELECTION: ModelSelection = { @@ -38,25 +38,29 @@ describe("chatThreadActions", () => { }); }); -describe("shouldClearSyncedDraftBranch", () => { +describe("shouldResetBranchForNewWorktree", () => { const input = { + currentEnvMode: "local", nextEnvMode: "worktree", worktreeBaseBranch: "dev", - draftBranch: "feature/checked-out", - environmentSelection: "auto", } as const; - it("drops the checkout branch so a new worktree starts from the configured base", () => { - expect(shouldClearSyncedDraftBranch(input)).toBe(true); - expect(shouldClearSyncedDraftBranch({ ...input, environmentSelection: undefined })).toBe(true); + it("starts a new worktree from the configured base instead of the checkout's branch", () => { + expect(shouldResetBranchForNewWorktree(input)).toBe(true); }); - it("keeps a branch the user picked", () => { - expect(shouldClearSyncedDraftBranch({ ...input, environmentSelection: "manual" })).toBe(false); + it("keeps a base already picked in worktree mode", () => { + expect(shouldResetBranchForNewWorktree({ ...input, currentEnvMode: "worktree" })).toBe(false); }); - it("keeps today's behavior without a configured base or outside worktree mode", () => { - expect(shouldClearSyncedDraftBranch({ ...input, worktreeBaseBranch: "" })).toBe(false); - expect(shouldClearSyncedDraftBranch({ ...input, nextEnvMode: "local" })).toBe(false); + it("keeps today's behavior without a configured base or when leaving worktree mode", () => { + expect(shouldResetBranchForNewWorktree({ ...input, worktreeBaseBranch: "" })).toBe(false); + expect( + shouldResetBranchForNewWorktree({ + currentEnvMode: "worktree", + nextEnvMode: "local", + worktreeBaseBranch: "dev", + }), + ).toBe(false); }); }); diff --git a/apps/web/src/lib/chatThreadActions.ts b/apps/web/src/lib/chatThreadActions.ts index a4188fd415268..4b7c7fa79ce7e 100644 --- a/apps/web/src/lib/chatThreadActions.ts +++ b/apps/web/src/lib/chatThreadActions.ts @@ -43,18 +43,16 @@ export function resolveNewDraftStartFromOrigin(input: { return input.envMode === "worktree" && input.newWorktreesStartFromOrigin; } -/** A configured base replaces the branch a draft synced from its checkout, never one the user picked. */ -export function shouldClearSyncedDraftBranch(input: { +/** A checkout's branch is not a worktree base, so leaving it for a new worktree starts from the configured base. */ +export function shouldResetBranchForNewWorktree(input: { + currentEnvMode: DraftThreadEnvMode | undefined; nextEnvMode: DraftThreadEnvMode; worktreeBaseBranch: string; - draftBranch: string | null; - environmentSelection: "auto" | "manual" | undefined; }): boolean { return ( + input.currentEnvMode === "local" && input.nextEnvMode === "worktree" && - input.worktreeBaseBranch !== "" && - input.draftBranch !== null && - input.environmentSelection !== "manual" + input.worktreeBaseBranch !== "" ); } From 92db5269e90cfc75663da5caa5566e12b671df53 Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Mon, 2 Nov 2026 16:16:27 +0530 Subject: [PATCH 4/9] feat(settings): pick the worktree base branch from the project's refs Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/Stack.tsx | 5 + .../SettingsServerControlsRouteScreen.tsx | 26 +++- .../WorktreeBaseBranchPickerRouteScreen.tsx | 78 ++++++++++ .../threads/NewTaskContextPickerScreens.tsx | 47 ++++-- .../WorktreeBaseBranchPicker.browser.test.tsx | 27 ++++ .../components/WorktreeBaseBranchPicker.tsx | 139 +++++++++++++----- .../components/settings/WorktreesSettings.tsx | 47 +++--- docs/user/project-settings.md | 8 +- 8 files changed, 295 insertions(+), 82 deletions(-) create mode 100644 apps/mobile/src/features/settings/WorktreeBaseBranchPickerRouteScreen.tsx diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx index 872ca142c8aaa..d23cc1159f1aa 100644 --- a/apps/mobile/src/Stack.tsx +++ b/apps/mobile/src/Stack.tsx @@ -115,6 +115,7 @@ import { ScheduledTaskModelPickerRouteScreen, ScheduledTaskBranchPickerRouteScreen, } from "./features/settings/ScheduledTaskPickerScreens"; +import { WorktreeBaseBranchPickerRouteScreen } from "./features/settings/WorktreeBaseBranchPickerRouteScreen"; import { SettingsKeyboardRouteScreen } from "./features/settings/SettingsKeyboardRouteScreen"; import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen"; import { SettingsMicrophoneRouteScreen } from "./features/settings/SettingsMicrophoneRouteScreen"; @@ -403,6 +404,10 @@ const SETTINGS_SCREENS = { screen: ScheduledTaskBranchPickerRouteScreen, options: { ...SETTINGS_PAGE_OPTIONS, title: "Base branch" }, }), + SettingsWorktreeBaseBranch: createNativeStackScreen({ + screen: WorktreeBaseBranchPickerRouteScreen, + options: { ...SETTINGS_PAGE_OPTIONS, title: "Base branch" }, + }), SettingsScheduledTaskModel: createNativeStackScreen({ screen: ScheduledTaskModelPickerRouteScreen, options: { diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx index 37da9e3b05779..ef36be2dff3b6 100644 --- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx @@ -447,12 +447,26 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) { {props.page === "worktrees" ? ( <> - + {projectSelected ? ( + navigation.navigate("SettingsWorktreeBaseBranch")} + /> + ) : ( + + )} group.key === selectedProjectKey)?.members ?? []; + const targets = resolveMobileSettingsTargets( + selectedTargets, + members.map((member) => member.project), + ); + const project = + members.find((member) => + targets.some((target) => target.environment.environmentId === member.project.environmentId), + )?.project ?? null; + const writable = useEnvironmentsWithScope(selectedTargets, AuthSettingsWriteScope); + const canWrite = + targets.length > 0 && targets.every((target) => writable.has(target.environment.environmentId)); + const writeSettings = useSettingsWriter(); + const [query, setQuery] = useState(""); + const debouncedQuery = useDebouncedValue(query, 150); + const branches = usePaginatedBranches({ + environmentId: project?.environmentId ?? null, + cwd: project?.workspaceRoot ?? null, + query: debouncedQuery, + }); + const visibleBranches = branches.refs.filter((branch) => + branch.name.toLowerCase().includes(query.trim().toLowerCase()), + ); + const value = uniformMobileSetting(targets, "newWorktreesBaseBranch"); + const select = (newWorktreesBaseBranch: string) => { + void Haptics.selectionAsync(); + void writeSettings( + targets, + planMobileScopedSettingsPatch(targets, true, { newWorktreesBaseBranch }), + ); + navigation.goBack(); + }; + + return ( + select(branch.name)} + defaultOption={{ + title: "Repository default", + selected: value === "", + onSelect: () => select(""), + }} + /> + ); +} diff --git a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx index 04c9a4bf4c921..0b95eb05b9b11 100644 --- a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx +++ b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx @@ -368,6 +368,11 @@ export function BranchPickerScreen(props: { readonly startFromOrigin: boolean; readonly onChangeStartFromOrigin: (value: boolean) => void; }; + readonly defaultOption?: { + readonly title: string; + readonly selected: boolean; + readonly onSelect: () => void; + }; }) { const searchRef = useRef(null); const navigation = useNavigation(); @@ -401,20 +406,34 @@ export function BranchPickerScreen(props: { /> ); - const branchListHeader = props.worktree ? ( - - - - ) : null; + const branchListHeader = + props.worktree || props.defaultOption ? ( + + {props.worktree ? ( + + ) : null} + {props.defaultOption ? ( + + ) : null} + + ) : null; const branchContent = props.branches.length === 0 ? ( diff --git a/apps/web/src/components/WorktreeBaseBranchPicker.browser.test.tsx b/apps/web/src/components/WorktreeBaseBranchPicker.browser.test.tsx index afd154a530db8..ae2732dec4a85 100644 --- a/apps/web/src/components/WorktreeBaseBranchPicker.browser.test.tsx +++ b/apps/web/src/components/WorktreeBaseBranchPicker.browser.test.tsx @@ -74,4 +74,31 @@ describe("WorktreeBaseBranchPicker", () => { expect(onValueChange).toHaveBeenCalledExactlyOnceWith(selected); }, ); + + it("selects the default option, or a typed ref that is not listed", async () => { + setup(); + mocks.resolvedQueries.add("v1.2"); + const onValueChange = vi.fn(); + const picker = () => ( + + ); + await using screen = await render(picker()); + + await userEvent.click(screen.getByRole("combobox")); + await userEvent.click(page.getByRole("option", { name: /^Repository default/ })); + expect(onValueChange).toHaveBeenLastCalledWith(""); + + await userEvent.click(screen.getByRole("combobox")); + await userEvent.type(page.getByPlaceholder("Search refs..."), "v1.2"); + await userEvent.click(page.getByRole("option", { name: 'Use "v1.2"' })); + expect(onValueChange).toHaveBeenLastCalledWith("v1.2"); + }); }); diff --git a/apps/web/src/components/WorktreeBaseBranchPicker.tsx b/apps/web/src/components/WorktreeBaseBranchPicker.tsx index 7076e5579a4ee..321834c8bc272 100644 --- a/apps/web/src/components/WorktreeBaseBranchPicker.tsx +++ b/apps/web/src/components/WorktreeBaseBranchPicker.tsx @@ -9,7 +9,11 @@ import { BranchPicker, BranchPickerRefItem } from "./BranchPicker"; import { resolveBranchTriggerLabel, sanitizeNewRefName } from "./BranchToolbar.logic"; import { MiddleTruncate } from "./ui/middle-truncate"; import { Button } from "./ui/button"; -import { ComboboxTrigger } from "./ui/combobox"; +import { ComboboxItem, ComboboxTrigger } from "./ui/combobox"; + +// Refs cannot contain NUL, so these item values never collide with a ref name. +const DEFAULT_ITEM_VALUE = "\u0000default"; +const CUSTOM_ITEM_PREFIX = "\u0000custom:"; export function WorktreeBaseBranchPicker({ environmentId, @@ -18,27 +22,40 @@ export function WorktreeBaseBranchPicker({ onValueChange, startFromOrigin, onStartFromOriginChange, + defaultOption, + allowCustomRef = false, + emptyLabel, disabled = false, id, + "aria-label": ariaLabel, }: { - environmentId: EnvironmentId; + environmentId: EnvironmentId | null; cwd: string | null; value: string; onValueChange: (branch: string) => void; startFromOrigin: boolean; - onStartFromOriginChange: (checked: boolean) => void; + /** Omit when the start-from-remote choice is edited elsewhere. */ + onStartFromOriginChange?: (checked: boolean) => void; + /** Lists an item that selects the empty value; its badge names the default ref. */ + defaultOption?: { label: string }; + /** Lets a typed name be used as is, for a tag, a commit, or a ref outside the list. */ + allowCustomRef?: boolean; + /** Shows the ref name as is, and this label while the value is empty. */ + emptyLabel?: string; disabled?: boolean; id?: string; + "aria-label"?: string; }) { const [open, setOpen] = useState(false); const [query, setQuery] = useState(""); + const trimmedQuery = query.trim(); const branches = usePaginatedBranches({ environmentId, cwd, - query: sanitizeNewRefName(query.trim()), + query: sanitizeNewRefName(trimmedQuery), }); const selectedRefQuery = useEnvironmentQuery( - cwd && value + environmentId && cwd && value ? vcsEnvironment.listRefs({ environmentId, input: { cwd, query: value, limit: 10 }, @@ -48,66 +65,118 @@ export function WorktreeBaseBranchPicker({ const selectedRef = branches.refs.find((branch) => branch.name === value) ?? selectedRefQuery.data?.refs.find((branch) => branch.name === value); - const label = resolveBranchTriggerLabel({ - activeWorktreePath: null, - effectiveEnvMode: "worktree", - resolvedActiveBranch: value || null, - resolvedActiveBranchIsRemote: selectedRef ? selectedRef.isRemote === true : null, - startFromOrigin, - }); + const label = + emptyLabel !== undefined + ? value || emptyLabel + : resolveBranchTriggerLabel({ + activeWorktreePath: null, + effectiveEnvMode: "worktree", + resolvedActiveBranch: value || null, + resolvedActiveBranchIsRemote: selectedRef ? selectedRef.isRemote === true : null, + startFromOrigin, + }); const branchByName = new Map(branches.refs.map((branch) => [branch.name, branch])); - const items = [...branchByName.keys()]; + const defaultRefName = branches.refs.find((branch) => branch.isDefault)?.name; + const customRefItemValue = + allowCustomRef && trimmedQuery !== "" && !branchByName.has(trimmedQuery) + ? `${CUSTOM_ITEM_PREFIX}${trimmedQuery}` + : null; + const items = [ + ...(defaultOption && trimmedQuery === "" ? [DEFAULT_ITEM_VALUE] : []), + ...branchByName.keys(), + ...(customRefItemValue ? [customRefItemValue] : []), + ]; const hasNextPage = branches.data?.nextCursor != null; - const statusText = - branches.error ?? - (branches.isPending && branches.data === null - ? "Loading refs..." - : branches.isFetchingNextPage - ? "Loading more refs..." - : hasNextPage - ? `Showing ${branches.refs.length} of ${branches.data?.totalCount} refs` - : null); + const statusText = !cwd + ? "Choose a project to list its branches." + : (branches.error ?? + (branches.isPending && branches.data === null + ? "Loading refs..." + : branches.isFetchingNextPage + ? "Loading more refs..." + : hasNextPage + ? `Showing ${branches.refs.length} of ${branches.data?.totalCount} refs` + : null)); const handleOpenChange = (next: boolean) => { setOpen(next); if (!next) setQuery(""); }; + const selectItem = (itemValue: string) => { + if (itemValue === DEFAULT_ITEM_VALUE) onValueChange(""); + else if (itemValue.startsWith(CUSTOM_ITEM_PREFIX)) + onValueChange(itemValue.slice(CUSTOM_ITEM_PREFIX.length)); + else onValueChange(itemValue); + handleOpenChange(false); + }; return ( { - onValueChange(name); - handleOpenChange(false); - }} + onSelectItem={selectItem} hasNextPage={hasNextPage} isFetchingNextPage={branches.isFetchingNextPage} onLoadNext={branches.loadNext} statusText={statusText} - originControl={{ checked: startFromOrigin, onCheckedChange: onStartFromOriginChange }} + originControl={ + onStartFromOriginChange + ? { checked: startFromOrigin, onCheckedChange: onStartFromOriginChange } + : undefined + } popupProps={{ align: "start", side: "bottom", className: "flex w-80 flex-col" }} - renderItem={(name, index) => { - const branch = branchByName.get(name); + renderItem={(itemValue, index) => { + if (defaultOption && itemValue === DEFAULT_ITEM_VALUE) { + return ( + selectItem(itemValue)} + > +
+ {defaultOption.label} + {defaultRefName && ( + + {defaultRefName} + + )} +
+
+ ); + } + if (customRefItemValue && itemValue === customRefItemValue) { + return ( + selectItem(itemValue)} + > + Use "{trimmedQuery}" + + ); + } + const branch = branchByName.get(itemValue); return branch ? ( { - onValueChange(branch.name); - handleOpenChange(false); - }} + onClick={() => selectItem(branch.name)} /> ) : null; }} > } className="w-full justify-between " > diff --git a/apps/web/src/components/settings/WorktreesSettings.tsx b/apps/web/src/components/settings/WorktreesSettings.tsx index 0d643643e8374..6a3570a35a680 100644 --- a/apps/web/src/components/settings/WorktreesSettings.tsx +++ b/apps/web/src/components/settings/WorktreesSettings.tsx @@ -1,7 +1,6 @@ -import { useRef } from "react"; import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; -import { Input } from "../ui/input"; +import { WorktreeBaseBranchPicker } from "../WorktreeBaseBranchPicker"; import { AdvancedSettings } from "./AdvancedSettings"; import { BranchNamingSettings } from "./BranchNamingSettings"; import { WorktreeSubmodulesRow } from "./ProjectDefaultsSettings"; @@ -23,17 +22,22 @@ import { function BaseBranchRow() { const settings = useScopedSettings(); - const { targets } = useSettingsScope(); - const scopeKey = targets.map((target) => `${target.environmentId}:${target.projectId}`).join(","); - const edited = useRef(false); + const { scope, target } = useSettingsScope(); const updateSettings = useUpdateScopedSettings(); const mixed = useScopedSettingsMixed(["newWorktreesBaseBranch"]); + const member = + (scope.kind === "project" || scope.kind === "checkout") && target?.projectId + ? scope.members.find( + (candidate) => + candidate.id === target.projectId && candidate.environmentId === target.environmentId, + ) + : undefined; return ( { - edited.current = true; - }} - placeholder={mixed ? "Mixed" : "Repository default"} - defaultValue={mixed ? "" : settings.newWorktreesBaseBranch} - onBlur={(event) => { - const value = event.target.value.trim(); - if (edited.current && (mixed || value !== settings.newWorktreesBaseBranch)) - updateSettings({ newWorktreesBaseBranch: value }); - edited.current = false; - }} - /> +
+ updateSettings({ newWorktreesBaseBranch })} + startFromOrigin={settings.newWorktreesStartFromOrigin} + defaultOption={{ label: "Repository default" }} + allowCustomRef + /> +
} /> ); diff --git a/docs/user/project-settings.md b/docs/user/project-settings.md index a8b754e820db6..ebae16445a560 100644 --- a/docs/user/project-settings.md +++ b/docs/user/project-settings.md @@ -65,10 +65,10 @@ A project on several machines must have every machine connected to pin or archiv ## Worktree base branch New worktrees start from the repository's default branch. If a project's work branches -from somewhere else, such as `dev`, select the project and enter that branch, tag, or -commit in **Settings → Worktrees → Base branch**. Leave it empty to go back to the -repository default. You can still choose a different base for any single thread -from the branch picker. +from somewhere else, such as `dev`, select the project and pick that branch in +**Settings → Worktrees → Base branch**. To use a tag or commit, type it in the picker's +search. Choose **Repository default** to go back. You can still choose a different base +for any single thread from the branch picker. ## Worktree branch names From 86c8f01a0381a194a84187d43424e2b39aa84fb7 Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Mon, 2 Nov 2026 23:49:59 +0530 Subject: [PATCH 5/9] fix(mobile): switching to a new worktree waits for the base branch setting Before server settings load, the base read as empty, so leaving Current checkout pinned the checkout's branch and the configured base never filled. The branch now stays unset until settings are known. Co-Authored-By: Claude Opus 5.5 --- .../features/threads/new-task-context-presentation.test.ts | 6 ++++++ .../src/features/threads/new-task-context-presentation.ts | 7 +++++-- .../mobile/src/features/threads/new-task-flow-provider.tsx | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/mobile/src/features/threads/new-task-context-presentation.test.ts b/apps/mobile/src/features/threads/new-task-context-presentation.test.ts index a373b4010613d..c02e6b8b8a1b5 100644 --- a/apps/mobile/src/features/threads/new-task-context-presentation.test.ts +++ b/apps/mobile/src/features/threads/new-task-context-presentation.test.ts @@ -208,6 +208,12 @@ describe("resolveWorktreeSwitchBranch", () => { ).toBeNull(); }); + it("leaves the branch to fill while settings are still loading", () => { + expect( + resolveWorktreeSwitchBranch({ selectedBranch: "release", worktreeBaseBranch: null }), + ).toBeNull(); + }); + it("keeps today's behavior without a configured base", () => { expect(resolveWorktreeSwitchBranch({ selectedBranch: "release", worktreeBaseBranch: "" })).toBe( "release", diff --git a/apps/mobile/src/features/threads/new-task-context-presentation.ts b/apps/mobile/src/features/threads/new-task-context-presentation.ts index f246bf45a89e2..f8c83e689b85f 100644 --- a/apps/mobile/src/features/threads/new-task-context-presentation.ts +++ b/apps/mobile/src/features/threads/new-task-context-presentation.ts @@ -72,10 +72,13 @@ export function resolveNewTaskLocalWorkspaceSelection(input: { }; } -/** A checkout's branch is not a worktree base, so leaving it for a new worktree starts from the configured base. */ +/** + * A checkout's branch is not a worktree base, so leaving it for a new worktree starts from the + * configured base. A null base means settings have not loaded, so the branch stays unset to fill. + */ export function resolveWorktreeSwitchBranch(input: { readonly selectedBranch: string | null; - readonly worktreeBaseBranch: string; + readonly worktreeBaseBranch: string | null; }): string | null { return input.worktreeBaseBranch === "" ? input.selectedBranch : null; } diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsx index ea9360009958f..6dc26a97a2174 100644 --- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx +++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx @@ -657,7 +657,9 @@ export function NewTaskFlowProvider( : workspaceMode === "local" ? resolveWorktreeSwitchBranch({ selectedBranch: selectedBranchName, - worktreeBaseBranch: projectSettings.settings.newWorktreesBaseBranch, + worktreeBaseBranch: selectedEnvironmentServerConfig + ? projectSettings.settings.newWorktreesBaseBranch + : null, }) : selectedBranchName, worktreePath: mode === "local" ? localSelection.worktreePath : selectedWorktreePath, From cb80403f20ec3c3e31d2cfedda66939f3ae01e48 Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Tue, 3 Nov 2026 00:00:33 +0530 Subject: [PATCH 6/9] fix(settings): the configured base applies when settings or refs load late - Web drafts left Current checkout before settings loaded with the checkout's branch pinned; they now leave it to fill, as mobile does. - Empty server-backed threads switching to New worktree now drop the checkout's branch too. - A failed first ref load no longer hides that the project is a repo. - Mobile no longer writes the filled base back when re-selecting New worktree or toggling Start from remote, so a later setting change applies. Co-Authored-By: Claude Opus 5.5 --- .../threads/new-task-flow-provider.tsx | 6 ++++-- .../BranchToolbarBranchSelector.tsx | 2 +- apps/web/src/components/ChatView.tsx | 2 ++ .../components/chat/useComposerSelection.ts | 21 ++++++++++++++++++- apps/web/src/lib/chatThreadActions.test.ts | 4 ++++ apps/web/src/lib/chatThreadActions.ts | 7 +++++-- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsx index 6dc26a97a2174..adb323c688bd2 100644 --- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx +++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx @@ -417,6 +417,8 @@ export function NewTaskFlowProvider( // only the explicit flag is ever written back to the draft, so the resolved // value keeps tracking the server setting when the config loads late. const draftStartFromOrigin = selectedProjectDraft.workspaceSelection?.startFromOrigin; + // Writing the filled worktree base back would pin it, so later setting changes would not apply. + const explicitDraftBranch = selectedProjectDraft.workspaceSelection?.branch ?? null; const startFromOrigin = isGitRepo && (draftStartFromOrigin ?? projectSettings.settings.newWorktreesStartFromOrigin); const defaultRuntimeMode = projectSettings.settings.defaultRuntimeMode; @@ -661,7 +663,7 @@ export function NewTaskFlowProvider( ? projectSettings.settings.newWorktreesBaseBranch : null, }) - : selectedBranchName, + : explicitDraftBranch, worktreePath: mode === "local" ? localSelection.worktreePath : selectedWorktreePath, ...(draftStartFromOrigin !== undefined ? { startFromOrigin: draftStartFromOrigin } : {}), // Refs have not named the current branch yet; the selection follows it. @@ -697,7 +699,7 @@ export function NewTaskFlowProvider( updateComposerDraftSettings(selectedProjectDraftKey, { workspaceSelection: { mode: workspaceMode, - branch: selectedBranchName, + branch: workspaceMode === "worktree" ? explicitDraftBranch : selectedBranchName, worktreePath: selectedWorktreePath, startFromOrigin: value, ...(selectedBranchName === null && workspaceSelection.followsCurrentCheckout diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx index 8b3227812d772..4f814537ab5de 100644 --- a/apps/web/src/components/BranchToolbarBranchSelector.tsx +++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx @@ -491,7 +491,7 @@ export function BranchToolbarBranchSelector({ environmentServerSettings, activeProject?.id ?? null, ).settings.newWorktreesBaseBranch, - isRepo: branchRefState.data?.isRepo ?? false, + isRepo: branchRefState.data?.isRepo ?? branchStatusQuery.data?.isRepo ?? false, defaultBranchName, currentGitBranch, }); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 6fd54db6bd52a..28c54c37f66e2 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2845,6 +2845,8 @@ export default function ChatView(props: ChatViewProps) { interactionModeEnabled, isLocalDraftThread, canOverrideServerThreadEnvMode, + envMode, + setPendingServerThreadBranch, setPendingServerThreadEnvModeEntry, setPendingServerThreadStartFromOriginByThreadId, scheduleComposerFocus, diff --git a/apps/web/src/components/chat/useComposerSelection.ts b/apps/web/src/components/chat/useComposerSelection.ts index 1c204dda2eb37..3b262d3cc51c3 100644 --- a/apps/web/src/components/chat/useComposerSelection.ts +++ b/apps/web/src/components/chat/useComposerSelection.ts @@ -1,3 +1,4 @@ +import { useAtomValue } from "@effect/atom-react"; import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; import type { UnifiedSettings } from "@t3tools/contracts"; import type { Dispatch } from "react"; @@ -17,6 +18,7 @@ import { scopeThreadRef } from "@t3tools/client-runtime/environment"; import { type SetStateAction } from "react"; import { useNavigate } from "@tanstack/react-router"; import { toastManager } from "../ui/toast"; +import { serverEnvironment } from "~/state/server"; import { resolveAppModelSelectionForInstance } from "../../modelSelection"; import { resolveNewDraftStartFromOrigin, @@ -50,6 +52,8 @@ interface ComposerSelectionInput { readonly interactionModeEnabled: boolean; readonly isLocalDraftThread: boolean; readonly canOverrideServerThreadEnvMode: boolean; + readonly envMode: DraftThreadEnvMode; + readonly setPendingServerThreadBranch: (branch: string | null) => void; readonly setPendingServerThreadEnvModeEntry: Dispatch< SetStateAction<{ readonly threadId: ThreadId; readonly mode: DraftThreadEnvMode } | null> >; @@ -81,10 +85,16 @@ export function useComposerSelection(input: ComposerSelectionInput) { interactionModeEnabled, isLocalDraftThread, canOverrideServerThreadEnvMode, + envMode, + setPendingServerThreadBranch, setPendingServerThreadEnvModeEntry, setPendingServerThreadStartFromOriginByThreadId, scheduleComposerFocus, } = input; + const settingsLoaded = useAtomValue(serverEnvironment.settingsValueAtom(environmentId)) !== null; + const worktreeBaseBranch = settingsLoaded + ? activeProjectSettings.settings.newWorktreesBaseBranch + : null; const navigate = useNavigate(); const setStickyComposerModelSelection = useComposerDraftStore( (store) => store.setStickyModelSelection, @@ -224,6 +234,15 @@ export function useComposerSelection(input: ComposerSelectionInput) { if (multipleModelSelections !== null) return; if (canOverrideServerThreadEnvMode) { if (activeThread) setPendingServerThreadEnvModeEntry({ threadId: activeThread.id, mode }); + if ( + shouldResetBranchForNewWorktree({ + currentEnvMode: envMode, + nextEnvMode: mode, + worktreeBaseBranch, + }) + ) { + setPendingServerThreadBranch(null); + } scheduleComposerFocus(); return; } @@ -238,7 +257,7 @@ export function useComposerSelection(input: ComposerSelectionInput) { ...(shouldResetBranchForNewWorktree({ currentEnvMode: draftThread?.envMode, nextEnvMode: mode, - worktreeBaseBranch: activeProjectSettings.settings.newWorktreesBaseBranch, + worktreeBaseBranch, }) ? { branch: null } : {}), diff --git a/apps/web/src/lib/chatThreadActions.test.ts b/apps/web/src/lib/chatThreadActions.test.ts index b6e99f8c70a05..727433b072b16 100644 --- a/apps/web/src/lib/chatThreadActions.test.ts +++ b/apps/web/src/lib/chatThreadActions.test.ts @@ -49,6 +49,10 @@ describe("shouldResetBranchForNewWorktree", () => { expect(shouldResetBranchForNewWorktree(input)).toBe(true); }); + it("leaves the branch to fill while settings are still loading", () => { + expect(shouldResetBranchForNewWorktree({ ...input, worktreeBaseBranch: null })).toBe(true); + }); + it("keeps a base already picked in worktree mode", () => { expect(shouldResetBranchForNewWorktree({ ...input, currentEnvMode: "worktree" })).toBe(false); }); diff --git a/apps/web/src/lib/chatThreadActions.ts b/apps/web/src/lib/chatThreadActions.ts index 4b7c7fa79ce7e..deaa5664b9efd 100644 --- a/apps/web/src/lib/chatThreadActions.ts +++ b/apps/web/src/lib/chatThreadActions.ts @@ -43,11 +43,14 @@ export function resolveNewDraftStartFromOrigin(input: { return input.envMode === "worktree" && input.newWorktreesStartFromOrigin; } -/** A checkout's branch is not a worktree base, so leaving it for a new worktree starts from the configured base. */ +/** + * A checkout's branch is not a worktree base, so leaving it for a new worktree starts from the + * configured base. A null base means settings have not loaded, so the branch is left to fill. + */ export function shouldResetBranchForNewWorktree(input: { currentEnvMode: DraftThreadEnvMode | undefined; nextEnvMode: DraftThreadEnvMode; - worktreeBaseBranch: string; + worktreeBaseBranch: string | null; }): boolean { return ( input.currentEnvMode === "local" && From 73c5513cf7440cf84d88da21fe5f51100f9d1c03 Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Fri, 6 Nov 2026 02:49:29 +0000 Subject: [PATCH 7/9] fix(mobile): use settingsPage for the worktree base branch route --- apps/mobile/src/Stack.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx index ab9ae146f3939..bf552c6ab83f6 100644 --- a/apps/mobile/src/Stack.tsx +++ b/apps/mobile/src/Stack.tsx @@ -304,7 +304,7 @@ const SETTINGS_SCREENS = { }), SettingsWorktreeBaseBranch: createNativeStackScreen({ screen: WorktreeBaseBranchPickerRouteScreen, - options: { ...SETTINGS_PAGE_OPTIONS, title: "Base branch" }, + options: settingsPage("Base branch"), }), SettingsScheduledTaskModel: createNativeStackScreen({ screen: ScheduledTaskModelPickerRouteScreen, From 5dc3d017847cd1bac174bcfd4e4dd686958e0689 Mon Sep 17 00:00:00 2001 From: Ayush Kaithwas Date: Sun, 15 Nov 2026 09:54:21 +0530 Subject: [PATCH 8/9] test(web): pass the base-branch inputs in useComposerSelection's browser test The test arrived from main after this PR added `newWorktreesBaseBranch`, `envMode` and `setPendingServerThreadBranch` to the hook's input. Co-Authored-By: Claude Opus 5.5 --- .../components/chat/useComposerSelection.browser.test.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/useComposerSelection.browser.test.tsx b/apps/web/src/components/chat/useComposerSelection.browser.test.tsx index 147a48aa8bd38..df62f5b27933c 100644 --- a/apps/web/src/components/chat/useComposerSelection.browser.test.tsx +++ b/apps/web/src/components/chat/useComposerSelection.browser.test.tsx @@ -85,7 +85,11 @@ function Picker(props: { draftThread: null, activeThread: props.thread, activeRuntime: props.runtime, - activeProjectSettings: { settings: { newWorktreesStartFromOrigin: false } }, + activeProjectSettings: { + settings: { newWorktreesStartFromOrigin: false, newWorktreesBaseBranch: "" }, + }, + envMode: "local", + setPendingServerThreadBranch: () => {}, settings: DEFAULT_UNIFIED_SETTINGS, providerStatuses: providers, lockedProvider: null, From 446faf15244eb9ef5f3475ec24730c247c3a0f72 Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Wed, 18 Nov 2026 09:28:53 +0000 Subject: [PATCH 9/9] fix(settings): integrate base branch controls with current settings APIs --- apps/mobile/src/Stack.tsx | 3 ++- .../settings/SettingsServerControlsRouteScreen.tsx | 6 +++--- .../WorktreeBaseBranchPickerRouteScreen.tsx | 8 +++++--- .../components/WorktreeBaseBranchSetting.tsx | 13 ++++++++----- apps/mobile/src/i18n/translations/de.json | 6 +++++- apps/mobile/src/i18n/translations/en.json | 6 +++++- apps/mobile/src/i18n/translations/es.json | 6 +++++- apps/mobile/src/i18n/translations/fr.json | 6 +++++- apps/mobile/src/i18n/translations/ja.json | 6 +++++- apps/mobile/src/i18n/translations/ko.json | 6 +++++- apps/mobile/src/i18n/translations/pt-BR.json | 6 +++++- apps/mobile/src/i18n/translations/ru.json | 6 +++++- apps/mobile/src/i18n/translations/sv.json | 6 +++++- apps/mobile/src/i18n/translations/zh.json | 6 +++++- .../src/components/WorktreeBaseBranchPicker.tsx | 2 +- .../src/components/settings/WorktreesSettings.tsx | 14 +++++++++----- apps/web/src/components/settings/settingsSearch.ts | 4 ++-- apps/web/src/i18n/translations/de.json | 9 ++++++++- apps/web/src/i18n/translations/en.json | 9 ++++++++- apps/web/src/i18n/translations/es.json | 9 ++++++++- apps/web/src/i18n/translations/fr.json | 9 ++++++++- apps/web/src/i18n/translations/ja.json | 9 ++++++++- apps/web/src/i18n/translations/ko.json | 9 ++++++++- apps/web/src/i18n/translations/pt-BR.json | 9 ++++++++- apps/web/src/i18n/translations/ru.json | 9 ++++++++- apps/web/src/i18n/translations/sv.json | 9 ++++++++- apps/web/src/i18n/translations/zh.json | 9 ++++++++- 27 files changed, 160 insertions(+), 40 deletions(-) diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx index 6c9d811c35dfb..1ba9ffe8c74e1 100644 --- a/apps/mobile/src/Stack.tsx +++ b/apps/mobile/src/Stack.tsx @@ -193,6 +193,7 @@ const ROUTE_TITLES: Readonly> = { SettingsScheduledTaskNew: msg("New scheduled task"), SettingsScheduledTaskEdit: msg("Edit scheduled task"), SettingsScheduledTaskBranch: msg("Base branch"), + SettingsWorktreeBaseBranch: msg("Base branch"), SettingsScheduledTaskThread: msg("Destination"), SettingsClientStorage: msg("Client Storage"), SettingsDiagnostics: msg("Diagnostics"), @@ -385,7 +386,7 @@ const SETTINGS_SCREENS = { }), SettingsWorktreeBaseBranch: createNativeStackScreen({ screen: WorktreeBaseBranchPickerRouteScreen, - options: settingsPage("Base branch"), + options: settingsPage(), }), SettingsScheduledTaskThread: createNativeStackScreen({ screen: ScheduledTaskThreadPickerRouteScreen, diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx index cb3ca09f9ef00..d180d0ba9a24c 100644 --- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx @@ -472,11 +472,11 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) { {projectSelected ? ( navigation.navigate("SettingsWorktreeBaseBranch")} diff --git a/apps/mobile/src/features/settings/WorktreeBaseBranchPickerRouteScreen.tsx b/apps/mobile/src/features/settings/WorktreeBaseBranchPickerRouteScreen.tsx index d0eba5e7816ef..0e7cf6baffecc 100644 --- a/apps/mobile/src/features/settings/WorktreeBaseBranchPickerRouteScreen.tsx +++ b/apps/mobile/src/features/settings/WorktreeBaseBranchPickerRouteScreen.tsx @@ -1,6 +1,7 @@ import { useNavigation } from "@react-navigation/native"; import { AuthSettingsWriteScope } from "@t3tools/contracts"; import * as Haptics from "expo-haptics"; +import { useGT } from "gt-react-native"; import { useState } from "react"; import { useEnvironmentsWithScope } from "../../state/session"; @@ -15,6 +16,7 @@ import { import { useSettingsWriter } from "./useSettingsWriter"; export function WorktreeBaseBranchPickerRouteScreen() { + const gt = useGT(); const navigation = useNavigation(); const { selectedTargets, projectGroups, selectedProjectKey } = useSettingsEnvironmentFilter(); const members = projectGroups.find((group) => group.key === selectedProjectKey)?.members ?? []; @@ -52,7 +54,7 @@ export function WorktreeBaseBranchPickerRouteScreen() { return ( select(branch.name)} defaultOption={{ - title: "Repository default", + title: gt("Repository default"), selected: value === "", onSelect: () => select(""), }} diff --git a/apps/mobile/src/features/settings/components/WorktreeBaseBranchSetting.tsx b/apps/mobile/src/features/settings/components/WorktreeBaseBranchSetting.tsx index 4db8b6b77b3db..dc96240d688df 100644 --- a/apps/mobile/src/features/settings/components/WorktreeBaseBranchSetting.tsx +++ b/apps/mobile/src/features/settings/components/WorktreeBaseBranchSetting.tsx @@ -1,4 +1,5 @@ import type { ServerSettingsPatch } from "@t3tools/contracts"; +import { useGT } from "gt-react-native"; import { useEffect, useEffectEvent, useRef } from "react"; import { View } from "react-native"; @@ -9,6 +10,7 @@ export function WorktreeBaseBranchSetting(props: { disabled: boolean; onChange: (patch: ServerSettingsPatch) => void; }) { + const gt = useGT(); // Save on exit too: Android Back hides the keyboard without ending editing. const draft = useRef<{ text: string; over: string | null } | null>(null); const save = () => { @@ -26,19 +28,20 @@ export function WorktreeBaseBranchSetting(props: { useEffect(() => () => saveOnExit(), []); return ( - Base branch + {gt("Base branch")} - The branch, tag, or commit new worktrees start from, such as dev. Leave empty to use the - repository’s default branch. + {gt( + "The branch, tag, or commit new worktrees start from, such as dev. Leave empty to use the repository’s default branch.", + )} { draft.current = { text, over: props.value }; }} defaultValue={props.value ?? ""} - placeholder={props.value === null ? "Mixed" : "Repository default"} + placeholder={props.value === null ? gt("Mixed") : gt("Repository default")} editable={!props.disabled} autoCapitalize="none" autoCorrect={false} diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json index c9d43d96b3eb8..80f458488507a 100644 --- a/apps/mobile/src/i18n/translations/de.json +++ b/apps/mobile/src/i18n/translations/de.json @@ -5206,5 +5206,9 @@ "ad208e3e32c85029": "Alle ausblenden", "3328503592789bed": "Zen", "856812e7e1fc445e": "Tool-Aufrufe im Chat", - "8d545d54c0a9e950": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt." + "8d545d54c0a9e950": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt.", + "a4d45e701fd1ecd6": "Repository-Standard", + "4bd759216dc953fc": "Wähle ein Projekt, um seine Branches aufzulisten.", + "16adc6c497760dc9": "Der Branch, Tag oder Commit, von dem neue Worktrees starten, etwa dev. Leer lassen, um den Standardbranch des Repositorys zu verwenden.", + "a136ae2ffe6eeb7c": "Basisbranch für neue Worktrees" } diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json index 7a89a1cf37c22..cb89f809643a6 100644 --- a/apps/mobile/src/i18n/translations/en.json +++ b/apps/mobile/src/i18n/translations/en.json @@ -5207,5 +5207,9 @@ "ad208e3e32c85029": "Hide all", "3328503592789bed": "Zen", "856812e7e1fc445e": "Tool calls in chat", - "8d545d54c0a9e950": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show." + "8d545d54c0a9e950": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show.", + "a4d45e701fd1ecd6": "Repository default", + "4bd759216dc953fc": "Choose a project to list its branches.", + "16adc6c497760dc9": "The branch, tag, or commit new worktrees start from, such as dev. Leave empty to use the repository’s default branch.", + "a136ae2ffe6eeb7c": "Base branch for new worktrees" } diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json index 288dbfc7da2cf..2425ad7e6c10b 100644 --- a/apps/mobile/src/i18n/translations/es.json +++ b/apps/mobile/src/i18n/translations/es.json @@ -5200,5 +5200,9 @@ "ad208e3e32c85029": "Ocultar todo", "3328503592789bed": "Zen", "856812e7e1fc445e": "Llamadas a herramientas en el chat", - "8d545d54c0a9e950": "Oculta los comandos, ediciones y búsquedas que ejecutan los agentes. Ocultar las correctas mantiene los fallos. Zen solo muestra las respuestas finales. Las aprobaciones, preguntas y errores siempre se muestran." + "8d545d54c0a9e950": "Oculta los comandos, ediciones y búsquedas que ejecutan los agentes. Ocultar las correctas mantiene los fallos. Zen solo muestra las respuestas finales. Las aprobaciones, preguntas y errores siempre se muestran.", + "a4d45e701fd1ecd6": "Predeterminada del repositorio", + "4bd759216dc953fc": "Elige un proyecto para ver sus ramas.", + "16adc6c497760dc9": "La rama, etiqueta o commit desde el que parten los nuevos worktrees, como dev. Déjalo vacío para usar la rama predeterminada del repositorio.", + "a136ae2ffe6eeb7c": "Rama base para nuevos worktrees" } diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json index 28ec2284fca74..75411196e8434 100644 --- a/apps/mobile/src/i18n/translations/fr.json +++ b/apps/mobile/src/i18n/translations/fr.json @@ -5200,5 +5200,9 @@ "ad208e3e32c85029": "Tout masquer", "3328503592789bed": "Zen", "856812e7e1fc445e": "Appels d’outils dans la discussion", - "8d545d54c0a9e950": "Masque les commandes, modifications et recherches lancées par les agents. Masquer les réussis garde les échecs. Zen n’affiche que les réponses finales. Les approbations, questions et erreurs s’affichent toujours." + "8d545d54c0a9e950": "Masque les commandes, modifications et recherches lancées par les agents. Masquer les réussis garde les échecs. Zen n’affiche que les réponses finales. Les approbations, questions et erreurs s’affichent toujours.", + "a4d45e701fd1ecd6": "Valeur par défaut du dépôt", + "4bd759216dc953fc": "Choisissez un projet pour afficher ses branches.", + "16adc6c497760dc9": "La branche, le tag ou le commit de départ des nouveaux worktrees, par exemple dev. Laissez vide pour utiliser la branche par défaut du dépôt.", + "a136ae2ffe6eeb7c": "Branche de base des nouveaux worktrees" } diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json index f6741fdb8b775..56905df70315e 100644 --- a/apps/mobile/src/i18n/translations/ja.json +++ b/apps/mobile/src/i18n/translations/ja.json @@ -5182,5 +5182,9 @@ "ad208e3e32c85029": "すべて非表示", "3328503592789bed": "Zen", "856812e7e1fc445e": "チャット内のツール呼び出し", - "8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。" + "8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。", + "a4d45e701fd1ecd6": "リポジトリの既定", + "4bd759216dc953fc": "ブランチを表示するプロジェクトを選択してください。", + "16adc6c497760dc9": "新しいワークツリーの開始元となるブランチ、タグ、コミット(例: dev)。空欄の場合はリポジトリの既定ブランチを使用します。", + "a136ae2ffe6eeb7c": "新しいワークツリーのベースブランチ" } diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json index b1ef20ba0f347..9caf6e9cd44ee 100644 --- a/apps/mobile/src/i18n/translations/ko.json +++ b/apps/mobile/src/i18n/translations/ko.json @@ -5186,5 +5186,9 @@ "ad208e3e32c85029": "모두 숨기기", "3328503592789bed": "Zen", "856812e7e1fc445e": "채팅의 도구 호출", - "8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다." + "8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다.", + "a4d45e701fd1ecd6": "저장소 기본값", + "4bd759216dc953fc": "브랜치를 나열할 프로젝트를 선택하세요.", + "16adc6c497760dc9": "새 워크트리의 시작 브랜치, 태그 또는 커밋입니다(예: dev). 비워 두면 저장소의 기본 브랜치를 사용합니다.", + "a136ae2ffe6eeb7c": "새 워크트리의 기준 브랜치" } diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json index b40494fca3885..ca022d788b37a 100644 --- a/apps/mobile/src/i18n/translations/pt-BR.json +++ b/apps/mobile/src/i18n/translations/pt-BR.json @@ -5200,5 +5200,9 @@ "ad208e3e32c85029": "Ocultar todas", "3328503592789bed": "Zen", "856812e7e1fc445e": "Chamadas de ferramentas no chat", - "8d545d54c0a9e950": "Oculta os comandos, edições e pesquisas que os agentes executam. \"Ocultar bem-sucedidas\" mantém as falhas. Zen mostra só as respostas finais. Aprovações, perguntas e erros sempre aparecem." + "8d545d54c0a9e950": "Oculta os comandos, edições e pesquisas que os agentes executam. \"Ocultar bem-sucedidas\" mantém as falhas. Zen mostra só as respostas finais. Aprovações, perguntas e erros sempre aparecem.", + "a4d45e701fd1ecd6": "Padrão do repositório", + "4bd759216dc953fc": "Escolha um projeto para listar suas branches.", + "16adc6c497760dc9": "A branch, tag ou commit de origem dos novos worktrees, como dev. Deixe vazio para usar a branch padrão do repositório.", + "a136ae2ffe6eeb7c": "Branch base para novos worktrees" } diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json index cadf07e57eda9..597dad49a5bbb 100644 --- a/apps/mobile/src/i18n/translations/ru.json +++ b/apps/mobile/src/i18n/translations/ru.json @@ -5280,5 +5280,9 @@ "ad208e3e32c85029": "Скрывать все", "3328503592789bed": "Дзен", "856812e7e1fc445e": "Вызовы инструментов в чате", - "8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда." + "8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда.", + "a4d45e701fd1ecd6": "По умолчанию в репозитории", + "4bd759216dc953fc": "Выберите проект, чтобы увидеть его ветки.", + "16adc6c497760dc9": "Ветка, тег или коммит, от которого создаются новые рабочие деревья, например dev. Оставьте пустым, чтобы использовать ветку репозитория по умолчанию.", + "a136ae2ffe6eeb7c": "Базовая ветка для новых рабочих деревьев" } diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json index 3a0273aef36fd..80f5e084ce2e5 100644 --- a/apps/mobile/src/i18n/translations/sv.json +++ b/apps/mobile/src/i18n/translations/sv.json @@ -5206,5 +5206,9 @@ "ad208e3e32c85029": "Dölj alla", "3328503592789bed": "Zen", "856812e7e1fc445e": "Verktygsanrop i chatten", - "8d545d54c0a9e950": "Dölj kommandon, redigeringar och sökningar som agenter kör. Dölj lyckade behåller misslyckanden. Zen visar bara slutliga svar. Godkännanden, frågor och fel visas alltid." + "8d545d54c0a9e950": "Dölj kommandon, redigeringar och sökningar som agenter kör. Dölj lyckade behåller misslyckanden. Zen visar bara slutliga svar. Godkännanden, frågor och fel visas alltid.", + "a4d45e701fd1ecd6": "Kodförrådets standard", + "4bd759216dc953fc": "Välj ett projekt för att visa dess grenar.", + "16adc6c497760dc9": "Grenen, taggen eller committen som nya worktrees utgår från, till exempel dev. Lämna tomt för att använda kodförrådets standardgren.", + "a136ae2ffe6eeb7c": "Basgren för nya worktrees" } diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json index f1c394c60c606..f3b954a5e8f24 100644 --- a/apps/mobile/src/i18n/translations/zh.json +++ b/apps/mobile/src/i18n/translations/zh.json @@ -5191,5 +5191,9 @@ "ad208e3e32c85029": "全部隐藏", "3328503592789bed": "专注模式", "856812e7e1fc445e": "聊天中的工具调用", - "8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。" + "8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。", + "a4d45e701fd1ecd6": "仓库默认值", + "4bd759216dc953fc": "选择一个项目以列出其分支。", + "16adc6c497760dc9": "新工作树的起始分支、标签或提交,例如 dev。留空则使用仓库的默认分支。", + "a136ae2ffe6eeb7c": "新工作树的基础分支" } diff --git a/apps/web/src/components/WorktreeBaseBranchPicker.tsx b/apps/web/src/components/WorktreeBaseBranchPicker.tsx index 4d46479415799..5cf3beb2aebd4 100644 --- a/apps/web/src/components/WorktreeBaseBranchPicker.tsx +++ b/apps/web/src/components/WorktreeBaseBranchPicker.tsx @@ -173,7 +173,7 @@ export function WorktreeBaseBranchPicker({ value={itemValue} onClick={() => selectItem(itemValue)} > - Use "{trimmedQuery}" + {gt('Use "{ref}"', { ref: trimmedQuery })} ); } diff --git a/apps/web/src/components/settings/WorktreesSettings.tsx b/apps/web/src/components/settings/WorktreesSettings.tsx index 0edc9fc58f87c..d43f85149fc70 100644 --- a/apps/web/src/components/settings/WorktreesSettings.tsx +++ b/apps/web/src/components/settings/WorktreesSettings.tsx @@ -22,6 +22,8 @@ import { } from "./useScopedSettings"; function BaseBranchRow() { + const gt = useGT(); + const searchableSetting = useSearchableSetting(); const settings = useScopedSettings(); const { scope, target } = useSettingsScope(); const updateSettings = useUpdateScopedSettings(); @@ -38,11 +40,13 @@ function BaseBranchRow() { serverScoped settingKeys={["newWorktreesBaseBranch"]} {...searchableSetting("worktree-base-branch")} - description="The branch new worktrees start from, such as dev. You can still pick another branch for each thread." + description={gt( + "The branch new worktrees start from, such as dev. You can still pick another branch for each thread.", + )} resetAction={ mixed || settings.newWorktreesBaseBranch !== "" ? ( updateSettings({ newWorktreesBaseBranch: "" })} /> ) : null @@ -51,14 +55,14 @@ function BaseBranchRow() {
updateSettings({ newWorktreesBaseBranch })} startFromOrigin={settings.newWorktreesStartFromOrigin} - defaultOption={{ label: "Repository default" }} + defaultOption={{ label: gt("Repository default") }} allowCustomRef />
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts index 1ccf37c4351cc..8651530939252 100644 --- a/apps/web/src/components/settings/settingsSearch.ts +++ b/apps/web/src/components/settings/settingsSearch.ts @@ -859,10 +859,10 @@ export const SETTINGS_SEARCH_ITEMS = [ }, { id: "worktree-base-branch", - title: "Base branch", + title: msg("Base branch"), to: "/settings/worktrees", scope: "project-defaults", - searchTerms: ["new worktrees start from default branch dev main base ref"], + searchTerms: [msg("new worktrees start from default branch dev main base ref")], }, { id: "start-from-origin", diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 648fd58859dbe..3704c15839864 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -12092,5 +12092,12 @@ "27d76249d09eb69f": "Review-Leitfaden bereit", "faa3bb26abb39c93": "Review-Leitfaden fehlgeschlagen", "b7df38b7d8792d78": "Leitfaden öffnen", - "9e91e9a77b664e4e": "Review-Leitfaden konnte nicht gestartet werden" + "9e91e9a77b664e4e": "Review-Leitfaden konnte nicht gestartet werden", + "4bd759216dc953fc": "Wähle ein Projekt, um seine Branches aufzulisten.", + "4b908ff6bee82250": "\"{ref}\" verwenden", + "ae1db3a86b9b495a": "Der Branch, von dem neue Worktrees starten, etwa dev. Du kannst für jeden Thread weiterhin einen anderen Branch wählen.", + "ba91614d241ab3e5": "Basisbranch auf Standard zurücksetzen", + "a136ae2ffe6eeb7c": "Basisbranch für neue Worktrees", + "a4d45e701fd1ecd6": "Repository-Standard", + "8058cd2d1c61c1e3": "neue Worktrees starten Standardbranch dev main Basis Ref" } diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 599944358b5bb..0bc9d20c21ae1 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -12101,5 +12101,12 @@ "27d76249d09eb69f": "Review guide ready", "faa3bb26abb39c93": "Review guide failed", "b7df38b7d8792d78": "Open guide", - "9e91e9a77b664e4e": "Could not start a review guide" + "9e91e9a77b664e4e": "Could not start a review guide", + "4bd759216dc953fc": "Choose a project to list its branches.", + "4b908ff6bee82250": "Use \"{ref}\"", + "ae1db3a86b9b495a": "The branch new worktrees start from, such as dev. You can still pick another branch for each thread.", + "ba91614d241ab3e5": "Reset base branch to default", + "a136ae2ffe6eeb7c": "Base branch for new worktrees", + "a4d45e701fd1ecd6": "Repository default", + "8058cd2d1c61c1e3": "new worktrees start from default branch dev main base ref" } diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 956f4e17a9617..67f49dfd1abf0 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -12087,5 +12087,12 @@ "27d76249d09eb69f": "Guía de revisión lista", "faa3bb26abb39c93": "Falló la guía de revisión", "b7df38b7d8792d78": "Abrir guía", - "9e91e9a77b664e4e": "No se pudo iniciar una guía de revisión" + "9e91e9a77b664e4e": "No se pudo iniciar una guía de revisión", + "4bd759216dc953fc": "Elige un proyecto para ver sus ramas.", + "4b908ff6bee82250": "Usar \"{ref}\"", + "ae1db3a86b9b495a": "La rama desde la que parten los nuevos worktrees, como dev. Puedes elegir otra rama para cada hilo.", + "ba91614d241ab3e5": "Restablecer la rama base predeterminada", + "a136ae2ffe6eeb7c": "Rama base para nuevos worktrees", + "a4d45e701fd1ecd6": "Predeterminada del repositorio", + "8058cd2d1c61c1e3": "nuevos worktrees iniciar rama predeterminada dev main base referencia" } diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 1c982cc6d6f58..39a950bbccdde 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -12092,5 +12092,12 @@ "27d76249d09eb69f": "Guide de revue prêt", "faa3bb26abb39c93": "Échec du guide de revue", "b7df38b7d8792d78": "Ouvrir le guide", - "9e91e9a77b664e4e": "Impossible de démarrer un guide de revue" + "9e91e9a77b664e4e": "Impossible de démarrer un guide de revue", + "4bd759216dc953fc": "Choisissez un projet pour afficher ses branches.", + "4b908ff6bee82250": "Utiliser \"{ref}\"", + "ae1db3a86b9b495a": "La branche de départ des nouveaux worktrees, par exemple dev. Vous pouvez toujours choisir une autre branche pour chaque fil.", + "ba91614d241ab3e5": "Réinitialiser la branche de base par défaut", + "a136ae2ffe6eeb7c": "Branche de base des nouveaux worktrees", + "a4d45e701fd1ecd6": "Valeur par défaut du dépôt", + "8058cd2d1c61c1e3": "nouveaux worktrees démarrer branche par défaut dev main base référence" } diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index 879531a396d2a..5053469b062df 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -12040,5 +12040,12 @@ "27d76249d09eb69f": "レビューガイドの準備ができました", "faa3bb26abb39c93": "レビューガイドの作成に失敗しました", "b7df38b7d8792d78": "ガイドを開く", - "9e91e9a77b664e4e": "レビューガイドを開始できませんでした" + "9e91e9a77b664e4e": "レビューガイドを開始できませんでした", + "4bd759216dc953fc": "ブランチを表示するプロジェクトを選択してください。", + "4b908ff6bee82250": "\"{ref}\" を使用", + "ae1db3a86b9b495a": "新しいワークツリーの開始元ブランチ(例: dev)。スレッドごとに別のブランチを選択できます。", + "ba91614d241ab3e5": "ベースブランチを既定に戻す", + "a136ae2ffe6eeb7c": "新しいワークツリーのベースブランチ", + "a4d45e701fd1ecd6": "リポジトリの既定", + "8058cd2d1c61c1e3": "新しい ワークツリー 開始 既定 ブランチ dev main ベース 参照" } diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index fae8ce2ec6fc4..2cb33c5743ef5 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -12036,5 +12036,12 @@ "27d76249d09eb69f": "검토 가이드 준비됨", "faa3bb26abb39c93": "검토 가이드 실패", "b7df38b7d8792d78": "가이드 열기", - "9e91e9a77b664e4e": "검토 가이드를 시작할 수 없습니다" + "9e91e9a77b664e4e": "검토 가이드를 시작할 수 없습니다", + "4bd759216dc953fc": "브랜치를 나열할 프로젝트를 선택하세요.", + "4b908ff6bee82250": "\"{ref}\" 사용", + "ae1db3a86b9b495a": "새 워크트리의 시작 브랜치입니다(예: dev). 스레드마다 다른 브랜치를 선택할 수 있습니다.", + "ba91614d241ab3e5": "기본 브랜치를 기본값으로 재설정", + "a136ae2ffe6eeb7c": "새 워크트리의 기준 브랜치", + "a4d45e701fd1ecd6": "저장소 기본값", + "8058cd2d1c61c1e3": "새 워크트리 시작 기본 브랜치 dev main 기준 참조" } diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 7010bef288b16..8fba12e29424f 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -12091,5 +12091,12 @@ "27d76249d09eb69f": "Guia de revisão pronto", "faa3bb26abb39c93": "O guia de revisão falhou", "b7df38b7d8792d78": "Abrir guia", - "9e91e9a77b664e4e": "Não foi possível iniciar um guia de revisão" + "9e91e9a77b664e4e": "Não foi possível iniciar um guia de revisão", + "4bd759216dc953fc": "Escolha um projeto para listar suas branches.", + "4b908ff6bee82250": "Usar \"{ref}\"", + "ae1db3a86b9b495a": "A branch de origem dos novos worktrees, como dev. Você ainda pode escolher outra branch para cada conversa.", + "ba91614d241ab3e5": "Redefinir a branch base para o padrão", + "a136ae2ffe6eeb7c": "Branch base para novos worktrees", + "a4d45e701fd1ecd6": "Padrão do repositório", + "8058cd2d1c61c1e3": "novos worktrees iniciar branch padrão dev main base referência" } diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index 0766d953dd02d..7ba332f1d8fcd 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -12091,5 +12091,12 @@ "27d76249d09eb69f": "Гид по ревью готов", "faa3bb26abb39c93": "Не удалось создать гид по ревью", "b7df38b7d8792d78": "Открыть гид", - "9e91e9a77b664e4e": "Не удалось запустить гид по ревью" + "9e91e9a77b664e4e": "Не удалось запустить гид по ревью", + "4bd759216dc953fc": "Выберите проект, чтобы увидеть его ветки.", + "4b908ff6bee82250": "Использовать \"{ref}\"", + "ae1db3a86b9b495a": "Ветка, от которой создаются новые рабочие деревья, например dev. Для каждого треда можно выбрать другую ветку.", + "ba91614d241ab3e5": "Сбросить базовую ветку по умолчанию", + "a136ae2ffe6eeb7c": "Базовая ветка для новых рабочих деревьев", + "a4d45e701fd1ecd6": "По умолчанию в репозитории", + "8058cd2d1c61c1e3": "новые рабочие деревья начало ветка по умолчанию dev main базовая ссылка" } diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 5e6d1607edf31..fe9be2d89b095 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -12099,5 +12099,12 @@ "27d76249d09eb69f": "Granskningsguiden är klar", "faa3bb26abb39c93": "Granskningsguiden misslyckades", "b7df38b7d8792d78": "Öppna guiden", - "9e91e9a77b664e4e": "Kunde inte starta en granskningsguide" + "9e91e9a77b664e4e": "Kunde inte starta en granskningsguide", + "4bd759216dc953fc": "Välj ett projekt för att visa dess grenar.", + "4b908ff6bee82250": "Använd \"{ref}\"", + "ae1db3a86b9b495a": "Grenen som nya worktrees utgår från, till exempel dev. Du kan fortfarande välja en annan gren för varje tråd.", + "ba91614d241ab3e5": "Återställ basgrenen till standard", + "a136ae2ffe6eeb7c": "Basgren för nya worktrees", + "a4d45e701fd1ecd6": "Kodförrådets standard", + "8058cd2d1c61c1e3": "nya worktrees starta standardgren dev main bas referens" } diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index c86b9e6c55e41..0d6116d47cc24 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -12117,5 +12117,12 @@ "27d76249d09eb69f": "审查导览已就绪", "faa3bb26abb39c93": "审查导览生成失败", "b7df38b7d8792d78": "打开导览", - "9e91e9a77b664e4e": "无法开始生成审查导览" + "9e91e9a77b664e4e": "无法开始生成审查导览", + "4bd759216dc953fc": "选择一个项目以列出其分支。", + "4b908ff6bee82250": "使用 \"{ref}\"", + "ae1db3a86b9b495a": "新工作树的起始分支,例如 dev。你仍然可以为每个会话选择其他分支。", + "ba91614d241ab3e5": "将基础分支重置为默认值", + "a136ae2ffe6eeb7c": "新工作树的基础分支", + "a4d45e701fd1ecd6": "仓库默认值", + "8058cd2d1c61c1e3": "新建 工作树 起始 默认 分支 dev main 基础 引用" }