@@ -3,6 +3,7 @@ import { openUrl } from "@tauri-apps/plugin-opener";
33import { Check , Copy , Info } from "lucide-react" ;
44
55import { useCommunityOnboarding } from "@/features/onboarding/communityOnboarding" ;
6+ import { normalizeRelayUrl } from "@/features/communities/relayProbe" ;
67import { InviteRedeemForm } from "@/features/onboarding/ui/InviteRedeemForm" ;
78import {
89 ONBOARDING_KEY_FRAME_CLASS ,
@@ -20,6 +21,7 @@ import {
2021import { getIdentity } from "@/shared/api/tauriIdentity" ;
2122import { pubkeyToNpub } from "@/shared/lib/nostrUtils" ;
2223import { Button } from "@/shared/ui/button" ;
24+ import { Input } from "@/shared/ui/input" ;
2325import { StartupWindowDragRegion } from "@/shared/ui/StartupWindowDragRegion" ;
2426import { useSystemColorScheme } from "@/shared/theme/useSystemColorScheme" ;
2527import { OnboardingChrome } from "@/features/onboarding/ui/OnboardingChrome" ;
@@ -56,6 +58,8 @@ export function WelcomeSetup({
5658 React . useState < WelcomeTransitionMode > ( initialTransitionMode ) ;
5759 const [ npub , setNpub ] = React . useState ( "" ) ;
5860 const [ identityError , setIdentityError ] = React . useState < string | null > ( null ) ;
61+ const [ relayUrl , setRelayUrl ] = React . useState ( "" ) ;
62+ const [ relayUrlError , setRelayUrlError ] = React . useState < string | null > ( null ) ;
5963 const [ copied , setCopied ] = React . useState ( false ) ;
6064 const communityOnboarding = useCommunityOnboarding ( ) ;
6165 const systemColorScheme = useSystemColorScheme ( ) ;
@@ -79,6 +83,24 @@ export function WelcomeSetup({
7983 setPage ( nextPage ) ;
8084 } , [ ] ) ;
8185
86+ const handleJoin = React . useCallback (
87+ ( event : React . FormEvent ) => {
88+ event . preventDefault ( ) ;
89+ const normalizedRelayUrl = normalizeRelayUrl ( relayUrl ) ;
90+ if ( ! normalizedRelayUrl ) {
91+ setRelayUrlError ( "Enter a valid community URL." ) ;
92+ return ;
93+ }
94+
95+ setRelayUrlError ( null ) ;
96+ communityOnboarding . start ( {
97+ source : "first-community" ,
98+ relayUrl : normalizedRelayUrl ,
99+ } ) ;
100+ } ,
101+ [ communityOnboarding , relayUrl ] ,
102+ ) ;
103+
82104 const handleInviteRedeem = React . useCallback (
83105 ( relayWsUrl : string , code : string , policyReceipt ?: string ) => {
84106 communityOnboarding . start ( {
@@ -172,58 +194,106 @@ export function WelcomeSetup({
172194 </ p >
173195 </ div >
174196 < div className = "flex w-full flex-1 items-center justify-center pb-4 pt-12" >
175- < div className = "w-full max-w-4xl" >
176- < div
177- className = { ONBOARDING_KEY_FRAME_CLASS }
178- data-testid = "welcome-join-npub-frame"
197+ < div className = "w-full max-w-4xl space-y-7" >
198+ < div >
199+ < div
200+ className = { ONBOARDING_KEY_FRAME_CLASS }
201+ data-testid = "welcome-join-npub-frame"
202+ >
203+ < div className = { ONBOARDING_KEY_ROW_CLASS } >
204+ < div className = "min-w-0 flex-1" >
205+ < code
206+ className = { `${ ONBOARDING_KEY_TEXT_CLASS } block` }
207+ data-testid = "welcome-join-npub"
208+ >
209+ { npub || "Loading…" }
210+ </ code >
211+ </ div >
212+ < Button
213+ aria-label = "Copy npub"
214+ className = "h-10 w-10 shrink-0 text-muted-foreground hover:text-foreground"
215+ disabled = { ! npub }
216+ onClick = { ( ) => {
217+ void writeTextToClipboard ( npub ) . then ( ( ) => {
218+ setCopied ( true ) ;
219+ window . setTimeout ( ( ) => setCopied ( false ) , 1500 ) ;
220+ } ) ;
221+ } }
222+ size = "icon"
223+ type = "button"
224+ variant = "ghost"
225+ >
226+ { copied ? (
227+ < Check
228+ className = "h-6 w-6 text-primary"
229+ aria-hidden = "true"
230+ />
231+ ) : (
232+ < Copy className = "h-6 w-6" aria-hidden = "true" />
233+ ) }
234+ </ Button >
235+ </ div >
236+ </ div >
237+ { identityError ? (
238+ < p className = "mt-4 text-sm text-destructive" >
239+ { identityError }
240+ </ p >
241+ ) : (
242+ < p className = "mx-auto mt-4 flex max-w-[440px] items-start justify-center gap-1.5 text-center text-xs leading-5 text-[var(--buzz-onboarding-backup-ink)]" >
243+ < Info className = "mt-0.5 h-3.5 w-3.5 shrink-0" />
244+ < span >
245+ This is safe to share. It does not reveal your private
246+ key.
247+ </ span >
248+ </ p >
249+ ) }
250+ </ div >
251+ < form
252+ className = "mx-auto w-full max-w-[680px] text-left"
253+ onSubmit = { handleJoin }
179254 >
180- < div className = { ONBOARDING_KEY_ROW_CLASS } >
255+ < label
256+ className = "text-sm font-medium"
257+ htmlFor = "welcome-join-community-url"
258+ >
259+ Community URL
260+ </ label >
261+ < div className = "mt-2 flex items-start gap-3" >
181262 < div className = "min-w-0 flex-1" >
182- < code
183- className = { `${ ONBOARDING_KEY_TEXT_CLASS } block` }
184- data-testid = "welcome-join-npub"
185- >
186- { npub || "Loading…" }
187- </ code >
263+ < Input
264+ autoCapitalize = "none"
265+ autoCorrect = "off"
266+ data-testid = "welcome-join-community-url"
267+ id = "welcome-join-community-url"
268+ onChange = { ( event ) => {
269+ setRelayUrl ( event . target . value ) ;
270+ setRelayUrlError ( null ) ;
271+ } }
272+ placeholder = "https://community.example.com"
273+ spellCheck = { false }
274+ type = "url"
275+ value = { relayUrl }
276+ />
277+ { relayUrlError ? (
278+ < p className = "mt-2 text-sm text-destructive" >
279+ { relayUrlError }
280+ </ p >
281+ ) : (
282+ < p className = "mt-2 text-xs leading-5 text-foreground/70" >
283+ Once the host adds your public key, enter the URL to
284+ join. You can retry if access is not ready yet.
285+ </ p >
286+ ) }
188287 </ div >
189288 < Button
190- aria-label = "Copy npub"
191- className = "h-10 w-10 shrink-0 text-muted-foreground hover:text-foreground"
192- disabled = { ! npub }
193- onClick = { ( ) => {
194- void writeTextToClipboard ( npub ) . then ( ( ) => {
195- setCopied ( true ) ;
196- window . setTimeout ( ( ) => setCopied ( false ) , 1500 ) ;
197- } ) ;
198- } }
199- size = "icon"
200- type = "button"
201- variant = "ghost"
289+ className = "h-10 shrink-0 rounded-full px-6"
290+ disabled = { ! relayUrl . trim ( ) }
291+ type = "submit"
202292 >
203- { copied ? (
204- < Check
205- className = "h-6 w-6 text-primary"
206- aria-hidden = "true"
207- />
208- ) : (
209- < Copy className = "h-6 w-6" aria-hidden = "true" />
210- ) }
293+ Join community
211294 </ Button >
212295 </ div >
213- </ div >
214- { identityError ? (
215- < p className = "mt-4 text-sm text-destructive" >
216- { identityError }
217- </ p >
218- ) : (
219- < p className = "mx-auto mt-6 flex max-w-[440px] items-start justify-center gap-1.5 text-center text-xs leading-5 text-[var(--buzz-onboarding-backup-ink)]" >
220- < Info className = "mt-0.5 h-3.5 w-3.5 shrink-0" />
221- < span >
222- This is safe to share. It does not reveal your private
223- key.
224- </ span >
225- </ p >
226- ) }
296+ </ form >
227297 </ div >
228298 </ div >
229299 < OnboardingFooter >
0 commit comments