Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: continue a stopped thread when its usage limit resets #12458

ClosedAryaBuddha(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12458/headopened View on GitHub

Showing 41 changed files with 107 additions and 0 deletions (loading 38).

x
0 of 41 viewed, 41 left
95 additions and 0 deletionsapps/mobile/src/features/threads/AutoContinueBanner.tsxAdded
View file
@@ -0,0 +1,95 @@
+import type { EnvironmentId, OrchestrationThreadShell } from "@t3tools/contracts";
+import { formatDuration } from "@t3tools/shared/usageLimits";
+import { useCallback } from "react";
+import { Pressable, View } from "react-native";
+​
+import { AppText as Text } from "../../components/AppText";
+import { appAtomRegistry } from "../../state/atom-registry";
+import { environmentServerConfigsAtom } from "../../state/server";
+import { threadEnvironment } from "../../state/threads";
+import { useAtomCommand } from "../../state/use-atom-command";
+​
+function environmentSupportsAutoContinue(environmentId: EnvironmentId) {
+ return (
+ appAtomRegistry.get(environmentServerConfigsAtom).get(environmentId)?.environment.capabilities
+ .threadAutoContinue === true
+ );
+}
+​
+/**
+ * "Continue when the limit resets" for a thread stopped by a provider usage
+ * limit: offers scheduling while the session error carries a structured reset
+ * instant, and shows the pending continuation with a cancel once scheduled.
+ * Hidden on servers that predate thread.auto-continue (version skew).
+ */
+export function AutoContinueBanner(props: {
+ readonly environmentId: EnvironmentId;
+ readonly thread: OrchestrationThreadShell;
+}) {
+ const setAutoContinue = useAtomCommand(threadEnvironment.setAutoContinue, {
+ reportFailure: false,