---
title: Zed
description: Zed's built-in agent is picked up on its own. Counting your typing in Zed needs Hindsight's extension.
sidebar:
  order: 9
---

Zed is two separate things. Its built-in agent needs no setup. Your typing needs Hindsight's Zed extension, which you
add in Zed yourself.

## Zed's agent

The agent in Zed's agent panel has no hooks, so Hindsight reads its saved threads instead. Zed writes each thread to
`threads/threads.db` in its data folder every time a message is added. While the daemon runs, it checks that file every 3
seconds and reads the threads that changed. It only opens the file read-only.

Zed's data folder is:

| System | Folder |
| --- | --- |
| Windows | `%LOCALAPPDATA%\Zed` |
| macOS | `~/Library/Application Support/Zed` |
| Linux | `$XDG_DATA_HOME/zed`, or `~/.local/share/zed` |
| Linux (Flatpak) | `~/.var/app/dev.zed.Zed/data/zed` |

What it turns the threads into:

- A message you sent: a prompt and the start of a run.
- Each tool call: the tool name, and for `edit_file` and `write_file` the lines added and removed, plus hashes of the
  lines written, so it can tell later how many you kept.
- A reply that calls no tools, which ends the turn: the end of the run, with the tokens the thread used since the last
  one and the model.

A thread the agent started itself (with its `spawn_agent` tool) is the agent's work, so its messages start runs but
are never your prompts.

Times are when the daemon noticed, a few seconds late at most. Anything that happened while the daemon wasn't running
isn't recorded. When it starts it reads recent threads (saved in the last 30 days) to learn where they stand, and only
what they get after that counts.

Other agents you run inside Zed's panel, such as Claude Code, Codex or Gemini over ACP, keep their threads to themselves
and aren't in that file. If one of them has hooks, like Claude Code, its own page covers it.

The prompt is read for its length and a hash, and tool calls for their name, line counts and a hash of the path.

## Your typing: the extension

Zed gives extensions no way to watch edits, so Hindsight's extension (id `hindsight`) works as a language server. It's
attached to a long list of languages, from Rust, Python and TypeScript to Markdown, YAML and plain text, and it offers
no completions, hovers or diagnostics. It only listens. A language Zed doesn't have installed is skipped.

The server is the daemon itself, running as `hindsight-daemon lsp`. Zed tells it about each change to an open file. It
counts typing with the same rules as the [VS Code extension](/docs/tools/vscode), keeps a copy of each open file in memory
to do it (never written anywhere), and stores the counts every 15 seconds, on save and on exit. It stores them straight
into the daemon's database, so edits count even if the daemon isn't running. It also remembers which lines you
typed, so commits can tell yours from the agent's.

It reports typing and lines only. It doesn't report diff reviews or reads.

### What you do by hand

Hindsight can't install a Zed extension for you. What `connect` does is write a file telling the extension where the
daemon is:

```text
<Zed data folder>/extensions/work/hindsight/daemon-path
```

It does that for every Zed data folder that has an `extensions` folder. If the extension isn't installed yet, the connect
line says "add the Hindsight extension in Zed". Add it in Zed, and typing starts counting.

The extension finds the daemon from, in order: Zed's `lsp.hindsight.binary.path` setting, the `daemon-path` file, then
`hindsight-daemon` on your `PATH`. If it can't find it, Zed shows an error that says so. You can point at the daemon
yourself in Zed's settings, with `"arguments": ["lsp"]`.

## Check that it's working

For the agent, run this in a terminal, use Zed's agent, and watch what it prints:

```powershell
hindsight-daemon zed-agent
```

It lists what it would record, one line per event, and records nothing. Ctrl+C stops it. Without the app, you can
also type in Zed and look at the timeline on your [Today page](/docs/dashboard/today). Errors from the language server go
to Zed's language server log.

## Disconnect

```powershell
hindsight-daemon disconnect
```

This deletes the `daemon-path` file. The extension itself stays installed in Zed, so remove it there if you want it gone.
Without the file it falls back to `PATH`. It comes back at Hindsight's next start unless you uninstall Hindsight.
