-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
(Happy to open PR if feature idea is good)
Problem
I've been wanting to use multiple worktrees with Opencode, to reach a similar ease-of-workflow as https://conductor.build supports for Claude Code.
Opencode can almost get there - I can create worktree for a task like a ticket, then start opencode in that worktree.
But the biggest challenge is coming back later to continue the work. I have to either keep track of tons of opencode worktrees, always cd in then start opencode to come back to the correct worktree each time, and I don't get a smooth list anywhere of all recent worktree-sessions.
Solution
I think a great solution to this would be twofold:
- Add configuration for a project to set one "root folder" to capture all sessions from all subfolders.
- This means if I set a project's 'session root' to /home/my-app, then running opencode anywhere within my-app/** would capture one master session list at
/home/my-app.
- Then, add "cwd" metadata to each session in the list. Then when switching sessions have opencode switch to that session's cwd automatically.
Then if I started a session under my-app/worktree/feature-a, I could later find it by running opencode anywhere under my-app - then I select feature-a's session and it cd's into worktree/feature-a for me and I can continue working.
Then when I'm ready, I just switch over to feature-b seamlessly via /sessions, without even closing opencode or cd-ing in the terminal.
This would make /sessions effectively be the index of all my open work in all my worktrees, and allow this multi-task multi-folder workflow.
Followup
After this feature, the follow-up feature is the ability to have opencode change its own working directory via its own api. Then I could for example tell it
"{task description}
create a git worktree for this task, then change the current session's cwd to that worktree's folder
And opencode would create the worktree, move the session into the worktree's folder for me, and switch to it.
Then I could finally create a subagent to start up new worktree-sessions for me easily