From 7e3df6e1aaace56145bd0059847a3fcb3e725df5 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 3 May 2026 00:31:04 -0700 Subject: [PATCH] fix(tui): label discord direct message panes --- internal/cli/cli_test.go | 3 +++ internal/cli/tui_commands.go | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index 9b5dfe8..c464a5d 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -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") } diff --git a/internal/cli/tui_commands.go b/internal/cli/tui_commands.go index c5ade95..12cdfe0 100644 --- a/internal/cli/tui_commands.go +++ b/internal/cli/tui_commands.go @@ -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