Skip to main content

Module watcher

Module watcher 

Source
Expand description

Polling-based watcher for Gemini CLI conversation files.

Gemini rewrites the chat JSON on every turn rather than appending, so there’s no byte-offset tail to follow. Instead, each poll():

  1. Re-parses the main chat file and every sibling sub-agent file.
  2. Diffs messages[] length against the last-seen per-file state, emitting WatcherEvent::Turn for any new messages.
  3. Checks toolCalls[].status transitions on previously-emitted messages and emits WatcherEvent::TurnUpdated when a status flips (e.g. pendingsuccess).
  4. Detects new sub-agent chat files and emits WatcherEvent::Progress { kind: "subagent_started" }; when a sub-agent’s summary appears, emits WatcherEvent::Progress { kind: "subagent_complete" }.

The watcher is deliberately polling-based in v1 — consumers drive the cadence. A push-based notify-powered async variant can layer on top later.

Structs§

ConversationWatcher
Watches a Gemini conversation for new turns and tool-call updates.