Skip to content

feat(v2): manage session families across worktrees - #649

Open
pascalandr wants to merge 23 commits into
NeuralNomadsAI:DEV-v2from
pascalandr:v2/worktree-sessions
Open

feat(v2): manage session families across worktrees#649
pascalandr wants to merge 23 commits into
NeuralNomadsAI:DEV-v2from
pascalandr:v2/worktree-sessions

Conversation

@pascalandr

@pascalandr pascalandr commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • use native OpenCode V2 project/session APIs to inventory, move, verify, and roll back complete session families across Git worktrees
  • make physical worktree deletion transactional across logical workspaces and projects, including nested workspace folders
  • organize the session list by authoritative SessionInfo.location with complete pagination, worktree badges, sorting, filtering, and localized labels
  • add authorized Electron and Tauri actions to open verified worktree directories, with accessible actions outside selector options

This supersedes #642 with a native V2 implementation. #642 is intentionally left open and unchanged.

Updated V2 Contract

Merged DEV-v2@bce40b7f; PR HEAD is ab9f5d8c (1,889+/606-, 52 files).

  • complete project inventories and search use bounded native opaque-cursor pagination; continuation requests contain only the cursor
  • session moves are serialized and transactional across complete families with active-session blocking, asynchronous verification, and rollback
  • session.moved consumes the complete authoritative location/project payload and avoids speculative cross-workspace transfers
  • instance proxy session lists, active sessions, direct session routes, and location validation preserve native workspaceID authority
  • server/UI generated client dependencies resolve to 0.0.0-beta-18414; the independently updated CLI is validated through service/API compatibility rather than an exact version gate

Deletion Safety

  • physical checkout reservations block published and in-flight logical workspaces before Git removal
  • project-level serialization and WorktreeDeletionFence cover every source/destination worktree used by a family mutation
  • deletion inventories the full current project, rejects sessions from other native workspaces, then checks every other project inside the deletion fence
  • nested logical workspaces resolve back to the registered physical checkout so sibling project sessions cannot be deleted accidentally
  • Git registration, branch, HEAD, canonical path, and filesystem identity are revalidated immediately before removal; replacement checkouts fail closed
  • rollback runs only while the original worktree identity remains

UI Behavior

  • server responses remain authoritative after create, move, and delete; failed refreshes remain retryable and receive one immediate retry after successful mutations
  • non-activity sorting exhausts the bounded root cursor chain before sorting; server search traverses its complete bounded cursor chain
  • stale worktree filters clear after deletion or instance replacement
  • worktree copy/open/delete actions are keyboard-accessible controls outside Select.Item
  • added labels include every supported locale, including Turkish

Validation

  • server: 377 passed, 2 platform skips
  • runnable UI matrix: 304 passed
  • browser-conditioned UI matrix: 148 passed
  • Electron native matrix: 180 passed
  • desktop packaging invariants: 3 passed
  • focused final server/UI regressions: 18 and 45 passed
  • server, UI, Electron, and root TypeScript checks
  • production UI build and release build:tauri/NSIS package
  • git diff --check and conflict-marker scan

Residual Limit

OpenCode V2 and Git do not expose a shared snapshot/CAS transaction to external clients. CodeNomad fails closed and narrows races with reservations, project locks, deletion fences, and repeated authoritative checks; an unrelated process operating outside CodeNomad can still mutate Git or OpenCode state beyond those admission controls.

Use the shared OpenCode V2 service to inventory complete project session families and move them through the native session.move API. Serialize project operations, verify authoritative locations, and roll back only transaction-owned moves when failures occur.

Make worktree deletion transactional by evacuating inactive session families before Git removal. Strict NUL-delimited inventory checks, HEAD revalidation, physical-root workspace reservations, nested workspace projection, and cache invalidation prevent stale or in-use worktrees from being removed.

Cover cursor pagination, family resolution, rollback, deletion evacuation, nested logical roots, exact Git slug resolution, and workspace creation races. Validated with server typecheck and the full 237-test server suite.
Treat SessionInfo.location as the authoritative worktree assignment, load every project-scoped cursor page, and project complete session families for search, filtering, and activity/name/worktree sorting. Family moves now run through the server transaction and refresh from OpenCode instead of mutating local paths optimistically.

Show localized root and linked-worktree badges, preserve complete ancestry during filters, refresh worktrees and sessions after deletion, and apply the complete authoritative session.moved payload. Expose the desktop file-manager action only for local paths with keyboard support.

Add coverage for project query construction, path normalization, family projection, native move events, request authority, serialized family moves, and deletion refresh; register the new runnable tests in CI. Validated with UI typecheck, 35 affected CI-mode tests, and production builds.
Add desktop-only Electron and Tauri commands for revealing local worktree directories. Reuse the existing renderer token, origin, frame, and generation authority instead of introducing a separate bridge.

Reject relative, control, network, device, and non-directory targets before opening. Canonicalize inputs, require exact NUL-delimited Git inventory membership, constrain logical subdirectories beneath registered worktrees, and repeat authorization and inventory checks to narrow races.

Keep Electron and Tauri behavior aligned with targeted parser, validation, authorization, containment, and revalidation tests. Validated with Electron typecheck and 124/124 native tests plus cargo check and 87/87 Rust tests.
@pascalandr
pascalandr marked this pull request as ready for review August 17, 2026 08:27
Integrate the current native V2 routing, workspace controls, shared desktop opener, lifecycle hardening, and pruned validation matrix while removing the PR's duplicate Electron and Tauri file-manager bridges.

Inventory sessions through paginated native project filtering, move complete families transactionally, revalidate worktree path and HEAD immediately before deletion, and fail closed if a checkout is replaced. Preserve evacuated sessions at the safe root rather than rolling them into a replacement checkout.

Reduce feature tests to project pagination, family moves, rollback, active-session blocking, replacement races, route ownership, UI projection, and authoritative refresh. Server, UI, Electron, and Rust checks plus focused suites and diff checks pass; the full server matrix had one transient process timeout that passed alone.
Merge upstream DEV-v2 while retaining server-owned transactional worktree evacuation. The UI issues one deletion request and refreshes authoritative worktree and session state, avoiding partial client-cache-driven family moves; server deletion remains blocked whenever complete-family evacuation fails and rolls back transaction-owned moves.

Preserve the upstream native createData and cursor pagination contracts and the removal of forceNew canonical duplication. Validated with server and UI typechecks, focused server worktree transaction tests, focused UI browser integration and pagination tests, and git diff checks.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32199550180

Artifacts expire in 7 days.
Artifacts:

  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos-arm64
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-windows
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-windows

1 similar comment
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32199550180

Artifacts expire in 7 days.
Artifacts:

  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos-arm64
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-windows
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-macos
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-tauri-linux
  • pr-649-0d3bdd1a01d692da3063167b63ffb2813fca27cf-electron-windows

…60818

# Conflicts:
#	packages/server/src/server/routes/worktrees.test.ts
#	packages/server/src/server/routes/worktrees.ts
…60818

# Conflicts:
#	packages/server/src/server/routes/worktrees.ts
#	packages/server/src/workspaces/worktree-session-evacuation.test.ts
#	packages/server/src/workspaces/worktree-session-evacuation.ts
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32202206795

Artifacts expire in 7 days.
Artifacts:

  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos-arm64
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-windows
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-windows

1 similar comment
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32202206795

Artifacts expire in 7 days.
Artifacts:

  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-macos-arm64
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-windows
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-macos
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-tauri-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-linux
  • pr-649-912482341c4bc06e6a3def48debd6f814607c14d-electron-windows

# Conflicts:
#	packages/server/src/workspaces/worktree-session-evacuation.ts
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32215068777

Artifacts expire in 7 days.
Artifacts:

  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos-arm64
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-windows
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-windows

1 similar comment
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32215068777

Artifacts expire in 7 days.
Artifacts:

  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-macos
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-macos-arm64
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-linux
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-tauri-windows
  • pr-649-f7573d1b1f0bf6b399b815b3d17e40cdf9d55bdd-electron-windows

Translate host worktree paths into the OpenCode service namespace before project resolution, moves, and evacuation while retaining host paths for Git deletion and reservations. Publish serviceDirectory so WSL session grouping and filtering compare native locations correctly.

Reject malformed cursors, poll boundedly for move and rollback visibility, and recheck activity before each move and Git removal. Add malformed-cursor, delayed-visibility, concurrent-activation, and route regressions; validate server/UI/Electron typechecks, 18 focused tests, and diff cleanliness.
Resolve OpenCode targets from mirrored nested workspace paths while preserving physical roots for Git operations. Determine rollback ownership from per-session state and compare POSIX service paths with case-sensitive semantics on Windows hosts.

Add nested-route, stale-inventory rollback, and WSL case-sensitivity regressions; validate server typecheck, 20 focused tests, and diff cleanliness.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32226249423

Artifacts expire in 7 days.
Artifacts:

  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-linux
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-macos-arm64
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-macos
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-tauri-windows
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-electron-macos
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-electron-linux
  • pr-649-eeccf022aea2486eb574f7545572da2f61ff4a7c-electron-windows

@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/32262724562

Artifacts expire in 7 days.
Artifacts:

  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-macos
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-electron-macos
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-windows
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-macos-arm64
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-tauri-linux
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-electron-linux
  • pr-649-e4699a3a60aa03164ecd81989f2b8b4a0c3acd4d-electron-windows

Merge the latest DEV-v2 baseline and replace directory-local worktree session handling with complete native OpenCode V2 project inventories. Session families now move transactionally with opaque cursor pagination, active-session checks, authoritative verification, rollback, workspace scoping, and post-mutation refreshes.

Protect physical worktree deletion with workspace reservations, project-level serialization, canonical path identities, and deletion fences covering every family source and destination. Revalidate Git identity before removal, block sessions owned by other workspaces or projects, and handle nested workspace roots without deleting sibling project sessions.

Keep the UI server-authoritative after moves and deletions, reconcile complete session.moved locations, exhaust pagination for global sorting and search, retry failed refreshes, and localize the added worktree controls. Add focused server and UI coverage for races, replacement checkouts, cursor loops, WSL paths, and nested worktrees.

Validated with server, UI, Electron, desktop packaging tests, workspace typechecks, and a release Tauri/NSIS build.
Move copy, open, and delete controls out of Kobalte Select.Item options into a toolbar for the selected worktree. This removes nested interactive controls and custom event suppression while preserving mouse and keyboard activation.

Validated with the UI typecheck and production UI build.
Integrate the latest DEV-v2 architecture-guide discovery update while preserving the finalized native OpenCode V2 worktree session transactions and accessible selector controls.\n\nThe upstream change is documentation-only and introduces no runtime conflict. This merge keeps PR NeuralNomadsAI#649 current without rewriting its reviewed history.
Make worktree deletion fail closed across complete native session families, shared Shell and PTY locations, concurrent workspace ownership, and final Git identity checks. Preserve rollback safety and WSL path semantics while keeping the OpenCode V2 service lifecycle native.

Make the selector actions explicit and accessible with localized labels, and resynchronize worktrees and moved-session catalogs after reconnects and foreground recovery. Exhaust every session page for global sorting while fencing superseded pagination and keeping SDK metadata separate from local runtime state.

Cover mixed-workspace families, late blockers, Git replacement races, WSL case sensitivity, multi-page sorting, superseded refreshes, and native metadata separation. Validated server, UI, Electron, and Rust suites plus typechecks, builds, lock integrity, and desktop resource closure.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/33347402492

Artifacts expire in 7 days.
Artifacts:

  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-tauri-windows
  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-tauri-macos
  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-tauri-linux
  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-electron-macos
  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-electron-linux
  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-electron-windows
  • pr-649-9c077dc8420fcf5668dd16dc2abbdcd3a817efe4-tauri-macos-arm64

Replace the obsolete fixed WebView2 profile and CDP port instructions with the persistent Developer Mode toggle and authenticated restart bridge introduced on DEV-v2.

Document that desktop relaunches preserve the shared OpenCode daemon, while Windows Tauri still permits a manual stop and relaunch only when the linker cannot replace the running executable.

Validated with complete server, UI, Electron native, and Rust test suites; server and Electron production builds; all workspace typechecks; dependency dry-run; and desktop resource integrity tests.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/33376915849

Artifacts expire in 7 days.
Artifacts:

  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-tauri-macos-arm64
  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-tauri-windows
  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-electron-macos
  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-tauri-macos
  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-tauri-linux
  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-electron-linux
  • pr-649-196bb6614bc4229fe506a6f066e71bb6bbf27661-electron-windows

@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/33379837386

Artifacts expire in 7 days.
Artifacts:

  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-tauri-windows
  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-tauri-macos
  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-electron-macos
  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-tauri-macos-arm64
  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-electron-linux
  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-tauri-linux
  • pr-649-d0b8383a4b48393f0cb10fa8ff62eede25f188df-electron-windows

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