-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Auto-connect configured production relay #2411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,10 @@ import { resetSidebarRelayConnectionCardState } from "@/features/sidebar/ui/useS | |
| import { clearMarkdownNodeCache } from "@/shared/ui/markdown/nodeCache"; | ||
| import { resetVideoPlayerState } from "@/shared/ui/videoPlayerState"; | ||
|
|
||
| import { initFirstCommunity } from "./communityStorage"; | ||
| import { | ||
| initFirstCommunity, | ||
| shouldAutoConnectDefaultRelay, | ||
| } from "./communityStorage"; | ||
| import type { Community } from "./types"; | ||
|
|
||
| /** | ||
|
|
@@ -94,12 +97,30 @@ export function useCommunityInit( | |
| try { | ||
| const defaultRelayUrl = await getDefaultRelayUrl(); | ||
|
|
||
| if (isSharedIdentity) { | ||
| // Signed builds carry a reviewed production relay. Treat that as the | ||
| // user's first community so first-run onboarding proceeds directly | ||
| // from machine setup into profile/team setup. Local development keeps | ||
| // the explicit add-a-community flow for ws://localhost defaults. | ||
| if ( | ||
| isSharedIdentity || | ||
| shouldAutoConnectDefaultRelay(defaultRelayUrl) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this gate,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 63d9135. |
||
| ) { | ||
| const identity = await getIdentity(); | ||
| if (cancelled) return; | ||
| initFirstCommunity(defaultRelayUrl, identity.pubkey); | ||
| if (!cancelled) { | ||
| const community = initFirstCommunity( | ||
| defaultRelayUrl, | ||
| identity.pubkey, | ||
| ); | ||
| if (community && !cancelled) { | ||
| window.location.reload(); | ||
| return; | ||
| } | ||
| if (!cancelled) { | ||
| setResult({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The persist-failure fallback correctly avoids the reload loop now, but it lands the user on
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The quota-aware storage helper already emits a one-time "Local storage is full" toast when persistence fails; keeping the setup fallback otherwise unchanged. |
||
| isReady: false, | ||
| needsSetup: true, | ||
| defaultRelayUrl, | ||
| }); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -560,7 +560,7 @@ test("first-launch key import continues to machine setup", async ({ page }) => { | |
| await expect(page.getByTestId("app-loading-gate")).toHaveCount(0); | ||
| }); | ||
|
|
||
| test("first-community choices route join, create, owner, and member intents", async ({ | ||
| test("non-local default auto-connects the first community", async ({ | ||
| page, | ||
| }) => { | ||
| await seedActiveIdentity(page, BLANK_TYLER_IDENTITY); | ||
|
|
@@ -577,6 +577,46 @@ test("first-community choices route join, create, owner, and member intents", as | |
| }); | ||
| await page.goto("/"); | ||
|
|
||
| await expectIncompleteOnboarding(page); | ||
| await expect | ||
| .poll(() => | ||
| page.evaluate(() => { | ||
| const raw = window.localStorage.getItem("buzz-communities"); | ||
| const communities = raw | ||
| ? (JSON.parse(raw) as Array<{ id: string; relayUrl: string }>) | ||
| : []; | ||
| return { | ||
| activeMatchesCommunity: | ||
| communities.length === 1 && | ||
| window.localStorage.getItem("buzz-active-community-id") === | ||
| communities[0]?.id, | ||
| relayUrl: communities[0]?.relayUrl ?? null, | ||
| }; | ||
| }), | ||
| ) | ||
| .toEqual({ | ||
| activeMatchesCommunity: true, | ||
| relayUrl: "wss://default.example.com", | ||
| }); | ||
| }); | ||
|
|
||
| test("first-community choices route join, create, owner, and member intents", async ({ | ||
| page, | ||
| }) => { | ||
| await seedActiveIdentity(page, BLANK_TYLER_IDENTITY); | ||
| await page.addInitScript((pubkey) => { | ||
| window.localStorage.setItem( | ||
| `buzz-machine-onboarding-complete.v2:${pubkey}`, | ||
| "true", | ||
| ); | ||
| }, BLANK_TYLER_IDENTITY.pubkey); | ||
| await installMockBridge(page, undefined, { | ||
| relayWsUrl: "ws://localhost:3000", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repointing these specs to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 63d9135. |
||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }); | ||
| await page.goto("/"); | ||
|
|
||
| await expect( | ||
| page.getByRole("button", { name: /Join a community/ }), | ||
| ).toBeVisible(); | ||
|
|
@@ -657,7 +697,7 @@ test("first-community owner can connect an existing hosted community", async ({ | |
| ], | ||
| }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -715,7 +755,7 @@ test("first-community owner can create and connect a hosted community", async ({ | |
| page, | ||
| {}, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -789,7 +829,7 @@ test("hosted community address line stays within the card for a long name", asyn | |
| page, | ||
| {}, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -860,7 +900,7 @@ test("first-community reports a created community without a relay address", asyn | |
| }, | ||
| }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -891,7 +931,7 @@ test("first-community X cancels a pending sign-in", async ({ page }) => { | |
| page, | ||
| { builderlabLoginDelayMs: 5_000 }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -933,7 +973,7 @@ test("first-community owner can replace a mismatched account identity", async ({ | |
| builderlabIdentity: { pubkey_hex: "f".repeat(64) }, | ||
| }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -983,7 +1023,7 @@ test("first-community explains when the local identity belongs to another accoun | |
| builderlabBindError: { code: "pubkey_already_bound" }, | ||
| }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -1024,7 +1064,7 @@ test("back clears Builderlab auth before returning to first-community choices", | |
| builderlabIdentity: { pubkey_hex: BLANK_TYLER_IDENTITY.pubkey }, | ||
| }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -1112,7 +1152,7 @@ test("first-community direct join reaches profile", async ({ page }) => { | |
| ); | ||
| }, BLANK_TYLER_IDENTITY.pubkey); | ||
| await installMockBridge(page, undefined, { | ||
| relayWsUrl: "wss://onboarding.communities.buzz.xyz", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }); | ||
|
|
@@ -1167,7 +1207,7 @@ test("first-community direct join cancel returns to request access", async ({ | |
| page, | ||
| { applyCommunityDelayMs: 5_000 }, | ||
| { | ||
| relayWsUrl: "wss://onboarding.communities.buzz.xyz", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| skipCommunitySeed: true, | ||
| }, | ||
|
|
@@ -1298,7 +1338,7 @@ test("connected first-community profile step offers equal-width Next and Back co | |
| id: "txn-profile-step", | ||
| source: "first-community", | ||
| stage: "profile", | ||
| relayUrl: "wss://default.example.com", | ||
| relayUrl: "ws://localhost:3000", | ||
| communityName: "Default", | ||
| communityId: "e2e-default-community", | ||
| addedCommunity: true, | ||
|
|
@@ -1346,7 +1386,7 @@ test("connected first-community profile step offers equal-width Next and Back co | |
| ], | ||
| }, | ||
| { | ||
| relayWsUrl: "wss://default.example.com", | ||
| relayWsUrl: "ws://localhost:3000", | ||
| skipOnboardingSeed: true, | ||
| }, | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the auto-created community carries no admission
token, soapplyCommunitygetstoken === undefinedon the production first-connect. Fine if the compiled default relay admits token-less first connections; if it ever requires one, first-run dead-ends with no token-entry UI. Worth a one-line comment documenting the assumption.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 63d9135.