feat(messages): cross-channel jump-to-reply resolution

Add resolveMessageJump and jumpToMessage so the UI can navigate to
reply parents in other text/DM channels before scrolling and highlighting.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-22 01:55:16 -04:00
co-authored by Cursor
parent 593cb1ec6c
commit ea21235813
+43
View File
@@ -2095,6 +2095,49 @@ class PearcordPlatform extends EventEmitter {
} }
} }
/** Locate a message by id across DM or guild text-like channels. */
async resolveMessageJump (messageId) {
const mid = String(messageId || '')
if (!mid) return null
if (this.mode === 'dm') {
const dms = await this.listDMConversations()
for (const ch of dms) {
const row = await this.db.get(COLLECTIONS.MESSAGES, { channelId: ch.id, id: mid })
if (row) {
return { message: enrichMessageRow(row), channelId: ch.id }
}
}
return null
}
if (!this.guild?.guild) return null
const channels = await this.guild.listChannels()
for (const ch of channels) {
if (
ch.type !== 'text' &&
ch.type !== 'thread' &&
ch.type !== 'forum' &&
ch.type !== 'announcement'
) {
continue
}
const row = await this.db.get(COLLECTIONS.MESSAGES, { channelId: ch.id, id: mid })
if (row) {
return { message: enrichMessageRow(row), channelId: ch.id, channel: ch }
}
}
return null
}
/** Switch channel if needed so the target message is in loaded history. */
async jumpToMessage (messageId) {
const hit = await this.resolveMessageJump(messageId)
if (!hit) return { found: false, messageId: String(messageId || '') }
if (hit.channelId !== this.activeChannelId) {
await this.selectChannel(hit.channelId)
}
return { found: true, messageId: hit.message.id, channelId: hit.channelId }
}
async joinVoiceChannel (channelId) { async joinVoiceChannel (channelId) {
const guild = this.guild?.guild const guild = this.guild?.guild
if (!guild || !this.voice) throw new Error('voice not available') if (!guild || !this.voice) throw new Error('voice not available')