fix(worktrees): route OpenCode calls through workspaces#521
Conversation
|
I want you to perform the gatekeeper checks for latest PR state check for regressions |
|
Gatekeeper review for latest PR state. Request understood: review PR #521 ruthlessly for regressions, implementation quality, and whether the fix should be implemented differently. Assumption: scope is the current single-commit PR diff against Findings: no blocking code findings found in the PR diff. Review notes:
Validation:
Residual risk:
Gatekeeper verdict: no code-quality blocker found. I would not request implementation changes for this diff, but I would want either CI typecheck confirmation or a clean local dependency install before merge, plus preferably a focused regression test for #518. -- |
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/26833236698 Artifacts expire in 7 days.
|
cbb0e22 to
b3594d2
Compare
|
PR is changed completely go through it again. check for regressions |
|
Gatekeeper review for the changed PR state. Request understood: the previous review is obsolete; review the current PR #521 diff against Findings:
Implementation review notes:
Validation:
Gatekeeper verdict: do not merge yet. The workspace-routing approach is directionally plausible, but the file browser save path is currently inconsistent with the new read routing and can write to the wrong directory for non-root worktrees. -- |
Migrate CodeNomad worktree execution from per-worktree OpenCode proxy clients and x-opencode-directory headers to OpenCode experimental workspace routing. OpenCode is now started with OPENCODE_EXPERIMENTAL_WORKSPACES=true and the root instance proxy path. The UI syncs OpenCode workspaces after worktree hydration and maps CodeNomad worktree slugs to OpenCode workspace IDs. Session, file, git status, permission, and question calls now use the root OpenCode client and pass the resolved workspace ID when the active session belongs to a worktree. Worktree metadata updates also use the root client. The obsolete worktree instance proxy routes, directory override handling, and x-opencode-directory forwarding were removed so existing-session routing no longer depends on stale directory headers. Validated with npm run typecheck --workspace @codenomad/ui, npm run typecheck --workspace @neuralnomads/codenomad, and git diff --check.
4111d14 to
0d24ce9
Compare
|
Check now |
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/26845457913 Artifacts expire in 7 days.
|
|
Re-check for latest PR state after the file-save fix. Request understood: verify the previous blocker and run another gatekeeper pass on the current PR state. Assumption: scope is the latest local PR head Findings: no blocking findings found in this pass. What changed relative to the previous blocker:
Gatekeeper assessment:
Validation:
Verdict: the previously blocking file-save issue is resolved. I would still require CI or a clean dependency-installed typecheck before merge, but I do not have a remaining code-level blocker from this re-check. -- |
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/26845817287 Artifacts expire in 7 days.
|
1 similar comment
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/26845817287 Artifacts expire in 7 days.
|
Summary
This fixes #518 by moving CodeNomad worktree execution from directory-header routing to OpenCode experimental workspace routing.
OpenCode changed existing-session routing so session routes can prefer the session's stored directory over
x-opencode-directory. That made the old CodeNomad worktree proxy model unreliable for sessions that should execute in a worktree. This PR switches CodeNomad to resolve an OpenCode workspace ID for each CodeNomad worktree and pass that workspace ID on worktree-scoped OpenCode calls.What changed
OPENCODE_EXPERIMENTAL_WORKSPACES=true./workspaces/:id/worktrees/root/instanceto/workspaces/:id/instance.packages/ui/src/stores/opencode-client.ts.packages/ui/src/stores/opencode-workspaces.ts.workspace.idvalues discovered byexperimental.workspace.syncListandexperimental.workspace.list.workspacepayloads where the active session/worktree requires it.Review fix
worktreequery parameter.worktreeSlugForViewer(), and the server resolves that slug to the same worktree directory used by local git worktree APIs before writing.Removed old routing
/workspaces/:id/worktrees/:slug/instanceOpenCode proxy routes./__dir/<encoded>.x-opencode-directory.x-opencode-directoryheader.getOrCreateWorktreeClient,getOrCreateWorktreeClientWithDirectoryOverride, and worktree proxy path helpers from the UI worktree store.sdkManager.createClientbecause clients are no longer keyed by worktree slug.Why this fixes #518
Worktree sessions can now stay visible under the root project session listing while worktree execution is selected through OpenCode's workspace routing model. CodeNomad no longer depends on
x-opencode-directoryto override existing session directories, so sessions should not disappear from the root-directory list or execute in the wrong directory because of stale session directory fallback behavior.Fixes #518
Validation
npm run typecheck --workspace @codenomad/uinpm run typecheck --workspace @neuralnomads/codenomadgit diff --checkNotes
Some touched files are already oversized and were not refactored as part of this migration:
packages/server/src/server/http-server.ts,packages/ui/src/stores/instances.ts,packages/ui/src/stores/session-api.ts,packages/ui/src/stores/session-state.ts,packages/ui/src/components/instance/shell/right-panel/RightPanel.tsx,packages/ui/src/stores/session-events.ts, andpackages/server/src/background-processes/manager.ts.