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

main
tsx 69 lines 2.73 KB
Raw
1 import { useGT } from "gt-react-native";
2 import { useAtomValue } from "@effect/atom-react";
3 import { AsyncResult } from "effect/reactivity";
4
5 import { copyTextWithHaptic } from "../../../lib/copyTextWithHaptic";
6 import { mobilePreferencesAtom, saveMobilePreferences } from "../../../state/preferences";
7 import { serverEnvironment } from "../../../state/server";
8 import { useAtomCommand } from "../../../state/use-atom-command";
9 import type { SettingsTarget } from "../settings-environment-filter";
10 import { ListActionRow as SettingsActionRow } from "../../../components/ui/ListActionRow";
11 import { SettingsSection } from "./SettingsSection";
12
13 /** Suggests `t3 doctor` on every machine whose database still holds at least 1 GiB of freed pages. */
14 export function DatabaseStorageNotice({
15 targets,
16 }: {
17 readonly targets: readonly SettingsTarget[];
18 }) {
19 const gt = useGT();
20 const recommendations = useAtomValue(
21 serverEnvironment.databaseCompactionRecommendations(
22 JSON.stringify(targets.map((target) => target.environmentId)),
23 ),
24 );
25 const preferences = useAtomValue(mobilePreferencesAtom);
26 const updatePreferences = useAtomCommand(saveMobilePreferences);
27 const dismissed = AsyncResult.isSuccess(preferences)
28 ? (preferences.value.dismissedDatabaseStorageNotices ?? [])
29 : [];
30 const visible = recommendations.filter(
31 (recommendation) => !dismissed.includes(recommendation.environmentId),
32 );
33 if (visible.length === 0) return null;
34 return (
35 <SettingsSection
36 title={gt("Reclaim database space")}
37 footer={gt(
38 "These databases still hold space freed by history cleanup. Run the command on each machine to reclaim it. It restarts the background service. Quit the desktop app first if it hosts the environment.",
39 )}
40 >
41 {visible.map(({ environmentId, status }) => (
42 <SettingsActionRow
43 key={environmentId}
44 icon="doc.on.doc"
45 label={targets.find((target) => target.environmentId === environmentId)?.label ?? ""}
46 description={status.compactCommand}
47 detail={gt("{size} GiB", { size: (status.reclaimableBytes / 1024 ** 3).toFixed(1) })}
48 onPress={() => copyTextWithHaptic(status.compactCommand, { target: "command" })}
49 />
50 ))}
51 <SettingsActionRow
52 icon="xmark"
53 label={gt("Dismiss")}
54 onPress={() => {
55 void updatePreferences({
56 transform: (current) => ({
57 dismissedDatabaseStorageNotices: [
58 ...new Set([
59 ...(current.dismissedDatabaseStorageNotices ?? []),
60 ...visible.map((recommendation) => recommendation.environmentId),
61 ]),
62 ],
63 }),
64 });
65 }}
66 />
67 </SettingsSection>
68 );
69 }