Skip to content

fix: remove abandoned preview session folders on startup - #6

Merged
cmaranes merged 1 commit into
mainfrom
fix/stale-preview-sessions
Oct 22, 2026
Merged

cmaranes merged 1 commit into
mainfrom
fix/stale-preview-sessions

Conversation

@cmaranes

@cmaranes cmaranes commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Replaces #5, which GitHub closed when its base branch (#4) was deleted after merging. Same commit, rebased onto main.

Problem

Each debug session writes its previews to .vscode/ply_preview/<session id>/, and the folder is deleted when the session terminates. If VS Code exits while a session is still running, the terminate event never fires, so the folder is kept forever. This happened during the 0.1.0 manual check, and the leftover file broke the integration tests until #4.

Fix

On activation, the extension deletes session folders under .vscode/ply_preview that haven't been modified for more than 24 hours. Each removal is logged to the "ViewPLY Debug" output channel.

The 24-hour threshold leaves room for long debug sessions. The only remaining edge case: a second VS Code window, debugging the same workspace, that hasn't written a preview in over a day would lose its old files. That seems acceptable.

The cleanup is the exported function removeStaleSessionDirs(baseDir, maxAgeMs, now), so it's tested directly, independent of when the extension activates.

Test plan

  • New tests: only folders older than the threshold are removed (fresh folders and non-folder files are kept), and a missing preview folder is a no-op
  • npm test: 8/8; npm run lint: 0 problems
  • CI green on Linux, Windows and macOS after the rebase (no debugger retries needed)

🤖 Generated with Claude Code

https://claude.ai/code/session_01JBDmV8VxTwVxxpuC8NMG8y

Session folders under .vscode/ply_preview are deleted when the debug
session terminates, but they were kept forever when VS Code exited
while a session was still running. On activation, folders untouched
for more than a day are now removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JBDmV8VxTwVxxpuC8NMG8y
@cmaranes
cmaranes merged commit a5e1632 into main Oct 22, 2026
3 checks passed
@cmaranes
cmaranes deleted the fix/stale-preview-sessions branch October 22, 2026 16:48
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.

1 participant