Skip to content

feat(core): worktree-based workspace switching with stash-based warp#36052

Open
haxllo wants to merge 37 commits into
anomalyco:devfrom
haxllo:worktree-cli-tui
Open

feat(core): worktree-based workspace switching with stash-based warp#36052
haxllo wants to merge 37 commits into
anomalyco:devfrom
haxllo:worktree-cli-tui

Conversation

@haxllo

@haxllo haxllo commented Jul 9, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36048

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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?

  • Tested VCS stash/pop round-trips across worktree switches
  • Verified bootstrap handles missing VCS gracefully
  • Confirmed workspace remove deletes sessions (not just unlinks)
  • Updated existing dialog-workspace-create tests
  • Ran typecheck in packages/opencode, packages/tui (app/enterprise OOM failures are pre-existing)

Screenshots / recordings

Screenshot 2026-07-09 143319 Screenshot 2026-07-09 143345 Screenshot 2026-07-09 143402 Screenshot 2026-07-09 143703

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Related

Copilot AI review requested due to automatic review settings July 9, 2026 09:16
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title Worktree cli tui doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@haxllo haxllo changed the title Worktree cli tui feat(core): worktree CLI + TUI warp dialog Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 })
}),
@haxllo haxllo changed the title feat(core): worktree CLI + TUI warp dialog feat(core): worktree-based workspace switching with stash-based warp Jul 9, 2026
@haxllo haxllo force-pushed the worktree-cli-tui branch from 96868be to ed77575 Compare July 9, 2026 12:40
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
@haxllo haxllo marked this pull request as ready for review July 15, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants