File tree Expand file tree Collapse file tree
desktop/src/features/communities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import test from "node:test";
44import {
55 clearCommunityStorage ,
66 migrateLegacyCommunityStorage ,
7+ shouldAutoConnectDefaultRelay ,
78} from "./communityStorage.ts" ;
89
910function createMemoryStorage ( initial = { } ) {
@@ -46,6 +47,16 @@ test("migrateLegacyCommunityStorage does not overwrite new community state", ()
4647 assert . equal ( storage . getItem ( "buzz-active-community-id" ) , "new" ) ;
4748} ) ;
4849
50+ test ( "signed-build relay defaults auto-connect during first-run onboarding" , ( ) => {
51+ assert . equal (
52+ shouldAutoConnectDefaultRelay ( "wss://buzz.block.builderlab.xyz" ) ,
53+ true ,
54+ ) ;
55+ assert . equal ( shouldAutoConnectDefaultRelay ( "ws://localhost:3000" ) , false ) ;
56+ assert . equal ( shouldAutoConnectDefaultRelay ( "ws://127.0.0.1:3000" ) , false ) ;
57+ assert . equal ( shouldAutoConnectDefaultRelay ( "not a valid relay" ) , false ) ;
58+ } ) ;
59+
4960test ( "clearCommunityStorage removes new and legacy state" , ( ) => {
5061 const storage = createMemoryStorage ( {
5162 "buzz-communities" : "new" ,
Original file line number Diff line number Diff line change @@ -108,6 +108,15 @@ export function normalizeRelayUrl(url: string): string {
108108 return url ;
109109}
110110
111+ export function shouldAutoConnectDefaultRelay ( relayUrl : string ) : boolean {
112+ try {
113+ const parsed = new URL ( normalizeRelayUrl ( relayUrl ) ) ;
114+ return parsed . hostname !== "localhost" && parsed . hostname !== "127.0.0.1" ;
115+ } catch {
116+ return false ;
117+ }
118+ }
119+
111120export function deriveCommunityName ( relayUrl : string ) : string {
112121 try {
113122 const url = new URL (
Original file line number Diff line number Diff line change @@ -23,7 +23,10 @@ import { resetSidebarRelayConnectionCardState } from "@/features/sidebar/ui/useS
2323import { clearMarkdownNodeCache } from "@/shared/ui/markdown/nodeCache" ;
2424import { resetVideoPlayerState } from "@/shared/ui/videoPlayerState" ;
2525
26- import { initFirstCommunity } from "./communityStorage" ;
26+ import {
27+ initFirstCommunity ,
28+ shouldAutoConnectDefaultRelay ,
29+ } from "./communityStorage" ;
2730import type { Community } from "./types" ;
2831
2932/**
@@ -94,7 +97,14 @@ export function useCommunityInit(
9497 try {
9598 const defaultRelayUrl = await getDefaultRelayUrl ( ) ;
9699
97- if ( isSharedIdentity ) {
100+ // Signed builds carry a reviewed production relay. Treat that as the
101+ // user's first community so first-run onboarding proceeds directly
102+ // from machine setup into profile/team setup. Local development keeps
103+ // the explicit add-a-community flow for ws://localhost defaults.
104+ if (
105+ isSharedIdentity ||
106+ shouldAutoConnectDefaultRelay ( defaultRelayUrl )
107+ ) {
98108 const identity = await getIdentity ( ) ;
99109 if ( cancelled ) return ;
100110 initFirstCommunity ( defaultRelayUrl , identity . pubkey ) ;
You can’t perform that action at this time.
0 commit comments