[PR #12015] feat: add per-session directory and /new <path> switching #14030

Closed
opened 2026-02-16 18:18:51 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12015

State: closed
Merged: No


Fixes #2177

Adds the ability to switch working directories from the TUI without restarting. Type /new ~/other-project (or /clear ~/other-project) and press Enter to switch.

What changed:

  • Tools now resolve paths from session.directory via Tool.Context instead of the global Instance.directory. This is concurrency-safe and follows the existing context-passing pattern.
  • The TUI prompt intercepts /new <path>, validates the target, restarts the worker event stream, recreates the SDK client, and re-bootstraps all project data for the new directory.
  • Error recovery rolls back to the previous directory on failure.

/new with no args still works as before.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12015 **State:** closed **Merged:** No --- Fixes #2177 Adds the ability to switch working directories from the TUI without restarting. Type `/new ~/other-project` (or `/clear ~/other-project`) and press Enter to switch. **What changed:** - Tools now resolve paths from `session.directory` via `Tool.Context` instead of the global `Instance.directory`. This is concurrency-safe and follows the existing context-passing pattern. - The TUI prompt intercepts `/new <path>`, validates the target, restarts the worker event stream, recreates the SDK client, and re-bootstraps all project data for the new directory. - Error recovery rolls back to the previous directory on failure. `/new` with no args still works as before.
yindo added the pull-request label 2026-02-16 18:18:51 -05:00
yindo closed this issue 2026-02-16 18:18:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14030