@@ -78,8 +78,22 @@ export type CommandOp =
7878 | 'tabs.query'
7979 | 'inspect'
8080
81+ /**
82+ * Granularity of a dev-loop reload. Mirrors `ReloadType` in
83+ * plugin-reload/classify-reload.ts: the launched-browser path feeds this
84+ * decision to the CDP controller; the `--no-browser` path feeds the same
85+ * decision to the broker, which broadcasts a {@link ReloadFrame} to the SW
86+ * producer.
87+ */
8188export type ReloadType = 'full' | 'service-worker' | 'content-scripts'
8289
90+ /**
91+ * Everything a {@link ReloadFrame} can carry in `reloadType`: the extension
92+ * reload granularities plus `'page'`, a notify-only signal for page-only
93+ * edits (popup/options/sidebar/devtools/newtab). For `'page'` the producer
94+ * performs NO reload (livereload owns the refresh); it only forwards the
95+ * announcement so the devtools pill mirrors the dev loop.
96+ */
8397export type DevReloadKind = ReloadType | 'page'
8498
8599export type GapReason =
@@ -160,12 +174,27 @@ export interface ResultFrame {
160174 }
161175}
162176
177+ /**
178+ * Dev-loop reload broadcast, server → producer. Sent by the broker on a compile
179+ * that completed without a CDP controller (`--no-browser`, headless/CI, remote)
180+ * so the service-worker producer can self-reload. Unlike a `reload` CommandFrame
181+ * (a controller-issued, `--allow-control`-gated act verb that expects a result),
182+ * this is a fire-and-forget dev-server signal, no cmdId, no result.
183+ */
163184export interface ReloadFrame {
164185 type : 'reload'
165186 reloadType : DevReloadKind
166187 changedContentScriptEntries ?: string [ ]
188+ /**
189+ * Server-built human context label, e.g. "content_script (content/scripts.tsx)".
190+ * Shown VERBATIM by every announcement surface (CLI stdout, the page's
191+ * devtools console line, the devtools-extension pill) so the three can
192+ * never disagree about what is reloading.
193+ */
167194 label ?: string
195+ /** Project-relative source files that triggered this reload. */
168196 changedFiles ?: string [ ]
197+ /** Emitted scripts/ bundles the SW should replay its executeScript calls for. */
169198 changedScriptFiles ?: string [ ]
170199}
171200
@@ -177,6 +206,15 @@ export interface ReloadAckFrame {
177206 label ?: string
178207}
179208
209+ /**
210+ * Server → producer keepalive. An MV3 service worker idles out after ~30s
211+ * without events, and a stopped SW holds no control socket, reload
212+ * broadcasts would reach zero producers and silently apply to nothing
213+ * (quiet extensions lost SW/manifest reloads once >30s passed between
214+ * edits). Receiving any WebSocket message resets the SW idle timer
215+ * (Chrome 116+), so a periodic ping keeps the dev extension's SW
216+ * responsive for the whole dev session. Producers ignore the frame.
217+ */
180218export interface PingFrame {
181219 type : 'ping'
182220}
@@ -198,7 +236,11 @@ export const CONTROL_WS_PATH = '/extjs-control'
198236// so it never has to spell 4002 in its own source. A close in this range is
199237// always a deliberate refusal, never a transport failure.
200238
239+ /** The hello named an instanceId from a previous dev session. */
201240export const CLOSE_BAD_INSTANCE = 4001
241+ /** The hello was malformed: wrong envelope version, or an unknown role. */
202242export const CLOSE_BAD_HELLO = 4002
243+ /** A controller dialed a session started without `--allow-control`. */
203244export const CLOSE_CONTROL_UNAVAILABLE = 4003
245+ /** The socket fell far enough behind that it was dropped to protect the broker. */
204246export const CLOSE_SLOW_CONSUMER = 4008
0 commit comments