Skip to content

Commit 8461c25

Browse files
authored
fix(web): disable linked pull requests when none are linked (pingdotgg#11348)
1 parent 8a2d5f5 commit 8461c25

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useLoadBalancedEnvironment } from "../hooks/useLoadBalancedEnvironment";
2+
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
23
import type { UsageLimitSourceSnapshots } from "@t3tools/contracts";
34
import {
45
collectProviderUsageLimits,
@@ -4203,10 +4204,14 @@ export default function ChatView(props: ChatViewProps) {
42034204
}, [activeThreadRef]);
42044205
const supportsThreadPullRequests =
42054206
serverConfig?.environment.capabilities.threadPullRequests === true;
4207+
const pullRequestsSurfaceAvailable =
4208+
isServerThread &&
4209+
supportsThreadPullRequests &&
4210+
visibleThreadPullRequests((activeThreadShell ?? activeThread)?.pullRequests ?? []).length > 0;
42064211
const addPullRequestsSurface = useCallback(() => {
4207-
if (!activeThreadRef || !supportsThreadPullRequests) return;
4212+
if (!activeThreadRef || !pullRequestsSurfaceAvailable) return;
42084213
useRightPanelStore.getState().open(activeThreadRef, "pull-requests");
4209-
}, [activeThreadRef, supportsThreadPullRequests]);
4214+
}, [activeThreadRef, pullRequestsSurfaceAvailable]);
42104215
const { state: deviceState, loaded: deviceStateLoaded } = useDeviceState(
42114216
activeThreadRef?.environmentId ?? null,
42124217
);
@@ -8340,7 +8345,7 @@ export default function ChatView(props: ChatViewProps) {
83408345
}
83418346
composerDraftTarget={composerDraftTarget}
83428347
onBack={
8343-
activeThreadRef !== null && supportsThreadPullRequests
8348+
activeThreadRef !== null && pullRequestsSurfaceAvailable
83448349
? addPullRequestsSurface
83458350
: undefined
83468351
}
@@ -8981,7 +8986,7 @@ export default function ChatView(props: ChatViewProps) {
89818986
diffAvailable={isServerThread && isGitRepo}
89828987
filesAvailable={activeProject !== null}
89838988
pullRequestAvailable={pullRequestSurfaceAvailable}
8984-
pullRequestsAvailable={isServerThread && supportsThreadPullRequests}
8989+
pullRequestsAvailable={pullRequestsSurfaceAvailable}
89858990
agentsAvailable
89868991
deviceAvailable={activeThreadRef !== null}
89878992
liveAgentCount={agentPanelModel.liveCount}
@@ -9039,7 +9044,7 @@ export default function ChatView(props: ChatViewProps) {
90399044
diffAvailable={isServerThread && isGitRepo}
90409045
filesAvailable={activeProject !== null}
90419046
pullRequestAvailable={pullRequestSurfaceAvailable}
9042-
pullRequestsAvailable={isServerThread && supportsThreadPullRequests}
9047+
pullRequestsAvailable={pullRequestsSurfaceAvailable}
90439048
agentsAvailable
90449049
deviceAvailable={activeThreadRef !== null}
90459050
liveAgentCount={agentPanelModel.liveCount}

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
4+
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
45

56
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
67
import {
@@ -1708,6 +1709,7 @@ function OpenCommandPaletteDialog(props: {
17081709
value: "action:open-thread-pull-requests",
17091710
searchTerms: ["pull requests", "linked", "stack", "prs"],
17101711
title: "Show linked pull requests",
1712+
disabled: visibleThreadPullRequests(activeThread.pullRequests).length === 0,
17111713
icon: <GitPullRequestArrowIcon className={ITEM_ICON_CLASS} />,
17121714
run: async () => {
17131715
useRightPanelStore.getState().open(threadRef, "pull-requests");

‎apps/web/src/components/RightPanelTabs.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const SURFACE_DISABLED_REASONS = {
154154
files: "Files are only available when a project is open.",
155155
diff: "Diff is only available for server threads in Git repositories.",
156156
pullRequest: "This thread's branch has no pull request yet.",
157-
pullRequests: "Linked pull requests are only available for server threads.",
157+
pullRequests: "No linked pull requests are available for this thread.",
158158
agents: "Agents are only available from a thread.",
159159
device: "Devices are only available from a thread.",
160160
} as const;
@@ -178,7 +178,7 @@ const SURFACE_UNAVAILABLE_HINTS = {
178178
files: "Available when a project is open.",
179179
diff: "Available for Git repositories.",
180180
pullRequest: "No pull request on this branch yet.",
181-
pullRequests: "Available for server threads.",
181+
pullRequests: "No linked pull requests available.",
182182
agents: "Available from a thread.",
183183
device: "Available from a thread.",
184184
} as const;

0 commit comments

Comments
 (0)