Skip to content

fix(web): keep names readable and chat responsive on slow relays - #13

Open
anasfik wants to merge 4 commits into
hardy4yooz:mainfrom
anasfik:fix/readable-profile-names-and-relay-timeouts
Open

anasfik wants to merge 4 commits into
hardy4yooz:mainfrom
anasfik:fix/readable-profile-names-and-relay-timeouts

Conversation

@anasfik

@anasfik anasfik commented Nov 2, 2026

Copy link
Copy Markdown

What this fixes

I hit three related issues while testing the web client against a slow relay:

  1. Names briefly show as raw hex, and some users stay hex forever. Kind-0 profiles were fetched after messages rendered, blank display_name values masked a valid name, and several surfaces fell back to truncatePubkey instead of a readable label.
  2. Channel switches can leave the message pane blank. Profile hydration was on the critical path, so a slow kind-0 query blocked the message render for up to the 25s operation timeout.
  3. Startup can hang forever. The presence HTTP query used fetch without a timeout, and channel loading awaited it before rendering.

This also fixes a malformed-relay-frame crash and lets an already-configured agent be associated with its channel when it has ordinary member membership rather than the bot role.

Changes

  • Parse the first usable kind-0 name (display_name, displayName, name), ignore blank/non-object metadata, and keep a previously known name when newer metadata has none.
  • Centralize the local fallback as Member <short> / Agent <short> in English and Simplified Chinese; no raw hex is used as a display name.
  • Hydrate profiles before first message render, then refresh names asynchronously without gating the channel.
  • Detach profile and presence lookups from the channel-loading gate.
  • Abort /query HTTP requests after the existing 25s operation timeout.
  • Reject malformed EVENT frames before they reach consumers.
  • Close subscriptions that resolve after their effect has been cancelled.
  • Count ordinary channel membership for already-known agents without discovering ordinary users as agents.
  • Update the related browser tests.

No Relay, protocol, identity, theme-storage, branding, or deployment changes. The fallbacks are local labels, not invented public profiles.

Verification

  • npm test — 24 files, 109 tests pass.
  • npm run typecheck, npm run check, npm run build — pass.
  • Playwright: the affected profile, member-management, agent, and message journeys pass. One unrelated Inbox assertion on this base still sees 3 unread where the test expects 2; I left that existing mismatch out of this PR.

Happy to split this into separate profile and relay-robustness PRs if you prefer a smaller review.

Gwhyyy added 4 commits November 2, 2026 22:35
Parse the first usable kind-0 name instead of letting a blank display_name mask a valid name, and treat malformed or non-object metadata as empty. Keep known and configured names when newer metadata has no name, hydrate channel and message authors before history becomes visible, and use one localized Member/Agent fallback across chat, inbox, repos, and agent activity surfaces.

Signed-off-by: Gwhyyy <gw@v2202608398033499741.nicesrv.de>
Render cached messages before profile hydration, detach startup presence
from the channel gate, bound HTTP queries, reject malformed relay events,
and reuse agent metadata names.

Signed-off-by: Gwhyyy <gw@v2202608398033499741.nicesrv.de>
Signed-off-by: Gwhyyy <gw@v2202608398033499741.nicesrv.de>
Signed-off-by: Gwhyyy <gw@v2202608398033499741.nicesrv.de>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 22:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The relay event guard still accepts missing or malformed tags and non-string content, allowing events with missing tags to crash chat rendering.

4 open issues
What changed in this PR

This PR improves the browser client's behavior on slow relays by making profile names more readable and removing profile and presence lookups from the channel-loading gate.

Changes:

  • Centralizes localized fallback names and preserves known names when metadata has no usable name.
  • Loads profiles and presence asynchronously, adds HTTP query timeouts, and closes subscriptions that resolve after cancellation.
  • Adds relay-event validation, recognizes ordinary membership for known agents, and updates related tests.
File Description
web/​tests/​e2e/​p0.spec.ts Updates the expected member fallback label.
web/​src/​shared/​i18n/​index.ts Adds English and Chinese member labels.
web/​src/​shared/​api/​relay-client.ts Adds HTTP timeouts and event-field checks.
web/​src/​shared/​api/​relay-client.test.ts Tests malformed events and stalled HTTP queries.
web/​src/​features/​repos/​ui/​ReposPanel.tsx Reuses the shared profile fallback.
web/​src/​features/​inbox/​ui/​InboxView.tsx Uses readable fallback names throughout Inbox.
web/​src/​features/​chat/​ui/​ThreadPanel.tsx Uses shared fallbacks for thread participants.
web/​src/​features/​chat/​ui/​MessageList.tsx Centralizes message-author fallback names.
web/​src/​features/​chat/​ui/​BuzzWebApp.tsx Uses the shared fallback for the settings profile.
web/​src/​features/​chat/​ui/​AppDialogs.tsx Uses readable author names in search results.
web/​src/​features/​chat/​ui/​AgentActivityPanel.tsx Adds agent-aware fallback names.
web/​src/​features/​chat/​lib/​use-buzz-session.ts Detaches lookups and handles late subscription cleanup.
web/​src/​features/​chat/​lib/​chat-model.ts Adds resilient name parsing, profile merging, and display helpers.
web/​src/​features/​chat/​lib/​chat-model.test.ts Tests metadata handling, name preservation, and localized fallbacks.
web/​src/​features/​agents/​lib/​relay-agents.ts Improves name parsing and known-agent channel associations.
web/​src/​features/​agents/​lib/​relay-agents.test.ts Tests membership handling and agent-name fallbacks.

Review effort: Balanced

Comment on lines +294 to +297
typeof event.id !== "string" ||
typeof event.pubkey !== "string" ||
typeof event.created_at !== "number" ||
typeof event.kind !== "number"
...config.agents.map((agent) => agent.pubkey),
...nextDiscovered.flatMap((channel) => channel.members.map((member) => member.pubkey)),
];
void loadProfiles(profilePubkeys);
limit: profilePubkeys.length,
},
])
.then((events) => applyPresenceEvents(events, profilePubkeys))
Comment on lines +462 to +464
void loadProfiles(
event.kind === 40099 ? systemMessagePubkeys(event) : [event.pubkey],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants