Skip to content
Open
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
30 changes: 0 additions & 30 deletions apps/web/src/components/BranchToolbar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
resolveEffectiveEnvMode,
resolveEnvModeLabel,
resolveBranchTriggerLabel,
resolveBranchToolbarPrBranch,
resolveBranchToolbarValue,
resolveLockedWorkspaceLabel,
resolveLocalCheckoutBranchMismatch,
Expand Down Expand Up @@ -272,35 +271,6 @@ describe("resolveBranchTriggerLabel", () => {
});
});

describe("resolveBranchToolbarPrBranch", () => {
it("uses the explicit thread branch when it matches the displayed branch", () => {
expect(
resolveBranchToolbarPrBranch({
activeThreadBranch: "feature/current",
resolvedActiveBranch: "feature/current",
}),
).toBe("feature/current");
});

it("hides PR state while an optimistic branch switch is in flight", () => {
expect(
resolveBranchToolbarPrBranch({
activeThreadBranch: "feature/current",
resolvedActiveBranch: "feature/next",
}),
).toBeNull();
});

it("does not infer PR state without an explicit thread branch", () => {
expect(
resolveBranchToolbarPrBranch({
activeThreadBranch: null,
resolvedActiveBranch: "feature/current",
}),
).toBeNull();
});
});

describe("resolveLocalCheckoutBranchMismatch", () => {
it("detects when a local thread is associated with a different branch than the checkout", () => {
expect(
Expand Down
7 changes: 0 additions & 7 deletions apps/web/src/components/BranchToolbar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,6 @@ export function resolveBranchTriggerLabel(input: {
return resolvedActiveBranch;
}

export function resolveBranchToolbarPrBranch(input: {
activeThreadBranch: string | null;
resolvedActiveBranch: string | null;
}): string | null {
return input.activeThreadBranch === input.resolvedActiveBranch ? input.activeThreadBranch : null;
}

export function resolveLocalCheckoutBranchMismatch(input: {
effectiveEnvMode: EnvMode;
activeWorktreePath: string | null;
Expand Down
54 changes: 0 additions & 54 deletions apps/web/src/components/BranchToolbarBranchSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { useSupportsMultiplePullRequests } from "~/hooks/useSupportsMultiplePullRequests";
import { resolveThreadCurrentPullRequestLink } from "@t3tools/shared/threadPullRequests";
import { useRightPanelStore } from "../rightPanelStore";
import { RefreshIcon } from "~/components/ui/refresh-icon";
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
import {
Expand Down Expand Up @@ -29,7 +26,6 @@ import {
import { useComposerDraftStore, type DraftId } from "../composerDraftStore";
import { writeTextToClipboard } from "../hooks/useCopyToClipboard";
import { readLocalApi } from "../localApi";
import { useOpenPrLink } from "../lib/openPullRequestLink";
import { shouldLoadNextBranchPageAfterScroll } from "../state/paginatedBranches";
import { usePaginatedBranches } from "../state/queries";
import { useProject, useThreadShell } from "../state/entities";
Expand All @@ -44,20 +40,13 @@ import { useComposerMenuProps } from "./chat/composerEventScope";
import {
deriveLocalBranchNameFromRemoteRef,
resolveBranchTriggerLabel,
resolveBranchToolbarPrBranch,
resolveBranchSelectionTarget,
resolveBranchToolbarValue,
resolveDraftEnvModeAfterBranchChange,
resolveEffectiveEnvMode,
sanitizeNewRefName,
shouldIncludeBranchPickerItem,
} from "./BranchToolbar.logic";
import {
ThreadPullRequestBadgeControl,
prStatusIndicator,
resolveThreadPullRequestBadge,
useLinkedThreadPullRequest,
} from "./ThreadStatusIndicators";
import { Button } from "./ui/button";
import { Switch } from "./ui/switch";
import { getVirtualizedScrollFadeClassName } from "./ui/scroll-area";
Expand Down Expand Up @@ -640,38 +629,6 @@ export function BranchToolbarBranchSelector({
startFromOrigin,
});

// Branch status is the fallback when this thread has no linked pull requests.
const branchPrBranch = resolveBranchToolbarPrBranch({
activeThreadBranch,
resolvedActiveBranch,
});
const branchPr =
branchPrBranch !== null && branchStatusQuery.data?.refName === branchPrBranch
? (branchStatusQuery.data.pr ?? null)
: null;
const supportsMultiplePullRequests = useSupportsMultiplePullRequests(environmentId);
const linkedStatus = useLinkedThreadPullRequest(
environmentId,
serverThread?.linkedPullRequest,
true,
serverThread?.pullRequests,
serverThread?.branchPullRequest,
);
const currentLinkedPr = supportsMultiplePullRequests
? resolveThreadCurrentPullRequestLink(serverThread?.pullRequests ?? [])
: null;
const prBadge = supportsMultiplePullRequests
? resolveThreadPullRequestBadge(serverThread?.pullRequests)
: null;
const displayedPr = linkedStatus?.pr ?? (currentLinkedPr === null ? branchPr : null);
const displayedPrStatus = prStatusIndicator(
displayedPr,
linkedStatus?.sourceControlProvider ?? branchStatusQuery.data?.sourceControlProvider,
);
const prNumber = currentLinkedPr?.number ?? displayedPr?.number;
const prUrl = currentLinkedPr?.url ?? displayedPr?.url;
const openPrLink = useOpenPrLink(threadRef);

function renderPickerItem(itemValue: string, index: number) {
if (checkoutPullRequestItemValue && itemValue === checkoutPullRequestItemValue) {
return (
Expand Down Expand Up @@ -773,17 +730,6 @@ export function BranchToolbarBranchSelector({
className={cn("flex min-w-0 items-center gap-1", className)}
data-composer-context-control
>
<ThreadPullRequestBadgeControl
variant="ghost"
badge={prBadge}
number={prNumber}
url={prUrl}
status={displayedPrStatus}
onOpenStack={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
onOpenPullRequest={(event) => {
if (prUrl) openPrLink(event, prUrl);
}}
/>
{/* Context menu lives on the wrapper: the disabled Button has
pointer-events-none, so the trigger itself never sees right-clicks
while refs are loading or a branch action is pending. */}
Expand Down
Loading
Loading