Skip to content
Draft
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
1 change: 0 additions & 1 deletion apps/web/src/components/BranchToolbarBranchSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ export function BranchToolbarBranchSelector({
const branchPr = resolveThreadPr({
threadBranch: resolvedActiveBranch,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium components/BranchToolbarBranchSelector.tsx:594

resolveThreadPr is called with resolvedActiveBranch, which falls back to currentGitBranch via resolveBranchToolbarValue. When the thread has no stored branch, resolvedActiveBranch equals gitStatus.refName, so the PR pill displays even though no thread-branch association exists — exactly the behavior the hasDedicatedWorktree removal was meant to eliminate. Pass activeThreadBranch instead so the PR only shows when the thread has an explicit stored branch.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/components/BranchToolbarBranchSelector.tsx around line 594:

`resolveThreadPr` is called with `resolvedActiveBranch`, which falls back to `currentGitBranch` via `resolveBranchToolbarValue`. When the thread has no stored branch, `resolvedActiveBranch` equals `gitStatus.refName`, so the PR pill displays even though no thread-branch association exists — exactly the behavior the `hasDedicatedWorktree` removal was meant to eliminate. Pass `activeThreadBranch` instead so the PR only shows when the thread has an explicit stored branch.

gitStatus: branchStatusQuery.data ?? null,
hasDedicatedWorktree: activeWorktreePath !== null,
});
const branchPrStatus = prStatusIndicator(branchPr, branchStatusQuery.data?.sourceControlProvider);
// Action-oriented tooltip (the pill opens the PR), distinct from the sidebar's
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,6 @@ function ChatViewContent(props: ChatViewProps) {
const activeThreadPr = resolveThreadPr({
threadBranch: activeThread?.branch ?? null,
gitStatus: gitStatusQuery.data ?? null,
hasDedicatedWorktree: (activeThread?.worktreePath ?? null) !== null,
});
const supportsSettlement = serverConfig?.environment.capabilities.threadSettlement === true;
const supportsSnooze = serverConfig?.environment.capabilities.threadSnooze === true;
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
const pr = resolveThreadPr({
threadBranch: thread.branch,
gitStatus: gitStatus.data,
hasDedicatedWorktree: thread.worktreePath !== null,
});
const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider);
const terminalStatus = terminalStatusFromRunningIds(runningTerminalIds);
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/SidebarV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
const pr = resolveThreadPr({
threadBranch: thread.branch,
gitStatus: gitStatus.data,
hasDedicatedWorktree: thread.worktreePath !== null,
});
const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider);
const settledPrHoverClass = pr ? settledPrHoverColorClass(pr.state) : undefined;
Expand Down
24 changes: 14 additions & 10 deletions apps/web/src/components/ThreadStatusIndicators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,35 @@ describe("resolveThreadPr", () => {
resolveThreadPr({
threadBranch: "feature/other",
gitStatus: status(),
hasDedicatedWorktree: false,
}),
).toBeNull();
});

it("shows PR indicators for dedicated worktree threads even when branch metadata is stale", () => {
const gitStatus = status();
it("hides PR indicators when a dedicated worktree has switched away from the thread branch", () => {
expect(
resolveThreadPr({
threadBranch: "stack/base",
gitStatus: status(),
}),
).toBeNull();
});

it("hides PR indicators when thread branch metadata is missing", () => {
expect(
resolveThreadPr({
threadBranch: "feature/old-name",
gitStatus,
hasDedicatedWorktree: true,
threadBranch: null,
gitStatus: status(),
}),
).toBe(gitStatus.pr);
).toBeNull();
});

it("shows PR indicators for dedicated worktree threads even when branch metadata is missing", () => {
it("shows the PR when the live checkout matches the stored thread branch", () => {
const gitStatus = status();

expect(
resolveThreadPr({
threadBranch: null,
threadBranch: "feature/current",
gitStatus,
hasDedicatedWorktree: true,
}),
).toBe(gitStatus.pr);
});
Expand Down
8 changes: 1 addition & 7 deletions apps/web/src/components/ThreadStatusIndicators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,12 @@ export function PrStatusTooltipContent({ status }: { status: PrStatusIndicator }
export function resolveThreadPr(input: {
threadBranch: string | null;
gitStatus: VcsStatusResult | null;
hasDedicatedWorktree: boolean;
}): ThreadPr | null {
const { threadBranch, gitStatus, hasDedicatedWorktree } = input;
const { threadBranch, gitStatus } = input;
if (gitStatus === null) {
return null;
}

if (hasDedicatedWorktree) {
return gitStatus.pr ?? null;
}

if (threadBranch === null || gitStatus.refName !== threadBranch) {
return null;
}
Expand Down Expand Up @@ -258,7 +253,6 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar
const pr = resolveThreadPr({
threadBranch: thread.branch,
gitStatus: gitStatus.data,
hasDedicatedWorktree: thread.worktreePath !== null,
});
const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider);
const threadStatus = resolveThreadStatusPill({
Expand Down
Loading