Repository navigation
Closed
Closed
Copy link
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Enable a worktree cleanup rule.
- Create a Git worktree in the managed worktrees folder without attaching it to a thread.
- Put a large build artifact in a subfolder of the worktree.
- After the worktree is at least an hour old, run Delete now under Settings → Maintenance.
- Open Last run to see the size of the kept worktree.
- Delete the build artifact without moving the worktree.
- Run Delete now again.
Expected behavior
The new report shows how much space the worktree still takes up.
Actual behavior
The new report still shows the size from before the build artifact was deleted.
Impact
Minor bug or occasional failure. Anyone who frees space inside a previously reported orphan worktree can see its old size on subsequent runs while cleanup keeps reporting the same folder.
Version or commit
main at 94baff19c6. The cause is at apps/server/src/storageCleanup.ts:597.
Environment
Linux x64 boat.dev default machine, a fresh checkout.
Logs or stack traces
expected: text containing /\b\d+(?:\.\d+)? KB\b/Automated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/scripts/scenarios/orphan-worktree-cleanup-refreshes-size.e2e.ts b/scripts/scenarios/orphan-worktree-cleanup-refreshes-size.e2e.ts
new file mode 100644
index 0000000000..71be92aa13
--- /dev/null
+++ b/scripts/scenarios/orphan-worktree-cleanup-refreshes-size.e2e.ts
@@ -0,0 +1,74 @@
+import { randomBytes } from "node:crypto";
+import { expect } from "e2e";
+import * as Effect from "effect/Effect";
+import * as FileSystem from "effect/FileSystem";
+import * as Schema from "effect/Schema";
+
+import { T3_HOME } from "../e2e.config.ts";
+import { run } from "./shell.ts";
+import { runPromise, test, WEB } from "./t3.ts";
+
+const decodeSettings = Schema.decodeSync(
+ Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown)),
+);
+
+test(
+ "Cleanup updates the displayed size of a kept worktree",
+ WEB,
+ async ({ t3, app, browser, screen }) => {
+ const project = await t3.project("cleanup-size", { "README.md": "Example project" });
+ const settingsPath = `${T3_HOME}/userdata/settings.json`;
+ const original = await runPromise(
+ Effect.flatMap(FileSystem.FileSystem, (fs) => fs.readFileString(settingsPath)),
+ );
+ const worktree = `${T3_HOME}/worktrees/cleanup-size-orphan`;
+ const build = `${worktree}/build`;
+ const git = (...args: ReadonlyArray<string>) => runPromise(run("git", args, { cwd: project }));
+ await git("worktree", "add", "--detach", worktree, "HEAD");
+ try {
+ await runPromise(
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ yield* fs.makeDirectory(build);
+ yield* fs.writeFile(`${build}/bundle.js`, randomBytes(8 * 1024 * 1024));
+ yield* fs.utimes(worktree, 1, 1);
+ yield* fs.writeFileString(
+ settingsPath,
+ JSON.stringify({
+ ...decodeSettings(original),
+ storageCleanup: { worktreeOnDelete: true },
+ }),
+ );
+ }),
+ );
+
+ await t3.open("/settings/maintenance");
+ const runCleanup = screen.getByRole("button", "Delete now", { exact: true });
+ await runCleanup.tap();
+ await screen.getByRole("button", /^Last run/).tap();
+ await screen.getByText(/^8\.\d{2} MB$/).waitFor();
+
+ await runPromise(
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ yield* fs.remove(`${build}/bundle.js`);
+ }),
+ );
+ await runCleanup.tap();
+ await runCleanup.waitFor();
+ await screen.getByText("No thread uses this worktree", { exact: true }).scrollIntoView();
+ try {
+ await expect(browser.locator("#storage-cleanup-last-run")).toContainText(
+ /\b\d+(?:\.\d+)? KB\b/,
+ );
+ } finally {
+ await app.screenshot("kept-worktree-after-build-file-removal");
+ }
+ } finally {
+ await git("worktree", "remove", "--force", worktree);
+ await runPromise(
+ Effect.flatMap(FileSystem.FileSystem, (fs) => fs.writeFileString(settingsPath, original)),
+ );
+ }
+ },
+);pnpm scenarios:prove scripts/scenarios/orphan-worktree-cleanup-refreshes-size.e2e.ts --base mainWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.


Activity