@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 48 lines 1.55 KB
Raw
1 import { msg } from "gt-react";
2
3 import { m } from "../i18n/messages";
4 import { appAtomRegistry } from "../rpc/atomRegistry";
5 import { primaryServerLegacyThreadMigrationAtom } from "../state/server";
6 import { toastManager } from "./ui/toast";
7
8 type MigrationToastId = ReturnType<typeof toastManager.add>;
9
10 /** A loading toast for as long as the primary server reports a legacy thread migration running. */
11 export function startLegacyThreadMigrationToast(): () => void {
12 let toastId: MigrationToastId | null = null;
13
14 const unsubscribe = appAtomRegistry.subscribe(
15 primaryServerLegacyThreadMigrationAtom,
16 (migration) => {
17 if (migration?.status === "running") {
18 if (toastId !== null) return;
19 toastId = toastManager.add({
20 type: "loading",
21 title: m(msg("Restoring your threads…")),
22 description: m(
23 msg(
24 "{count, plural, one {Migrating {total} thread from the previous version. You can keep working while this finishes.} other {Migrating {total} threads from the previous version. You can keep working while this finishes.}}",
25 {
26 count: migration.totalThreadCount,
27 total: migration.totalThreadCount.toLocaleString(),
28 },
29 ),
30 ),
31 timeout: 0,
32 });
33 return;
34 }
35
36 if (toastId !== null) {
37 toastManager.close(toastId);
38 toastId = null;
39 }
40 },
41 { immediate: true },
42 );
43
44 return () => {
45 unsubscribe();
46 if (toastId !== null) toastManager.close(toastId);
47 };
48 }