Wire /wt, MCP new_session, and loops to run sessions in-app on the project instance #268

Closed
opened 2026-07-09 10:20:52 +02:00 by dries · 0 comments
Owner

Parent

#265 — One OpenCode per project: worktree sessions run in-app.

What to build

Wire all three session-creation callers through
EnsureProjectOpencode (#267) + directory-aware CreateSession (#266)
so worktree and same-directory sessions run in-app against the
project's single opencode instance. This is the first fully demoable
slice of #265.

  • /wt (local.Host.CreateWorktreeSession): create the git
    worktree, call EnsureProjectOpencode(repoRoot), then create an in-app
    session pointed at the worktree path against the returned port. Stop
    calling LaunchWorktreeTmux.
  • MCP new_session (worktree) + loops spawn_worktree
    (mcp.SessionLauncher.LaunchWithWorktree): replace
    launchTmux(repoRoot, worktreePath) + waitForPort(worktreePath) with
    the injected EnsureProjectOpencode(repoRoot), then Launch with
    Directory = worktreePath.
  • MCP new_session (same directory) (SessionLauncher.Launch):
    ensure the project instance before CreateSession, so same-dir splits
    self-heal instead of returning ErrPlatformUnreachable.
  • Result shape: hostsvc.WorktreeSessionResult returns the created
    session ID (plus worktree path, branch, reused flags). The
    /api/worktree/create-and-launch response changes accordingly.
  • Frontend: /wt navigates to the created session in-app instead
    of tmux switch-client. Worktrees view associates each worktree with
    its sessions by the session's own directory (now distinct from the
    process cwd), which ocman surfaces per session (folds in the original
    attribution ticket).
  • Multi-remote: EnsureProjectOpencode runs on the owning host, same as
    CreateWorktreeSession today.

Acceptance criteria

  • /wt creates a worktree session on the shared project instance —
    no new opencode process, no per-worktree tmux window.
  • Second /wt for the same project reuses the same instance.
  • MCP worktree new_session and loops spawn_worktree reuse the
    project instance.
  • Same-directory MCP new_session launches the instance if none is
    running (no ErrPlatformUnreachable).
  • create-and-launch response carries the session ID; frontend
    opens it in-app.
  • Worktrees view associates sessions by per-session directory.
  • Host + launcher + handler + frontend tests cover the new paths;
    old per-worktree tmux launcher is no longer invoked.
  • make test && make lint green; coverage delta ≥ 0 both sides.

Blocked by

  • #266 — CreateSession sends the session directory.
  • #267 — EnsureProjectOpencode host primitive.
## Parent #265 — One OpenCode per project: worktree sessions run in-app. ## What to build Wire all three session-creation callers through `EnsureProjectOpencode` (#267) + directory-aware `CreateSession` (#266) so worktree and same-directory sessions run **in-app** against the project's single opencode instance. This is the first fully demoable slice of #265. - **`/wt`** (`local.Host.CreateWorktreeSession`): create the git worktree, call `EnsureProjectOpencode(repoRoot)`, then create an in-app session pointed at the worktree path against the returned port. Stop calling `LaunchWorktreeTmux`. - **MCP `new_session` (worktree) + loops `spawn_worktree`** (`mcp.SessionLauncher.LaunchWithWorktree`): replace `launchTmux(repoRoot, worktreePath)` + `waitForPort(worktreePath)` with the injected `EnsureProjectOpencode(repoRoot)`, then `Launch` with `Directory = worktreePath`. - **MCP `new_session` (same directory)** (`SessionLauncher.Launch`): ensure the project instance before `CreateSession`, so same-dir splits self-heal instead of returning `ErrPlatformUnreachable`. - **Result shape**: `hostsvc.WorktreeSessionResult` returns the created **session ID** (plus worktree path, branch, reused flags). The `/api/worktree/create-and-launch` response changes accordingly. - **Frontend**: `/wt` navigates to the created session **in-app** instead of `tmux switch-client`. Worktrees view associates each worktree with its sessions by the **session's own `directory`** (now distinct from the process cwd), which ocman surfaces per session (folds in the original attribution ticket). - Multi-remote: `EnsureProjectOpencode` runs on the owning host, same as `CreateWorktreeSession` today. ## Acceptance criteria - [ ] `/wt` creates a worktree session on the shared project instance — no new opencode process, no per-worktree tmux window. - [ ] Second `/wt` for the same project reuses the same instance. - [ ] MCP worktree `new_session` and loops `spawn_worktree` reuse the project instance. - [ ] Same-directory MCP `new_session` launches the instance if none is running (no `ErrPlatformUnreachable`). - [ ] `create-and-launch` response carries the session ID; frontend opens it in-app. - [ ] Worktrees view associates sessions by per-session directory. - [ ] Host + launcher + handler + frontend tests cover the new paths; old per-worktree tmux launcher is no longer invoked. - [ ] `make test && make lint` green; coverage delta ≥ 0 both sides. ## Blocked by - #266 — CreateSession sends the session directory. - #267 — EnsureProjectOpencode host primitive.
dries closed this issue 2026-07-09 14:29:36 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#268
No description provided.