Phase 782: surface presence count on guild-sync ingest and ready events

Return presence applied from vector ingest; wire emits guild-sync-ready when
presenceVector-only bundles arrive so workers push peer status to UI.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-03 21:16:59 -04:00
co-authored by Cursor
parent bc663d29fc
commit f5f2f2987d
3 changed files with 18 additions and 7 deletions
+2
View File
@@ -2,6 +2,8 @@
Application facade: one `PearcordPlatform` class that wires identity, database, guild mesh, DMs, invites, voice, discovery, bots, and dozens of feature modules for the Pearcord desktop sidecar and companion. **Mixin sources:** [`mixins/README.md`](mixins/README.md) — `domain/`, `json-export/`, `runtime/{core,mesh,guild-sync,search-discovery,partition-heal,view,voice-dm,features}/`. Architecture: [PLATFORM_MIXINS.md](../../docs/PLATFORM_MIXINS.md). Regenerate after manifest edits: `cd apps/pearcord && npm run regenerate:platform-mixins`. OTA prestage recursively verifies symbols under `mixins/` — [RELEASE.md](../../docs/RELEASE.md#prestage-sync-file-deps).
**Phase 782 (v0.8.749):** Presence vector ingest → `guild-sync-ready` with `presence`; wire vector-only slice detection. Bundle: `npm run test:ci-phase782`.
**Phase 781 (v0.8.748):** Member roster mesh sync — `guild-sync-ready` on member-page ingest; UI propagation via worker structural push. Bundle: `npm run test:ci-phase781`.
**Phase 780 (v0.8.747):** Guild mesh loading sync — peer retry on `createGuild` with 0 peers; `guild-loading` structural push path (worker + ui-flow). Bundle: `npm run test:ci-phase780`.
@@ -582,11 +582,13 @@ async _ingestGuildSync (payload) {
if (added > 0) {
this._gossipGuildSyncAck(this.activeChannelId)
}
let presenceApplied = 0
if (payload.presenceVector?.length) {
await this._ingestPresenceVectorBundle(
payload.guildId,
payload.presenceVector
).catch(() => {})
presenceApplied =
(await this._ingestPresenceVectorBundle(
payload.guildId,
payload.presenceVector
).catch(() => 0)) || 0
}
const reactionChanges = await this._ingestReactionsSyncBundle(payload.reactions || [])
let sparse = { mode: 'gossip', added: 0 }
@@ -613,6 +615,7 @@ async _ingestGuildSync (payload) {
return {
messages: added,
members: membersAdded,
presence: presenceApplied,
reactions: reactionChanges,
sparse,
attachPull,
@@ -244,7 +244,8 @@ _wireGuild (guildInstance) {
})
const payloadMsgs = payload?.messages?.length || 0
const payloadMems = payload?.members?.length || 0
const hasSlice = payloadMsgs > 0 || payloadMems > 0
const payloadPres = payload?.presenceVector?.length || 0
const hasSlice = payloadMsgs > 0 || payloadMems > 0 || payloadPres > 0
if (!result && !hasSlice) return
this._lastGuildSyncIngestAt = Date.now()
const msgCount =
@@ -255,11 +256,16 @@ _wireGuild (guildInstance) {
typeof result === 'object'
? Math.max(result.members || 0, payloadMems)
: payloadMems
if (msgCount > 0 || memCount > 0 || hasSlice) {
const presCount =
typeof result === 'object'
? Math.max(result.presence || 0, payloadPres)
: payloadPres
if (msgCount > 0 || memCount > 0 || presCount > 0 || hasSlice) {
this.emit('guild-sync-ready', {
guildId: payload?.guildId,
messages: msgCount,
members: memCount
members: memCount,
presence: presCount
})
if (payload?.guildId === this.guild?.guild?.id) {
this._touchAllGuildMeshPeersSeen(payload.guildId, 'guild-sync')