diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 2dca46d99a4a274300e82f67b6f0eac96bb55ee9..59b0a5b1cefb3582189671212cba21837717556e 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -15,6 +15,7 @@ - [Tools](./ai/tools.md) - [Tool Permissions](./ai/tool-permissions.md) - [External Agents](./ai/external-agents.md) +- [Parallel Agents](./ai/parallel-agents.md) - [Inline Assistant](./ai/inline-assistant.md) - [Edit Prediction](./ai/edit-prediction.md) - [Rules](./ai/rules.md) diff --git a/docs/src/ai/agent-panel.md b/docs/src/ai/agent-panel.md index 5ac27c907356893dd686a11481091378c1b92f80..5f7fe17baec03feeb6dd33caee0f2247791fd335 100644 --- a/docs/src/ai/agent-panel.md +++ b/docs/src/ai/agent-panel.md @@ -34,7 +34,26 @@ The sections below cover what you can do from here. By default, the Agent Panel uses Zed's first-party agent. -To choose another agent, go to the plus button in the top-right of the Agent Panel and pick one of the [external agents](./external-agents.md) installed out of the box. +Start a new thread with {#kb agent::NewThread}, or open the "New Thread…" menu via the `+` icon in the top-right of the panel toolbar (in the empty state, this menu is exposed as the agent selector button on the left). You can also open that menu with {#kb agent::ToggleNewThreadMenu}. + +From the "New Thread…" menu you can: + +- Pick **Zed Agent** or any installed [external agent](./external-agents.md) to start a new thread with that agent. +- Choose **New From Summary** to start a fresh Zed Agent thread seeded with a summary of the current conversation — useful for compacting long threads as you approach the context window limit. + +{#action agent::NewExternalAgentThread} creates another thread with the currently selected agent. + +You can also start a new thread from the [Threads Sidebar](./parallel-agents.md#threads-sidebar), scoped to a specific project — see [Running Multiple Threads](./parallel-agents.md#running-multiple-threads). + +### Managing Multiple Threads {#multiple-threads} + +You can run multiple agent threads at once, each working independently with its own agent, context window, and conversation history. Open the Threads Sidebar with {#kb multi_workspace::ToggleWorkspaceSidebar} to see all your threads grouped by project. Click any thread to switch to it, or use the thread switcher ({#kb agents_sidebar::ToggleThreadSwitcher}) to cycle between recent threads without opening the sidebar. + +Threads you're no longer working on can be archived by hovering over them in the sidebar and clicking the archive icon, or selecting them and pressing {#kb agent::ArchiveSelectedThread}. The Thread History holds all your threads across all projects, sorted chronologically, and you can restore them at any time. + +If two threads might edit the same files, you can isolate one in a new Git worktree. Use the worktree picker in the title bar to pick which worktree the agent runs in, or create a new one. See [Worktree Isolation](./parallel-agents.md#worktree-isolation) for details. + +For more details on the Threads Sidebar and managing multiple projects, see [Parallel Agents](./parallel-agents.md). ### Editing Messages {#editing-messages} diff --git a/docs/src/ai/overview.md b/docs/src/ai/overview.md index 7ea435975ec5ba12f68a7a3ad19007fd65ba65e8..0859d47c127cb685085c68667b4f8f7f2ba62623 100644 --- a/docs/src/ai/overview.md +++ b/docs/src/ai/overview.md @@ -18,7 +18,9 @@ Zed's AI features run inside a native, GPU-accelerated application built in Rust ## Agentic editing -The [Agent Panel](./agent-panel.md) is where you work with AI agents. Agents can read files, edit code, run terminal commands, search the web, and access diagnostics through [built-in tools](./tools.md). +The [Threads Sidebar](./parallel-agents.md#threads-sidebar) is where you organize agent work. Start a thread, give it a task, and the agent reads, edits, and runs code in your project. You can run multiple threads at once, each using a different agent and working against different projects. See [Tools](./tools.md) for the capabilities available to Zed's built-in agent. + +The [Agent Panel](./agent-panel.md) is the conversation view for the active thread. Use it to send prompts, review changes, add context, and interact with the agent as it works. You can extend agents with additional tools through [MCP servers](./mcp.md), control what they can access with [tool permissions](./tool-permissions.md), and shape their behavior with [rules](./rules.md). @@ -33,6 +35,7 @@ The default provider is Zeta, Zed's open-source model trained on open data. You ## Getting started - [Configuration](./configuration.md): Connect to Anthropic, OpenAI, Ollama, Google AI, or other LLM providers. +- [Parallel Agents](./parallel-agents.md): Run multiple threads at once with the Threads Sidebar. - [External Agents](./external-agents.md): Run Claude Agent, Codex, Aider, or other external agents inside Zed. - [Subscription](./subscription.md): Zed's hosted models and billing. - [Privacy and Security](./privacy-and-security.md): How Zed handles data when using AI features. diff --git a/docs/src/ai/parallel-agents.md b/docs/src/ai/parallel-agents.md new file mode 100644 index 0000000000000000000000000000000000000000..152173f94458fd3433dfd78b7fc3e96be6d6f926 --- /dev/null +++ b/docs/src/ai/parallel-agents.md @@ -0,0 +1,75 @@ +--- +title: Parallel Agents - Zed +description: Run multiple agent threads concurrently using the Threads Sidebar, manage them across projects, and isolate work using Git worktrees. +--- + +# Parallel Agents + +Parallel Agents lets you run multiple agent threads at once, each working independently with its own agent, context window, and conversation history. The Threads Sidebar is where you start, manage, and switch between them. + +Open the Threads Sidebar with {#kb multi_workspace::ToggleWorkspaceSidebar}. + +> **Note:** From version 0.233.0 onward, the Agent Panel and Threads Sidebar are on the left by default. The Project Panel, Git Panel, and other panels move to the right, keeping the thread list and conversation next to each other. To rearrange panels, right-click any panel icon. + +## Threads Sidebar {#threads-sidebar} + +The sidebar shows your threads grouped by project. Each project gets its own section with a header. Threads appear below with their title, status indicator, and which agent is running them. Threads running in linked Git worktrees appear under the same project as their main worktree. See [Worktree Isolation](#worktree-isolation). + +To focus the sidebar without toggling it, use {#kb multi_workspace::FocusWorkspaceSidebar}. To search your threads, press {#kb agents_sidebar::FocusSidebarFilter} while the sidebar is focused. + +### Switching Threads {#switching-threads} + +Click any thread in the sidebar to switch to it. The Agent Panel updates to show that thread's conversation. + +For quick switching without opening the sidebar, use the thread switcher: press {#kb agents_sidebar::ToggleThreadSwitcher} to cycle forward through recent threads, or hold `Shift` while pressing that binding to go backward. This works from both the Agent Panel and the Threads Sidebar. + +### Thread History {#threads-history} + +To remove a thread from the sidebar, you can archive it by hovering over it and clicking the archive icon that appears. You can also select a thread and press {#kb agent::ArchiveSelectedThread}. Running threads cannot be moved to history until they finish. + +The Thread History view holds all your threads, including ones that you have archived. Toggle it with {#kb agents_sidebar::ToggleThreadHistory} or by clicking the clock icon in the sidebar bottom bar, next to the sidebar toggle. + +To restore a thread, open Thread History and click the thread you want to bring back. Zed moves it back to the thread list and opens it in the Agent Panel. If the thread was running in a Git worktree that was removed, Zed restores the worktree automatically. + +To permanently delete a thread, open Thread History, hover over the thread, and click the trash icon. This removes the thread's conversation history and cleans up any associated worktree data. Deleted threads cannot be recovered. + +You can search your threads in history; search will fuzzy match on thread titles. + +### Importing External Agent Threads {#importing-threads} + +If you have external agents installed, Zed will detect whether you have existing threads and invite you to import them into Zed. Once you open Thread History, you'll find an import icon button in the Thread History toolbar that lets you import threads at any time. Clicking on it opens a modal where you can select the agents whose threads you want to import. + +## Running Multiple Threads {#running-multiple-threads} + +Each thread runs independently, so you can send a prompt, open a second thread, and give it a different task while the first continues working. To scope a new thread to a specific project, hover over that project's header in the Threads Sidebar and click the `+` button, or use {#action agents_sidebar::NewThreadInGroup} from the keyboard. See [Creating New Threads](./agent-panel.md#new-thread) for the other entry points. + +Each thread can use a different agent, so you can run Zed's built-in agent in one thread and an [external agent](./external-agents.md) like Claude Code or Codex in another. + +## Multiple Projects {#multiple-projects} + +The Threads Sidebar can hold multiple projects at once. Each project gets its own group with its own threads and conversation history. + +To add another project to the sidebar, click the **Add Project** button (open-folder icon) in the sidebar bottom bar. The popover that opens lists your recent projects and also provides **Add Local Folders** and **Add Remote Folder** buttons at the bottom. + +### Multi-Root Folder Projects {#multi-root-folder-projects} + +A single project can contain multiple folders (a multi-root folder project). Agents can then read and write across all of those folders in a single thread. There are two ways to set one up: + +- **From the sidebar:** Click the **Add Project** button, choose **Add Local Folders**, and select multiple folders in the file picker. They open together as one multi-root project. +- **From the title bar:** Click the project picker (the leftmost project name). For any local entry in the recent projects list, hover it and click the folder-with-plus icon (**Add Folder to this Project**) to merge that project's folders into the current project. + +## Worktree Isolation {#worktree-isolation} + +If two threads might edit the same files, start one in a new Git worktree to give it an isolated checkout. + +Worktrees are managed from the title bar. Click the worktree picker (to the right of the project picker) to switch between existing worktrees or create a new one. New worktrees are created in a detached HEAD state, so you won't accidentally share a branch between worktrees. + +Once you're in a new worktree, use the branch picker next to the worktree picker to create a new branch or check out an existing one. If the branch you pick is already checked out in another worktree, the current worktree stays in detached HEAD until you choose a different branch. + +After the agent finishes, review the diff and merge the changes through your normal Git workflow. If the thread was running in a linked worktree and no other active threads use it, moving the thread to Thread History saves the worktree's Git state and removes it from disk. Restoring the thread from history restores the worktree. + +## See Also {#see-also} + +- [Agent Panel](./agent-panel.md): Manage individual threads and configure the agent +- [External Agents](./external-agents.md): Use Claude Code, Gemini CLI, and other agents +- [Tools](./tools.md): Built-in tools available in each thread diff --git a/docs/src/tasks.md b/docs/src/tasks.md index 3bbef85e9760ad036b75d50f26d3536b2e5b20f1..8364b460378a2853ee42a482847c6fbcc4f59883 100644 --- a/docs/src/tasks.md +++ b/docs/src/tasks.md @@ -96,6 +96,7 @@ These variables allow you to pull information from the current editor and use it - `ZED_SELECTED_TEXT`: currently selected text - `ZED_LANGUAGE`: language of the currently opened buffer (e.g. `Rust`, `Python`, `Shell Script`) - `ZED_WORKTREE_ROOT`: absolute path to the root of the current worktree. (e.g. `/Users/my-user/path/to/project`) +- `ZED_MAIN_GIT_WORKTREE`: absolute path to the main git worktree's working directory. For normal checkouts this equals `ZED_WORKTREE_ROOT`; for linked git worktrees this is the original repository's working directory. - `ZED_CUSTOM_RUST_PACKAGE`: (Rust-specific) name of the parent package of $ZED_FILE source file. To use a variable in a task, prefix it with a dollar sign (`$`): @@ -229,6 +230,31 @@ This could be useful for launching a terminal application that you want to use i } ``` +## Hooks + +In addition to being spawned manually, tasks can be configured to run automatically in response to certain Zed events by adding a hook to the `hooks` field on a task template. A task with a matching hook will be resolved and spawned when that event fires. + +The following hooks are currently supported: + +- `create_worktree` — runs after Zed creates a new linked Git worktree, either directly through the CLI or through the UI with the worktree modal. The task is spawned with `ZED_WORKTREE_ROOT` pointing at the newly created worktree and `ZED_MAIN_GIT_WORKTREE` pointing at the original repository's working directory, which makes these hooks well-suited to copying untracked files (such as `.env` files) or running per-worktree setup commands. + +Hook tasks are resolved from the same global and worktree-local `tasks.json` files as manually spawned tasks, and multiple tasks may register for the same hook; they all run when the hook fires. A hook task still benefits from the usual task configuration fields — `cwd`, `env`, `reveal`, `hide`, and so on — so you can control how much of the terminal UI is shown while it runs. + +```json [tasks] +[ + { + "label": "copy .env into new worktree", + "command": "cp", + "args": ["$ZED_MAIN_GIT_WORKTREE/.env", "$ZED_WORKTREE_ROOT/.env"], + "hooks": ["create_worktree"], + "reveal": "no_focus", + "hide": "on_success" + } +] +``` + +Tasks that define `hooks` are still available from the task modal like any other task, so the same template can be reused for manual runs. + ## VS Code Task Format When importing VS Code tasks from `.vscode/tasks.json`, you can omit the `label` field. Zed automatically generates labels based on the task type: