fix(tui): label discord direct message panes

This commit is contained in:
Vincent Koc 2026-05-03 00:31:04 -07:00
parent b8ca909174
commit 61a4cef4c2
No known key found for this signature in database
2 changed files with 19 additions and 2 deletions

View File

@ -241,6 +241,8 @@ func TestDiscordTUIRowsIncludePaneMetadata(t *testing.T) {
}})
require.Len(t, rows, 1)
require.Equal(t, "hello from desktop", rows[0].Title)
require.Equal(t, "Direct messages", rows[0].Scope)
require.Equal(t, "Vincent K", rows[0].Container)
require.Contains(t, rows[0].Tags, "dm")
require.Equal(t, "true", rows[0].Fields["attachments"])
require.Equal(t, "true", rows[0].Fields["pinned"])
@ -257,6 +259,7 @@ func TestDiscordTUIRowsIncludePaneMetadata(t *testing.T) {
Source: "discord_desktop",
}})
require.Equal(t, "user:439223...3932", rows[0].Author)
require.Equal(t, "DM c2", discordContainerLabel(store.MessageRow{GuildID: "@me", ChannelID: "c2"}))
require.Contains(t, rows[0].Tags, "discord_desktop")
}

View File

@ -126,8 +126,8 @@ func discordTUIRows(rows []store.MessageRow) []tui.Row {
Kind: "message",
ID: row.MessageID,
ParentID: row.ReplyToMessage,
Scope: firstNonEmpty(row.GuildName, row.GuildID),
Container: firstNonEmpty(row.ChannelName, row.ChannelID),
Scope: discordScopeLabel(row),
Container: discordContainerLabel(row),
Author: discordAuthorLabel(row),
Title: title,
Text: row.Content,
@ -147,6 +147,20 @@ func discordTUIRows(rows []store.MessageRow) []tui.Row {
return items
}
func discordScopeLabel(row store.MessageRow) string {
if row.GuildID == "@me" {
return "Direct messages"
}
return firstNonEmpty(row.GuildName, row.GuildID)
}
func discordContainerLabel(row store.MessageRow) string {
if row.GuildID == "@me" {
return firstNonEmpty(row.ChannelName, "DM "+compactDiscordID(row.ChannelID))
}
return firstNonEmpty(row.ChannelName, row.ChannelID)
}
func discordAuthorLabel(row store.MessageRow) string {
if name := strings.TrimSpace(row.AuthorName); name != "" {
return name