Resolves once a mount matching query is present (immediately if it already
is). Handy for "use it when it appears" — e.g.
await waitForMount({ type: 'firestore' }) before reading /firestore.
timeoutMs (optional, additive) rejects with a timeout-coded error instead of
waiting forever. Omit it to keep the original unbounded behaviour — but prefer
setting it on any path whose caller would otherwise hang silently: a mount that
never arrives is indistinguishable from one that is merely slow, and an awaited
promise that never settles surfaces to the user as a feature that quietly does
nothing.
Hazard — onMountsChange calls its listener SYNCHRONOUSLY on subscribe (the
documented initial replay). So when the mount is already present — the common
case, since callers typically await the host request that creates it first —
the callback below runs during the onMountsChange(...) call, before the
assignment to unsubscribe completes. unsubscribe is therefore declared with
let ABOVE the subscription and read only inside a deferred closure: writing
const unsubscribe = onMountsChange(...) and referencing it in the callback
throws ReferenceError: Cannot access 'unsubscribe' before initialization (a
temporal-dead-zone read) on exactly that path. That bug silently broke
openSettings() — and with it the agent's conversation memory.
Resolves once a mount matching
queryis present (immediately if it already is). Handy for "use it when it appears" — e.g.await waitForMount({ type: 'firestore' })before reading/firestore.timeoutMs(optional, additive) rejects with atimeout-coded error instead of waiting forever. Omit it to keep the original unbounded behaviour — but prefer setting it on any path whose caller would otherwise hang silently: a mount that never arrives is indistinguishable from one that is merely slow, and an awaited promise that never settles surfaces to the user as a feature that quietly does nothing.Hazard —
onMountsChangecalls its listener SYNCHRONOUSLY on subscribe (the documented initial replay). So when the mount is already present — the common case, since callers typicallyawaitthe host request that creates it first — the callback below runs during theonMountsChange(...)call, before the assignment tounsubscribecompletes.unsubscribeis therefore declared withletABOVE the subscription and read only inside a deferred closure: writingconst unsubscribe = onMountsChange(...)and referencing it in the callback throwsReferenceError: Cannot access 'unsubscribe' before initialization(a temporal-dead-zone read) on exactly that path. That bug silently brokeopenSettings()— and with it the agent's conversation memory.