Skip to content
Open
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
300 changes: 153 additions & 147 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IdentitySetup } from "../features/identity/IdentitySetup";
import { MeSidebar } from "../bundled/me/MeSidebar";
import { ChannelSidebar } from "../features/channel-navigation/ChannelSidebar";
import { ChannelNavigationProvider } from "../features/channel-navigation/ChannelNavigationState";
import { Agents2Context } from "../features/agents2/react";
import { ToastProvider } from "../shared/design-system/ui/Toast";
import { Button } from "../shared/design-system/ui/Button";
import { AgentWakeNotice } from "../features/agents/AgentWakeNotice";
Expand Down Expand Up @@ -148,16 +149,147 @@ function ConnectedApp({ services }: { services: AppServices }) {
portalContainer={document.getElementById("buzz-toast-root") ?? undefined}
>
<ChannelNavigationProvider relay={services.relay}>
<AppShell
sidebar={(pageNavigation) =>
settings ? (
<SettingsSidebar
<Agents2Context.Provider value={services.agents2}>
<AppShell
sidebar={(pageNavigation) =>
settings ? (
<SettingsSidebar
cards={services.settingsCards}
communities={services.communities}
{...(route.target.kind === "settings" && route.target.section
? { selected: route.target.section }
: {})}
onBack={route.leaveSettings}
onSection={(section) => {
const client = services.communities.snapshot();
void services.navigation.open({
version: 1,
kind: "settings",
section,
...(client.viewer && client.selected
? {
scope: {
viewer: client.viewer,
communityOrigin: communityDestination(
client.selected,
).url,
},
}
: { scope: null }),
});
}}
/>
) : route.selected === "buzz.me/me" ? (
<MeSidebar
relay={services.relay}
navigator={services.navigation}
target={route.target}
/>
) : (
<ChannelSidebar
relay={services.relay}
navigator={services.navigation}
providers={services.channelTemplates}
target={route.target}
meEnabled={route.pages.some(
(page) => page.key === "buzz.me/me",
)}
sessionsEnabled={route.pages.some(
(page) => page.pluginId === "buzz.sessions",
)}
>
{pageNavigation}
</ChannelSidebar>
)
}
navigationControls={
<NavigationControls navigation={services.navigation} />
}
onCommunitySelect={(id) => {
const recovering =
services.navigation.snapshot().ingress &&
services.navigation.snapshot().retryable;
services.communities.select(id);
if (!recovering) select("buzz.channels/channels");
}}
// A scoped Settings target selects its community on the way.
onOpenTarget={(target) => void services.navigation.open(target)}
communities={services.communities}
invite={invite?.viewer === client.viewer ? invite : undefined}
onInviteClose={services.invites.clear}
settingsCards={services.settingsCards}
accountActions={services.accountActions}
onProfile={
ownProfile && launcher.canOpen(ownProfile)
? (trigger) => launcher.open(ownProfile, trigger)
: undefined
}
searchServices={services}
launchers={
<PanelLaunchers
panels={launcher.available}
selected={selectedPanel}
launch={launcher.launch}
/>
}
companion={pageOwnsCompanion ? undefined : companion}
pages={startup === "ready" ? route.pages : []}
selected={route.selected}
navigationAttempt={route.state.attempt.id}
onSelect={select}
tone={presentation.tone}
workspace={
startup === "ready" && route.page?.layout === "workspace"
}
>
<AgentWakeNotice control={services.agentControl} />
<AgentUpdateReview
relay={services.relay}
control={services.agentControl}
/>
<SnapshotPreview
relay={services.relay}
control={services.agentControl}
/>
<UpdateNotice updates={services.updates} />
{startup === "recovery" && !settings ? (
<RecoveryScreen plugins={plugins} />
) : (!route.state.ingress && route.failure) ||
route.state.status === "failed" ? (
<div role="alert" className="notice">
<h1>This destination couldn’t open</h1>
<p>
{(route.state.reason ?? route.failure) === "denied"
? "This target needs its original account and an already joined community."
: route.state.ingress && !route.state.retryable
? "This link is invalid or unsupported."
: "The destination is unavailable or isn’t supported yet. Your target has been kept for retry."}
</p>
{(!route.state.ingress || route.state.retryable) && (
<Button type="button" onClick={route.retry}>
Retry navigation
</Button>
)}
<Button type="button" onClick={() => select("settings")}>
Open Settings
</Button>
</div>
) : route.waiting ? (
<p role="status">Opening destination…</p>
) : settings ? (
<Settings
plugins={plugins}
cards={services.settingsCards}
communities={services.communities}
{...(route.target.kind === "settings" && route.target.section
? { selected: route.target.section }
: {})}
onBack={route.leaveSettings}
identity={services.identity}
appearance={services.appearance}
shortcuts={services.shortcuts}
shortcutBindings={services.shortcutBindings}
notifications={services.notifications}
agentControl={services.agentControl}
updates={services.updates}
navigation={route.request}
navigationPane
onSection={(section) => {
const client = services.communities.snapshot();
void services.navigation.open({
Expand All @@ -177,146 +309,20 @@ function ConnectedApp({ services }: { services: AppServices }) {
});
}}
/>
) : route.selected === "buzz.me/me" ? (
<MeSidebar
relay={services.relay}
navigator={services.navigation}
target={route.target}
) : startup === "loading" ? (
<p role="status">Opening destination…</p>
) : route.page ? (
<PageView
page={route.page}
navigation={route.request}
companion={pageOwnsCompanion ? companion : undefined}
companionOpening={
pageOwnsCompanion ? launcher.opening : undefined
}
/>
) : (
<ChannelSidebar
relay={services.relay}
navigator={services.navigation}
providers={services.channelTemplates}
target={route.target}
meEnabled={route.pages.some(
(page) => page.key === "buzz.me/me",
)}
sessionsEnabled={route.pages.some(
(page) => page.pluginId === "buzz.sessions",
)}
>
{pageNavigation}
</ChannelSidebar>
)
}
navigationControls={
<NavigationControls navigation={services.navigation} />
}
onCommunitySelect={(id) => {
const recovering =
services.navigation.snapshot().ingress &&
services.navigation.snapshot().retryable;
services.communities.select(id);
if (!recovering) select("buzz.channels/channels");
}}
// A scoped Settings target selects its community on the way.
onOpenTarget={(target) => void services.navigation.open(target)}
communities={services.communities}
invite={invite?.viewer === client.viewer ? invite : undefined}
onInviteClose={services.invites.clear}
settingsCards={services.settingsCards}
accountActions={services.accountActions}
onProfile={
ownProfile && launcher.canOpen(ownProfile)
? (trigger) => launcher.open(ownProfile, trigger)
: undefined
}
searchServices={services}
launchers={
<PanelLaunchers
panels={launcher.available}
selected={selectedPanel}
launch={launcher.launch}
/>
}
companion={pageOwnsCompanion ? undefined : companion}
pages={startup === "ready" ? route.pages : []}
selected={route.selected}
navigationAttempt={route.state.attempt.id}
onSelect={select}
tone={presentation.tone}
workspace={startup === "ready" && route.page?.layout === "workspace"}
>
<AgentWakeNotice control={services.agentControl} />
<AgentUpdateReview
relay={services.relay}
control={services.agentControl}
/>
<SnapshotPreview
relay={services.relay}
control={services.agentControl}
/>
<UpdateNotice updates={services.updates} />
{startup === "recovery" && !settings ? (
<RecoveryScreen plugins={plugins} />
) : (!route.state.ingress && route.failure) ||
route.state.status === "failed" ? (
<div role="alert" className="notice">
<h1>This destination couldn’t open</h1>
<p>
{(route.state.reason ?? route.failure) === "denied"
? "This target needs its original account and an already joined community."
: route.state.ingress && !route.state.retryable
? "This link is invalid or unsupported."
: "The destination is unavailable or isn’t supported yet. Your target has been kept for retry."}
</p>
{(!route.state.ingress || route.state.retryable) && (
<Button type="button" onClick={route.retry}>
Retry navigation
</Button>
)}
<Button type="button" onClick={() => select("settings")}>
Open Settings
</Button>
</div>
) : route.waiting ? (
<p role="status">Opening destination…</p>
) : settings ? (
<Settings
plugins={plugins}
cards={services.settingsCards}
communities={services.communities}
identity={services.identity}
appearance={services.appearance}
shortcuts={services.shortcuts}
shortcutBindings={services.shortcutBindings}
notifications={services.notifications}
agentControl={services.agentControl}
updates={services.updates}
navigation={route.request}
navigationPane
onSection={(section) => {
const client = services.communities.snapshot();
void services.navigation.open({
version: 1,
kind: "settings",
section,
...(client.viewer && client.selected
? {
scope: {
viewer: client.viewer,
communityOrigin: communityDestination(client.selected)
.url,
},
}
: { scope: null }),
});
}}
/>
) : startup === "loading" ? (
<p role="status">Opening destination…</p>
) : route.page ? (
<PageView
page={route.page}
navigation={route.request}
companion={pageOwnsCompanion ? companion : undefined}
companionOpening={
pageOwnsCompanion ? launcher.opening : undefined
}
/>
) : null}
</AppShell>
) : null}
</AppShell>
</Agents2Context.Provider>
</ChannelNavigationProvider>
</ToastProvider>
);
Expand Down
Loading
Loading