Bug
Opening a standalone shell terminal while viewing an agent session starts the shell in the registered project's main root, not in the worktree where that session is running.
This makes the terminal look colocated with the active agent while commands actually run against a different checkout/branch. A user can easily inspect, build, or edit the wrong tree.
Source: user report after the standalone terminal feature landed in #2861 / #2828
Analyzed against: main at d79977a9f5ed5b33f1b6188fe704b5d309023679 (2026-07-24)
Confidence: High — the current request path drops session context and resolves only the project root.
Reproduction
- Open a project in AO.
- Spawn an agent session that runs in its own generated worktree.
- Navigate to that session's terminal view.
- Open a standalone terminal using either the
+ terminal-tab action or `Ctrl+Shift+``.
- Run:
pwd
git rev-parse --show-toplevel
git branch --show-current
Expected
When the action is invoked from a session view, the new terminal starts in that session's current workspace/worktree (SessionRecord.Metadata.WorkspacePath) and therefore on the same checkout/branch as the agent.
Opening a terminal from a project board can continue to use the registered project root. Opening one without project or session context can continue to use the daemon data-dir fallback.
Actual
The new shell starts in the registered project root (the main worktree), even though it was opened from a worker session running in a different worktree.
Root cause
The session route is reduced to project scope before the open request is made:
frontend/src/renderer/routes/_shell.tsx derives scopedProjectId from the current route/session and calls openShellTerminal.mutate(scopedProjectId).
frontend/src/renderer/hooks/useShellTerminals.ts sends only { projectId } to POST /api/v1/shell-terminals.
controllers.OpenShellTerminalRequest and shellterm.OpenShellTerminalInput have no session identifier.
shellterm.Service.resolveShellTerminalWorkingDir can therefore only call ProjectRootLocator.ProjectRoot, so it deterministically chooses the main project root.
The UI knows which session is active, but that context never reaches the daemon.
Fix shape
Add a session-scoped way to open a shell without accepting an arbitrary filesystem path from the renderer:
- Extend the open-shell request/input with
sessionId (define precedence or validation if both sessionId and projectId are present).
- When the current route is a session, have both the
+ action and shortcut pass that session id.
- Resolve the id server-side through the session/service boundary and use the durable session workspace path.
- Preserve the existing project-root and data-dir fallbacks outside a session.
- Regenerate the OpenAPI spec and frontend schema after changing the DTO.
Acceptance criteria
Duplicate search
Searched open and closed issues for combinations of: terminal, standalone terminal, shell terminal, worktree, working directory, cwd, project root, session worktree, shellterm, workingDir, and references to #2828/#2861. No issue covering this behavior was found. #2828 is the completed feature request and specifies project-root scope, but it does not track the session-worktree context bug introduced by the landed implementation.
Bug
Opening a standalone shell terminal while viewing an agent session starts the shell in the registered project's main root, not in the worktree where that session is running.
This makes the terminal look colocated with the active agent while commands actually run against a different checkout/branch. A user can easily inspect, build, or edit the wrong tree.
Source: user report after the standalone terminal feature landed in #2861 / #2828
Analyzed against:
mainatd79977a9f5ed5b33f1b6188fe704b5d309023679(2026-07-24)Confidence: High — the current request path drops session context and resolves only the project root.
Reproduction
+terminal-tab action or `Ctrl+Shift+``.pwd git rev-parse --show-toplevel git branch --show-currentExpected
When the action is invoked from a session view, the new terminal starts in that session's current workspace/worktree (
SessionRecord.Metadata.WorkspacePath) and therefore on the same checkout/branch as the agent.Opening a terminal from a project board can continue to use the registered project root. Opening one without project or session context can continue to use the daemon data-dir fallback.
Actual
The new shell starts in the registered project root (the main worktree), even though it was opened from a worker session running in a different worktree.
Root cause
The session route is reduced to project scope before the open request is made:
frontend/src/renderer/routes/_shell.tsxderivesscopedProjectIdfrom the current route/session and callsopenShellTerminal.mutate(scopedProjectId).frontend/src/renderer/hooks/useShellTerminals.tssends only{ projectId }toPOST /api/v1/shell-terminals.controllers.OpenShellTerminalRequestandshellterm.OpenShellTerminalInputhave no session identifier.shellterm.Service.resolveShellTerminalWorkingDircan therefore only callProjectRootLocator.ProjectRoot, so it deterministically chooses the main project root.The UI knows which session is active, but that context never reaches the daemon.
Fix shape
Add a session-scoped way to open a shell without accepting an arbitrary filesystem path from the renderer:
sessionId(define precedence or validation if bothsessionIdandprojectIdare present).+action and shortcut pass that session id.Acceptance criteria
+action and `Ctrl+Shift+`` behave the same way.Duplicate search
Searched open and closed issues for combinations of:
terminal,standalone terminal,shell terminal,worktree,working directory,cwd,project root,session worktree,shellterm,workingDir, and references to #2828/#2861. No issue covering this behavior was found. #2828 is the completed feature request and specifies project-root scope, but it does not track the session-worktree context bug introduced by the landed implementation.