Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): compact superseded history and reclaim database space #19249

Closedjuliusmarmingewants to merge 8 commits intomain fromt3/database-compactionopened View on GitHub

Showing 49 changed files with 74 additions and 0 deletions (loading 46).

x
0 of 49 viewed, 49 left
57 additions and 0 deletionsapps/mobile/src/features/settings/components/DatabaseStorageNotice.tsxAdded
View file
@@ -0,0 +1,57 @@
+import { useAtomSet, useAtomValue } from "@effect/atom-react";
+import { shouldRecommendDatabaseCompaction } from "@t3tools/shared/databaseStorage";
+import { View } from "react-native";
+​
+import { AppText as Text } from "../../../components/AppText";
+import { copyTextWithHaptic } from "../../../lib/copyTextWithHaptic";
+import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../../state/preferences";
+import { serverEnvironment } from "../../../state/server";
+import type { SettingsTarget } from "../settings-environment-filter";
+import { SettingsActionRow } from "./SettingsActionRow";
+import { SettingsSection } from "./SettingsSection";
+​
+export function DatabaseStorageNotice({ target }: { readonly target: SettingsTarget }) {
+ const result = useAtomValue(
+ serverEnvironment.databaseStorage({ environmentId: target.environmentId, input: {} }),
+ );
+ const preferences = useAtomValue(mobilePreferencesAtom);
+ const updatePreferences = useAtomSet(updateMobilePreferencesAtom);
+ const dismissed =
+ preferences._tag === "Success" &&
+ preferences.value.dismissedDatabaseNotices?.includes(target.environmentId);
+ const status = result._tag === "Success" ? result.value : null;
+ if (dismissed || status === null || !shouldRecommendDatabaseCompaction(status)) return null;
+ const gib = (status.reclaimableBytes / 1024 ** 3).toFixed(1);
+ return (
+ <SettingsSection title={`Reclaim ${gib} GB on ${target.label}`}>
+ <View className="gap-3 p-4">
+ <Text className="text-sm text-muted-foreground">
+ History cleanup is automatic. To return unused space to disk and enable automatic
+ shrinking, run this command on {target.label}. Doctor pauses and restarts its background