fix(session): clean up orphaned artifact directories when pruning excess sessions in enforceSessionLimits (#1345) - #1363
Conversation
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 — 🟠 important · The bug described in issue #1345 is already fixed in the base codebase. 🟠 important · The changeset body ( 🔴 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 |
Fixes #1345.
When the number of saved sessions exceeds
maxSessions,enforceSessionLimitsunlinks excess session.jsonfiles and removes them fromsessions.json. This change verifies and tests thatthis.artifacts.deleteSessionArtifacts(session.id)is properly invoked so that orphaned session artifact directories (plans, walkthroughs, task lists) are deleted alongside pruned sessions.Changes
source/session/session-manager.spec.tswith a dedicated test that configuresmaxSessions: 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/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)