Skip to content

Open worktree sessions in matching VS Code windows - #26

Merged
foundev merged 2 commits into
masterfrom
agent/worktree-editor-handoff
Jul 28, 2026
Merged

Open worktree sessions in matching VS Code windows#26
foundev merged 2 commits into
masterfrom
agent/worktree-editor-handoff

Conversation

@foundev

@foundev foundev commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • default the new-session screen to a new isolated Git worktree while keeping the shared current checkout as an explicit option
  • make the picker copy and primary action state exactly where the agent will run
  • launch the ACP host against the selected worktree and automatically open that same path in a new VS Code window
  • apply the editor handoff to newly created, reused, resumed, and relinked worktree sessions
  • route the command-palette Connect action through the setup screen instead of silently starting in the root checkout
  • preserve the agent connection and show actionable feedback if VS Code cannot open the editor window
  • update the README and unreleased changelog

Root cause

The worktree plumbing correctly passed a selected checkout through the Rust host, ACP lifecycle requests, filesystem/terminal boundary, and persisted session record. However, the start screen defaulted to Current workspace, the command-palette path bypassed the working-directory choice entirely, and opening the selected worktree in VS Code required a small manual action. It was therefore easy to start both the editor and agent in the repository root and conclude that worktree support had not taken effect.

Runtime evidence

Before this change, the active Mjolnir session was persisted with cwd: $HOME/code/mjolnir and no worktree metadata, and its bundled Anvil process had that same live process cwd. A separate sharp-grove session was correctly persisted at $HOME/code/mjolnir/.brokk/worktrees/sharp-grove, confirming that the path handoff worked only when the non-default worktree option was explicitly selected.

Validation

  • rebased onto 97f6333 (fix duplicate streaming cursors (#25)), retaining both unreleased changelog entries and both webview regression suites
  • npx vitest run test/sessionStore.test.ts test/extension.test.ts test/webview.test.ts (37 tests)
  • npm test (51 TypeScript tests, 29 Rust tests, every production module above the per-file 80% gate, plus Markdown/layout/plan/lifecycle/packaging/release checks)
  • npm run package (Darwin ARM64 VSIX built successfully from the rebased source)
  • git diff --check origin/master...HEAD

The VSIX was packaged without installing, reloading, or controlling the active VS Code window.

@foundev
foundev force-pushed the agent/worktree-editor-handoff branch from d8ee2ce to 4cc785d Compare July 28, 2026 11:54
@foundev
foundev marked this pull request as ready for review July 28, 2026 11:56
@foundev

foundev commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

Live VS Code validation on macOS passed after commit 25ab67a: the new-session picker defaulted to Create an isolated worktree, VS Code opened keen-grove in a new window, Brokk ACP focused automatically with Anvil Ready and a usable composer, and both the bundled Anvil process cwd and persisted session cwd matched .brokk/worktrees/keen-grove. Full npm test and VSIX packaging also passed.

@foundev
foundev merged commit 97c1ada into master Jul 28, 2026
6 checks passed
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.

1 participant