Repository navigation
fix: remove abandoned preview session folders on startup - #6
Merged
Merged
Conversation
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
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_previewthat 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
npm test: 8/8;npm run lint: 0 problems🤖 Generated with Claude Code
https://claude.ai/code/session_01JBDmV8VxTwVxxpuC8NMG8y