From 7ea1f4244dde19cfbdc883e1702b388ecd9d3534 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Jan 2026 16:04:06 +0000 Subject: [PATCH] fix: reconstruct chat command for edit button Add chat case to reconstructCommand to properly reconstruct the chat command string when clicking the edit button in the window toolbar. - NIP-29 groups: reconstruct as `chat relay'group-id` - NIP-53 live activities: reconstruct as `chat naddr1...` --- src/lib/command-reconstructor.ts | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/lib/command-reconstructor.ts b/src/lib/command-reconstructor.ts index 3e0ae84..627c8d3 100644 --- a/src/lib/command-reconstructor.ts +++ b/src/lib/command-reconstructor.ts @@ -96,6 +96,49 @@ export function reconstructCommand(window: WindowInstance): string { case "debug": return "debug"; + case "chat": { + // Reconstruct chat command from protocol and identifier + const { protocol, identifier } = props; + + if (!identifier) { + return "chat"; + } + + // NIP-29 relay groups: chat relay'group-id + if (protocol === "nip-29" && identifier.type === "group") { + const relayUrl = identifier.relays?.[0] || ""; + const groupId = identifier.value; + + if (relayUrl && groupId) { + // Strip wss:// prefix for cleaner command + const cleanRelay = relayUrl.replace(/^wss?:\/\//, ""); + return `chat ${cleanRelay}'${groupId}`; + } + } + + // NIP-53 live activities: chat naddr1... + if (protocol === "nip-53" && identifier.type === "live-activity") { + const { pubkey, identifier: dTag } = identifier.value || {}; + const relays = identifier.relays; + + if (pubkey && dTag) { + try { + const naddr = nip19.naddrEncode({ + kind: 30311, + pubkey, + identifier: dTag, + relays, + }); + return `chat ${naddr}`; + } catch { + // Fallback if encoding fails + } + } + } + + return "chat"; + } + default: return appId; // Fallback to just the command name }