@@ -62,6 +62,21 @@ export const loadLspQuery = (directory: string, sdk: OpencodeClient) =>
6262 queryFn : ( ) => sdk . lsp . status ( ) . then ( ( r ) => r . data ?? [ ] ) ,
6363 } )
6464
65+ function makeQueryOptionsApi ( globalSDK : ( ) => OpencodeClient , sdkFor : ( dir : string ) => OpencodeClient ) {
66+ return {
67+ globalConfig : ( ) => loadGlobalConfigQuery ( globalSDK ( ) ) ,
68+ projects : ( ) => loadProjectsQuery ( globalSDK ( ) ) ,
69+ providers : ( directory : string | null ) =>
70+ loadProvidersQuery ( directory , directory === null ? globalSDK ( ) : sdkFor ( directory ) ) ,
71+ path : ( directory : string | null ) => loadPathQuery ( directory , directory === null ? globalSDK ( ) : sdkFor ( directory ) ) ,
72+ agents : ( directory : string ) => loadAgentsQuery ( directory , sdkFor ( directory ) ) ,
73+ mcp : ( directory : string ) => loadMcpQuery ( directory , sdkFor ( directory ) ) ,
74+ lsp : ( directory : string ) => loadLspQuery ( directory , sdkFor ( directory ) ) ,
75+ sessions : ( directory : string ) => ( { queryKey : [ directory , "loadSessions" ] as const } ) ,
76+ }
77+ }
78+ export type QueryOptionsApi = ReturnType < typeof makeQueryOptionsApi >
79+
6580function createGlobalSync ( ) {
6681 const globalSDK = useGlobalSDK ( )
6782 const language = useLanguage ( )
@@ -85,18 +100,7 @@ function createGlobalSync() {
85100 return sdk
86101 }
87102
88- const queryOptionsApi = {
89- globalConfig : ( ) => loadGlobalConfigQuery ( globalSDK . client ) ,
90- projects : ( ) => loadProjectsQuery ( globalSDK . client ) ,
91- providers : ( directory : string | null ) =>
92- loadProvidersQuery ( directory , directory === null ? globalSDK . client : sdkFor ( directory ) ) ,
93- path : ( directory : string | null ) =>
94- loadPathQuery ( directory , directory === null ? globalSDK . client : sdkFor ( directory ) ) ,
95- agents : ( directory : string ) => loadAgentsQuery ( directory , sdkFor ( directory ) ) ,
96- mcp : ( directory : string ) => loadMcpQuery ( directory , sdkFor ( directory ) ) ,
97- lsp : ( directory : string ) => loadLspQuery ( directory , sdkFor ( directory ) ) ,
98- sessions : ( directory : string ) => ( { queryKey : [ directory , "loadSessions" ] as const } ) ,
99- }
103+ const queryOptionsApi = makeQueryOptionsApi ( ( ) => globalSDK . client , sdkFor )
100104
101105 const [ configQuery , providerQuery , pathQuery ] = useQueries ( ( ) => ( {
102106 queries : [ queryOptionsApi . globalConfig ( ) , queryOptionsApi . providers ( null ) , queryOptionsApi . path ( null ) ] ,
0 commit comments