@@ -4,31 +4,27 @@ import { OpenCode } from "@opencode/client"
44import { Global } from "@opencode/util/global"
55import { testRender } from "@opentui/solid"
66import { Effect } from "effect"
7- import fs from "node:fs/promises"
87import path from "node:path"
98import { tmpdirScoped } from "../../../core/test/fixture/tmpdir"
109import { it } from "../../../core/test/lib/effect"
1110import { startServer } from "../../../server/test/fixture/server"
1211import { ClientProvider , useClient } from "../../src/context/client"
13- import { directoryAutocomplete , directoryRecentValue } from "../../src/prompt/directory-completion"
1412import { TestTuiContexts } from "../fixture/tui-environment"
1513
16- it . live ( "uses server home for remote directory completion and recent paths " , ( ) =>
14+ it . live ( "resolves the server home instead of the remote client's home " , ( ) =>
1715 Effect . gen ( function * ( ) {
1816 const tmp = yield * tmpdirScoped ( )
19- const current = path . join ( tmp . path , "project" )
20- yield * Effect . promise ( ( ) => fs . mkdir ( current ) )
2117 const server = yield * startServer ( path . join ( tmp . path , "config" ) )
2218 const api = OpenCode . make ( { baseUrl : server . base , headers : server . headers } )
2319 let client ! : ReturnType < typeof useClient >
2420 function Probe ( ) {
2521 client = useClient ( )
2622 return < box />
2723 }
28- const setup = yield * Effect . acquireRelease (
24+ yield * Effect . acquireRelease (
2925 Effect . promise ( ( ) =>
3026 testRender ( ( ) => (
31- < TestTuiContexts paths = { { home : "/Users/remote-client" , cwd : current } } >
27+ < TestTuiContexts paths = { { home : "/Users/remote-client" } } >
3228 < ClientProvider api = { api } >
3329 < Probe />
3430 </ ClientProvider >
@@ -37,16 +33,6 @@ it.live("uses server home for remote directory completion and recent paths", ()
3733 ) ,
3834 ( setup ) => Effect . sync ( ( ) => setup . renderer . destroy ( ) ) ,
3935 )
40- const home = yield * Effect . promise ( ( ) => client . resolveServerHome ( ) )
41- if ( ! home ) throw new Error ( "Server did not report its home directory" )
42- expect ( home ) . toBe ( Global . Path . home )
43- expect ( home ) . not . toBe ( "/Users/remote-client" )
44- const completions = yield * Effect . promise ( ( ) => directoryAutocomplete ( api . file , { directory : current } , "~" , home ) )
45- expect ( completions [ 0 ] ) . toEqual ( { value : "~" , absolute : home } )
46- const destination = yield * Effect . promise ( ( ) => api . location . get ( { location : { directory : home } } ) )
47- expect ( destination . directory ) . toBe ( home )
48- expect ( directoryRecentValue ( destination . directory , home ) ) . toBe ( "~" )
49- expect ( directoryRecentValue ( "/Users/remote-client/project" , home ) ) . toBe ( "/Users/remote-client/project" )
50- expect ( setup . renderer . isDestroyed ) . toBe ( false )
36+ expect ( yield * Effect . promise ( ( ) => client . resolveServerHome ( ) ) ) . toBe ( Global . Path . home )
5137 } ) ,
5238)
0 commit comments