fix(web): disable linked pull requests when none are linked (#11348)

This commit is contained in:
maria authored and GitHub committed 2026-09-11 21:36:13 -03:00
1 parent 8a2d5f545a
commit 8461c25ffd
3 files changed
+14 -7

No files matched your search

+10 -5
View File
@@ -1,4 +1,5 @@
import { useLoadBalancedEnvironment } from "../hooks/useLoadBalancedEnvironment";
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
import type { UsageLimitSourceSnapshots } from "@t3tools/contracts";
import {
collectProviderUsageLimits,
@@ -4203,10 +4204,14 @@ export default function ChatView(props: ChatViewProps) {
}, [activeThreadRef]);
const supportsThreadPullRequests =
serverConfig?.environment.capabilities.threadPullRequests === true;
const pullRequestsSurfaceAvailable =
isServerThread &&
supportsThreadPullRequests &&
visibleThreadPullRequests((activeThreadShell ?? activeThread)?.pullRequests ?? []).length > 0;
const addPullRequestsSurface = useCallback(() => {
if (!activeThreadRef || !supportsThreadPullRequests) return;
if (!activeThreadRef || !pullRequestsSurfaceAvailable) return;
useRightPanelStore.getState().open(activeThreadRef, "pull-requests");
}, [activeThreadRef, supportsThreadPullRequests]);
}, [activeThreadRef, pullRequestsSurfaceAvailable]);
const { state: deviceState, loaded: deviceStateLoaded } = useDeviceState(
activeThreadRef?.environmentId ?? null,
);
@@ -8340,7 +8345,7 @@ export default function ChatView(props: ChatViewProps) {
}
composerDraftTarget={composerDraftTarget}
onBack={
activeThreadRef !== null && supportsThreadPullRequests
activeThreadRef !== null && pullRequestsSurfaceAvailable
? addPullRequestsSurface
: undefined
}
@@ -8981,7 +8986,7 @@ export default function ChatView(props: ChatViewProps) {
diffAvailable={isServerThread && isGitRepo}
filesAvailable={activeProject !== null}
pullRequestAvailable={pullRequestSurfaceAvailable}
pullRequestsAvailable={isServerThread && supportsThreadPullRequests}
pullRequestsAvailable={pullRequestsSurfaceAvailable}
agentsAvailable
deviceAvailable={activeThreadRef !== null}
liveAgentCount={agentPanelModel.liveCount}
@@ -9039,7 +9044,7 @@ export default function ChatView(props: ChatViewProps) {
diffAvailable={isServerThread && isGitRepo}
filesAvailable={activeProject !== null}
pullRequestAvailable={pullRequestSurfaceAvailable}
pullRequestsAvailable={isServerThread && supportsThreadPullRequests}
pullRequestsAvailable={pullRequestsSurfaceAvailable}
agentsAvailable
deviceAvailable={activeThreadRef !== null}
liveAgentCount={agentPanelModel.liveCount}
@@ -1,6 +1,7 @@
"use client";
import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
import {
@@ -1708,6 +1709,7 @@ function OpenCommandPaletteDialog(props: {
value: "action:open-thread-pull-requests",
searchTerms: ["pull requests", "linked", "stack", "prs"],
title: "Show linked pull requests",
disabled: visibleThreadPullRequests(activeThread.pullRequests).length === 0,
icon: <GitPullRequestArrowIcon className={ITEM_ICON_CLASS} />,
run: async () => {
useRightPanelStore.getState().open(threadRef, "pull-requests");
+2 -2
View File
@@ -154,7 +154,7 @@ const SURFACE_DISABLED_REASONS = {
files: "Files are only available when a project is open.",
diff: "Diff is only available for server threads in Git repositories.",
pullRequest: "This thread's branch has no pull request yet.",
pullRequests: "Linked pull requests are only available for server threads.",
pullRequests: "No linked pull requests are available for this thread.",
agents: "Agents are only available from a thread.",
device: "Devices are only available from a thread.",
} as const;
@@ -178,7 +178,7 @@ const SURFACE_UNAVAILABLE_HINTS = {
files: "Available when a project is open.",
diff: "Available for Git repositories.",
pullRequest: "No pull request on this branch yet.",
pullRequests: "Available for server threads.",
pullRequests: "No linked pull requests available.",
agents: "Available from a thread.",
device: "Available from a thread.",
} as const;