Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions desktop/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default defineConfig({
"**/top-chrome-zoom-clearance.spec.ts",
"**/thread-unread.spec.ts",
"**/workspace-rail.spec.ts",
"**/community-home.spec.ts",
"**/boot-splash.spec.ts",
"**/thread-reply-anchor-roleplay.spec.ts",
"**/threadpane-ultrawide.spec.ts",
Expand Down
35 changes: 24 additions & 11 deletions desktop/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
onAddCommunityPrefillAvailable,
requestAddCommunityPrefill,
} from "@/features/communities/addCommunityPrefill";
import { CommunityHome } from "@/features/communities/ui/CommunityHome";
import { WelcomeSetup } from "@/features/communities/ui/WelcomeSetup";
import { CommunityApplyErrorScreen } from "@/features/communities/ui/CommunityApplyErrorScreen";
import { CommunityChangeOverlay } from "@/features/communities/ui/CommunityChangeOverlay";
Expand Down Expand Up @@ -275,8 +276,7 @@ function CommunityApp({
const communityOnboarding = useCommunityOnboarding();
const connectingTransactionRef = useRef<string | null>(null);
const [isCommunityChangeOpen, setIsCommunityChangeOpen] = useState(false);
const [resumeFirstCommunityJoin, setResumeFirstCommunityJoin] =
useState(false);
const [isJoinCommunityOpen, setIsJoinCommunityOpen] = useState(false);

// Surface nest-related backend events (repos-dir errors, legacy migration)
// as toasts. Mounted before useCommunityInit so the listeners are registered
Expand All @@ -303,6 +303,12 @@ function CommunityApp({
sharedIdentity,
);

useEffect(() => {
if (activeCommunity !== null) {
setIsJoinCommunityOpen(false);
}
}, [activeCommunity]);

const handleCommunityOnboardingConnect = useCallback(() => {
const transaction = communityOnboarding.transaction;
if (transaction?.stage !== "connecting") return;
Expand Down Expand Up @@ -353,10 +359,8 @@ function CommunityApp({
return;
}
if (communities.length === 1) {
if (transaction.source === "first-community") {
setResumeFirstCommunityJoin(true);
}
clearCommunities();
setIsJoinCommunityOpen(true);
return;
}
removeCommunity(transaction.communityId);
Expand Down Expand Up @@ -407,13 +411,22 @@ function CommunityApp({
let appContent: ReactNode = null;
if (!transaction) {
if (community.needsSetup) {
// Show welcome setup for first-run users with no communities
appContent = (
appContent = isJoinCommunityOpen ? (
<WelcomeSetup
defaultRelayUrl={community.defaultRelayUrl}
initialPage={resumeFirstCommunityJoin ? "join" : undefined}
onBack={onBackToMachineConfig}
initialPage="join"
onBack={() => setIsJoinCommunityOpen(false)}
/>
) : (
<CommunityQueryProvider>
<CommunityHome
communities={communities}
onBackToMachineConfig={onBackToMachineConfig}
onJoinCommunity={() => setIsJoinCommunityOpen(true)}
onOpenCommunity={switchCommunity}
onRemoveCommunity={removeCommunity}
/>
</CommunityQueryProvider>
);
} else if ("error" in community && community.error) {
// Surface apply failures so the user can retry or change community.
Expand Down Expand Up @@ -489,10 +502,10 @@ function CommunityApp({
}

function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) {
const { activeCommunity } = useCommunities();
const { activeCommunity, communities } = useCommunities();
const communityOnboarding = useCommunityOnboarding();
const machine = useMachineOnboardingState({
hasConfiguredCommunity: activeCommunity !== null,
hasConfiguredCommunity: communities.length > 0,
isSharedIdentity: sharedIdentity,
});
const [machineInitialPage, setMachineInitialPage] =
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/app/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ const LazySettingsScreen = React.lazy(async () => {
const module = await import("@/features/settings/ui/SettingsScreen");
return { default: module.SettingsScreen };
});

export function AppShell() {
useWebviewZoomShortcuts();
useTauriWindowDrag();
useWebviewScrollBoundaryLock();

const communitiesHook = useCommunities();
const hasCommunityRail = communitiesHook.communities.length > 1;
const hasCommunityRail = communitiesHook.communities.length > 0;
const addCommunityDialog = useAddCommunityDialogState();
const [isChannelManagementOpen, setIsChannelManagementOpen] =
React.useState(false);
Expand Down Expand Up @@ -771,6 +770,7 @@ export function AppShell() {
}
onAddCommunity={addCommunityDialog.openDialog}
onRemoveCommunity={communitiesHook.removeCommunity}
onShowCommunityHome={communitiesHook.showCommunityHome}
onSwitchCommunity={handleSwitchCommunity}
onUpdateCommunity={communitiesHook.updateCommunity}
communities={communitiesHook.communities}
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/features/communities/communityStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export function saveActiveCommunityId(id: string): void {
setLocalStorageItemWithRecovery(ACTIVE_COMMUNITY_KEY, id);
}

export function clearActiveCommunityId(storage: Storage = localStorage): void {
storage.removeItem(ACTIVE_COMMUNITY_KEY);
}

export function normalizeRelayUrl(url: string): string {
if (!url.startsWith("ws://") && !url.startsWith("wss://")) {
return `wss://${url}`;
Expand Down
Loading