fix: clean up forked sessions after extraction and auto-dream#14
Merged
fix: clean up forked sessions after extraction and auto-dream#14
Conversation
opencode run --fork creates visible fork sessions that clutter the session list. Unlike Claude Code which runs extraction in-process with skipTranscript, the CLI wrapper must create real sessions. Snapshot the session list before running post-session tasks, diff afterward to find newly created fork sessions, and delete them via opencode session delete. Only deletes sessions matching the current project directory to avoid removing unrelated sessions.
kuitos
commented
Apr 9, 2026
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move session list snapshot/cleanup from run_post_session_tasks (spanning both extraction + auto-dream, ~minutes) into each individual function right around the opencode run --fork call. This shrinks the race window from minutes to milliseconds, preventing accidental deletion of a user's new interactive session started during background maintenance.
Check transcript line count before triggering post-session tasks. Sessions where the user opened the TUI and exited without interacting have at most 1 transcript line (empty user entry). Real sessions have 3+ lines (user + tool_use + tool_result at minimum). Adds session_has_conversation() that checks the transcript file and short-circuits when the session is trivially empty.
|
🎉 This PR is included in version 1.6.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
opencode run --forkwhich creates visible fork sessions that clutter the session list (e.g. "xxx (fork #1)")skipTranscript: true— no session artifact is created. Since we use CLI invocation, fork sessions are unavoidable.cleanup_forked_sessions()that snapshots the session list before tasks run, diffs afterward to find newly created sessions, and deletes them viaopencode session delete