@@ -45,6 +45,7 @@ import { ScopedKey, type ServerScope } from "@/utils/server-scope"
4545import { normalizeSessionInfo } from "@/utils/session"
4646import type { ServerProtocol } from "@/utils/server-protocol"
4747import type { ServerApi } from "@/utils/server"
48+ import { locationPath } from "@/utils/location-path"
4849
4950type GlobalStore = {
5051 ready : boolean
@@ -119,6 +120,11 @@ type ProjectApi = {
119120 readonly current : ( input ?: ProjectCurrentInput ) => Promise < ProjectCurrentOutput >
120121}
121122
123+ type LocationApi = {
124+ readonly get : ( input ?: {
125+ readonly location ?: { readonly directory ?: string ; readonly workspace ?: string }
126+ } ) => Promise < unknown >
127+ }
122128type McpApi = ServerApi [ "mcp" ]
123129type PermissionApi = ServerApi [ "permission" ]
124130type QuestionApi = ServerApi [ "question" ]
@@ -142,7 +148,7 @@ export const loadProjectsQuery = (scope: ServerScope, api: ProjectApi) =>
142148
143149export async function bootstrapGlobal ( input : {
144150 serverSDK : OpencodeClient
145- serverAPI : CatalogApi & { readonly project : ProjectApi }
151+ serverAPI : CatalogApi & { readonly location : LocationApi ; readonly project : ProjectApi }
146152 protocol ?: Promise < ServerProtocol >
147153 scope : ServerScope
148154 requestFailedTitle : string
@@ -157,7 +163,10 @@ export async function bootstrapGlobal(input: {
157163 input . queryClient . fetchQuery (
158164 loadProvidersQuery ( input . scope , null , input . serverAPI , input . serverSDK , input . protocol ) ,
159165 ) ,
160- ( ) => input . queryClient . fetchQuery ( loadPathQuery ( input . scope , null , input . serverSDK , input . protocol ) ) ,
166+ ( ) =>
167+ input . queryClient . fetchQuery (
168+ loadPathQuery ( input . scope , null , input . serverAPI . location , input . serverSDK , input . protocol ) ,
169+ ) ,
161170 ( ) =>
162171 input . queryClient
163172 . fetchQuery ( loadProjectsQuery ( input . scope , input . serverAPI . project ) )
@@ -298,15 +307,17 @@ export const loadCommands = (
298307export const loadPathQuery = (
299308 scope : ServerScope ,
300309 directory : string | null ,
310+ api : LocationApi ,
301311 sdk : OpencodeClient ,
302312 protocol ?: Promise < ServerProtocol > ,
303313) =>
304314 queryOptions < Path > ( {
305315 queryKey : [ scope , directory , "path" ] ,
306316 queryFn : async ( ) => {
307- if ( ( await protocol ) !== "v1" )
308- return { state : "" , config : "" , worktree : "" , directory : directory ?? "" , home : "" }
309- return retry ( ( ) => sdk . path . get ( { directory : directory ?? undefined } ) . then ( ( result ) => result . data ! ) )
317+ if ( ( await protocol ) === "v1" ) {
318+ return retry ( ( ) => sdk . path . get ( { directory : directory ?? undefined } ) . then ( ( result ) => result . data ! ) )
319+ }
320+ return retry ( ( ) => api . get ( { location : directory ? { directory } : undefined } ) ) . then ( locationPath )
310321 } ,
311322 } )
312323
@@ -336,6 +347,7 @@ export async function bootstrapDirectory(input: {
336347 readonly agent : AgentListApi
337348 readonly command : CommandListApi
338349 readonly mcp : McpApi
350+ readonly location : LocationApi
339351 readonly permission : PermissionApi
340352 readonly project : ProjectApi
341353 readonly question : QuestionApi
@@ -418,7 +430,7 @@ export async function bootstrapDirectory(input: {
418430 ! seededPath &&
419431 ( ( ) =>
420432 input . queryClient
421- . ensureQueryData ( loadPathQuery ( input . scope , input . directory , input . sdk , input . protocol ) )
433+ . ensureQueryData ( loadPathQuery ( input . scope , input . directory , input . api . location , input . sdk , input . protocol ) )
422434 . then ( ( data ) => {
423435 const next = projectID ( data . directory ?? input . directory , input . global . project )
424436 if ( next ) input . setStore ( "project" , next )
0 commit comments