Skip to content

[FEATURE]: worktree-based workspace switching with stash-based warp #36048

Closed as not planned

Description

@haxllo

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 workspace-level worktree support to the core workspace system: CLI commands (opencode worktree create|list|remove|reset) and TUI dialog integration that lets users switch between working copies via git worktree without leaving their current session.

why it matters

working on multiple branches simultaneously is a common workflow. Previously, users had to either:

  • Manually manage separate clones
  • Use git worktree externally and relaunch opencode
  • Stash/discard uncommitted work manually
    None of these preserve session continuity when switching context.

what i did

  • CLI: opencode worktree create|list|remove|reset commands
  • TUI: Warp dialog to switch between worktrees via stash-based git worktree
  • Core: Optional directory field on workspace, VCS stash/stashPop endpoints
  • UX: Status indicator, sidebar/footer worktree labels, auto-stash on leave + pop on return

Benefits

  • Switch branches without leaving your opencode session
  • No manual stash management auto stash on leave, auto-pop on return
  • No separate clones needed leverages git worktree
  • Workspace continuity: same project context, just different working tree

Activity

  1. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues and comment on how your request differs if it does.

  2. haxllo commented on Jul 15, 2026

    @haxllo
    Author

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues and comment on how your request differs if it does.

    #35525 is the same high-level need (workspace on different branch). #36048 adds the specific implementation design (worktree CLI subcommands + stash-based warp). My PR #36052 implements it. #35471 (CLI flag) and #33332 (configurability) are complementary, different approaches or extensions Not a duplicate.

    @jlongster

  3. prestonbrown commented on Aug 10, 2026

    @prestonbrown

    The current behavior is worth calling out explicitly because it's not just "no worktree support" — it's actively misleading. The sidebar git label is resolved once at launch against the workspace root (the launch directory), via git symbolic-ref --short HEAD. That command is itself worktree-aware, but it's only ever run in the launch dir. So when I start opencode in the main repo and then create/enter a worktree to do branch work, the sidebar stays pinned at projectname:main for the entire session even though git symbolic-ref in the worktree correctly returns feature/foo.

    The workflow we want this for: create the worktree from inside opencode, and have the sidebar reflect the tree the session is actually operating in. Today we launch opencode from the main repo and choose the launch directory up front, committing to it for the whole session. If opencode worktree create + the warp dialog move us between trees mid-session, the sidebar needs to follow, otherwise the label and the working tree disagree and the agent's mental model of "what branch am I on" comes from grepping git branch in bash output rather than the UI.

    +1 to the scope as proposed — the stash-on-warp semantics are the right call for preserving uncommitted state. The one piece I'd add to the acceptance criteria: the sidebar label (and any status-bar branch indicator) must re-resolve from the active worktree, not the launch dir, after every warp.

  4. github-actions commented on Oct 11, 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.

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