Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/web/src/components/BranchToolbar.logic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EnvironmentId, VcsRef, ProjectId } from "@t3tools/contracts";
import { deriveLocalBranchNameFromRemoteRef } from "@t3tools/shared/git";
import { deriveLocalBranchNameFromRemoteRef, stripRemoteRefPrefix } from "@t3tools/shared/git";
import * as Schema from "effect/Schema";
import { toSortableTimestamp } from "../lib/threadSort";
export { dedupeRemoteBranchesWithLocalMatches } from "@t3tools/shared/git";
Expand Down Expand Up @@ -236,7 +236,7 @@ export function resolveBranchSelectionTarget(input: {

export function resolveExactBranchWorktreeInput(input: {
activeProjectCwd: string;
ref: Pick<VcsRef, "name" | "isRemote" | "worktreePath">;
ref: Pick<VcsRef, "name" | "isRemote" | "remoteName" | "worktreePath">;
}):
| { kind: "reuse"; branch: string; worktreePath: string | null }
| {
Expand All @@ -263,7 +263,11 @@ export function resolveExactBranchWorktreeInput(input: {
kind: "create",
cwd: activeProjectCwd,
refName: ref.name,
newRefName: deriveLocalBranchNameFromRemoteRef(ref.name),
// The ref's own remote is the only prefix worth stripping; falling back to
// the first segment covers refs listed without a parsed remote name.
newRefName: ref.remoteName
? stripRemoteRefPrefix(ref.name, ref.remoteName)
: deriveLocalBranchNameFromRemoteRef(ref.name),
path: null,
};
}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/components/BranchToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
className="flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent"
onMouseDown={(event) => event.preventDefault()}
onClick={() => {
onCheckoutPullRequest(
ref.remoteName ? `${ref.remoteName}/${ref.name}` : ref.name,
);
// `name` already carries the remote prefix for a remote ref,
// so re-adding `remoteName` would ask for
// `origin/origin/<branch>`: a ref that resolves to nothing
// and never gets its worktree.
onCheckoutPullRequest(ref.name);
setCheckoutReference("");
}}
>
<FolderGitIcon className="size-3.5 shrink-0 text-muted-foreground" />
<span className="min-w-0 truncate">
{ref.remoteName ? `${ref.remoteName}/${ref.name}` : ref.name}
</span>
<span className="min-w-0 truncate">{ref.name}</span>
</button>
))}
</div>
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/components/BranchToolbarEnvModeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
className="flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent"
onMouseDown={(event) => event.preventDefault()}
onClick={() => {
onCheckoutPullRequest?.(
ref.remoteName ? `${ref.remoteName}/${ref.name}` : ref.name,
);
// `name` already carries the remote prefix for a remote ref,
// so re-adding `remoteName` would ask for
// `origin/origin/<branch>`: a ref that resolves to nothing
// and never gets its worktree.
onCheckoutPullRequest?.(ref.name);
setCheckoutReference("");
}}
>
<FolderGitIcon className="size-3.5 shrink-0 text-muted-foreground" />
<span className="min-w-0 truncate">
{ref.remoteName ? `${ref.remoteName}/${ref.name}` : ref.name}
</span>
<span className="min-w-0 truncate">{ref.name}</span>
</button>
))}
</div>
Expand Down
Loading