Skip to content

Commit 180b915

Browse files
authored
feat: allow using typed branch name directly (#2195)
## Problem the branch dropdown is slow as **** for large repos ## Changes allows using a typed/pasted branch name through a check button, or by pressing enter ![Screenshot 2026-05-18 at 17.50.00.png](https://app.graphite.com/user-attachments/assets/6ffb0b0e-6c9a-4045-8300-52aa98e4364d.png) ## How did you test this? tried locally
1 parent 2c7f228 commit 180b915

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

apps/code/src/renderer/features/git-interaction/components/BranchSelector.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { invalidateGitBranchQueries } from "@features/git-interaction/utils/gitC
55
import {
66
ArrowClockwise,
77
CaretDown,
8+
Check,
89
GitBranch,
910
Plus,
1011
Spinner,
@@ -175,6 +176,16 @@ export function BranchSelector({
175176

176177
const isDisabled = !!(disabled || !repoPath || cloudStillLoading);
177178
const inputValue = isCloudMode ? (cloudSearchQuery ?? "") : searchQuery;
179+
const trimmedInputValue = inputValue.trim();
180+
const canUseInputBranch =
181+
!isDisabled &&
182+
trimmedInputValue.length > 0 &&
183+
trimmedInputValue !== displayedBranch;
184+
185+
const handleUseInputBranch = () => {
186+
if (!canUseInputBranch) return;
187+
handleBranchChange(trimmedInputValue);
188+
};
178189

179190
return (
180191
<Combobox
@@ -237,8 +248,46 @@ export function BranchSelector({
237248
<ComboboxInput
238249
placeholder="Search branches..."
239250
showTrigger={false}
251+
onKeyDownCapture={(event) => {
252+
if (
253+
event.key !== "Enter" ||
254+
event.nativeEvent.isComposing ||
255+
!canUseInputBranch
256+
) {
257+
return;
258+
}
259+
260+
// If the combobox already has a highlighted item, let Base UI select it.
261+
if (event.currentTarget.getAttribute("aria-activedescendant")) {
262+
return;
263+
}
264+
265+
event.preventDefault();
266+
event.stopPropagation();
267+
handleUseInputBranch();
268+
}}
240269
/>
241270
</div>
271+
<Tooltip content="Use this branch name" side="bottom">
272+
<Button
273+
variant="outline"
274+
size="sm"
275+
disabled={!canUseInputBranch}
276+
aria-label="Use this branch name"
277+
onMouseDown={(event) => {
278+
// Keep focus inside the combobox so the popover doesn't close before click.
279+
event.preventDefault();
280+
event.stopPropagation();
281+
}}
282+
onClick={(event) => {
283+
event.preventDefault();
284+
event.stopPropagation();
285+
handleUseInputBranch();
286+
}}
287+
>
288+
<Check size={14} />
289+
</Button>
290+
</Tooltip>
242291
{onRefresh ? (
243292
<Button
244293
variant="outline"

0 commit comments

Comments
 (0)