mirror of
https://github.com/penpot/penpot.git
synced 2026-11-06 01:50:39 +00:00
The extension's service worker holds one WebSocket per MCP server URL and user token used by its sessions, on the endpoint the plugin uses. Each connection registers as a wake agent with a stable agent ID, sends the full session list whenever it changes, and sends a heartbeat every 20 seconds, which also keeps the worker running. It reconnects with capped backoff and stops for good when the server closes it with code 1008. A connection whose last session goes is closed. An alarm every 30 seconds restarts the worker after Chrome stops it, so the connections open again. On a wake request, when waking is turned on and a tab holds the session, the extension activates the tab and focuses its window, which makes the browser resume a frozen page, and answers activated. Otherwise it answers disabled, unknown-session, or tab-closed for a tab that no longer exists, whose session it then forgets. Waking stays on until the user turns it off; the setting is kept in chrome.storage.local.