Repository navigation
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
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.
| 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 { useSync } from "../context/sync" | ||
| 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" |
| @@ -15,6 +15,7 @@ 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, | |||
| 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 }) | ||
| }), |
Ported from upstream anomalyco#36052.
…dd error handling
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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