Skip to content

fix(shellterm): open session-scoped terminals in the session's worktree#3106

Open
ikeshavvarshney wants to merge 1 commit into
AgentWrapper:mainfrom
ikeshavvarshney:fix/shellterm-session-worktree
Open

fix(shellterm): open session-scoped terminals in the session's worktree#3106
ikeshavvarshney wants to merge 1 commit into
AgentWrapper:mainfrom
ikeshavvarshney:fix/shellterm-session-worktree

Conversation

@ikeshavvarshney

Copy link
Copy Markdown
Contributor

Summary

Fixes #3061. Terminal opened from session view landed in project's registered root instead of that session's worktree — session id never reached working-directory resolver, only project id did.

Adds SessionWorkspaceLocator to internal/service/shellterm, resolved through new daemon-side adapter over real session service.

resolveShellTerminalWorkingDir precedence order now:

  1. Session workspace
  2. Project root
  3. Daemon data directory

A session with no workspace of its own (or no session id provided) falls back through the existing chain unchanged.

Renderer, DTO, and OpenAPI spec already carried sessionId end-to-end from an earlier pass — the gap was purely in the backend resolver.

Test plan

  • go build ./...
  • go vet ./...
  • New service tests:
    • Session workspace takes precedence over project root.
    • Falls back to project root when the session has no workspace.
    • Returns 404 for an unknown session.
  • New controller test:
    • Verifies sessionId in the request body reaches the service input.
  • New frontend test:
    • Session route submits sessionId scope.
    • Board route submits project scope only.
  • Manual verification:
    • Built the fixed binary.
    • Ran a real AO daemon against a real Git repository.
    • Spawned a real worker session (using the fake harness).
    • Sent the exact POST /api/v1/shell-terminals request used by the UI with both ids present.
    • Confirmed workingDir resolved to the session's real worktree.
    • Verified pwd, git rev-parse --show-toplevel, and git branch --show-current all matched the worktree and its ao/<session>/root branch, rather than the registered repository root.
    • Confirmed opening a terminal from the project board (no sessionId) still resolves to the project root, unchanged.

Opening a terminal from a worker/orchestrator session view resolved the
working directory from the project's registered root only, dropping the
session id and colocating the shell with the wrong checkout/branch.

Adds a SessionWorkspaceLocator alongside the existing ProjectRootLocator
so the shellterm service can resolve a session id to its live workspace
(worktree) and use it ahead of the project root; falls back to the
project root when a session has no workspace of its own, and to the
data dir when neither is given. Project-board and no-context opens are
unaffected.
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.

bug(shellterm): terminal opened from a session starts in the project root instead of the session worktree

1 participant