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 24, 00:15 UTC
fix(web): route keyboard submit through the primary worktree action (#12526)
maria committed
Sep 20, 2026 at 20:32 UTC
67285e4b8719000eecb9de2a424609ca5c6f0274
2 files changed
+45
-13
apps/web/src/components/BranchToolbarBranchSelector.tsx
+41
-12
@@ -545,6 +545,7 @@ export function BranchToolbarBranchSelector({
545
setIsBranchMenuOpen(open);
546
if (!open) {
547
setBranchQuery("");
548
+ highlightedBranchValueRef.current = null;
549
}
550
}, []);
551
@@ -594,6 +595,9 @@ export function BranchToolbarBranchSelector({
595
}, [fetchNextBranchPage, hasNextPage, isBranchMenuOpen, isFetchingNextPage]);
596
597
const branchListRef = useRef<LegendListRef | null>(null);
598
+ // Tracks the highlighted picker value so Enter can activate it even when the
599
+ // virtualized row is not mounted (Base UI Enter clicks the mounted element).
600
+ const highlightedBranchValueRef = useRef<string | null>(null);
601
const updateBranchListScrollFades = useCallback(() => {
602
const scrollElement = branchListRef.current?.getScrollableNode?.();
603
if (!(scrollElement instanceof HTMLElement)) {
@@ -676,6 +680,20 @@ export function BranchToolbarBranchSelector({
680
const prUrl = currentLinkedPr?.url ?? displayedPr?.url;
681
const openPrLink = useOpenPrLink(threadRef);
682
683
+ function selectPickerItem(itemValue: string) {
684
+ highlightedBranchValueRef.current = null;
685
+ if (itemValue === checkoutPullRequestItemValue && prReference && onCheckoutPullRequestRequest) {
686
+ handleOpenChange(false);
687
+ onComposerFocusRequest?.();
688
+ onCheckoutPullRequestRequest(prReference);
689
+ } else if (itemValue === createBranchItemValue) {
690
+ createRef(trimmedBranchQuery);
691
+ } else {
692
+ const refName = branchByName.get(itemValue);
693
+ if (refName) selectBranch(refName);
694
+ }
695
+ }
696
+
697
function renderPickerItem(itemValue: string, index: number) {
698
if (checkoutPullRequestItemValue && itemValue === checkoutPullRequestItemValue) {
699
return (
@@ -685,15 +703,7 @@ export function BranchToolbarBranchSelector({
703
index={index}
704
value={itemValue}
705
className="pe-2"
688
- onClick={() => {
689
- if (!prReference || !onCheckoutPullRequestRequest) {
690
- return;
691
- }
692
- setIsBranchMenuOpen(false);
693
- setBranchQuery("");
694
- onComposerFocusRequest?.();
695
- onCheckoutPullRequestRequest(prReference);
696
- }}
706
+ onClick={() => selectPickerItem(itemValue)}
707
>
708
<div className="flex min-w-0 items-center gap-2 py-1">
709
<SourceControlIcon className="size-3.5 shrink-0 text-muted-foreground" />
@@ -715,7 +725,7 @@ export function BranchToolbarBranchSelector({
725
index={index}
726
value={itemValue}
727
className="pe-1.5"
718
- onClick={() => createRef(trimmedBranchQuery)}
728
+ onClick={() => selectPickerItem(itemValue)}
729
>
730
<span className="truncate">Create new ref "{newRefName}"</span>
731
</ComboboxItem>
@@ -743,7 +753,7 @@ export function BranchToolbarBranchSelector({
753
index={index}
754
value={itemValue}
755
className="pe-1.5"
746
- onClick={() => selectBranch(refName)}
756
+ onClick={() => selectPickerItem(itemValue)}
757
onContextMenu={(event) => handleBranchContextMenu(event, itemValue)}
758
>
759
<div className="flex w-full min-w-0 items-center justify-between gap-2">
@@ -760,7 +770,8 @@ export function BranchToolbarBranchSelector({
770
filteredItems={filteredBranchPickerItems}
771
autoHighlight
772
virtualized
763
- onItemHighlighted={(_value, eventDetails) => {
773
+ onItemHighlighted={(value, eventDetails) => {
774
+ highlightedBranchValueRef.current = typeof value === "string" ? value : null;
775
if (!isBranchMenuOpen || eventDetails.index < 0 || eventDetails.reason !== "keyboard") {
776
return;
777
}
@@ -828,6 +839,24 @@ export function BranchToolbarBranchSelector({
839
placeholder="Search refs..."
840
value={branchQuery}
841
onChange={(event) => setBranchQuery(event.target.value)}
842
+ onKeyDown={(event) => {
843
+ if (event.key !== "Enter" || event.nativeEvent.isComposing || event.keyCode === 229) {
844
+ return;
845
+ }
846
+ const highlightedValue = highlightedBranchValueRef.current;
847
+ if (
848
+ highlightedValue === null ||
849
+ !filteredBranchPickerItems.includes(highlightedValue)
850
+ ) {
851
+ return;
852
+ }
853
+ (
854
+ event as typeof event & { preventBaseUIHandler?: () => void }
855
+ ).preventBaseUIHandler?.();
856
+ event.preventDefault();
857
+ event.stopPropagation();
858
+ selectPickerItem(highlightedValue);
859
+ }}
860
/>
861
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
862
<ComboboxEmpty>No refs found.</ComboboxEmpty>
apps/web/src/components/PullRequestThreadDialog.tsx
+4
-1
@@ -222,9 +222,12 @@ export function PullRequestThreadDialog({
222
if (event.key !== "Enter") {
223
return;
224
}
225
+ if (event.nativeEvent.isComposing || event.keyCode === 229) {
226
+ return;
227
+ }
228
event.preventDefault();
229
if (!isResolving && !preparePullRequestThreadAction.isPending) {
227
- void handleConfirm("local");
230
+ void handleConfirm("worktree");
231
}
232
}}
233
/>