Skip to content

Commit e512ca0

Browse files
PR Batch Testerclaude
andcommitted
fix(web): ChatGPT sharing limits show in the composer recovery card
The sharing limit showed a floating ChatGPT banner on top of the usage-limit timeline line and recovery card. The recovery card now carries the ChatGPT title, icon and Manage usage or admin-request action, and the floating banner is suppressed like other usage limits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 929ec38 commit e512ca0

4 files changed

Lines changed: 55 additions & 20 deletions

File tree

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ import { RightPanelSurfaceContent } from "./chat/RightPanelSurfaceContent";
4242
import { usePendingThreadRequests } from "./chat/usePendingThreadRequests";
4343
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
4444
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
45-
import {
46-
CHATGPT_USAGE_LIMIT_CODE,
47-
CHATGPT_WORKSPACE_USAGE_LIMIT_CODE,
48-
} from "@t3tools/shared/usageLimits";
4945
import {
5046
latestExecutedRun,
5147
latestRootProviderFailure,
@@ -971,12 +967,9 @@ export default function ChatView(props: ChatViewProps) {
971967
);
972968
const browserAvailable = isPreviewSupportedInRuntime() || activeEnvironmentServerBrowser;
973969
const activeThreadShell = serverThread;
974-
// ChatGPT sharing limits keep their own banner; OpenAI's partner guidelines specify it.
975970
const timelineThreadError =
976971
serverRuntime?.status === "failed" &&
977972
serverRuntime.lastErrorClass === "usage_limit" &&
978-
serverRuntime.lastErrorCode !== CHATGPT_USAGE_LIMIT_CODE &&
979-
serverRuntime.lastErrorCode !== CHATGPT_WORKSPACE_USAGE_LIMIT_CODE &&
980973
activeThreadShell?.latestRun &&
981974
visibleThreadError === serverRuntime.lastError
982975
? null
@@ -2507,6 +2500,7 @@ export default function ChatView(props: ChatViewProps) {
25072500
activeThreadShell?.latestRun
25082501
? usageLimitRecoveryBannerItem({
25092502
runId: activeThreadShell.latestRun.runId,
2503+
errorCode: serverRuntime.lastErrorCode ?? null,
25102504
resetAt: serverRuntime.usageLimitResetAt ?? null,
25112505
stoppedAt: activeThreadShell.latestRun.completedAt ?? activeThreadShell.updatedAt,
25122506
recovery: activeThreadShell.limitRecovery ?? null,

‎apps/web/src/components/chat/ThreadErrorBanner.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { OpenAI } from "../Icons";
1414
import { ChatGptUsageButton } from "../settings/ChatGptUsageButton";
1515
import { ExpandableText } from "../settings/ExpandableText";
1616

17-
function copyAdminRequest() {
17+
export function copyAdminRequest() {
1818
void writeTextToClipboard(CHATGPT_WORKSPACE_ADMIN_REQUEST, "admin request").then(
1919
() =>
2020
toastManager.add({
@@ -96,11 +96,13 @@ export const ThreadErrorBanner = memo(function ThreadErrorBanner({
9696
{chatGptLimit ? (
9797
<div className="space-y-1">
9898
<p className="font-medium">ChatGPT usage limit reached</p>
99-
<p>
100-
{workspaceLimit
101-
? "You've reached your workspace's limit for using your ChatGPT plan in other apps. Copy a request to ask your workspace admin for increased usage limits."
102-
: "Review your usage settings in ChatGPT."}
103-
</p>
99+
{workspaceLimit ? (
100+
<p>
101+
{
102+
"You've reached your workspace's limit for using your ChatGPT plan in other apps. Copy a request to ask your workspace admin for increased usage limits."
103+
}
104+
</p>
105+
) : null}
104106
</div>
105107
) : (
106108
<ExpandableText text={error} collapsedText={getThreadErrorBannerMessage(error)} />

‎apps/web/src/components/chat/UsageLimitRecoveryBanner.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const stoppedAt = new Date(2026, 9, 20, 12, 0);
99
function bannerDescription(resetAt: Date, timestampFormat: TimestampFormat) {
1010
return usageLimitRecoveryBannerItem({
1111
runId: RunId.make("run-1"),
12+
errorCode: null,
1213
resetAt: resetAt.toISOString(),
1314
stoppedAt: stoppedAt.toISOString(),
1415
snoozedUntil: null,

‎apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx‎

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ import {
55
} from "@t3tools/contracts";
66
import { type TimestampFormat } from "@t3tools/contracts/settings";
77
import { deadlineStore } from "@t3tools/client-runtime/clock";
8+
import {
9+
CHATGPT_USAGE_LIMIT_CODE,
10+
CHATGPT_WORKSPACE_USAGE_LIMIT_CODE,
11+
} from "@t3tools/shared/usageLimits";
812
import { GaugeIcon } from "lucide-react";
913
import { useState } from "react";
1014
import { useDeadlinePassed } from "../../hooks/useDeadline";
15+
import { OpenAI } from "../Icons";
16+
import { ChatGptUsageButton } from "../settings/ChatGptUsageButton";
1117
import { Button } from "../ui/button";
1218
import { formatUpcomingTimestamp } from "../../timestampFormat";
1319
import { toastManager } from "../ui/toast";
1420
import type { ComposerBannerStackItem } from "./ComposerBannerStack";
21+
import { copyAdminRequest } from "./ThreadErrorBanner";
1522

1623
type RecoveryProps = {
1724
runId: RunId;
25+
errorCode: string | null;
1826
resetAt: string | null;
1927
stoppedAt: string;
2028
snoozedUntil: string | null;
@@ -24,17 +32,47 @@ type RecoveryProps = {
2432
};
2533

2634
export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBannerStackItem {
27-
const { runId, resetAt, stoppedAt, timestampFormat } = props;
35+
const { runId, errorCode, resetAt, stoppedAt, timestampFormat } = props;
2836
const canSchedule = resetAt !== null && Date.parse(resetAt) > Date.parse(stoppedAt);
37+
const workspaceLimit = errorCode === CHATGPT_WORKSPACE_USAGE_LIMIT_CODE;
38+
const chatGptLimit = workspaceLimit || errorCode === CHATGPT_USAGE_LIMIT_CODE;
39+
const recoveryActions = canSchedule ? (
40+
<RecoveryActions key={`${runId}:${resetAt}`} {...props} />
41+
) : null;
42+
const resetDescription = resetAt
43+
? `Resets ${formatUpcomingTimestamp(resetAt, timestampFormat)}`
44+
: "Reset time unavailable; retry manually";
45+
if (!chatGptLimit) {
46+
return {
47+
id: `usage-limit-recovery:${runId}`,
48+
variant: "warning",
49+
icon: <GaugeIcon />,
50+
title: "Usage limit reached",
51+
description: resetDescription,
52+
actions: recoveryActions,
53+
};
54+
}
55+
// OpenAI's partner guidelines specify this ChatGPT notice and its actions.
2956
return {
3057
id: `usage-limit-recovery:${runId}`,
3158
variant: "warning",
32-
icon: <GaugeIcon />,
33-
title: "Usage limit reached",
34-
description: resetAt
35-
? `Resets ${formatUpcomingTimestamp(resetAt, timestampFormat)}`
36-
: "Reset time unavailable; retry manually",
37-
actions: canSchedule ? <RecoveryActions key={`${runId}:${resetAt}`} {...props} /> : null,
59+
icon: <OpenAI aria-hidden="true" />,
60+
title: "ChatGPT usage limit reached",
61+
description: workspaceLimit
62+
? "You've reached your workspace's limit for using your ChatGPT plan in other apps."
63+
: resetDescription,
64+
actions: (
65+
<>
66+
{recoveryActions}
67+
{workspaceLimit ? (
68+
<Button size="xs" variant="ghost" onClick={copyAdminRequest}>
69+
Copy request for admin
70+
</Button>
71+
) : (
72+
<ChatGptUsageButton size="xs" variant="ghost" />
73+
)}
74+
</>
75+
),
3876
};
3977
}
4078

0 commit comments

Comments
 (0)