first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Handoff Environment Selection: PWD-Based Overlap at Activation
|
||||
Linear: [APP-4427](https://linear.app/warpdotdev/issue/APP-4427)
|
||||
|
||||
## Summary
|
||||
When a user enters `&` handoff compose mode or uses `/handoff`, auto-select the cloud environment that matches the repo they're currently working in — at activation time, not after pressing Enter. This replaces the current two-layer system where the environment visibly shifts after the handoff is dispatched.
|
||||
|
||||
Figma: none provided
|
||||
|
||||
## Behavior
|
||||
|
||||
1. When the user types `&` or runs `/handoff` (no query), the system checks the terminal's current working directory for a git repo (walk up to `.git`, read `origin` remote URL, parse `<owner>/<repo>`).
|
||||
|
||||
2. If a git repo is found and at least one cloud environment's `github_repos` contains that repo, select the environment with the most overlap (breaking ties by most-recently-used). The user can still override this from the environment dropdown.
|
||||
|
||||
3. If no git repo is found, or no environment matches the repo, fall back to the existing default: saved `last_selected_environment_id` setting, then most-recently-used environment.
|
||||
|
||||
4. The environment chip in the footer reflects the selected environment immediately (or near-immediately after the async git check completes).
|
||||
|
||||
5. When the user presses Enter, the compose state's current `selected_environment_id` is passed directly to the new cloud pane. The environment does not change during the transition from compose mode to the cloud pane.
|
||||
|
||||
6. For `/handoff query` (auto-submit path), the environment is `None` (compose state isn't active), so the cloud pane falls back to its own default selection.
|
||||
|
||||
7. The pwd-based check uses the same `find_git_root` / `git_origin_url` / `parse_github_repo` / `pick_handoff_overlap_env` utilities as the existing touched-workspace pipeline — just scoped to a single directory instead of the full conversation history.
|
||||
|
||||
8. The async git check should complete quickly (single local git command with the existing 5-second timeout). If the check hasn't completed when the user presses Enter, the current selection (from the fallback defaults) is used.
|
||||
@@ -0,0 +1,43 @@
|
||||
# Handoff Environment Selection: PWD-Based Overlap at Activation — Tech Spec
|
||||
Product spec: `specs/APP-4427/PRODUCT.md`
|
||||
Linear: [APP-4427](https://linear.app/warpdotdev/issue/APP-4427)
|
||||
|
||||
## Context
|
||||
Environment auto-selection for `&` handoff has two layers:
|
||||
- **Layer 1** (activation time): `start_pwd_environment_overlap` in `input.rs:3769` spawns an async task that resolves the pwd's git repo and calls `pick_handoff_overlap_env` to select the best environment. `EnvironmentSelector::ensure_default_selection` (`environment_selector.rs:372`) also runs synchronously to pick a saved/MRU fallback.
|
||||
- **Layer 2** (post-dispatch): After pressing Enter, an async task in `workspace/view.rs:13422-13488` re-resolves the pwd repo and overwrites the environment on the new cloud pane model.
|
||||
|
||||
Layer 2 causes a visible environment flicker after the handoff pane opens. The compose state already has the correct environment by the time Enter is pressed — layer 2 is redundant.
|
||||
|
||||
Key files:
|
||||
- `app/src/terminal/input/handoff_compose.rs` — `HandoffComposeState` model
|
||||
- `app/src/terminal/input.rs:3739` — `activate_cloud_handoff_compose`
|
||||
- `app/src/terminal/input.rs:3769` — `start_pwd_environment_overlap` (layer 1)
|
||||
- `app/src/terminal/input.rs:3973` — `maybe_launch_cloud_handoff_request` (Enter dispatch)
|
||||
- `app/src/ai/blocklist/agent_view/agent_input_footer/environment_selector.rs:372` — `ensure_default_selection`
|
||||
- `app/src/workspace/view.rs:13319` — `complete_local_to_cloud_handoff_open`
|
||||
- `app/src/workspace/view.rs:13450-13464` — post-dispatch overlap overwrite (to remove)
|
||||
- `app/src/workspace/action.rs:493` — `OpenLocalToCloudHandoffPane` action
|
||||
|
||||
## Proposed changes
|
||||
### 1. Rename action field and pass compose state's selection
|
||||
Rename `explicit_environment_id` → `environment_id` on `OpenLocalToCloudHandoffPane` (`workspace/action.rs:498`). In `maybe_launch_cloud_handoff_request` (`input.rs:3991`), pass `selected_environment_id().cloned()` from the compose state instead of `explicit_environment_id()`. This carries the pwd-overlap result (or MRU fallback) to the new cloud pane.
|
||||
|
||||
### 2. Remove async env overwrite in `complete_local_to_cloud_handoff_open`
|
||||
Remove the `resolve_repo_for_path` call inside the async task (`workspace/view.rs:13435-13442`), the `pwd_repo` plumbing through the tuple, and the env overwrite block in the completion handler (`view.rs:13450-13464`). The `source_pwd` capture (`view.rs:13420`) is also removed. The workspace derivation and snapshot upload continue unchanged.
|
||||
|
||||
### 3. Clean up `PendingHandoff.explicit_environment_id`
|
||||
Remove the `explicit_environment_id` field from `PendingHandoff`, the `pending_handoff_has_explicit_environment()` method on `AmbientAgentViewModel` (`model.rs:549`), and the guard in `EnvironmentSelectorTarget::ensure_default_environment_id` (`environment_selector.rs:84-87`). The guard is no longer needed: the env is set on the model before the `EnvironmentSelector` is created, so `ensure_default_selection` already short-circuits at line 374 (`if current_selection.is_some() { return; }`).
|
||||
|
||||
### 4. Update all dispatch and handler sites
|
||||
Rename `explicit_environment_id` → `environment_id` at all sites that construct or destructure the action, and update intermediate function signatures (`start_local_to_cloud_handoff`, `complete_local_to_cloud_handoff_open`, `start_fresh_cloud_launch`, `restore_source_handoff_draft`, `restore_cloud_handoff_draft`).
|
||||
|
||||
## Testing and validation
|
||||
### Manual
|
||||
- In a terminal whose pwd is inside a repo that matches exactly one environment: type `&`, observe the matching environment in the chip. Press Enter — the cloud pane opens with the same environment, no shift.
|
||||
- Same setup but explicitly pick a different environment from the dropdown, press Enter — the explicit choice is preserved.
|
||||
- In a directory outside any git repo: type `&`, observe fallback to saved/MRU default. Press Enter — same env, no shift.
|
||||
- `/handoff query` from a repo-matching directory: cloud pane opens with its own default selection (compose state isn't active in this path).
|
||||
|
||||
## Parallelization
|
||||
This is a small, tightly coupled change across a few files in a single call chain. A single agent should implement it sequentially.
|
||||
Reference in New Issue
Block a user