Skip to content

Commit f759432

Browse files
fix(mobile): surface failed limit recovery changes
1 parent 4aa1fc1 commit f759432

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎apps/mobile/src/features/threads/UsageLimitRecoveryCard.tsx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
12
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
23
import type { EnvironmentId } from "@t3tools/contracts";
34
import * as DateTime from "effect/DateTime";
@@ -16,6 +17,7 @@ export function UsageLimitRecoveryCard({
1617
}) {
1718
const updateMetadata = useAtomCommand(threadEnvironment.updateMetadata);
1819
const [pending, setPending] = useState(false);
20+
const [error, setError] = useState<string | null>(null);
1921
const resetAt = thread.runtime?.usageLimitResetAt ?? null;
2022
const canSchedule =
2123
resetAt !== null &&
@@ -33,11 +35,15 @@ export function UsageLimitRecoveryCard({
3335
async function toggle() {
3436
if (!resetAt || !runId || !canSchedule) return;
3537
setPending(true);
38+
setError(null);
3639
try {
37-
await updateMetadata({
40+
const result = await updateMetadata({
3841
environmentId,
3942
input: { threadId: thread.id, limitRecovery: { runId, resetAt, autoResume: !scheduled } },
4043
});
44+
if (result._tag === "Failure") throw squashAtomCommandFailure(result);
45+
} catch (cause) {
46+
setError(cause instanceof Error ? cause.message : "Could not change limit recovery.");
4147
} finally {
4248
setPending(false);
4349
}
@@ -61,6 +67,11 @@ export function UsageLimitRecoveryCard({
6167
</Text>
6268
</Pressable>
6369
) : null}
70+
{error ? (
71+
<Text accessibilityRole="alert" className="text-sm text-destructive">
72+
{error}
73+
</Text>
74+
) : null}
6475
</View>
6576
);
6677
}

0 commit comments

Comments
 (0)