@@ -6,15 +6,16 @@ import type { ListRef } from "@opencode-ai/ui/list"
66import { getDirectory , getFilename } from "@opencode-ai/core/util/path"
77import fuzzysort from "fuzzysort"
88import { createMemo , createResource , createSignal } from "solid-js"
9- import { useServerSDK } from "@/context/server-sdk"
10- import { useServerSync } from "@/context/server-sync"
11- import { useLayout } from "@/context/layout"
9+ import { ServerSDK } from "@/context/server-sdk"
1210import { useLanguage } from "@/context/language"
11+ import { ServerConnection } from "@/context/server"
12+ import { useGlobal } from "@/context/global"
1313
1414interface DialogSelectDirectoryProps {
1515 title ?: string
1616 multiple ?: boolean
1717 onSelect : ( result : string | string [ ] | null ) => void
18+ server : ServerConnection . Any
1819}
1920
2021type Row = {
@@ -127,11 +128,7 @@ function uniqueRows(rows: Row[]) {
127128 } )
128129}
129130
130- function useDirectorySearch ( args : {
131- sdk : ReturnType < typeof useServerSDK >
132- start : ( ) => string | undefined
133- home : ( ) => string
134- } ) {
131+ function useDirectorySearch ( args : { sdk : ServerSDK ; start : ( ) => string | undefined ; home : ( ) => string } ) {
135132 const cache = new Map < string , Promise < Array < { name : string ; absolute : string } > > > ( )
136133 let current = 0
137134
@@ -246,9 +243,8 @@ function useDirectorySearch(args: {
246243}
247244
248245export function DialogSelectDirectory ( props : DialogSelectDirectoryProps ) {
249- const sync = useServerSync ( )
250- const sdk = useServerSDK ( )
251- const layout = useLayout ( )
246+ const global = useGlobal ( )
247+ const { sync, sdk, ...serverCtx } = global . createServerCtx ( props . server )
252248 const dialog = useDialog ( )
253249 const language = useLanguage ( )
254250
@@ -279,7 +275,7 @@ export function DialogSelectDirectory(props: DialogSelectDirectoryProps) {
279275 } )
280276
281277 const recentProjects = createMemo ( ( ) => {
282- const projects = layout . projects . list ( )
278+ const projects = serverCtx . projects . list ( )
283279 const byProject = new Map < string , number > ( )
284280
285281 for ( const project of projects ) {
@@ -324,6 +320,7 @@ export function DialogSelectDirectory(props: DialogSelectDirectoryProps) {
324320 return (
325321 < Dialog title = { props . title ?? language . t ( "command.project.open" ) } >
326322 < List
323+ class = "px-3"
327324 search = { { placeholder : language . t ( "dialog.directory.search.placeholder" ) , autofocus : true } }
328325 emptyMessage = { language . t ( "dialog.directory.empty" ) }
329326 loadingMessage = { language . t ( "common.loading" ) }
0 commit comments