@@ -17,6 +17,8 @@ import { useSDK } from "@tui/context/sdk"
1717import { Binary } from "@/util/binary"
1818import { createSimpleContext } from "./helper"
1919import type { Snapshot } from "@/snapshot"
20+ import { useExit } from "./exit"
21+ import { onMount } from "solid-js"
2022
2123export const { use : useSync , provider : SyncProvider } = createSimpleContext ( {
2224 name : "Sync" ,
@@ -215,28 +217,36 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
215217 }
216218 } )
217219
218- // blocking
219- Promise . all ( [
220- sdk . client . config . providers ( { throwOnError : true } ) . then ( ( x ) => setStore ( "provider" , x . data ! . providers ) ) ,
221- sdk . client . app . agents ( { throwOnError : true } ) . then ( ( x ) => setStore ( "agent" , x . data ?? [ ] ) ) ,
222- sdk . client . config . get ( { throwOnError : true } ) . then ( ( x ) => setStore ( "config" , x . data ! ) ) ,
223- ] ) . then ( ( ) => {
224- setStore ( "status" , "partial" )
225- // non-blocking
220+ const exit = useExit ( )
221+
222+ onMount ( ( ) => {
223+ // blocking
226224 Promise . all ( [
227- sdk . client . session . list ( ) . then ( ( x ) =>
228- setStore (
229- "session" ,
230- ( x . data ?? [ ] ) . toSorted ( ( a , b ) => a . id . localeCompare ( b . id ) ) ,
231- ) ,
232- ) ,
233- sdk . client . command . list ( ) . then ( ( x ) => setStore ( "command" , x . data ?? [ ] ) ) ,
234- sdk . client . lsp . status ( ) . then ( ( x ) => setStore ( "lsp" , x . data ! ) ) ,
235- sdk . client . mcp . status ( ) . then ( ( x ) => setStore ( "mcp" , x . data ! ) ) ,
236- sdk . client . formatter . status ( ) . then ( ( x ) => setStore ( "formatter" , x . data ! ) ) ,
237- ] ) . then ( ( ) => {
238- setStore ( "status" , "complete" )
239- } )
225+ sdk . client . config . providers ( { throwOnError : true } ) . then ( ( x ) => setStore ( "provider" , x . data ! . providers ) ) ,
226+ sdk . client . app . agents ( { throwOnError : true } ) . then ( ( x ) => setStore ( "agent" , x . data ?? [ ] ) ) ,
227+ sdk . client . config . get ( { throwOnError : true } ) . then ( ( x ) => setStore ( "config" , x . data ! ) ) ,
228+ ] )
229+ . then ( ( ) => {
230+ setStore ( "status" , "partial" )
231+ // non-blocking
232+ Promise . all ( [
233+ sdk . client . session . list ( ) . then ( ( x ) =>
234+ setStore (
235+ "session" ,
236+ ( x . data ?? [ ] ) . toSorted ( ( a , b ) => a . id . localeCompare ( b . id ) ) ,
237+ ) ,
238+ ) ,
239+ sdk . client . command . list ( ) . then ( ( x ) => setStore ( "command" , x . data ?? [ ] ) ) ,
240+ sdk . client . lsp . status ( ) . then ( ( x ) => setStore ( "lsp" , x . data ! ) ) ,
241+ sdk . client . mcp . status ( ) . then ( ( x ) => setStore ( "mcp" , x . data ! ) ) ,
242+ sdk . client . formatter . status ( ) . then ( ( x ) => setStore ( "formatter" , x . data ! ) ) ,
243+ ] ) . then ( ( ) => {
244+ setStore ( "status" , "complete" )
245+ } )
246+ } )
247+ . catch ( async ( e ) => {
248+ await exit ( e )
249+ } )
240250 } )
241251
242252 const result = {
0 commit comments