diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 1b96bb71cba..eba6e0f9b77 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -278,7 +278,6 @@ function buildThreadJumpLabelMap(input: { interface SidebarThreadRowProps { thread: SidebarThreadSummary; - projectCwd: string | null; orderedProjectThreadKeys: readonly string[]; isActive: boolean; jumpLabel: string | null; @@ -313,6 +312,49 @@ interface SidebarThreadRowProps { openPrLink: (event: React.MouseEvent, prUrl: string) => void; } +function SidebarThreadPrStatusButton({ + thread, + openPrLink, +}: { + thread: SidebarThreadSummary; + openPrLink: (event: React.MouseEvent, prUrl: string) => void; +}) { + const threadProjectCwd = useStore( + (state: import("../store").AppState) => + selectProjectByRef(state, scopeProjectRef(thread.environmentId, thread.projectId))?.cwd ?? + null, + ); + const gitCwd = thread.worktreePath ?? threadProjectCwd; + const gitStatus = useGitStatus({ + environmentId: thread.environmentId, + cwd: thread.branch != null ? gitCwd : null, + }); + const pr = resolveThreadPr(thread.branch, gitStatus.data); + const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider); + + if (!prStatus) { + return null; + } + + return ( + + openPrLink(event, prStatus.url)} + > + + + } + /> + {prStatus.tooltip} + + ); +} + const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowProps) { const { orderedProjectThreadKeys, @@ -358,22 +400,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP const threadEnvironmentLabel = isRemoteThread ? (remoteEnvLabel ?? remoteEnvSavedLabel ?? "Remote") : null; - // For grouped projects, the thread may belong to a different environment - // than the representative project. Look up the thread's own project cwd - // so git status (and thus PR detection) queries the correct path. - const threadProjectCwd = useStore( - useMemo( - () => (state: import("../store").AppState) => - selectProjectByRef(state, scopeProjectRef(thread.environmentId, thread.projectId))?.cwd ?? - null, - [thread.environmentId, thread.projectId], - ), - ); - const gitCwd = thread.worktreePath ?? threadProjectCwd ?? props.projectCwd; - const gitStatus = useGitStatus({ - environmentId: thread.environmentId, - cwd: thread.branch != null ? gitCwd : null, - }); const isHighlighted = isActive || isSelected; const isThreadRunning = thread.session?.status === "running" && thread.session.activeTurnId != null; @@ -383,8 +409,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP lastVisitedAt, }, }); - const pr = resolveThreadPr(thread.branch, gitStatus.data); - const prStatus = prStatusIndicator(pr, gitStatus.data?.sourceControlProvider); const terminalStatus = terminalStatusFromRunningIds(runningTerminalIds); const isConfirmingArchive = confirmingArchiveThreadKey === threadKey && !isThreadRunning; const threadMetaClassName = isConfirmingArchive @@ -446,13 +470,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP }, [clearSelection, handleMultiSelectContextMenu, handleThreadContextMenu, isSelected, threadRef], ); - const handlePrClick = useCallback( - (event: React.MouseEvent) => { - if (!prStatus) return; - openPrLink(event, prStatus.url); - }, - [openPrLink, prStatus], - ); const handleRenameInputRef = useCallback( (element: HTMLInputElement | null) => { if (element && renamingInputRef.current !== element) { @@ -559,23 +576,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP onContextMenu={handleRowContextMenu} >
- {prStatus && ( - - - - - } - /> - {prStatus.tooltip} - - )} + {thread.branch !== null ? ( + + ) : null} {threadStatus && } {renamingThreadKey === threadKey ? ( ; appSettingsConfirmThreadArchive: boolean; @@ -778,7 +780,6 @@ const SidebarProjectThreadList = memo(function SidebarProjectThreadList( showEmptyThreadState, shouldShowThreadPanel, isThreadListExpanded, - projectCwd, activeRouteThreadKey, threadJumpLabelByKey, appSettingsConfirmThreadArchive, @@ -828,7 +829,6 @@ const SidebarProjectThreadList = memo(function SidebarProjectThreadList(