[PR #12856] feat: bugfix to snapshot pruning and allow snapshot config to accept positive integer for retention lifespan in days (resolves #10626, #10782, #6845, #3182, #10532) #14404

Open
opened 2026-02-16 18:19:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12856

State: open
Merged: No


What does this PR do?

This PR corrects a bug in the current snapshot pruning implementation where old snapshots' directories are not being properly pruned: currently only individual objects inside the snapshot are pruned after their exceeds the retention time limit, not the folders in their entirety. This PR ensures that expired snapshots' folders are correctly pruned.

Additionally, this PR allows for the value of the snapshot setting in opencode.json to be either a boolean value (as is the case currently) or a positive integer controlling how many days snapshots should be retained for. A value of 0 is treated equivelantly to "snapshot": false, disabling the snapshots feature entirely.

This feature will allow users to better control how much space is ultimately used by OpenCode for the storage of snapshots.

Tests are included to make sure that valid configuration values for snapshot are parsed correctly.

Resolves #10626.
Resolves #10782.
Resolves #6845.
Resolves #3182.
Resolves #10532.

This feature should also provide a means to mitigate numerous other issues involving complaints about a huge snapshot folder consuming excessive disk space.

Note: Pull request re-created after the original PR (#10628) was accidentally clobbered by a bad merge from upstream/dev.

How did you verify your code works?

Manual testing plus bun test and bun typecheck: no new failing tests introduced relative to the current HEAD of dev. Dogfooding: I have been using this in my own fork since the original PR's (#10628) time of submission and it does appear to be working exactly as it was designed to. Yay!

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12856 **State:** open **Merged:** No --- ### What does this PR do? This PR corrects a bug in the current snapshot pruning implementation where old snapshots' directories are not being properly pruned: currently only individual objects inside the snapshot are pruned after their exceeds the retention time limit, not the folders in their entirety. This PR ensures that expired snapshots' folders are correctly pruned. Additionally, this PR allows for the value of the `snapshot` setting in `opencode.json` to be either a boolean value (as is the case currently) _or_ a positive integer controlling how many days snapshots should be retained for. A value of 0 is treated equivelantly to `"snapshot": false`, disabling the snapshots feature entirely. This feature will allow users to better control how much space is ultimately used by OpenCode for the storage of snapshots. Tests are included to make sure that valid configuration values for `snapshot` are parsed correctly. Resolves #10626. Resolves #10782. Resolves #6845. Resolves #3182. Resolves #10532. This feature should also provide a means to mitigate numerous other issues involving complaints about a huge snapshot folder consuming excessive disk space. **Note**: Pull request re-created after the original PR (#10628) was accidentally clobbered by a bad merge from upstream/dev. ### How did you verify your code works? Manual testing plus `bun test` and `bun typecheck`: no new failing tests introduced relative to the current HEAD of dev. Dogfooding: I have been using this in my own fork since the original PR's (#10628) time of submission and it does appear to be working exactly as it was designed to. Yay!
yindo added the pull-request label 2026-02-16 18:19:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14404