Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de766bac62 | ||
|
|
5341a44fda | ||
|
|
7f1949ec9f |
No files matched your search
@@ -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<HTMLElement>, prUrl: string) => void;
|
||||
}
|
||||
|
||||
function SidebarThreadPrStatusButton({
|
||||
thread,
|
||||
openPrLink,
|
||||
}: {
|
||||
thread: SidebarThreadSummary;
|
||||
openPrLink: (event: React.MouseEvent<HTMLElement>, 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 (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
aria-label={prStatus.tooltip}
|
||||
className={`inline-flex items-center justify-center ${prStatus.colorClass} cursor-pointer rounded-sm outline-hidden focus-visible:ring-1 focus-visible:ring-ring`}
|
||||
onClick={(event) => openPrLink(event, prStatus.url)}
|
||||
>
|
||||
<ChangeRequestStatusIcon className="size-3" />
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{prStatus.tooltip}</TooltipPopup>
|
||||
</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<HTMLButtonElement>) => {
|
||||
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}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5 text-left">
|
||||
{prStatus && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
aria-label={prStatus.tooltip}
|
||||
className={`inline-flex items-center justify-center ${prStatus.colorClass} cursor-pointer rounded-sm outline-hidden focus-visible:ring-1 focus-visible:ring-ring`}
|
||||
onClick={handlePrClick}
|
||||
>
|
||||
<ChangeRequestStatusIcon className="size-3" />
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{prStatus.tooltip}</TooltipPopup>
|
||||
</Tooltip>
|
||||
)}
|
||||
{thread.branch !== null ? (
|
||||
<SidebarThreadPrStatusButton thread={thread} openPrLink={openPrLink} />
|
||||
) : null}
|
||||
{threadStatus && <ThreadStatusLabel status={threadStatus} />}
|
||||
{renamingThreadKey === threadKey ? (
|
||||
<input
|
||||
@@ -728,7 +731,6 @@ interface SidebarProjectThreadListProps {
|
||||
showEmptyThreadState: boolean;
|
||||
shouldShowThreadPanel: boolean;
|
||||
isThreadListExpanded: boolean;
|
||||
projectCwd: string;
|
||||
activeRouteThreadKey: string | null;
|
||||
threadJumpLabelByKey: ReadonlyMap<string, string>;
|
||||
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(
|
||||
<SidebarThreadRow
|
||||
key={threadKey}
|
||||
thread={thread}
|
||||
projectCwd={projectCwd}
|
||||
orderedProjectThreadKeys={orderedProjectThreadKeys}
|
||||
isActive={activeRouteThreadKey === threadKey}
|
||||
jumpLabel={threadJumpLabelByKey.get(threadKey) ?? null}
|
||||
@@ -2082,7 +2082,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
showEmptyThreadState={showEmptyThreadState}
|
||||
shouldShowThreadPanel={shouldShowThreadPanel}
|
||||
isThreadListExpanded={isThreadListExpanded}
|
||||
projectCwd={project.cwd}
|
||||
activeRouteThreadKey={activeRouteThreadKey}
|
||||
threadJumpLabelByKey={threadJumpLabelByKey}
|
||||
appSettingsConfirmThreadArchive={appSettingsConfirmThreadArchive}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user