Add working-directory commands to the TUI (#38894)

## What changed

- Add `/cd [path]` for changing an idle local session's working directory while preserving conversation history. Relative paths resolve from the current directory, and omitting the path selects `~`.
- Reload project configuration, instructions, permissions, keybindings, file search, and hooks for the destination before replacing the active session.
- Reject unsafe transitions, including active or queued work, background terminals, remote environments, untrusted destinations, and incompatible permission profiles.
- Add `/pwd` and its `/cwd` alias to display the current working directory, and discard asynchronous results left over from the previous directory.

## Testing

- Cover command parsing, aliases, default paths, session eligibility, transition failures, history preservation, destination policy loading, hooks, and stale events.

GitOrigin-RevId: 1a987c029f157a087ba02c0f26e022260409132b
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-08-16 19:48:07 +00:00
1 parent 375996d3f5
commit ed32158e90
18 files changed
+776 -24

No files matched your search

+10
View File
@@ -49,6 +49,9 @@ pub enum SlashCommand {
Diff,
Mention,
Status,
Cd,
#[strum(to_string = "pwd", serialize = "cwd")]
Pwd,
Usage,
DebugConfig,
Title,
@@ -105,6 +108,8 @@ impl SlashCommand {
SlashCommand::Import => "import setup, this project, and recent chats from Claude Code",
SlashCommand::Hooks => "view and manage lifecycle hooks",
SlashCommand::Status => "show current session configuration and token usage",
SlashCommand::Cd => "change the current working directory",
SlashCommand::Pwd => "show the current working directory",
SlashCommand::Usage => "view account usage or use a usage limit reset",
SlashCommand::DebugConfig => "show config layers and requirement sources for debugging",
SlashCommand::Title => "configure which items appear in the terminal title",
@@ -167,6 +172,8 @@ impl SlashCommand {
| SlashCommand::Mcp
| SlashCommand::Export
| SlashCommand::Raw
| SlashCommand::Cd
| SlashCommand::Pwd
| SlashCommand::Usage
| SlashCommand::Pets
| SlashCommand::Side
@@ -186,6 +193,7 @@ impl SlashCommand {
| SlashCommand::Diff
| SlashCommand::Mention
| SlashCommand::Status
| SlashCommand::Pwd
| SlashCommand::Usage
| SlashCommand::Ide
)
@@ -210,6 +218,7 @@ impl SlashCommand {
| SlashCommand::Import
| SlashCommand::Review
| SlashCommand::Plan
| SlashCommand::Cd
| SlashCommand::Clear
| SlashCommand::Logout
| SlashCommand::MemoryDrop
@@ -226,6 +235,7 @@ impl SlashCommand {
| SlashCommand::Skills
| SlashCommand::Hooks
| SlashCommand::Status
| SlashCommand::Pwd
| SlashCommand::Usage
| SlashCommand::DebugConfig
| SlashCommand::Ps