docs/diagrams/screen-share-system.mmd
flowchart TD
A["User asks to share screen"] --> B["Voice tool / reply pipeline
start_screen_watch"]
B --> C{"Native Discord watch available?"}
C -->|yes| D["clankvox native stream watch
subscribe + decrypt + decode"]
C -->|no / fallback| E["ScreenShareSessionManager.createSession()
token + share URL"]
E --> F["Share page /share/:token
capture loop every keyframeIntervalMs"]
F --> G["POST /api/voice/share-session/:token/frame"]
D --> H["Frame ingest / latest frame buffer"]
G --> H
H --> I["Background note loop<br/>adaptive interval + change cooldown"]
I --> J["Rolling note buffer<br/>streamWatch.noteEntries"]
J --> K["Prompt note payload<br/>streamWatch.notePayload"]
H --> L["Commentary trigger check<br/>share start / interval / change"]
K --> M["Voice brain turn"]
H -->|commentary or screen question| M
L -->|quiet-window gates pass| M
J --> N["Context compaction<br/>pendingCompactionNotes"]
N --> O["Running session summary<br/>compactedContextSummary"]
