The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; |
| 2 | import { useGT } from "gt-react"; |
| 3 | |
| 4 | import { AdvancedSettings } from "./AdvancedSettings"; |
| 5 | import { BranchNamingSettings } from "./BranchNamingSettings"; |
| 6 | import { WorktreeSubmodulesRow } from "./ProjectDefaultsSettings"; |
| 7 | import { ScopedSwitch } from "./ScopedSwitch"; |
| 8 | import { useSettingsScope } from "./SettingsScopeContext"; |
| 9 | import { |
| 10 | SettingResetButton, |
| 11 | SettingsPageContainer, |
| 12 | SettingsRow, |
| 13 | SettingsSection, |
| 14 | } from "./settingsLayout"; |
| 15 | import { useSearchableSetting } from "./settingsSearch"; |
| 16 | import { WorktreeCleanupSection, WorktreesDirectoryRow } from "./StorageSettings"; |
| 17 | import { useScopedSettings, useUpdateScopedSettings } from "./useScopedSettings"; |
| 18 | |
| 19 | function StartFromRemoteRow() { |
| 20 | const gt = useGT(); |
| 21 | const searchableSetting = useSearchableSetting(); |
| 22 | const settings = useScopedSettings(); |
| 23 | const updateSettings = useUpdateScopedSettings(); |
| 24 | return ( |
| 25 | <SettingsRow |
| 26 | serverScoped |
| 27 | settingKeys={["newWorktreesStartFromOrigin"]} |
| 28 | {...searchableSetting("start-from-origin")} |
| 29 | description={gt( |
| 30 | "Uses the latest commit of the base branch’s tracked remote branch, even if its name differs. Otherwise uses the same-named branch on origin. Uses your local branch if that remote branch is missing.", |
| 31 | )} |
| 32 | resetAction={ |
| 33 | settings.newWorktreesStartFromOrigin !== |
| 34 | DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin ? ( |
| 35 | <SettingResetButton |
| 36 | ariaLabel={gt("Reset new worktrees start from remote to default")} |
| 37 | onClick={() => |
| 38 | updateSettings({ |
| 39 | newWorktreesStartFromOrigin: DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin, |
| 40 | }) |
| 41 | } |
| 42 | /> |
| 43 | ) : null |
| 44 | } |
| 45 | control={ |
| 46 | <ScopedSwitch |
| 47 | settingKeys={["newWorktreesStartFromOrigin"]} |
| 48 | checked={settings.newWorktreesStartFromOrigin} |
| 49 | onCheckedChange={(checked) => |
| 50 | updateSettings({ newWorktreesStartFromOrigin: Boolean(checked) }) |
| 51 | } |
| 52 | aria-label={gt("Start new worktrees from remote by default")} |
| 53 | /> |
| 54 | } |
| 55 | /> |
| 56 | ); |
| 57 | } |
| 58 | |
| 59 | export function WorktreesSettingsPanel() { |
| 60 | const gt = useGT(); |
| 61 | const searchableSetting = useSearchableSetting(); |
| 62 | const { scope } = useSettingsScope(); |
| 63 | const isProjectScope = scope.kind === "project" || scope.kind === "checkout"; |
| 64 | |
| 65 | return ( |
| 66 | <SettingsPageContainer> |
| 67 | <SettingsSection |
| 68 | id="worktree-creation" |
| 69 | title={gt("Creation", { $context: "settings section about creating worktrees" })} |
| 70 | > |
| 71 | {!isProjectScope && <WorktreesDirectoryRow />} |
| 72 | <StartFromRemoteRow /> |
| 73 | <AdvancedSettings targetIds={[searchableSetting("worktree-submodules").id]}> |
| 74 | <WorktreeSubmodulesRow /> |
| 75 | </AdvancedSettings> |
| 76 | </SettingsSection> |
| 77 | <SettingsSection id="worktree-branches" title={gt("Branches")}> |
| 78 | <BranchNamingSettings /> |
| 79 | </SettingsSection> |
| 80 | <WorktreeCleanupSection /> |
| 81 | </SettingsPageContainer> |
| 82 | ); |
| 83 | } |