Skip to content

fix(shellterm): resolve session workspace path for terminals opened f… - #3086

Open
anmol0b wants to merge 2 commits into
Untrivial-ai:mainfrom
anmol0b:fix/shellterm-session-workspace
Open

fix(shellterm): resolve session workspace path for terminals opened f…#3086
anmol0b wants to merge 2 commits into
Untrivial-ai:mainfrom
anmol0b:fix/shellterm-session-workspace

Conversation

@anmol0b

@anmol0b anmol0b commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

What

Adds session-scoped workspace resolution to OpenShellTerminal, so a standalone terminal opened while viewing an agent session starts in that session's worktree instead of always defaulting to the project's main root.

Why

Fixes #3061. A terminal opened from a session view looked co-located with the active agent, but ran against a different checkout/branch — the project root, not the session's worktree — making it easy to inspect, build, or edit the wrong tree.

How

  • Added SessionWorkspaceLocator and wired a concrete implementation through daemon.go/shellterm_wiring.go, so shellterm.Service can resolve a session id to its durable workspace path (SessionRecord.Metadata.WorkspacePath) rather than only ever consulting ProjectRootLocator.
  • resolveShellTerminalWorkingDir now checks the session locator first when a sessionId is present, falling back to the project root if the session exists but hasn't resolved a workspace yet, and to the existing project-root/data-dir fallbacks when no session id is sent at all.
  • No controller, DTO, or frontend changes were needed — sessionId was already threaded end-to-end from useShellTerminals.ts through OpenShellTerminalRequest/OpenShellTerminalInput; the gap was purely that the service layer never used it once it arrived.
  • Both the terminal-tab + action and the Ctrl+Shift+` shortcut share the same useOpenShellTerminal mutation, so both pick up the fix identically without separate handling.

Testing

Backend (backend/):
New/updated backend tests: TestOpenShellTerminalStartsInSessionWorkspaceNotProjectRoot, TestOpenShellTerminalFallsBackToProjectRootWhenSessionHasNoWorkspaceYet, TestOpenShellTerminalReturnsNotFoundForUnknownSession, TestOpenShellTerminalWithoutSessionIgnoresSessionLocator, and TestOpenShellTerminalScopesToSession (updated to use a populated session locator).
Screenshot 2026-07-25 at 6 43 41 AM

Frontend (frontend/):
New test: "scopes the terminal to the session in scope", alongside the existing "scopes the terminal to the project in scope".

Screenshot 2026-07-25 at 6 45 14 AM

Checklist

  • Branched from main (or continuing an existing PR branch)
  • One focused change; links the related issue when applicable
  • Follows AGENTS.md conventions and PR hygiene
  • Tests added/updated for user-visible behavior where it makes sense
  • Relevant CI checks pass for the area touched (go, frontend, etc.)

@somewherelostt

Copy link
Copy Markdown
Collaborator

Thanks for contributing to Agent Orchestrator.

This PR is being picked up by the current external contributor on-call pair:

If someone is already working on this, please continue as usual.
The on-call pair is added for visibility, tracking, and support, not to take over the work.
If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @Pulkit7070 here.

For faster context or live questions, you can also join the AO Discord.

Join the session here:
https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

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

5 participants