Skip to content

[Bug]: No project scratch folders with any file never expire unless the global keep rule also deletes untracked files in worktrees #39374

Closed as not planned

Description

@ryoppippi

Note

🤖 Claude Opus 5.5 responding on behalf of ryoppippi

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

  1. Keep the default worktree keep rule (worktreeKeepWhen: "uncommitted-changes") and set worktreeAfterDays: 7.
  2. Use No project threads; the agent writes any file into its ~/.t3/scratch/<name> folder.
  3. Leave the threads idle well past 7 days and let the sweep run.

Expected behavior

Idle scratch folders expire after a retention of their own, without changing how worktrees are kept — for example a separate scratchAfterDays (and its own keep rule), still respecting threads with enabled scheduled tasks as #36369 does.

Actual behavior

Since #36369, scratchKeepReason keeps every scratch folder holding anything besides node_modules unless worktreeKeepWhen is "tracked-changes". Nearly every No project thread writes a file, so in practice the folders never expire: here 31 folders from the past month remain (8.5 GiB), and the sweep has removed a single folder.

The only way to expire them is switching the global keep rule to "Edited tracked files", which also lets cleanup delete untracked files in real worktrees. Scratch and worktrees need different rules: a worktree's untracked files are often in-progress work, while a scratch folder is throwaway by design.

Impact

Minor bug or occasional failure. Disk use grows without bound for heavy No project users, with no safe setting to stop it.

Version or commit

0.1.10-nightly.20261116.4774

Environment

macOS, T3 Code (Nightly) desktop app

Workaround

Deleting old folders under ~/.t3/scratch by hand.

Activity

  1. ryoppippi commented on Nov 19, 2026

    @ryoppippi
    Author

    Note

    🤖 Claude Opus 5.5 responding on behalf of ryoppippi

    Closing: there is a safe setting after all. No project can be selected under Settings → Worktrees → Cleanup and set to Custom, and cleanWorktrees resolves rules per thread via resolveWorktreeCleanup(serverSettings, thread.projectId), so scratch folders can use Edited tracked files with their own retention while every other project keeps Uncommitted changes.

    I missed that the per-project override also covers the scratch project; docs/user/project-settings.md does not mention it, which may be worth a line there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions