@@ -3,6 +3,7 @@ import { IdentitySetup } from "../features/identity/IdentitySetup";
33import { MeSidebar } from "../bundled/me/MeSidebar" ;
44import { ChannelSidebar } from "../features/channel-navigation/ChannelSidebar" ;
55import { ChannelNavigationProvider } from "../features/channel-navigation/ChannelNavigationState" ;
6+ import { Agents2Context } from "../features/agents2/react" ;
67import { ToastProvider } from "../shared/design-system/ui/Toast" ;
78import { Button } from "../shared/design-system/ui/Button" ;
89import { AgentWakeNotice } from "../features/agents/AgentWakeNotice" ;
@@ -148,16 +149,147 @@ function ConnectedApp({ services }: { services: AppServices }) {
148149 portalContainer = { document . getElementById ( "buzz-toast-root" ) ?? undefined }
149150 >
150151 < ChannelNavigationProvider relay = { services . relay } >
151- < AppShell
152- sidebar = { ( pageNavigation ) =>
153- settings ? (
154- < SettingsSidebar
152+ < Agents2Context . Provider value = { services . agents2 } >
153+ < AppShell
154+ sidebar = { ( pageNavigation ) =>
155+ settings ? (
156+ < SettingsSidebar
157+ cards = { services . settingsCards }
158+ communities = { services . communities }
159+ { ...( route . target . kind === "settings" && route . target . section
160+ ? { selected : route . target . section }
161+ : { } ) }
162+ onBack = { route . leaveSettings }
163+ onSection = { ( section ) => {
164+ const client = services . communities . snapshot ( ) ;
165+ void services . navigation . open ( {
166+ version : 1 ,
167+ kind : "settings" ,
168+ section,
169+ ...( client . viewer && client . selected
170+ ? {
171+ scope : {
172+ viewer : client . viewer ,
173+ communityOrigin : communityDestination (
174+ client . selected ,
175+ ) . url ,
176+ } ,
177+ }
178+ : { scope : null } ) ,
179+ } ) ;
180+ } }
181+ />
182+ ) : route . selected === "buzz.me/me" ? (
183+ < MeSidebar
184+ relay = { services . relay }
185+ navigator = { services . navigation }
186+ target = { route . target }
187+ />
188+ ) : (
189+ < ChannelSidebar
190+ relay = { services . relay }
191+ navigator = { services . navigation }
192+ providers = { services . channelTemplates }
193+ target = { route . target }
194+ meEnabled = { route . pages . some (
195+ ( page ) => page . key === "buzz.me/me" ,
196+ ) }
197+ sessionsEnabled = { route . pages . some (
198+ ( page ) => page . pluginId === "buzz.sessions" ,
199+ ) }
200+ >
201+ { pageNavigation }
202+ </ ChannelSidebar >
203+ )
204+ }
205+ navigationControls = {
206+ < NavigationControls navigation = { services . navigation } />
207+ }
208+ onCommunitySelect = { ( id ) => {
209+ const recovering =
210+ services . navigation . snapshot ( ) . ingress &&
211+ services . navigation . snapshot ( ) . retryable ;
212+ services . communities . select ( id ) ;
213+ if ( ! recovering ) select ( "buzz.channels/channels" ) ;
214+ } }
215+ // A scoped Settings target selects its community on the way.
216+ onOpenTarget = { ( target ) => void services . navigation . open ( target ) }
217+ communities = { services . communities }
218+ invite = { invite ?. viewer === client . viewer ? invite : undefined }
219+ onInviteClose = { services . invites . clear }
220+ settingsCards = { services . settingsCards }
221+ accountActions = { services . accountActions }
222+ onProfile = {
223+ ownProfile && launcher . canOpen ( ownProfile )
224+ ? ( trigger ) => launcher . open ( ownProfile , trigger )
225+ : undefined
226+ }
227+ searchServices = { services }
228+ launchers = {
229+ < PanelLaunchers
230+ panels = { launcher . available }
231+ selected = { selectedPanel }
232+ launch = { launcher . launch }
233+ />
234+ }
235+ companion = { pageOwnsCompanion ? undefined : companion }
236+ pages = { startup === "ready" ? route . pages : [ ] }
237+ selected = { route . selected }
238+ navigationAttempt = { route . state . attempt . id }
239+ onSelect = { select }
240+ tone = { presentation . tone }
241+ workspace = {
242+ startup === "ready" && route . page ?. layout === "workspace"
243+ }
244+ >
245+ < AgentWakeNotice control = { services . agentControl } />
246+ < AgentUpdateReview
247+ relay = { services . relay }
248+ control = { services . agentControl }
249+ />
250+ < SnapshotPreview
251+ relay = { services . relay }
252+ control = { services . agentControl }
253+ />
254+ < UpdateNotice updates = { services . updates } />
255+ { startup === "recovery" && ! settings ? (
256+ < RecoveryScreen plugins = { plugins } />
257+ ) : ( ! route . state . ingress && route . failure ) ||
258+ route . state . status === "failed" ? (
259+ < div role = "alert" className = "notice" >
260+ < h1 > This destination couldn’t open</ h1 >
261+ < p >
262+ { ( route . state . reason ?? route . failure ) === "denied"
263+ ? "This target needs its original account and an already joined community."
264+ : route . state . ingress && ! route . state . retryable
265+ ? "This link is invalid or unsupported."
266+ : "The destination is unavailable or isn’t supported yet. Your target has been kept for retry." }
267+ </ p >
268+ { ( ! route . state . ingress || route . state . retryable ) && (
269+ < Button type = "button" onClick = { route . retry } >
270+ Retry navigation
271+ </ Button >
272+ ) }
273+ < Button type = "button" onClick = { ( ) => select ( "settings" ) } >
274+ Open Settings
275+ </ Button >
276+ </ div >
277+ ) : route . waiting ? (
278+ < p role = "status" > Opening destination…</ p >
279+ ) : settings ? (
280+ < Settings
281+ plugins = { plugins }
155282 cards = { services . settingsCards }
156283 communities = { services . communities }
157- { ...( route . target . kind === "settings" && route . target . section
158- ? { selected : route . target . section }
159- : { } ) }
160- onBack = { route . leaveSettings }
284+ identity = { services . identity }
285+ appearance = { services . appearance }
286+ shortcuts = { services . shortcuts }
287+ shortcutBindings = { services . shortcutBindings }
288+ notifications = { services . notifications }
289+ agentControl = { services . agentControl }
290+ updates = { services . updates }
291+ navigation = { route . request }
292+ navigationPane
161293 onSection = { ( section ) => {
162294 const client = services . communities . snapshot ( ) ;
163295 void services . navigation . open ( {
@@ -177,146 +309,20 @@ function ConnectedApp({ services }: { services: AppServices }) {
177309 } ) ;
178310 } }
179311 />
180- ) : route . selected === "buzz.me/me" ? (
181- < MeSidebar
182- relay = { services . relay }
183- navigator = { services . navigation }
184- target = { route . target }
312+ ) : startup === "loading" ? (
313+ < p role = "status" > Opening destination…</ p >
314+ ) : route . page ? (
315+ < PageView
316+ page = { route . page }
317+ navigation = { route . request }
318+ companion = { pageOwnsCompanion ? companion : undefined }
319+ companionOpening = {
320+ pageOwnsCompanion ? launcher . opening : undefined
321+ }
185322 />
186- ) : (
187- < ChannelSidebar
188- relay = { services . relay }
189- navigator = { services . navigation }
190- providers = { services . channelTemplates }
191- target = { route . target }
192- meEnabled = { route . pages . some (
193- ( page ) => page . key === "buzz.me/me" ,
194- ) }
195- sessionsEnabled = { route . pages . some (
196- ( page ) => page . pluginId === "buzz.sessions" ,
197- ) }
198- >
199- { pageNavigation }
200- </ ChannelSidebar >
201- )
202- }
203- navigationControls = {
204- < NavigationControls navigation = { services . navigation } />
205- }
206- onCommunitySelect = { ( id ) => {
207- const recovering =
208- services . navigation . snapshot ( ) . ingress &&
209- services . navigation . snapshot ( ) . retryable ;
210- services . communities . select ( id ) ;
211- if ( ! recovering ) select ( "buzz.channels/channels" ) ;
212- } }
213- // A scoped Settings target selects its community on the way.
214- onOpenTarget = { ( target ) => void services . navigation . open ( target ) }
215- communities = { services . communities }
216- invite = { invite ?. viewer === client . viewer ? invite : undefined }
217- onInviteClose = { services . invites . clear }
218- settingsCards = { services . settingsCards }
219- accountActions = { services . accountActions }
220- onProfile = {
221- ownProfile && launcher . canOpen ( ownProfile )
222- ? ( trigger ) => launcher . open ( ownProfile , trigger )
223- : undefined
224- }
225- searchServices = { services }
226- launchers = {
227- < PanelLaunchers
228- panels = { launcher . available }
229- selected = { selectedPanel }
230- launch = { launcher . launch }
231- />
232- }
233- companion = { pageOwnsCompanion ? undefined : companion }
234- pages = { startup === "ready" ? route . pages : [ ] }
235- selected = { route . selected }
236- navigationAttempt = { route . state . attempt . id }
237- onSelect = { select }
238- tone = { presentation . tone }
239- workspace = { startup === "ready" && route . page ?. layout === "workspace" }
240- >
241- < AgentWakeNotice control = { services . agentControl } />
242- < AgentUpdateReview
243- relay = { services . relay }
244- control = { services . agentControl }
245- />
246- < SnapshotPreview
247- relay = { services . relay }
248- control = { services . agentControl }
249- />
250- < UpdateNotice updates = { services . updates } />
251- { startup === "recovery" && ! settings ? (
252- < RecoveryScreen plugins = { plugins } />
253- ) : ( ! route . state . ingress && route . failure ) ||
254- route . state . status === "failed" ? (
255- < div role = "alert" className = "notice" >
256- < h1 > This destination couldn’t open</ h1 >
257- < p >
258- { ( route . state . reason ?? route . failure ) === "denied"
259- ? "This target needs its original account and an already joined community."
260- : route . state . ingress && ! route . state . retryable
261- ? "This link is invalid or unsupported."
262- : "The destination is unavailable or isn’t supported yet. Your target has been kept for retry." }
263- </ p >
264- { ( ! route . state . ingress || route . state . retryable ) && (
265- < Button type = "button" onClick = { route . retry } >
266- Retry navigation
267- </ Button >
268- ) }
269- < Button type = "button" onClick = { ( ) => select ( "settings" ) } >
270- Open Settings
271- </ Button >
272- </ div >
273- ) : route . waiting ? (
274- < p role = "status" > Opening destination…</ p >
275- ) : settings ? (
276- < Settings
277- plugins = { plugins }
278- cards = { services . settingsCards }
279- communities = { services . communities }
280- identity = { services . identity }
281- appearance = { services . appearance }
282- shortcuts = { services . shortcuts }
283- shortcutBindings = { services . shortcutBindings }
284- notifications = { services . notifications }
285- agentControl = { services . agentControl }
286- updates = { services . updates }
287- navigation = { route . request }
288- navigationPane
289- onSection = { ( section ) => {
290- const client = services . communities . snapshot ( ) ;
291- void services . navigation . open ( {
292- version : 1 ,
293- kind : "settings" ,
294- section,
295- ...( client . viewer && client . selected
296- ? {
297- scope : {
298- viewer : client . viewer ,
299- communityOrigin : communityDestination ( client . selected )
300- . url ,
301- } ,
302- }
303- : { scope : null } ) ,
304- } ) ;
305- } }
306- />
307- ) : startup === "loading" ? (
308- < p role = "status" > Opening destination…</ p >
309- ) : route . page ? (
310- < PageView
311- page = { route . page }
312- navigation = { route . request }
313- companion = { pageOwnsCompanion ? companion : undefined }
314- companionOpening = {
315- pageOwnsCompanion ? launcher . opening : undefined
316- }
317- />
318- ) : null }
319- </ AppShell >
323+ ) : null }
324+ </ AppShell >
325+ </ Agents2Context . Provider >
320326 </ ChannelNavigationProvider >
321327 </ ToastProvider >
322328 ) ;
0 commit comments