Open-Source Wikis

/

Zed

/

Apps

/

zed

zed-industries/zed

zed

Active contributors: ConradIrwin, mikayla-maki, Veykril, SomeoneToIgnore, cole-miller

Purpose

The zed crate produces the desktop editor binary. It owns the application's startup sequence, wires every subsystem into a running GPUI app, exposes top-level actions and menus, and hosts integration with the OS (single-instance handling, URL handlers, file association). It is the entry point that turns ~230 sibling crates into "the editor."

Directory layout

crates/zed/
├── build.rs                    # Embeds version/commit metadata
├── Cargo.toml                  # Heavy dependency block — pulls in nearly everything
├── RELEASE_CHANNEL             # Build-time release-channel marker file
├── contents/                   # OS bundle resources (.icns, .desktop, etc.)
├── resources/                  # Default settings, keymaps, prompts
└── src/
    ├── main.rs                 # Entry point — `pub fn main()`, ~2k LOC
    ├── zed.rs                  # Top-level wiring shared across subsystems (~6.6k LOC)
    ├── reliability.rs          # Crash handler integration
    ├── visual_test_runner.rs   # Visual regression test harness
    └── zed/
        ├── app_menus.rs        # Native macOS menu bar
        ├── edit_prediction_registry.rs  # Wires edit-prediction providers
        ├── mac_only_instance.rs / windows_only_instance.rs  # Single-instance enforcement
        ├── migrate.rs          # Settings/keymap migrations on startup
        ├── open_listener.rs    # IPC listener for the CLI to forward args/URLs
        ├── open_url_modal.rs   # In-app URL opener
        ├── quick_action_bar/   # The toolbar above the editor
        ├── remote_debug.rs     # Remote debugger entry point
        ├── telemetry_log.rs    # In-app log viewer (telemetry-related)
        ├── visual_tests.rs     # Visual-test runner glue
        └── ...

Key abstractions

Type / function File Description
pub fn main() crates/zed/src/main.rs Boot. Parses args, sets up GPUI app, opens window(s)
Application::new() (GPUI) via gpui Root context for the desktop app
OpenListener crates/zed/src/zed/open_listener.rs Receives args/URLs from a CLI invocation while the app is running
mac_only_instance / windows_only_instance crates/zed/src/zed/... Enforces single instance per user
quick_action_bar crates/zed/src/zed/quick_action_bar/ Toolbar with assistant, debugger, and other quick actions
app_menus crates/zed/src/zed/app_menus.rs Native menu definitions
edit_prediction_registry crates/zed/src/zed/edit_prediction_registry.rs Registers Zeta + Copilot + Supermaven providers
migrate crates/zed/src/zed/migrate.rs Runs crates/migrator rules on startup

How it works

main does roughly the following:

graph TD
    A[parse args / env] --> B[init crash handler]
    B --> C[init GPUI App]
    C --> D[load SettingsStore]
    D --> E[load BaseKeymap]
    E --> F[init Client + Cloud auth]
    F --> G[init LanguageRegistry]
    G --> H[init ExtensionHost]
    H --> I[init AgentPanel + ThreadStore]
    I --> J[init ProjectPanel, terminal, debugger UI, ...]
    J --> K[run OpenListener]
    K --> L[open initial workspace]
    L --> M[event loop]

Subsystem initialization is register-then-run: each subsystem registers globals or factories on the App, and the workspace fetches them on demand when a window is created.

Integration points

  • Inputs: Command-line args (via clap), CliRequest IPC from the CLI, OS file/URL associations, environment variables (crates/zed_env_vars).
  • Owns: the GPUI App, all global registries (LanguageRegistry, Client, UserStore, SettingsStore, ExtensionHostProxy, ThreadStore, PromptBuilder, NodeRuntime, AppSession).
  • Cross-cutting: every crate listed in Cargo.toml is reachable from main. The crate is the seam between "library code" and "app".

Entry points for modification

If you need to:

  • Add a new top-level subsystem that the app should boot — register it in crates/zed/src/main.rs near the other init_* calls.
  • Add a quick-action — see crates/zed/src/zed/quick_action_bar/.
  • Add a startup migration — crates/zed/src/zed/migrate.rs and the crates/migrator crate.
  • Adjust the macOS menu bar — crates/zed/src/zed/app_menus.rs.
  • Hook a new URL scheme or argument — crates/zed/src/zed/open_listener.rs plus URL_PREFIX in crates/cli/src/main.rs.

For app-wide policies (e.g. how to treat opt-in telemetry, how to wire a new LLM provider), look in crates/zed/src/zed.rs. It is the long file that holds most of the cross-subsystem glue.

  • Architecture — how this app wires the systems together
  • GPUI — the runtime backing the UI
  • Settings — how the SettingsStore is built up
  • AI agent — agent integration entry points

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

zed – Zed wiki | Factory