# Simplify New Worktree to only restore active buffer or fullscreen agent panel \(\#51700\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/bfa5e88b66c9fd2ecbff7aaa107d62b7c2285299)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: bfa5e88b66c9fd2ecbff7aaa107d62b7c2285299

Requested commit: bfa5e88b66c9fd2ecbff7aaa107d62b7c2285299

Commit: bfa5e88b66c9fd2ecbff7aaa107d62b7c2285299

Tree: 402e2054acacd3886b5a84a8e5695705e6e2f2b8

Author: Richard Feldman

Committer: GitHub

## Message

```
Simplify New Worktree to only restore active buffer or fullscreen agent panel (#51700)

Dramatically simplifies what "New Worktree" does when forking a
workspace.

Previously we captured the entire dock structure and all open file
paths, then restored them all in the new worktree workspace. Now the
behavior is:

- If you have an active buffer open, we reopen just that one file (no
other buffer state is carried over).
- If you do not have an active buffer open, we instead fullscreen (zoom)
the agent panel (equivalent to cmd-esc).

No other workspace state is carried over.

Implementation details:
- Replace `capture_dock_state` / `set_dock_structure` /
`open_item_abs_paths` with a single `active_file_path` lookup.
- Pass `None` for the `init` closure instead of restoring dock layout.
- Only reopen the single active file via `open_paths`, with proper error
logging (`detach_and_log_err`) instead of silent `.detach()`.
- Emit `PanelEvent::ZoomIn` on the agent panel when no active buffer
exists, after `focus_panel` to ensure the panel is properly activated
first.
- Warn when an active file exists but cannot be remapped to the new
worktree.

Closes AI-87

Release Notes:

- N/A
```

## Parents

- [c17bc26b3a8fddca20b595805cfa558334787fcc](https://git.cafe/gitcafe/zed/commit/c17bc26b3a8fddca20b595805cfa558334787fcc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/bfa5e88b66c9fd2ecbff7aaa107d62b7c2285299?format=markdown)
