1# Remote Worktree Support — Summary of Changes
2
3## Problem
4The agent panel's "create new thread in worktree" feature only supported local projects. Remote (SSH/WSL/Docker) projects need the same capability, plus correct sidebar integration.
5
6## Changes Made
7
8### 1. `HeadlessRemoteClientDelegate` (`remote_connection/src/remote_connection.rs`)
9New public struct implementing `RemoteClientDelegate` without UI. Forwards binary downloads to `AutoUpdater`, drops password prompts with a log warning.
10
11### 2. Remote worktree workspace creation (`agent_ui/src/agent_panel.rs`)
12- `handle_worktree_requested`: extracts `remote_connection_options` from project, fails early if disconnected
13- `open_worktree_workspace_and_start_thread`: new remote branch using `remote::connect()` → `RemoteClient::new()` → `Project::remote()` → `open_remote_project_with_existing_connection()` + `multi_workspace.add()`
14
15### 3. Sidebar remote thread support (`sidebar/src/sidebar.rs`)
16- `ThreadEntryWorkspace::Closed` now carries `host: Option<RemoteConnectionOptions>`
17- `open_workspace_and_activate_thread`: branches on `host` — remote uses headless delegate flow, local unchanged
18- All pattern match sites updated, `activate_archived_thread` looks up host from project group keys
19- Worktree tooltip says "Remote" vs "Local" (`ui/src/components/ai/thread_item.rs`)
20
21### 4. Proto: `root_repo_common_dir` in `WorktreeMetadata` + `AddWorktreeResponse`
22- `proto/worktree.proto`: added `optional string root_repo_common_dir` to both messages
23- `remote_server/headless_project.rs`: includes value in `AddWorktreeResponse`
24- `worktree/worktree.rs`: `Worktree::remote()` sets it from metadata; `metadata_proto()` includes it; `apply_remote_update` only updates when `Some` (never clears)
25- `project/worktree_store.rs`: passes through in `create_remote_worktree`, `worktree_metadata_protos`; emits new `WorktreeUpdatedRootRepoCommonDir` event
26- `project/project.rs`: new `Event::WorktreeUpdatedRootRepoCommonDir`, forwarded from worktree store
27
28### 5. Stale key cleanup (`workspace/src/multi_workspace.rs`)
29- `subscribe_to_workspace`: handles `WorktreeUpdatedRootRepoCommonDir` — adds correct key, removes stale keys, notifies
30- New `remove_stale_project_group_keys()` method
31
32### 6. Dependency changes
33- `agent_ui/Cargo.toml`: added `remote`, `remote_connection` to deps; added remote test infra to dev-deps
34- `sidebar/Cargo.toml`: added `remote_connection`, `futures` to deps; added remote test infra to dev-deps
35
36### 7. Tests
37- `agent_ui`: `test_worktree_creation_for_remote_project` — verifies remote code path is taken
38- `sidebar`: `test_clicking_closed_remote_thread_opens_remote_workspace` — verifies grouping and stale key cleanup
39
40## What's Left
41See `plan.md`.