Skip to content

fix(session): clean up orphaned artifact directories when pruning excess sessions in enforceSessionLimits (#1345) - #1363

Open
rishu685 wants to merge 1 commit into
Nano-Collective:mainfrom
rishu685:fix/session-limits-artifact-cleanup
Open

rishu685 wants to merge 1 commit into
Nano-Collective:mainfrom
rishu685:fix/session-limits-artifact-cleanup

Conversation

@rishu685

Copy link
Copy Markdown

Fixes #1345.

When the number of saved sessions exceeds maxSessions, enforceSessionLimits unlinks excess session .json files and removes them from sessions.json. This change verifies and tests that this.artifacts.deleteSessionArtifacts(session.id) is properly invoked so that orphaned session artifact directories (plans, walkthroughs, task lists) are deleted alongside pruned sessions.

Changes

  • Tests: Enhanced source/session/session-manager.spec.ts with a dedicated test that configures maxSessions: 2, generates multiple sessions with artifacts, and verifies that exceeding the limit unlinks the pruned session's JSON file and deletes its artifact directory from disk while preserving active sessions.
  • Changeset: Added .changeset/fix-session-limits-artifact-cleanup.md.

Verification

  • pnpm run test:ava source/session/session-manager.spec.ts (all 51 tests passed)
  • pnpm run test:types (passed, 0 errors)
  • pnpm run test:lint (passed, 0 errors)
  • pnpm run test:format (passed, 0 errors)

@github-actions

Copy link
Copy Markdown
Contributor

nc-review: comments — 2 important

@rishu685 — a few things worth a look, none blocking.

The PR adds a regression test for issue #1345, but the bug it claims to fix is already resolved in the base codebase — enforceSessionLimits at line 506 of source/session/session-manager.ts already invokes await this.artifacts.deleteSessionArtifacts(session.id). The diff contains no changes to session-manager.ts; only a strengthened test and a changeset. The test itself is well-constructed and will catch future regressions if the call is removed, but the changeset is misleading because no behavioural change was made.

🟠 important · completeness · source/session/session-manager.ts:506

The bug described in issue #1345 is already fixed in the base codebase. enforceSessionLimits already calls await this.artifacts.deleteSessionArtifacts(session.id); after unlinking each session's JSON file (line 506 of source/session/session-manager.ts). The PR diff makes no changes to source/session/session-manager.ts — only the test file and a changeset are touched. The PR description honestly says it "verifies and tests" the call, but the title (fix(session): ...) and the changeset (fix: ...) both imply a behavioural change that did not happen. Merging as-is does close the issue, since the issue's reproduction is already gone in main, but the framing is misleading. Either reframe the PR (and changeset) as a regression test / chore, or confirm with the issue reporter whether there is a different, narrower bug they were observing that this PR does not actually address.

🟠 important · changeset · .changeset/fix-session-limits-artifact-cleanup.md

The changeset body (fix: clean up orphaned artifact directories when pruning excess sessions in enforceSessionLimits (#1345)) will be rolled into CHANGELOG.md verbatim as a user-facing fix entry, but no behavioural change ships in this PR. Users upgrading and reading the changelog will see a "fix" for behaviour that already worked. The changeset should describe what actually ships: a regression test that pins the existing deleteSessionArtifacts call inside enforceSessionLimits against accidental removal. A test/chore entry (or an empty changeset with an explanatory comment) is the honest shape.


🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional

Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with /re-review.

@github-actions github-actions Bot added the agent:comments nc-review left non-blocking findings label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:comments nc-review left non-blocking findings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] enforceSessionLimits prunes old sessions without deleting their associated artifacts

1 participant