zed-industries/zed
Terminal
Active contributors: kubkon, Veykril
Purpose
Zed embeds a real terminal. Tasks run there, the agent shells through it, and you can drop into a shell whenever you need. The implementation is built on alacritty_terminal and rendered through GPUI.
Crates
| Crate | Role |
|---|---|
crates/terminal |
Headless terminal model (uses alacritty) |
crates/terminal_view |
The GPUI view that renders a terminal |
crates/task |
Task definitions consumed by the terminal |
crates/tasks_ui |
Task picker UI |
crates/shell_command_parser |
Parses shell-quoted command strings |
Key abstractions
| Type | File | Description |
|---|---|---|
Terminal |
crates/terminal/src/terminal.rs |
Headless terminal session (a PTY + alacritty grid) |
TerminalView |
crates/terminal_view/src/terminal_view.rs |
The GPUI element |
TerminalSettings |
crates/terminal/src/... |
User-tunable behaviour |
Task |
crates/task/src/task.rs |
A reproducible runnable |
How it works
graph TD
User[User] -->|type| TV[TerminalView]
TV -->|bytes| T[Terminal]
T -->|PTY write| Sh[Shell process]
Sh -->|PTY read| T
T -->|cells| TV
Tasks[task_store] -->|spawn| TTasks
Tasks are JSON-defined runnables (tasks.json) keyed by name. The terminal can spawn them via the task picker (crates/tasks_ui). Per-task config supports:
- Working directory (project root, file dir, custom).
- Environment variables.
- Shell selection.
- Reveal-on-error / always.
- Reuse semantics (kill previous instance / open in new).
Rendering
crates/terminal_view paints alacritty's grid via GPUI elements, with attention to:
- Subpixel layout (recent commit:
Support BGR subpixel layout). - True color, bold, italic, underline, strikethrough.
- Hyperlink detection (URLs become click targets).
- Multi-cursor selection; copy/paste integrating with the system clipboard.
Hyperlink detection
The view inspects rendered cells for URL-shaped strings and emits clickable spans. Path-shaped strings can also become navigable links into the project (crates/util/paths.rs::PathWithPosition).
Integration points
- Spawned by: the agent's shell tool, the task system, or a user manually opening a terminal.
- Inputs:
TerminalSettings,tasks.json, environment. - Outputs: PTY writes to the child process; rendered grid into the GPUI tree.
Entry points for modification
- New escape-sequence handling —
crates/terminal/src/.... - Render-side issues —
crates/terminal_view/src/terminal_view.rs. - Task schema changes —
crates/task/src/task.rs.
Related pages
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.