@devries-cameron20 / t3code-1 / commits / 8cd561ef6f
Fork 0

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

fix(web,mobile): list database space for all machines in one notice (#22575)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 20, 2026 at 17:43 UTC 8cd561ef6f8d09e22b50429982acaf1e9b896086
5 files changed +112 -80
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+6 -7
@@ -434,15 +434,14 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
434
435 {props.page === "maintenance" ? (
436 <>
437 - {!projectSelected &&
438 - selectedTargets
439 - .filter(
437 + {!projectSelected ? (
438 + <DatabaseStorageNotice
439 + targets={selectedTargets.filter(
440 (target) =>
441 target.serverConfig.environment.capabilities.databaseStorage === true,
442 - )
443 - .map((target) => (
444 - <DatabaseStorageNotice key={target.environmentId} target={target} />
445 - ))}
442 + )}
443 + />
444 + ) : null}
445 {!projectSelected ? (
446 <SettingsSection title="Manage environments">
447 {selectedTargets.map((target) => (
apps/mobile/src/features/settings/components/DatabaseStorageNotice.tsx
+32 -30
@@ -1,9 +1,6 @@
1 import { useAtomSet, useAtomValue } from "@effect/atom-react";
2 -import { shouldRecommendDatabaseCompaction } from "@t3tools/contracts";
2 import { AsyncResult } from "effect/reactivity";
4 -import { View } from "react-native";
3
6 -import { AppText as Text } from "../../../components/ui/AppText";
4 import { copyTextWithHaptic } from "../../../lib/copyTextWithHaptic";
5 import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../../state/preferences";
6 import { serverEnvironment } from "../../../state/server";
@@ -11,36 +8,41 @@ import type { SettingsTarget } from "../settings-environment-filter";
8 import { SettingsActionRow } from "./SettingsActionRow";
9 import { SettingsSection } from "./SettingsSection";
10
14 -/** Suggests `t3 doctor` for a database that still holds at least 1 GiB of freed pages. */
15 -export function DatabaseStorageNotice({ target }: { readonly target: SettingsTarget }) {
16 - const result = useAtomValue(
17 - serverEnvironment.databaseStorage({ environmentId: target.environmentId, input: {} }),
11 +/** Suggests `t3 doctor` on every machine whose database still holds at least 1 GiB of freed pages. */
12 +export function DatabaseStorageNotice({
13 + targets,
14 +}: {
15 + readonly targets: readonly SettingsTarget[];
16 +}) {
17 + const recommendations = useAtomValue(
18 + serverEnvironment.databaseCompactionRecommendations(
19 + JSON.stringify(targets.map((target) => target.environmentId)),
20 + ),
21 );
22 const preferences = useAtomValue(mobilePreferencesAtom);
23 const updatePreferences = useAtomSet(updateMobilePreferencesAtom);
21 - const dismissed =
22 - AsyncResult.isSuccess(preferences) &&
23 - preferences.value.dismissedDatabaseStorageNotices?.includes(target.environmentId) === true;
24 - const status = result._tag === "Success" ? result.value : null;
25 - if (dismissed || status === null || !shouldRecommendDatabaseCompaction(status)) return null;
26 - const gib = (status.reclaimableBytes / 1024 ** 3).toFixed(1);
24 + const dismissed = AsyncResult.isSuccess(preferences)
25 + ? (preferences.value.dismissedDatabaseStorageNotices ?? [])
26 + : [];
27 + const visible = recommendations.filter(
28 + (recommendation) => !dismissed.includes(recommendation.environmentId),
29 + );
30 + if (visible.length === 0) return null;
31 return (
28 - <SettingsSection title={`Reclaim ${gib} GiB on ${target.label}`}>
29 - <View className="gap-3 p-4">
30 - <Text className="text-sm text-muted-foreground">
31 - Old history is cleaned up automatically, but this database still holds the freed space.
32 - Run this command on {target.label} to return it to disk; it pauses and restarts the
33 - background service. Quit the desktop app first if it hosts this environment.
34 - </Text>
35 - <Text selectable className="font-mono text-sm text-foreground">
36 - {status.compactCommand}
37 - </Text>
38 - </View>
39 - <SettingsActionRow
40 - icon="doc.on.doc"
41 - label="Copy command"
42 - onPress={() => copyTextWithHaptic(status.compactCommand, { target: "command" })}
43 - />
32 + <SettingsSection
33 + title="Reclaim database space"
34 + footer="Old history is cleaned up automatically, but these databases still hold the freed space. Run the command on each machine to return it to disk; it pauses and restarts the background service. Quit the desktop app first if it hosts the environment."
35 + >
36 + {visible.map(({ environmentId, status }) => (
37 + <SettingsActionRow
38 + key={environmentId}
39 + icon="doc.on.doc"
40 + label={targets.find((target) => target.environmentId === environmentId)?.label ?? ""}
41 + description={status.compactCommand}
42 + detail={`${(status.reclaimableBytes / 1024 ** 3).toFixed(1)} GiB`}
43 + onPress={() => copyTextWithHaptic(status.compactCommand, { target: "command" })}
44 + />
45 + ))}
46 <SettingsActionRow
47 icon="xmark"
48 label="Dismiss"
@@ -50,7 +52,7 @@ export function DatabaseStorageNotice({ target }: { readonly target: SettingsTar
52 dismissedDatabaseStorageNotices: [
53 ...new Set([
54 ...(current.dismissedDatabaseStorageNotices ?? []),
53 - target.environmentId,
55 + ...visible.map((recommendation) => recommendation.environmentId),
56 ]),
57 ],
58 }),
apps/web/src/components/settings/DatabaseStorageNotice.tsx
+37 -27
@@ -1,60 +1,70 @@
1 import { useAtomValue } from "@effect/atom-react";
2 -import { shouldRecommendDatabaseCompaction, type EnvironmentId } from "@t3tools/contracts";
2 +import type { EnvironmentId } from "@t3tools/contracts";
3 import * as Schema from "effect/Schema";
4
5 import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
6 import { useLocalStorage } from "../../hooks/useLocalStorage";
7 import { serverEnvironment } from "../../state/server";
8 import { Button } from "../ui/button";
9 -import { SettingsGroup } from "./SettingsGroup";
9 import { SettingsRow, SettingsSection } from "./settingsLayout";
10
12 -/** Suggests `t3 doctor` for a database that still holds at least 1 GiB of freed pages. */
11 +const DismissedEnvironmentIds = Schema.Array(Schema.String);
12 +
13 +/** Suggests `t3 doctor` on every machine whose database still holds at least 1 GiB of freed pages. */
14 export function DatabaseStorageNotice({
14 - environmentId,
15 - label,
15 + environments,
16 }: {
17 - environmentId: EnvironmentId;
18 - label: string;
17 + environments: ReadonlyArray<{ readonly environmentId: EnvironmentId; readonly label: string }>;
18 }) {
20 - const result = useAtomValue(serverEnvironment.databaseStorage({ environmentId, input: {} }));
19 + const recommendations = useAtomValue(
20 + serverEnvironment.databaseCompactionRecommendations(
21 + JSON.stringify(environments.map((environment) => environment.environmentId)),
22 + ),
23 + );
24 const [dismissed, setDismissed] = useLocalStorage(
22 - `database-storage-notice-dismissed:${environmentId}`,
23 - false,
24 - Schema.Boolean,
25 + "database-storage-notice-dismissed",
26 + [],
27 + DismissedEnvironmentIds,
28 );
29 const { copyToClipboard } = useCopyToClipboard({ target: "command" });
27 - const status = result._tag === "Success" ? result.value : null;
28 - if (dismissed || status === null || !shouldRecommendDatabaseCompaction(status)) return null;
30 + const visible = recommendations.filter(
31 + (recommendation) => !dismissed.includes(recommendation.environmentId),
32 + );
33 + if (visible.length === 0) return null;
34 return (
30 - <SettingsSection id={`storage-database-${environmentId}`} title="Database">
31 - <SettingsGroup>
35 + <SettingsSection id="storage-database" title="Database">
36 + <SettingsRow
37 + title="Reclaim freed database space"
38 + description="Old history is cleaned up automatically, but these databases still hold the freed space. Run the command on each machine to return it to disk; it pauses and restarts the background service. Quit the desktop app first if it hosts the environment."
39 + />
40 + {visible.map(({ environmentId, status }) => (
41 <SettingsRow
33 - title={`Reclaim ${(status.reclaimableBytes / 1024 ** 3).toFixed(1)} GiB on ${label}`}
34 - description={
35 - <>
36 - Old history is cleaned up automatically, but this database still holds the freed
37 - space. Run the command on {label} to return it to disk; it pauses and restarts the
38 - background service. Quit the desktop app first if it hosts this environment.
39 - <code className="mt-2 block select-text break-all">{status.compactCommand}</code>
40 - </>
41 - }
42 + key={environmentId}
43 + title={`${(status.reclaimableBytes / 1024 ** 3).toFixed(1)} GiB on ${
44 + environments.find((environment) => environment.environmentId === environmentId)
45 + ?.label ?? environmentId
46 + }`}
47 + description={<code className="select-text break-all">{status.compactCommand}</code>}
48 control={
49 <div className="flex flex-wrap items-center gap-1.5">
50 <Button
51 variant="outline"
46 - size="sm"
52 + size="xs"
53 onClick={() => copyToClipboard(status.compactCommand, undefined)}
54 >
55 Copy command
56 </Button>
51 - <Button variant="ghost" size="sm" onClick={() => setDismissed(true)}>
57 + <Button
58 + variant="ghost"
59 + size="xs"
60 + onClick={() => setDismissed((current) => [...current, environmentId])}
61 + >
62 Dismiss
63 </Button>
64 </div>
65 }
66 />
57 - </SettingsGroup>
67 + ))}
68 </SettingsSection>
69 );
70 }
apps/web/src/components/settings/StorageSettings.tsx
+6 -11
@@ -491,19 +491,14 @@ export function StorageSettingsPanel() {
491
492 return (
493 <SettingsPageContainer>
494 - {!isProjectScope &&
495 - connectedEnvironments
496 - .filter(
494 + {!isProjectScope && (
495 + <DatabaseStorageNotice
496 + environments={connectedEnvironments.filter(
497 (environment) =>
498 environment.serverConfig?.environment.capabilities.databaseStorage === true,
499 - )
500 - .map((environment) => (
501 - <DatabaseStorageNotice
502 - key={environment.environmentId}
503 - environmentId={environment.environmentId}
504 - label={environment.label}
505 - />
506 - ))}
499 + )}
500 + />
501 + )}
502 <SettingsSection id="storage-worktrees" title="Worktrees">
503 {!isProjectScope && <WorktreesDirectoryRow />}
504 {isProjectScope && (
packages/client-runtime/src/state/server.ts
+31 -5
@@ -6,6 +6,7 @@ import {
6 type ServerLifecycleStreamReadyEvent,
7 type ServerSelfUpdateProgressEvent,
8 type ServerSelfUpdateResult,
9 + shouldRecommendDatabaseCompaction,
10 WS_METHODS,
11 } from "@t3tools/contracts";
12 import * as Cause from "effect/Cause";
@@ -954,6 +955,34 @@ export function createServerEnvironmentAtoms<R, E>(
955 : AsyncResult.success(result.value, result);
956 }).pipe(Atom.withLabel(`environment-data:server:welcome:${environmentId}`)),
957 );
958 + const databaseStorage = createEnvironmentRpcSubscriptionAtomFamily(runtime, {
959 + label: "environment-data:server:database-storage",
960 + tag: WS_METHODS.serverGetDatabaseStorage,
961 + idleTtlMs: 0,
962 + });
963 + // Keyed by a JSON array of environment ids so one notice can list every machine.
964 + const databaseCompactionRecommendations = Atom.family((environmentIdsKey: string) => {
965 + const sources = (JSON.parse(environmentIdsKey) as EnvironmentId[]).map((environmentId) => ({
966 + environmentId,
967 + atom: databaseStorage({ environmentId, input: {} }),
968 + }));
969 + return Atom.make((get) =>
970 + sources
971 + .flatMap(({ environmentId, atom }) => {
972 + const result = get(atom);
973 + return result._tag === "Success" &&
974 + result.value !== null &&
975 + shouldRecommendDatabaseCompaction(result.value)
976 + ? [{ environmentId, status: result.value }]
977 + : [];
978 + })
979 + .sort((left, right) => right.status.reclaimableBytes - left.status.reclaimableBytes),
980 + ).pipe(
981 + Atom.withLabel(
982 + `environment-data:server:database-compaction-recommendations:${environmentIdsKey}`,
983 + ),
984 + );
985 + });
986 const welcome = (target: {
987 readonly environmentId: EnvironmentId;
988 readonly input: EnvironmentRpcInput<typeof WS_METHODS.subscribeServerLifecycle>;
@@ -972,11 +1001,8 @@ export function createServerEnvironmentAtoms<R, E>(
1001 tag: WS_METHODS.serverRunStorageCleanup,
1002 concurrency: { mode: "singleFlight", key: ({ environmentId }) => environmentId },
1003 }),
975 - databaseStorage: createEnvironmentRpcSubscriptionAtomFamily(runtime, {
976 - label: "environment-data:server:database-storage",
977 - tag: WS_METHODS.serverGetDatabaseStorage,
978 - idleTtlMs: 0,
979 - }),
1004 + databaseStorage,
1005 + databaseCompactionRecommendations,
1006 storageCleanupReport: createEnvironmentRpcSubscriptionAtomFamily(runtime, {
1007 label: "environment-data:server:storage-cleanup-report",
1008 tag: WS_METHODS.serverGetStorageCleanupReport,