Files
buzz/desktop/src/app/RelayEntryGate.tsx
Brad Seiler 8a113ed99e fix(desktop): show upgrade guidance (BUZZ-517) (#9033)
## Summary

Old Buzz desktop clients now check a community’s public requirement
before each connection. An explicit `requires_nip_fi: true` shows an
upgrade screen with a fixed https://buzz.xyz download action and manual
fallback. Missing or false requirements, and failed discovery, preserve
normal connection behavior.

Retry, community navigation and address editing preserve keys and saved
communities. Changing an address cancels the old onboarding transaction
and fences pending profile checks. Native discovery sends no
credentials, follows no redirects, and limits requests to five seconds
and 256 KiB. Wire fixtures are exported from main `6b8a72e835` with
reproducible provenance.

### Related issue


[BUZZ-517](https://linear.app/squareup/issue/BUZZ-517/v0-clients-show-an-upgrade-screen-for-communities-requiring-nip-fi).
Related: [#8984](https://github.com/block/buzz/pull/8984) contains
mobile parser preparation;
[#8920](https://github.com/block/buzz/pull/8920) repairs relay rejection
messages.

### Rollout

There is no client flag. The upgrade screen appears only when the relay
advertises `requires_nip_fi: true`. Public auto-update delivery requires
a desktop release containing this change and promotion to the [OSS
auto-update
feed](aa749a862e/RELEASING.md (promote-an-oss-desktop-release-to-auto-update)).

In Shadow mode, requiring a community activates the screen; making it
optional restores normal connections. Global Enforce requires every
community regardless of that setting. Rollback must restore an effective
non-required policy. The optional and required outcomes are demonstrated
by Brad’s two manual cases below.

### Testing

At `71689b4708`, Honor’s isolated browser journeys passed 3/3 with zero
retries and verified served assets, including the fixed
`https://buzz.xyz` opener and manual fallback. McKeon independently
built and passed the same three journeys at the previous head
`8caa25260b` with the repository command: `CI=1 pnpm --dir desktop
build:e2e`, then `CI=1 pnpm --dir desktop exec playwright test
relay-entry-guidance.spec.ts --project=smoke`. Native IPC was mocked.

Brad [tested the running pre-rebase app
locally](https://github.com/block/buzz/pull/9033#issuecomment-6662960875):
an optional bb-public community in Shadow connected without a message;
required bb-block staging showed the upgrade message. These results
apply to that running app, not the rebased head.

Before:

![Earlier upgrade card with synthetic community
data](https://github.com/user-attachments/assets/63fbaa66-d551-4c20-ab04-c7fd966638e0)

After:

![Public upgrade card with Download latest Buzz action at
buzz.xyz](https://github.com/user-attachments/assets/f26a5d2a-47b4-4510-a86f-667d6f7c6d3d)

Generated with Codex

---------

Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
2026-11-05 19:22:01 +00:00

94 lines
3.2 KiB
TypeScript

import { useState, useSyncExternalStore } from "react";
import { openUrl } from "@tauri-apps/plugin-opener";
import { relayClient } from "@/shared/api/relayClient";
import { Button } from "@/shared/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogTitle,
} from "@/shared/ui/dialog";
import { CommunityChangeOverlay } from "@/features/communities/ui/CommunityChangeOverlay";
export function RelayEntryGate({
relayUrl,
communities,
onSwitch,
onRetry,
onAddressChanged,
}: {
relayUrl: string;
communities: { id: string; name: string; relayUrl: string }[];
onSwitch: (id: string) => void;
onRetry: () => void;
onAddressChanged: () => void;
}) {
const entry = relayClient.entryRequirements;
const state = useSyncExternalStore(entry.subscribe, entry.getSnapshot);
const [editing, setEditing] = useState(false);
const [openError, setOpenError] = useState(false);
const visible = state.relayUrl === relayUrl && state.verdict === "required";
return (
<>
<Dialog open={visible && !editing}>
<DialogContent
showCloseButton={false}
onEscapeKeyDown={(event) => event.preventDefault()}
onPointerDownOutside={(event) => event.preventDefault()}
data-testid="relay-entry-guidance"
>
<DialogTitle>Upgrade Buzz to join this community</DialogTitle>
<DialogDescription>
This community requires sign-in supported by a newer Buzz app. Your
keys and saved communities are still here.
</DialogDescription>
<p className="break-all text-sm text-muted-foreground">{relayUrl}</p>
<p className="text-sm">
Download the latest Buzz client at buzz.xyz to continue.
</p>
<Button
onClick={() => {
setOpenError(false);
void openUrl("https://buzz.xyz").catch(() => setOpenError(true));
}}
>
Download latest Buzz
</Button>
{openError ? (
<p role="alert" className="text-sm">
Could not open the download page. Open https://buzz.xyz in your
browser to download the latest Buzz client.
</p>
) : null}
<Button variant="outline" disabled={state.pending} onClick={onRetry}>
{state.pending ? "Checking community…" : "Retry community check"}
</Button>
{communities
.filter((community) => community.relayUrl !== relayUrl)
.map((community) => (
<Button
variant="outline"
key={community.id}
onClick={() => onSwitch(community.id)}
>
Open {community.name}
</Button>
))}
<Button variant="ghost" onClick={() => setEditing(true)}>
Change community address
</Button>
</DialogContent>
</Dialog>
{editing ? (
<CommunityChangeOverlay
onClose={() => setEditing(false)}
onUpdated={(_name, updatedRelayUrl) => {
if (updatedRelayUrl !== relayUrl) onAddressChanged();
setEditing(false);
}}
/>
) : null}
</>
);
}