Skip to content

fix(sessions): preserve populated sessions during automatic cleanup - #755

Merged
pascalandr merged 1 commit into
devfrom
fix/blank-session-cleanup
Sep 23, 2026
Merged

pascalandr merged 1 commit into
devfrom
fix/blank-session-cleanup

Conversation

@pascalandr

Copy link
Copy Markdown
Contributor

Closes #754.

I reproduced real native data loss: creating another session deleted a populated conversation because its cached creation and update timestamps still matched.

I replaced that heuristic with fresh native content checks. Automatic cleanup preserves local drafts and attachments, pending activity, queued input and child sessions. Failed or stale checks do not authorize deletion. The explicitly confirmed deep-clean command keeps its separate policy.

I moved automatic cleanup off the creation/first-send critical path and coalesced overlapping sweeps per connection.

Validation

  • 157 targeted tests pass, including 40 cleanup regressions.
  • The isolated native fixture fails on the baseline and passes on OpenCode 2.0.7 and 2.0.14.
  • UI and Electron typechecks, workflow YAML validation and diff checks pass.
  • I added cleanup regressions and the native fixture to CI.

Review

I ran two independent gatekeeper rounds. The first found a responsiveness issue in the historical scan; I fixed it and added a stalled-read/first-send regression. The second reported zero findings.

CI status is tracked below; the validation results above are local.

Prevent creating a new conversation from deleting populated sessions whose cached creation and update timestamps still match. Automatic cleanup now checks fresh, unfiltered native messages and preserves drafts, attachments, pending activity, queued input and child sessions. Failed or obsolete reads never authorize deletion, and the message check is refreshed before dispatch.

Run automatic cleanup outside the creation and first-send critical path. Coalesce sweeps per connection, capture candidates synchronously, and fence reconnects and local activity. Keep the explicitly confirmed deep-clean policy separate and count only successful deletions.

Add 40 cleanup regressions and an isolated native fixture to minimum/latest runtime CI. The fixture reproduces native data loss on the baseline and passes on OpenCode 2.0.7 and 2.0.14. All 157 targeted tests and UI/Electron typechecks pass. Two independent gatekeeper rounds concluded with zero findings after fixing the historical-scan responsiveness issue.
@pascalandr

Copy link
Copy Markdown
Contributor Author

I am admin-merging the reviewed 4d33c5e head after the local validation and zero-finding gatekeeper review recorded above. The full GitHub Actions run is still in progress: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/35845489242. I am not treating pending CI checks as passed.

@pascalandr
pascalandr merged commit f26d92c into dev Sep 23, 2026
8 of 14 checks passed
@pascalandr
pascalandr deleted the fix/blank-session-cleanup branch September 23, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Creating a new session deletes non-empty sessions when “Auto-cleanup blank sessions” is enabled

1 participant