The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 08:45 UTC
Inline branch picker filtering and drop PR-only shortcut
- move branch filtering logic into `BranchToolbarBranchSelector` - remove unused `filterBranchPickerItems` helper and related tests - keep create-branch option pinned while filtering by query
Julius Marminge committed
Mar 9, 2026 at 14:57 UTC
ac3f22c274e5b116b04220b29d1470e9d39bd0f2
3 files changed
+7
-66
apps/web/src/components/BranchToolbar.logic.test.ts
-29
@@ -1,7 +1,6 @@
1
import type { GitBranch } from "@t3tools/contracts";
2
import { describe, expect, it } from "vitest";
3
import {
4
- filterBranchPickerItems,
4
dedupeRemoteBranchesWithLocalMatches,
5
deriveLocalBranchNameFromRemoteRef,
6
resolveBranchSelectionTarget,
@@ -197,34 +196,6 @@ describe("dedupeRemoteBranchesWithLocalMatches", () => {
196
});
197
});
198
200
-describe("filterBranchPickerItems", () => {
201
- it("shows only the pull request action when the query is a PR reference", () => {
202
- expect(
203
- filterBranchPickerItems({
204
- itemValues: [
205
- "__checkout_pull_request__:488",
206
- "codething/76f09488",
207
- "origin/cursor/rollback-error",
208
- ],
209
- normalizedQuery: "488",
210
- createBranchItemValue: null,
211
- checkoutPullRequestItemValue: "__checkout_pull_request__:488",
212
- }),
213
- ).toEqual(["__checkout_pull_request__:488"]);
214
- });
215
-
216
- it("filters branch items normally when the query is not a PR reference", () => {
217
- expect(
218
- filterBranchPickerItems({
219
- itemValues: ["feature/488", "main", "__create_new_branch__:48"],
220
- normalizedQuery: "48",
221
- createBranchItemValue: "__create_new_branch__:48",
222
- checkoutPullRequestItemValue: null,
223
- }),
224
- ).toEqual(["feature/488", "__create_new_branch__:48"]);
225
- });
226
-});
227
-
199
describe("resolveBranchSelectionTarget", () => {
200
it("reuses an existing secondary worktree for the selected branch", () => {
201
expect(
apps/web/src/components/BranchToolbar.logic.ts
-24
@@ -89,30 +89,6 @@ export function dedupeRemoteBranchesWithLocalMatches(
89
});
90
}
91
92
-export function filterBranchPickerItems(input: {
93
- itemValues: ReadonlyArray<string>;
94
- normalizedQuery: string;
95
- createBranchItemValue: string | null;
96
- checkoutPullRequestItemValue: string | null;
97
-}): ReadonlyArray<string> {
98
- const { itemValues, normalizedQuery, createBranchItemValue, checkoutPullRequestItemValue } = input;
99
-
100
- if (checkoutPullRequestItemValue) {
101
- return [checkoutPullRequestItemValue];
102
- }
103
-
104
- if (normalizedQuery.length === 0) {
105
- return itemValues;
106
- }
107
-
108
- return itemValues.filter((itemValue) => {
109
- if (createBranchItemValue && itemValue === createBranchItemValue) {
110
- return true;
111
- }
112
- return itemValue.toLowerCase().includes(normalizedQuery);
113
- });
114
-}
115
-
92
export function resolveBranchSelectionTarget(input: {
93
activeProjectCwd: string;
94
activeWorktreePath: string | null;
apps/web/src/components/BranchToolbarBranchSelector.tsx
+7
-13
@@ -26,7 +26,6 @@ import {
26
dedupeRemoteBranchesWithLocalMatches,
27
deriveLocalBranchNameFromRemoteRef,
28
EnvMode,
29
- filterBranchPickerItems,
29
resolveBranchSelectionTarget,
30
resolveBranchToolbarValue,
31
} from "./BranchToolbar.logic";
@@ -137,18 +136,13 @@ export function BranchToolbarBranchSelector({
136
);
137
const filteredBranchPickerItems = useMemo(
138
() =>
140
- filterBranchPickerItems({
141
- itemValues: branchPickerItems,
142
- normalizedQuery: normalizedDeferredBranchQuery,
143
- createBranchItemValue,
144
- checkoutPullRequestItemValue,
145
- }),
146
- [
147
- branchPickerItems,
148
- checkoutPullRequestItemValue,
149
- createBranchItemValue,
150
- normalizedDeferredBranchQuery,
151
- ],
139
+ normalizedDeferredBranchQuery.length === 0
140
+ ? branchPickerItems
141
+ : branchPickerItems.filter((itemValue) => {
142
+ if (createBranchItemValue && itemValue === createBranchItemValue) return true;
143
+ return itemValue.toLowerCase().includes(normalizedDeferredBranchQuery);
144
+ }),
145
+ [branchPickerItems, createBranchItemValue, normalizedDeferredBranchQuery],
146
);
147
const [resolvedActiveBranch, setOptimisticBranch] = useOptimistic(
148
canonicalActiveBranch,