Skip to content

[FEATURE]: Add session migration dialog to recover orphaned or misplaced sessions #23249

Description

@sim590

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Add a TUI dialog that allows users to migrate sessions between projects. This serves three main use cases:

  1. Recovering orphaned sessions — When a project directory is renamed or moved (Sessions become orphaned when project directory is renamed #23248, Session lookup fails with NotFoundError when PTY spawned from non-git directory context #8538), sessions become invisible because their directory field points to a path that no longer exists. The migration dialog shows all sessions across all projects, marks orphaned ones with a visual indicator, and allows moving them to the correct project.

  2. Intentionally migrating sessions between projects — When work was started in the wrong project, users can move the session (with its full conversation history) to another project rather than starting over.

  3. Deleting orphaned sessions — Since orphaned sessions don't appear in the normal /sessions list, there is currently no way to delete them. The migration dialog provides access to these sessions for deletion.

Proposed solution:

  • A new "Migrate Session" dialog accessible via ctrl+o from the session list
  • The dialog shows all sessions across all projects, grouped by project
  • Orphaned sessions are marked with a ! indicator in the gutter
  • Selecting a session opens a destination picker (current project, home directory, or any known project)
  • ctrl+d allows deleting sessions (with double-press confirmation)
  • New server routes GET /session/orphans and POST /session/:sessionID/migrate

Note: this does not fix the root cause of orphaned sessions (#23248). An automatic fix in fromDirectory() would still be valuable.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 18, 2026
  2. rektide commented on Apr 28, 2026

    @rektide
    Contributor

    One additional wrinkle, that perhaps deserves it's own ticket: opencode session list will show sessions that opencode tui will not show. The TUI requires both the session's project-id to match and the directory to match, where-as the cli only requires one (I think the directory?). The inconsistency can be confusing.

    I've tackled this on the cli with #24728. One thing I like about my cli work: I can very quickly mass-target sessions for moving, using directories (with wildcard support!) (or project id or session id). As someone who has a lot of jj workspaces, and often a lot of sessions in each, my cli PR should let me quickly move a lot of sessions with ease. I'd love to have both good cli tools, and good tui tools. In #24726 we also started to see some api tools as well, which is another important leg of the session management triangle/polygon.

  3. sim590 commented on Apr 28, 2026

    @sim590
    Author

    Hi! I'm the author of #23250 (the TUI migration dialog). I noticed there are now three PRs tackling session migration from different angles:

    There's significant overlap on the backend side between #23250 and #24726: same API paths, same functions (listOrphans, migrate). Since #24726 already reimplements the backend using Effect Service (which is more idiomatic with the project's conventions), I'd be happy to drop the backend portion of #23250 and rebase my TUI dialog on top of that instead.

    I also want to acknowledge @rektide's points about bulk migration with wildcard support and the --dry-run workflow. Those are valid use cases that the backend API should probably accommodate. It would be worth agreeing on a shared backend implementation that serves all three surfaces (TUI, CLI, and bulk operations) before we move forward independently.

    Let's keep the discussion here on this issue rather than spreading it across the individual PRs, so we can converge on a unified approach.

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. sim590 commented on May 18, 2026

    @sim590
    Author

    @kitlangton Heads up: this issue now has three open PRs (#23250, #24726, #24728) with overlapping backend implementations. We're trying to coordinate here to avoid duplicating work. Would appreciate your input on which direction to take for the backend so we can align our efforts.

    Also, #23250 was automatically closed by the cleanup bot (not enough reactions, never reviewed). I've left a comment requesting it be reopened. It's the only PR that provides the TUI dialog for session migration, which the other two PRs intentionally leave out.

  6. github-actions commented on Jul 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  7. sim590 commented on Aug 26, 2026

    @sim590
    Author

    Anybody interested in this feature can lookup the plugin where I moved the implementation of #23250:

    https://github.com/sim590/opencode-session-migrate

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions