Files
ShellBook/apps/server/src/watch

Notebook event source

createNotebookWatcher(workspaceDir, { debounceMs?, onError? }) watches workspaceDir/notebooks recursively. Await ready before relying on events; existing files do not trigger an initial reload. on(listener) returns an unsubscribe function. close() stops watching and cancels pending notifications. Errors reject readiness during startup and reach onError (stderr by default), including errors after readiness. Owners should report failures through their logger.

Subscribe the /api/events broadcaster to this source; it does not create an HTTP route itself. Events are the core protocol's file.changed and file.deleted, with paths relative to notebooks/ and forward slashes. Adds are changes, deletes are deletions, and a per-path debounce (100 ms default) keeps the most recent event. Non-Markdown files are ignored; symlinks are not followed. Chokidar 4 provides recursive Linux/Windows watching and normalizes atomic editor saves, avoiding platform-specific recursion and rename handling with raw fs.watch.