Skip to content

fix: clean up forked sessions after extraction and auto-dream#14

Merged
kuitos merged 7 commits intomainfrom
session-fork
Apr 9, 2026
Merged

fix: clean up forked sessions after extraction and auto-dream#14
kuitos merged 7 commits intomainfrom
session-fork

Conversation

@kuitos
Copy link
Copy Markdown
Owner

@kuitos kuitos commented Apr 9, 2026

Summary

  • Post-session extraction/auto-dream uses opencode run --fork which creates visible fork sessions that clutter the session list (e.g. "xxx (fork #1)")
  • Claude Code avoids this by running extraction in-process with skipTranscript: true — no session artifact is created. Since we use CLI invocation, fork sessions are unavoidable.
  • Added cleanup_forked_sessions() that snapshots the session list before tasks run, diffs afterward to find newly created sessions, and deletes them via opencode session delete
  • Safety: only deletes sessions matching the current project directory to prevent removing unrelated concurrent sessions

kuitos added 4 commits April 8, 2026 20:14
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.
Comment thread package.json Outdated
@kuitos kuitos requested a review from Copilot April 9, 2026 07:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

kuitos added 2 commits April 9, 2026 16:59
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.
@kuitos kuitos merged commit 26f3d7b into main Apr 9, 2026
1 check passed
@kuitos kuitos deleted the session-fork branch April 9, 2026 09:29
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

🎉 This PR is included in version 1.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants