Add dm.open, contacts, and discovery.list platform spans (Phase 452).

Structured logging for DM open, friend requests, and public listing refresh improves discovery/DM diagnostics and matches tightened dm-errors dev-log filters.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-24 00:04:45 -04:00
co-authored by Cursor
parent 2f847deb7e
commit 2089724f92
2 changed files with 32 additions and 5 deletions
+2
View File
@@ -150,6 +150,8 @@ Primary consumer: `apps/pearcord/index.js` sidecar reading pear-pipe JSON.
**v0.8.413 (Phase 450):** `stageAttachment`/`readAttachmentPreview`/`embed.resolve` spans/errors include `guildId` + `channelId`; `_assertCanParticipate('attach')` for read-only attach gate. Dev-log **attachment-errors** filter: `attachment.stage|read`; **embed-errors**: `embed.resolve`. UI: staging bar + btn-attach `aria-busy`, attach-files permission toast, staging/embed keyboard roving, empty-state hints. Bundle: `npm run test:phase450-attachments-media`. **v0.8.413 (Phase 450):** `stageAttachment`/`readAttachmentPreview`/`embed.resolve` spans/errors include `guildId` + `channelId`; `_assertCanParticipate('attach')` for read-only attach gate. Dev-log **attachment-errors** filter: `attachment.stage|read`; **embed-errors**: `embed.resolve`. UI: staging bar + btn-attach `aria-busy`, attach-files permission toast, staging/embed keyboard roving, empty-state hints. Bundle: `npm run test:phase450-attachments-media`.
**v0.8.415 (Phase 452):** `openDM`/`openGroupDM` log `dm.open` spans + `dm.open error`; `sendFriendRequest`/`acceptFriendRequest` log `contacts.request`/`contacts.accept` spans; `_buildView` logs `discovery.list` span + `discovery.list error`. Dev-log **dm-errors** filter: `dm.open|group`, `contacts.request|accept|decline`, `discovery.list`. UI-flow emits `composer-focus-channel` after DM open. Bundle: `npm run test:phase452-discovery-dm`.
**v0.8.414 (Phase 451):** `joinVoiceChannel`/`leaveVoiceChannel`/`joinStageChannel`/`requestStageSpeak`/`approveStageSpeaker`/`demoteStageSpeaker`/`startScreenShare`/`stopScreenShare` spans/errors include `guildId` + `channelId`. Dev-log **voice-errors** filter: `voice.join|leave`, `stage.join|speaker.*`, `screen.start|stop`. UI: voice/stage bars + channel list `aria-busy`, stage connect/speak permission toasts, stage approve keyboard, stream popout autofocus. Bundle: `npm run test:phase451-voice-stage`. **v0.8.414 (Phase 451):** `joinVoiceChannel`/`leaveVoiceChannel`/`joinStageChannel`/`requestStageSpeak`/`approveStageSpeaker`/`demoteStageSpeaker`/`startScreenShare`/`stopScreenShare` spans/errors include `guildId` + `channelId`. Dev-log **voice-errors** filter: `voice.join|leave`, `stage.join|speaker.*`, `screen.start|stop`. UI: voice/stage bars + channel list `aria-busy`, stage connect/speak permission toasts, stage approve keyboard, stream popout autofocus. Bundle: `npm run test:phase451-voice-stage`.
**v0.8.402:** `sendMessage`/`editMessage`/`deleteMessage` log `message.*` spans and errors; `toggleReaction` logs `reaction.toggle` span and `reaction.toggle error` on failure. **v0.8.402:** `sendMessage`/`editMessage`/`deleteMessage` log `message.*` spans and errors; `toggleReaction` logs `reaction.toggle` span and `reaction.toggle error` on failure.
+30 -5
View File
@@ -908,6 +908,7 @@ class PearcordPlatform extends EventEmitter {
} }
async openDM ({ peerUserId, peerDisplayName }) { async openDM ({ peerUserId, peerDisplayName }) {
const span = this.log.time('dm.open', { peerUserId: peerUserId || null })
try { try {
await this._initDmSession() await this._initDmSession()
const channel = await this.dm.openWithPeer({ peerUserId, peerDisplayName }) const channel = await this.dm.openWithPeer({ peerUserId, peerDisplayName })
@@ -915,12 +916,14 @@ class PearcordPlatform extends EventEmitter {
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 })
return channel return channel
} catch (err) { } catch (err) {
this.log.error('dm.open error', { this.log.error('dm.open error', {
peerUserId, peerUserId,
err: err?.message || String(err) err: err?.message || String(err)
}) })
span.end()
throw err throw err
} }
} }
@@ -950,6 +953,7 @@ class PearcordPlatform extends EventEmitter {
} }
async openGroupDM ({ channelId }) { async openGroupDM ({ channelId }) {
const span = this.log.time('dm.open', { channelId: channelId || null, group: true })
try { try {
await this._initDmSession() await this._initDmSession()
const channel = await this.dm.openChannelById(channelId) const channel = await this.dm.openChannelById(channelId)
@@ -957,12 +961,14 @@ class PearcordPlatform extends EventEmitter {
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 })
return channel return channel
} catch (err) { } catch (err) {
this.log.error('dm.open error', { this.log.error('dm.open error', {
channelId, channelId,
err: err?.message || String(err) err: err?.message || String(err)
}) })
span.end()
throw err throw err
} }
} }
@@ -1173,28 +1179,36 @@ class PearcordPlatform extends EventEmitter {
} }
async sendFriendRequest ({ peerUserId, peerDisplayName }) { async sendFriendRequest ({ peerUserId, peerDisplayName }) {
const span = this.log.time('contacts.request', { peerUserId: peerUserId || null })
try { try {
if (!this.contacts) await this._joinContactsMesh() if (!this.contacts) await this._joinContactsMesh()
if (!this.contacts) throw new Error('contacts unavailable') if (!this.contacts) throw new Error('contacts unavailable')
return await this.contacts.sendRequest({ peerUserId, peerDisplayName }) const row = await this.contacts.sendRequest({ peerUserId, peerDisplayName })
span.end({ status: row?.status || null })
return row
} catch (err) { } catch (err) {
this.log.error('contacts.request error', { this.log.error('contacts.request error', {
peerUserId, peerUserId,
err: err?.message || String(err) err: err?.message || String(err)
}) })
span.end()
throw err throw err
} }
} }
async acceptFriendRequest (peerUserId) { async acceptFriendRequest (peerUserId) {
const span = this.log.time('contacts.accept', { peerUserId: peerUserId || null })
try { try {
if (!this.contacts) throw new Error('contacts unavailable') if (!this.contacts) throw new Error('contacts unavailable')
return await this.contacts.acceptRequest(peerUserId) const row = await this.contacts.acceptRequest(peerUserId)
span.end({ status: row?.status || null })
return row
} catch (err) { } catch (err) {
this.log.error('contacts.accept error', { this.log.error('contacts.accept error', {
peerUserId, peerUserId,
err: err?.message || String(err) err: err?.message || String(err)
}) })
span.end()
throw err throw err
} }
} }
@@ -11442,9 +11456,20 @@ class PearcordPlatform extends EventEmitter {
} }
} }
const directory = this.discovery ? await this.discovery.listGuilds() : [] const directory = this.discovery ? await this.discovery.listGuilds() : []
const publicListings = this.discovery let publicListings = []
? await this.discovery.listPublicListings() if (this.discovery) {
: [] const listSpan = this.log.time('discovery.list', {})
try {
publicListings = await this.discovery.listPublicListings()
listSpan.end({ count: publicListings.length })
} catch (err) {
this.log.error('discovery.list error', {
err: err?.message || String(err)
})
listSpan.end()
publicListings = []
}
}
const filteredPublicListings = this.discovery const filteredPublicListings = this.discovery
? this.discovery.filterPublicListings(publicListings, this._discoveryFilter) ? this.discovery.filterPublicListings(publicListings, this._discoveryFilter)
: [] : []