feat(platform): Phase 516 contacts spans — request, accept, decline (v0.8.479)

Extend contacts.request/accept/decline with spanKind metadata,
peerDisplayNameLen, and span.fail on errors; add contacts.decline span.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-24 10:00:46 -04:00
co-authored by Cursor
parent f435ca580e
commit 489117acf6
2 changed files with 35 additions and 9 deletions
+2
View File
@@ -137,6 +137,8 @@ Expose a single `EventEmitter` API the UI drives over IPC (`apps/pearcord/index.
**v0.8.476 (Phase 513):** Guild-admin spans — `channel.create` (`nameLen`, `hadParent`), `channel.delete` (`wasActive`, `channelType`), `channel.reorder` (`updatedCount`, `channelCount`). UI `syncGuildAdminPanelsDuringGuildLoading`, `#composer-guild-admin-hint`, dev-log guild-admin-errors + clipboard meta. Bundle: `npm run test:phase513-guild-admin`. See [CHANNELS.md](../../docs/CHANNELS.md). **v0.8.476 (Phase 513):** Guild-admin spans — `channel.create` (`nameLen`, `hadParent`), `channel.delete` (`wasActive`, `channelType`), `channel.reorder` (`updatedCount`, `channelCount`). UI `syncGuildAdminPanelsDuringGuildLoading`, `#composer-guild-admin-hint`, dev-log guild-admin-errors + clipboard meta. Bundle: `npm run test:phase513-guild-admin`. See [CHANNELS.md](../../docs/CHANNELS.md).
**v0.8.479 (Phase 516):** Contact spans — `contacts.request` (`peerDisplayNameLen`), `contacts.accept` (`accepted`), `contacts.decline` (`declined`). UI `syncContactsPanelsDuringGuildLoading`, **contacts-errors** filter, clipboard contacts meta. Bundle: `npm run test:phase516-contacts`. See [CONTACTS.md](../../docs/CONTACTS.md).
**v0.8.478 (Phase 515):** DM spans — `dm.open` (`spanKind`, `reusedChannel`, `peerDisplayNameLen`), `dm.send` (when `guildId === dm`), `dm.group.create` (`participantCount`, `nameLen`). UI `syncDmsPanelsDuringGuildLoading`, tightened **dm-errors**, clipboard DM meta. Bundle: `npm run test:phase515-dms`. See [DM.md](../../docs/DM.md). **v0.8.478 (Phase 515):** DM spans — `dm.open` (`spanKind`, `reusedChannel`, `peerDisplayNameLen`), `dm.send` (when `guildId === dm`), `dm.group.create` (`participantCount`, `nameLen`). UI `syncDmsPanelsDuringGuildLoading`, tightened **dm-errors**, clipboard DM meta. Bundle: `npm run test:phase515-dms`. See [DM.md](../../docs/DM.md).
**v0.8.477 (Phase 514):** Invite spans — `guild.invite` (`shareCodeLen`, `channelCount`), `invite.join` (`inviteGuildId`, `portable`), `invite.revoke` (`revoked`). UI `syncInvitesPanelsDuringGuildLoading`, `#composer-invite-hint`, dev-log invite-errors + clipboard meta. Bundle: `npm run test:phase514-invites`. See [INVITES.md](../../docs/INVITES.md). **v0.8.477 (Phase 514):** Invite spans — `guild.invite` (`shareCodeLen`, `channelCount`), `invite.join` (`inviteGuildId`, `portable`), `invite.revoke` (`revoked`). UI `syncInvitesPanelsDuringGuildLoading`, `#composer-invite-hint`, dev-log invite-errors + clipboard meta. Bundle: `npm run test:phase514-invites`. See [INVITES.md](../../docs/INVITES.md).
+33 -9
View File
@@ -1257,32 +1257,45 @@ class PearcordPlatform extends EventEmitter {
} }
async sendFriendRequest ({ peerUserId, peerDisplayName }) { async sendFriendRequest ({ peerUserId, peerDisplayName }) {
const span = this.log.time('contacts.request', { peerUserId: peerUserId || null }) const span = this.log.time('contacts.request', {
spanKind: 'contacts.request',
peerUserId: peerUserId || null,
peerDisplayNameLen: String(peerDisplayName || '').trim().length
})
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')
const row = await this.contacts.sendRequest({ peerUserId, peerDisplayName }) const row = await this.contacts.sendRequest({ peerUserId, peerDisplayName })
span.end({ status: row?.status || null }) span.end({
spanKind: 'contacts.request',
status: row?.status || null,
peerUserId: peerUserId || null,
peerDisplayNameLen: String(peerDisplayName || '').trim().length
})
return row 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) error: err?.message || String(err)
}) })
span.end() span.fail(err)
throw err throw err
} }
} }
async acceptFriendRequest (peerUserId) { async acceptFriendRequest (peerUserId) {
const span = this.log.time('contacts.accept', { peerUserId: peerUserId || null }) const span = this.log.time('contacts.accept', {
spanKind: 'contacts.accept',
peerUserId: peerUserId || null
})
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({ span.end({
spanKind: 'contacts.accept',
status: row?.status || null, status: row?.status || null,
peerUserId: peerUserId || null, peerUserId: peerUserId || null,
accepted: row?.status === 'friend' accepted: row?.status === 'accepted' || row?.status === 'friend'
}) })
return row return row
} catch (err) { } catch (err) {
@@ -1290,20 +1303,31 @@ class PearcordPlatform extends EventEmitter {
peerUserId, peerUserId,
error: err?.message || String(err) error: err?.message || String(err)
}) })
span.end() span.fail(err)
throw err throw err
} }
} }
async declineFriendRequest (peerUserId) { async declineFriendRequest (peerUserId) {
const span = this.log.time('contacts.decline', {
spanKind: 'contacts.decline',
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.declineRequest(peerUserId) const row = await this.contacts.declineRequest(peerUserId)
span.end({
spanKind: 'contacts.decline',
peerUserId: peerUserId || null,
declined: true
})
return row
} catch (err) { } catch (err) {
this.log.error('contacts.decline error', { this.log.error('contacts.decline error', {
peerUserId, peerUserId,
err: err?.message || String(err) error: err?.message || String(err)
}) })
span.fail(err)
throw err throw err
} }
} }