TypeScript
fix(web): disable linked pull requests when none are linked (#11348)
maria8461c25ffd0a
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex 212c23ecdb3..b74f5a07325 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -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}agentsAvailabledeviceAvailable={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}agentsAvailabledeviceAvailable={activeThreadRef !== null}liveAgentCount={agentPanelModel.liveCount}diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsxindex 3533678ecb2..72842dd2a1d 100644--- a/apps/web/src/components/CommandPalette.tsx+++ b/apps/web/src/components/CommandPalette.tsx@@ -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");diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsxindex c791a632b79..e0fb70b8080 100644--- a/apps/web/src/components/RightPanelTabs.tsx+++ b/apps/web/src/components/RightPanelTabs.tsx@@ -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;