feat(core): worktree-based workspace switching with stash-based warp#36052
Open
haxllo wants to merge 37 commits into
Open
feat(core): worktree-based workspace switching with stash-based warp#36052haxllo wants to merge 37 commits into
haxllo wants to merge 37 commits into
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds worktree-based workspace switching across the core workspace system, exposing it via new CLI worktree subcommands and enhancing the TUI warp dialog to better surface and manage worktree workspaces, including VCS stash/pop support.
Changes:
- Add CLI support for git worktrees (
opencode worktree create|list|remove|reset) and related core adapter updates. - Extend instance HTTP API + JS SDK for VCS stash/stash-pop and workspace warp/create payload updates.
- Update TUI workspace warp UX (workspace list/details, footer labels, directory display, bootstrap syncing).
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/tui/test/cli/cmd/tui/dialog-workspace-create.test.ts | Updates tests to validate workspace detail rendering (directory/details). |
| packages/tui/src/ui/dialog-select.tsx | Minor layout alignment tweak for dialog option rows. |
| packages/tui/src/routes/session/index.tsx | Ensures VCS branch state is synced when workspace changes. |
| packages/tui/src/feature-plugins/sidebar/footer.tsx | Adjusts footer path/branch display to rely on global path + VCS state. |
| packages/tui/src/feature-plugins/home/footer.tsx | Switches home footer directory display to the shared useDirectory() logic. |
| packages/tui/src/context/sync.tsx | Adds VCS fetch into bootstrap and uses syncKeepCurrent() for workspace syncing. |
| packages/tui/src/context/sdk.tsx | Starts workspace syncing unconditionally after event subscriptions are active. |
| packages/tui/src/context/project.tsx | Adds syncKeepCurrent() option to avoid clearing current workspace during certain syncs. |
| packages/tui/src/context/directory.ts | Changes directory label to prefer workspace name (or project root) + branch suffix. |
| packages/tui/src/component/prompt/workspace.tsx | Implements stash-based warp flow and supports naming new worktree workspaces. |
| packages/tui/src/component/prompt/index.tsx | Removes experimental flag gating and improves workspace-type labeling text. |
| packages/tui/src/component/dialog-workspace-create.tsx | Reworks warp dialog: full workspace list with details/gutter status and delete action; adds detail builder. |
| packages/tui/src/app.tsx | Removes the legacy “Manage workspaces” command entry. |
| packages/sdk/js/src/v2/gen/types.gen.ts | Updates generated types for VCS stash endpoints and workspace create/warp payloads. |
| packages/sdk/js/src/v2/gen/sdk.gen.ts | Adds generated JS SDK methods for VCS stash/stash-pop and updates workspace create/warp params. |
| packages/opencode/src/session/session.ts | Extends session setWorkspace to optionally persist a directory. |
| packages/opencode/src/server/routes/instance/httpapi/handlers/workspace.ts | Sets root-directory when warping to workspace root (id=null). |
| packages/opencode/src/server/routes/instance/httpapi/handlers/instance.ts | Adds instance HTTP handlers for VCS stash and stash-pop. |
| packages/opencode/src/server/routes/instance/httpapi/groups/workspace.ts | Extends warp payload schema (currently includes directory). |
| packages/opencode/src/server/routes/instance/httpapi/groups/instance.ts | Adds instance HTTP API endpoints for VCS stash and stash-pop. |
| packages/opencode/src/project/vcs.ts | Implements VCS stash and stashPop operations for git-backed projects. |
| packages/opencode/src/index.ts | Registers the new CLI worktree command. |
| packages/opencode/src/control-plane/workspace.ts | Adds optional workspace name on create and optional directory on session warp inputs; adjusts sync gating. |
| packages/opencode/src/control-plane/workspace-adapter-runtime.ts | Ensures adapter context has a workspaceID when creating a workspace. |
| packages/opencode/src/control-plane/adapters/worktree.ts | Renames the adapter and wires name/branch info into configured worktree workspaces. |
| packages/opencode/src/cli/cmd/worktree.ts | Introduces the new CLI command group for creating/listing/removing/resetting worktrees. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+113
to
+123
| if (warped) { | ||
| showNotice(workspace.name) | ||
| if (hasStashed && stashMsg) { | ||
| const popped = await sdk.client.vcs.stashPop({ message: stashMsg, workspace: sourceWorkspaceID }).catch(() => undefined) | ||
| if (!popped?.data) { | ||
| toast.show({ title: "Warp", message: "Failed to restore stashed changes", variant: "error" }) | ||
| } else { | ||
| toast.show({ title: "Warp", message: "Uncommitted changes restored", variant: "success" }) | ||
| } | ||
| } | ||
| } |
| import { useProject } from "../context/project" | ||
| import { useRoute } from "../context/route" | ||
| import { createMemo, createSignal, onMount } from "solid-js" | ||
| import { createEffect, createMemo, createSignal, onMount } from "solid-js" |
Comment on lines
14
to
+18
| export const WarpPayload = Schema.Struct({ | ||
| id: Schema.NullOr(Workspace.Info.fields.id), | ||
| sessionID: Workspace.SessionWarpInput.fields.sessionID, | ||
| copyChanges: Workspace.SessionWarpInput.fields.copyChanges, | ||
| directory: Workspace.SessionWarpInput.fields.directory, |
Comment on lines
+424
to
+428
| stash: Effect.fn("Vcs.stash")(function* (input: StashInput) { | ||
| const ctx = yield* InstanceState.context | ||
| if (ctx.project.vcs !== "git") return | ||
| yield* git.run(["stash", "push", "-m", input.message], { cwd: ctx.directory }) | ||
| }), |
CreatorGhost
added a commit
to CreatorGhost/TheCode
that referenced
this pull request
Jul 12, 2026
Ported from upstream anomalyco#36052.
1 task
…dd error handling
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.
Issue for this PR
Closes #36048
Type of change
What does this PR do?
Adds worktree-based workspace switching to core workspace system. CLI subcommands (
opencode worktree create|list|remove|reset) and TUI warp dialog let users switch between git worktrees without leaving their session. Stash-based warp auto-stashes on leave, auto-pops on return. Status indicator, sidebar/footer labels show linked worktree name.How did you verify your code works?
Screenshots / recordings
Checklist
Related