<!-- https://zerolog.ch/docs/stitch · Docs / Chat -->
# Context stitching

Bring relevant parts of your own material into a conversation. Switch on sources in Settings → Memory → Context Index.

## The seam

### Your side

- Your past chats
- Gmail, Drive and Calendar, once your Google account is connected

### The conversation

On every message, ZeroLog searches the index by keyword and adds the best four matches. The chat shows a notice naming the sources it used.

*Only your own material is indexed, and no administrator can read it.*

## Where the seam ends

Nothing is indexed until you switch a source on, and each source is separate. Then press Index now.

Search the index, delete one source or delete everything in Settings → Memory → Context Index. Anonymous chats are never indexed. Search is by keyword, not by meaning.

You control what is included

## How the context index reaches a chat

Mermaid source of the diagram on this page:

```mermaid
%% Context stitching: from sources to a chat turn. Facts from server/stitch.js (SOURCES, CHUNK_CHARS 1200, contextFor k=4, lexical FTS) and server/routes/chats.js (stitched_context notice).
flowchart TB
  src["Sources you switch on:<br/>your chats, Gmail, Drive, Calendar<br/>(Google needs a connection)"]
  idx["Index now: text is cut into<br/>chunks and stored encrypted;<br/>search is by keyword"]
  msg["You send a message"]
  find["Best 4 chunks for<br/>your message are found"]:::hot
  add["Added to the turn,<br/>chat shows a notice<br/>naming the sources"]

  src --> idx
  idx --> find
  msg --> find
  find --> add

  linkStyle 1 stroke:#8f7ac9
  linkStyle 2 stroke:#8f7ac9
  linkStyle 3 stroke:#8f7ac9
```
