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 22, 23:15 UTC
fix(web): identify cleanup results by machine and folder (#20211)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Kolja committed
Oct 20, 2026 at 06:26 UTC
5803c8b299da822afa93f35b0d3315b7566ee84f
5 files changed
+74
-20
apps/server/src/storageCleanup.test.ts
+12
-4
@@ -896,6 +896,7 @@ describe("orphan worktree reports", () => {
896
outcome: "kept",
897
reason: "No thread uses this worktree",
898
path: orphan,
899
+ projectPath: null,
900
threadId: null,
901
threadTitle: null,
902
bytes: sizes.reduce((sum, size) => sum + size, 0),
@@ -1472,7 +1473,7 @@ describe("storage cleanup reports and local file policies", () => {
1473
it.live("compares the checked-out branch without a full status", () =>
1474
runCleanupTest(
1475
Effect.gen(function* () {
1475
- const { service, fs, worktree, command, setThreads, fullStatusCalls } =
1476
+ const { service, fs, repo, worktree, command, setThreads, fullStatusCalls } =
1477
yield* cleanupFixture();
1478
const changed = { outcome: "kept", reason: "Repository or branch changed" };
1479
yield* command(worktree, ["checkout", "--detach"]);
@@ -1490,8 +1491,15 @@ describe("storage cleanup reports and local file policies", () => {
1491
const index = (yield* command(worktree, ["rev-parse", "--git-path", "index"])).stdout;
1492
yield* fs.writeFileString(`${index.trim()}.lock`, "");
1493
const locked = (yield* service.runNow).entries[0];
1493
- expect(locked).toMatchObject({ outcome: "failed" });
1494
+ expect(locked).toMatchObject({
1495
+ outcome: "failed",
1496
+ projectPath: repo,
1497
+ path: worktree,
1498
+ threadId: "thread-1",
1499
+ threadTitle: "Thread",
1500
+ });
1501
expect(locked?.reason).toContain("Git index is locked");
1502
+ expect(yield* fs.readFileString(`${worktree}/tracked.txt`)).toBe("original\n");
1503
yield* fs.remove(`${index.trim()}.lock`);
1504
const gitFile = yield* fs.readFileString(`${worktree}/.git`);
1505
yield* fs.writeFileString(`${worktree}/.git`, "gitdir: /missing-git-directory\n");
@@ -1502,7 +1510,7 @@ describe("storage cleanup reports and local file policies", () => {
1510
}),
1511
),
1512
);
1505
- it("decodes reports from servers without size fields", () => {
1513
+ it("decodes reports from servers without size or project fields", () => {
1514
const report = decodeCleanupReport({
1515
trigger: "manual",
1516
startedAt: "2026-06-10T12:00:00.000Z",
@@ -1521,7 +1529,7 @@ describe("storage cleanup reports and local file policies", () => {
1529
omittedCount: 0,
1530
});
1531
expect(report.bytesFreed).toBe(0);
1524
- expect(report.entries[0]).toMatchObject({ bytes: null, files: null });
1532
+ expect(report.entries[0]).toMatchObject({ bytes: null, files: null, projectPath: null });
1533
});
1534
it.live.each([
1535
["any-local-files", ".env", "kept"],
apps/server/src/storageCleanup.ts
+5
@@ -414,6 +414,7 @@ const make = Effect.gen(function* () {
414
? "No thread uses this worktree"
415
: "No thread uses this folder, and it isn't a git worktree",
416
path: worktreePath,
417
+ projectPath: null,
418
threadId: null,
419
threadTitle: null,
420
bytes,
@@ -616,6 +617,7 @@ const make = Effect.gen(function* () {
617
outcome: "kept",
618
reason: "",
619
path: worktreePath,
620
+ projectPath: project?.workspaceRoot ?? null,
621
threadId: thread.id,
622
threadTitle: thread.title,
623
bytes: null,
@@ -947,6 +949,7 @@ const make = Effect.gen(function* () {
949
outcome: "failed",
950
reason: cleanupFailureReason(error),
951
path: null,
952
+ projectPath: null,
953
threadId: null,
954
threadTitle: null,
955
bytes: null,
@@ -979,6 +982,7 @@ const make = Effect.gen(function* () {
982
outcome: files > 0 ? "removed" : "kept",
983
reason: files === 0 ? "No expired files" : `Removed ${files} ${category.label}`,
984
path: null,
985
+ projectPath: null,
986
threadId: null,
987
threadTitle: null,
988
bytes: files > 0 ? bytes : null,
@@ -992,6 +996,7 @@ const make = Effect.gen(function* () {
996
outcome: "failed",
997
reason: cleanupFailureReason(error),
998
path: null,
999
+ projectPath: null,
1000
threadId: null,
1001
threadTitle: null,
1002
bytes: removed.files > 0 ? removed.bytes : null,
apps/web/src/components/settings/StorageSettings.browser.test.tsx
+25
-5
@@ -8,6 +8,7 @@ import {
8
import { act, type ReactNode } from "react";
9
import { createRoot, type Root } from "react-dom/client";
10
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
11
+import { page } from "vite-plus/test/browser";
12
13
const state = vi.hoisted(() => ({
14
settings: {} as typeof DEFAULT_SERVER_SETTINGS,
@@ -41,7 +42,7 @@ vi.mock(import("./SettingsScopeContext"), async (original) => ({
42
useSettingsScope: (() => {
43
const environment = {
44
environmentId: "env",
44
- label: "Machine",
45
+ label: "Build workstation",
46
serverConfig: {
47
settings: state.settings,
48
environment: {
@@ -188,7 +189,7 @@ it("keeps cleanup disabled when settled retention and all other rules are off",
189
expect(state.run).not.toHaveBeenCalled();
190
});
191
191
-it("shows an orphan's full path and size while keeping thread row titles unchanged", async () => {
192
+it("shows orphan sizes and identifies failed worktrees with one connected machine", async () => {
193
state.settings = {
194
...state.settings,
195
storageCleanup: { ...state.settings.storageCleanup, worktreeSettledAfterDays: 0 },
@@ -202,6 +203,7 @@ it("shows an orphan's full path and size while keeping thread row titles unchang
203
kind: "worktree",
204
outcome: "kept",
205
path: "/worktrees/repo/orphan",
206
+ projectPath: null,
207
threadId: null,
208
threadTitle: null,
209
reason: "No thread uses this folder, and it isn't a git worktree",
@@ -210,16 +212,17 @@ it("shows an orphan's full path and size while keeping thread row titles unchang
212
},
213
{
214
kind: "worktree",
213
- outcome: "kept",
215
+ outcome: "failed",
216
path: "/worktrees/repo/thread-checkout",
217
+ projectPath: "/projects/repo",
218
threadId: ThreadId.make("thread"),
219
threadTitle: "Thread title",
217
- reason: "Thread is running or has pending work",
220
+ reason: "Git index is locked. Status will resume when the index lock is removed.",
221
bytes: null,
222
files: null,
223
},
224
],
222
- counts: { removed: 0, kept: 2, failed: 0 },
225
+ counts: { removed: 0, kept: 1, failed: 1 },
226
omittedCount: 0,
227
bytesFreed: 0,
228
};
@@ -231,6 +234,23 @@ it("shows an orphan's full path and size while keeping thread row titles unchang
234
const titles = Array.from(container.querySelectorAll("h3"), (heading) => heading.textContent);
235
expect(titles).toContain("/worktrees/repo/orphan");
236
expect(titles).toContain("thread-checkout");
237
+ const failedRow = page.elementLocator(
238
+ page.getByRole("heading", { name: "thread-checkout", exact: true }).element().parentElement!,
239
+ );
240
+ await expect.element(failedRow.getByText("Build workstation", { exact: true })).toBeVisible();
241
+ await expect.element(failedRow.getByText("/projects/repo", { exact: true })).toBeVisible();
242
+ await expect
243
+ .element(failedRow.getByText("/worktrees/repo/thread-checkout", { exact: true }))
244
+ .toBeVisible();
245
+ await expect.element(failedRow.getByText("Thread title", { exact: true })).toBeVisible();
246
+ await expect
247
+ .element(
248
+ failedRow.getByText(
249
+ "Git index is locked. Status will resume when the index lock is removed.",
250
+ { exact: true },
251
+ ),
252
+ )
253
+ .toBeVisible();
254
expect(titles).not.toContain("/worktrees/repo/thread-checkout");
255
expect(container.textContent).toContain(
256
"No thread uses this folder, and it isn't a git worktree",
apps/web/src/components/settings/StorageSettings.tsx
+31
-11
@@ -192,7 +192,7 @@ function CleanupResults({
192
environmentLabel,
193
}: {
194
report: StorageCleanupReport;
195
- environmentLabel: string | undefined;
195
+ environmentLabel: string;
196
}) {
197
return (
198
<>
@@ -208,13 +208,34 @@ function CleanupResults({
208
return (
209
<SettingsRow
210
key={`${entry.path ?? entry.kind}:${entry.threadId ?? index}`}
211
- title={environmentLabel ? `${environmentLabel}: ${name}` : name}
211
+ title={<span className="wrap-anywhere select-text">{name}</span>}
212
description={
213
- <span
214
- className={`wrap-anywhere ${entry.outcome === "failed" ? "text-destructive" : ""}`}
215
- >
216
- {entry.threadTitle && entry.threadTitle !== name ? `${entry.threadTitle}. ` : ""}
217
- {entry.reason}
213
+ <span className="block space-y-2 wrap-anywhere select-text">
214
+ <span className={`block ${entry.outcome === "failed" ? "text-destructive" : ""}`}>
215
+ {entry.reason}
216
+ </span>
217
+ <span className="grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-l border-border/60 pl-3">
218
+ <span>Machine</span>
219
+ <span className="text-foreground/80">{environmentLabel}</span>
220
+ {entry.projectPath && (
221
+ <>
222
+ <span>Project</span>
223
+ <code className="text-foreground/80">{entry.projectPath}</code>
224
+ </>
225
+ )}
226
+ {entry.path && (
227
+ <>
228
+ <span>Folder</span>
229
+ <code className="text-foreground/80">{entry.path}</code>
230
+ </>
231
+ )}
232
+ {entry.threadTitle && (
233
+ <>
234
+ <span>Thread</span>
235
+ <span>{entry.threadTitle}</span>
236
+ </>
237
+ )}
238
+ </span>
239
</span>
240
}
241
control={
@@ -237,13 +258,12 @@ function CleanupResults({
258
})}
259
{report.omittedCount > 0 && (
260
<p className="px-3 py-2.5 text-xs text-muted-foreground sm:px-4">
240
- {environmentLabel ? `${environmentLabel}: ` : ""}
241
- {report.omittedCount.toLocaleString()} more results.
261
+ {environmentLabel}: {report.omittedCount.toLocaleString()} more results.
262
</p>
263
)}
264
{report.entries.length === 0 && report.omittedCount === 0 && (
265
<p className="px-3 py-2.5 text-xs text-muted-foreground sm:px-4">
246
- {environmentLabel ? `${environmentLabel}: ` : ""}Nothing needed cleanup.
266
+ {environmentLabel}: Nothing needed cleanup.
267
</p>
268
)}
269
</>
@@ -392,7 +412,7 @@ function CleanupSection() {
412
<CleanupResults
413
key={environment.environmentId}
414
report={report}
395
- environmentLabel={connectedEnvironments.length > 1 ? label : undefined}
415
+ environmentLabel={label}
416
/>
417
),
418
)}
packages/contracts/src/settings.ts
+1
@@ -1053,6 +1053,7 @@ export const StorageCleanupReportEntry = Schema.Struct({
1053
outcome: Schema.Literals(["removed", "kept", "failed"]),
1054
reason: Schema.String,
1055
path: Schema.NullOr(Schema.String),
1056
+ projectPath: Schema.NullOr(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
1057
threadId: Schema.NullOr(ThreadId),
1058
threadTitle: Schema.NullOr(Schema.String),
1059
bytes: Schema.NullOr(Schema.Number).pipe(Schema.withDecodingDefault(Effect.succeed(null))),