diff --git a/FORK.md b/FORK.md index 6ae517de06505..54eb1a5c6c4b7 100644 --- a/FORK.md +++ b/FORK.md @@ -6,6 +6,16 @@ This fork keeps the Windows reliability, durable checkpointing, and workspace ca ## Divergence Log +### DL060 — Usage-limit retry scheduling + +When a provider usage limit stops a thread and automatic recovery has not resumed it, the web client offers a Schedule retry popup from the Usage limit reached banner. Its choices use the environment's configurable snooze presets, arm the existing usage-limit auto-resume recovery, and snooze the thread until the selected local time. + +**Implementation evidence:** `apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx`, `apps/web/src/components/ChatView.tsx`, and `apps/web/src/components/chat/UsageLimitRecoveryBanner.test.tsx`. + +**Recorded validation:** Web package typecheck, focused Oxlint, formatting, and `git diff --check` pass. The integrated preview reached the dev splash screen after the web bundle loaded. + +**Last updated:** 2026-11-23 + Each behavior where this fork differs from upstream has one entry here. If you change code in this repository, check if this log needs an update. The rules: diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 27fc1afc51b6e..d5ca858b6805a 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -45,6 +45,7 @@ import { ThreadFind, ThreadFindCanvas } from "./chat/ThreadFindProvider"; import { closeThreadFind, openThreadFind, useThreadFindOpen } from "./chat/threadFindStore"; import { THREAD_FIND_BAR_RESERVED_HEIGHT } from "./chat/ThreadFindBar"; import { usageLimitRecoveryBannerItem } from "./chat/UsageLimitRecoveryBanner"; +import { resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled"; import { isThreadEnvironmentLocked, resolveDraftHeroState } from "./ChatView.logic"; import { useQueuedRunEdit } from "./chat/useQueuedRunEdit"; import { @@ -140,6 +141,7 @@ import { use, useEffect, useLayoutEffect, + useMemo, useRef, useState, } from "react"; @@ -237,6 +239,7 @@ import { useEnvironmentSettings, } from "../hooks/useSettings"; import { useNowMinute } from "../hooks/useNowMinute"; +import { formatUpcomingTimestamp } from "../timestampFormat"; import { usePanelAnimationSettings, usePanelPresence } from "../panelAnimations"; import { useNewThreadHandler } from "../hooks/useHandleNewThread"; import { useOpenPanelPullRequestUrl } from "../hooks/useOpenPanelPullRequestUrl"; @@ -498,6 +501,9 @@ export default function ChatView(props: ChatViewProps) { const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, { reportFailure: false, }); + const snoozeThread = useOrchestrationCommand(threadEnvironment.snooze, { + reportFailure: false, + }); const resumeAutoRetry = useAtomCommand(threadEnvironment.resumeAutoRetry, "resume auto retry"); const canResumeAutoRetry = useAtomValue( threadEnvironment.resumeAutoRetry.permissionAtom(environmentId), @@ -867,6 +873,14 @@ export default function ChatView(props: ChatViewProps) { } } const nowMinute = useNowMinute(); + const retryPresets = useMemo( + () => + resolveSnoozePresets(new Date(Date.parse(`${nowMinute}:00Z`)), { + presets: settings.snoozePresets, + formatTime: (date) => formatUpcomingTimestamp(date.toISOString(), timestampFormat), + }), + [nowMinute, settings.snoozePresets, timestampFormat], + ); const draftDefaultModelSelection = draftThread ? resolveProjectSettings( settings, @@ -2738,6 +2752,24 @@ export default function ChatView(props: ChatViewProps) { }); if (result._tag === "Failure") throw squashAtomCommandFailure(result); }, + retryPresets, + onScheduleRetry: async (snoozedUntil) => { + const resetAt = serverRuntime?.usageLimitResetAt; + if (resetAt === null || resetAt === undefined) + throw new Error("Reset time unavailable."); + await updateThreadMetadata({ + environmentId, + input: { + threadId: activeThreadShell.id, + limitRecovery: { runId: limitRecoveryRun.runId, resetAt, autoResume: true }, + }, + }); + const result = await snoozeThread({ + environmentId, + input: { threadId: activeThreadShell.id, snoozedUntil }, + }); + if (result._tag === "Failure") throw squashAtomCommandFailure(result); + }, }) : null; const composerBannerItems = (() => { diff --git a/apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx b/apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx index 744db5ea3a1e9..7f2327b206520 100644 --- a/apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx +++ b/apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx @@ -4,6 +4,7 @@ import { type RunId, } from "@t3tools/contracts"; import { type TimestampFormat } from "@t3tools/contracts/settings"; +import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled"; import { deadlineStore } from "@t3tools/client-runtime/clock"; import { limitRecoveryOwnsSnooze } from "@t3tools/client-runtime/state/thread-execution"; import { @@ -16,6 +17,7 @@ import { useDeadlinePassed } from "../../hooks/useDeadline"; import { OpenAI } from "../Icons"; import { ChatGptUsageButton } from "../settings/ChatGptUsageButton"; import { Button, InlineButton } from "../ui/button"; +import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover"; import { formatUpcomingTimestamp } from "../../timestampFormat"; import { toastManager } from "../ui/toast"; import type { ComposerBannerStackItem } from "./ComposerBannerStack"; @@ -32,6 +34,8 @@ type RecoveryProps = { recovery: OrchestrationV2LimitRecovery | null; timestampFormat: TimestampFormat; onChange: (recovery: OrchestrationV2LimitRecoveryUpdate) => Promise; + retryPresets?: ReadonlyArray; + onScheduleRetry?: (snoozedUntil: string) => Promise; }; export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBannerStackItem { @@ -56,6 +60,14 @@ export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBann const recoveryActions = canSchedule ? ( ) : null; + const scheduleAction = + canSchedule && props.onScheduleRetry && props.retryPresets?.length ? ( + + ) : null; const displayAt = resumes && resetAt && snoozedUntil && Date.parse(snoozedUntil) > Date.parse(resetAt) ? snoozedUntil @@ -71,7 +83,12 @@ export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBann icon: , title: "Usage limit reached", description: resetDescription, - actions: recoveryActions, + actions: ( + <> + {recoveryActions} + {scheduleAction} + + ), }; } // OpenAI's partner guidelines specify this ChatGPT notice and its actions. @@ -87,6 +104,7 @@ export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBann actions: ( <> {recoveryActions} + {scheduleAction} {workspaceLimit ? ( + ))} + + + + ); +}