feat(platform): extend discovery/DM span metadata for Phase 479

Add discovery.join span, discovery.list meshLive/filteredCount, dm.open
reusedChannel, and contacts.accept accepted flag.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-24 05:44:02 -04:00
co-authored by Cursor
parent 459c9cc6e6
commit 929517f860
2 changed files with 50 additions and 6 deletions
+2
View File
@@ -39,6 +39,8 @@ Expose a single `EventEmitter` API the UI drives over IPC (`apps/pearcord/index.
**v0.8.430 (Phase 467):** `voice.leave` span `end` includes `leavingIsStage`; `screen.start` span `end` includes `label`. Bundle: `npm run test:phase467-voice-stage`. See [VOICE.md](../../docs/VOICE.md), [STAGE_CHANNELS.md](../../docs/STAGE_CHANNELS.md). **v0.8.430 (Phase 467):** `voice.leave` span `end` includes `leavingIsStage`; `screen.start` span `end` includes `label`. Bundle: `npm run test:phase467-voice-stage`. See [VOICE.md](../../docs/VOICE.md), [STAGE_CHANNELS.md](../../docs/STAGE_CHANNELS.md).
**v0.8.442 (Phase 479):** `discovery.list` `meshLive`/`filteredCount`; `discovery.join` on `joinPublicDiscovery`; `dm.open` `reusedChannel`; `contacts.accept` `accepted`. UI discovery compositor. Bundle: `npm run test:phase479-discovery`. See [DISCOVERY.md](../../docs/DISCOVERY.md).
**v0.8.441 (Phase 478):** `notification.markRead` `wasUnread`/`hadMessageId`; `notification.markAll` `unreadBefore`; `notification.open` `hasMessageId`; `inbox.mark-read` `clearedInboxCount`. UI `syncNotificationPanelsDuringGuildLoading` compositor. Bundle: `npm run test:phase478-notifications`. See [NOTIFICATIONS.md](../../docs/NOTIFICATIONS.md), [INBOX.md](../../docs/INBOX.md). **v0.8.441 (Phase 478):** `notification.markRead` `wasUnread`/`hadMessageId`; `notification.markAll` `unreadBefore`; `notification.open` `hasMessageId`; `inbox.mark-read` `clearedInboxCount`. UI `syncNotificationPanelsDuringGuildLoading` compositor. Bundle: `npm run test:phase478-notifications`. See [NOTIFICATIONS.md](../../docs/NOTIFICATIONS.md), [INBOX.md](../../docs/INBOX.md).
**v0.8.440 (Phase 477):** `message.send` `hasMention`/`isSlash`; `message.edit` `priorLength`; `message.delete` `hadAttachments`; `reaction.toggle` `emojiLength`; `pin.message`/`pin.unpin` span start `channelId`. UI `syncMessagingPanelsDuringGuildLoading`. Bundle: `npm run test:phase477-messaging`. See [MESSAGING.md](../../docs/MESSAGING.md), [REACTIONS.md](../../docs/REACTIONS.md). **v0.8.440 (Phase 477):** `message.send` `hasMention`/`isSlash`; `message.edit` `priorLength`; `message.delete` `hadAttachments`; `reaction.toggle` `emojiLength`; `pin.message`/`pin.unpin` span start `channelId`. UI `syncMessagingPanelsDuringGuildLoading`. Bundle: `npm run test:phase477-messaging`. See [MESSAGING.md](../../docs/MESSAGING.md), [REACTIONS.md](../../docs/REACTIONS.md).
+48 -6
View File
@@ -12,7 +12,12 @@ const { PearcordGuild } = require('pearcord-guild')
const { PearcordMessage } = require('pearcord-message') const { PearcordMessage } = require('pearcord-message')
const { PearcordPresence } = require('pearcord-presence') const { PearcordPresence } = require('pearcord-presence')
const { PearcordInvite } = require('pearcord-invite') const { PearcordInvite } = require('pearcord-invite')
const { PearcordDM, DM_GUILD_ID, listDmConversations } = require('pearcord-dm') const {
PearcordDM,
DM_GUILD_ID,
dmChannelId,
listDmConversations
} = require('pearcord-dm')
const { PearcordAttachments } = require('pearcord-attachments') const { PearcordAttachments } = require('pearcord-attachments')
const { PearcordModeration } = require('pearcord-moderation') const { PearcordModeration } = require('pearcord-moderation')
const { PearcordVoice } = require('pearcord-voice') const { PearcordVoice } = require('pearcord-voice')
@@ -921,12 +926,25 @@ class PearcordPlatform extends EventEmitter {
const span = this.log.time('dm.open', { peerUserId: peerUserId || null }) const span = this.log.time('dm.open', { peerUserId: peerUserId || null })
try { try {
await this._initDmSession() await this._initDmSession()
const uid = this.identity?.user?.id
const reusedChannel =
uid && peerUserId
? !!(await this.db.get(COLLECTIONS.CHANNELS, {
guildId: DM_GUILD_ID,
id: dmChannelId(uid, peerUserId)
}))
: false
const channel = await this.dm.openWithPeer({ peerUserId, peerDisplayName }) const channel = await this.dm.openWithPeer({ peerUserId, peerDisplayName })
this.messages.setChannel({ channelId: channel.id, guildId: DM_GUILD_ID }) this.messages.setChannel({ channelId: channel.id, guildId: DM_GUILD_ID })
this.activeChannelId = channel.id this.activeChannelId = channel.id
await this.markChannelRead(channel.id, DM_GUILD_ID) await this.markChannelRead(channel.id, DM_GUILD_ID)
this.emit('dm', channel) this.emit('dm', channel)
span.end({ channelId: channel.id, group: false, peerUserId: peerUserId || null }) span.end({
channelId: channel.id,
group: false,
peerUserId: peerUserId || null,
reusedChannel
})
return channel return channel
} catch (err) { } catch (err) {
this.log.error('dm.open error', { this.log.error('dm.open error', {
@@ -956,7 +974,7 @@ class PearcordPlatform extends EventEmitter {
return channel return channel
} catch (err) { } catch (err) {
this.log.error('dm.group error', { this.log.error('dm.group error', {
err: err?.message || String(err) error: err?.message || String(err)
}) })
throw err throw err
} }
@@ -1229,7 +1247,11 @@ class PearcordPlatform extends EventEmitter {
try { try {
if (!this.contacts) throw new Error('contacts unavailable') if (!this.contacts) throw new Error('contacts unavailable')
const row = await this.contacts.acceptRequest(peerUserId) const row = await this.contacts.acceptRequest(peerUserId)
span.end({ status: row?.status || null, peerUserId: peerUserId || null }) span.end({
status: row?.status || null,
peerUserId: peerUserId || null,
accepted: row?.status === 'friend'
})
return row return row
} catch (err) { } catch (err) {
this.log.error('contacts.accept error', { this.log.error('contacts.accept error', {
@@ -7434,7 +7456,20 @@ class PearcordPlatform extends EventEmitter {
async joinPublicDiscovery (inviteCode) { async joinPublicDiscovery (inviteCode) {
if (!inviteCode) throw new Error('invite code required') if (!inviteCode) throw new Error('invite code required')
return this.joinInvite(inviteCode) const span = this.log.time('discovery.join', {
inviteLen: String(inviteCode).length
})
try {
const guild = await this.joinInvite(inviteCode)
span.end({ guildId: guild?.id || null, joined: !!guild })
return guild
} catch (err) {
this.log.error('discovery.join error', {
error: err?.message || String(err)
})
span.end()
throw err
}
} }
async _memberRoles () { async _memberRoles () {
@@ -11914,9 +11949,16 @@ class PearcordPlatform extends EventEmitter {
if (!light) { if (!light) {
const listSpan = this.log.time('discovery.list', {}) const listSpan = this.log.time('discovery.list', {})
publicListings = await this.discovery.listPublicListings() publicListings = await this.discovery.listPublicListings()
const filter = this._discoveryFilter
const filteredCount = this.discovery
? this.discovery.filterPublicListings(publicListings, filter).length
: publicListings.length
listSpan.end({ listSpan.end({
count: publicListings.length, count: publicListings.length,
filterTag: this._discoveryFilter?.tag || null filterTag: filter?.tag || null,
meshLive: (this.discovery?.peers?.size || 0) > 0,
fromCache: false,
filteredCount
}) })
} else { } else {
publicListings = await this.discovery.listPublicListings() publicListings = await this.discovery.listPublicListings()