@@ -27,9 +27,9 @@ const it = testEffect(
2727 Layer . mergeAll ( NodeServices . layer , Project . defaultLayer , Session . defaultLayer , Workspace . defaultLayer ) ,
2828)
2929
30- function request ( path : string , directory : string , init : RequestInit = { } ) {
30+ function request ( path : string , directory : string , init : RequestInit = { } , httpApi = true ) {
3131 return Effect . promise ( ( ) => {
32- Flag . OPENCODE_EXPERIMENTAL_HTTPAPI = true
32+ Flag . OPENCODE_EXPERIMENTAL_HTTPAPI = httpApi
3333 const headers = new Headers ( init . headers )
3434 headers . set ( "x-opencode-directory" , directory )
3535 return Promise . resolve ( Server . Default ( ) . app . request ( path , { ...init , headers } ) )
@@ -195,6 +195,55 @@ describe("workspace HttpApi", () => {
195195 } ) ,
196196 )
197197
198+ it . live ( "creates workspace with the TUI payload shape" , ( ) =>
199+ Effect . gen ( function * ( ) {
200+ Flag . OPENCODE_EXPERIMENTAL_WORKSPACES = true
201+ const dir = yield * tmpdirScoped ( { git : true } )
202+ const project = yield * Project . use . fromDirectory ( dir )
203+ registerAdapter ( project . project . id , "local-test" , localAdapter ( path . join ( dir , ".workspace" ) ) )
204+
205+ const created = yield * request ( WorkspacePaths . list , dir , {
206+ method : "POST" ,
207+ headers : { "content-type" : "application/json" } ,
208+ body : JSON . stringify ( { type : "local-test" , branch : null } ) ,
209+ } )
210+
211+ expect ( created . status ) . toBe ( 200 )
212+ expect ( ( yield * Effect . promise ( ( ) => created . json ( ) ) ) as Workspace . Info ) . toMatchObject ( {
213+ type : "local-test" ,
214+ name : "local-test" ,
215+ extra : null ,
216+ } )
217+ } ) ,
218+ )
219+
220+ it . live ( "documents legacy Hono accepting the TUI payload shape" , ( ) =>
221+ Effect . gen ( function * ( ) {
222+ Flag . OPENCODE_EXPERIMENTAL_WORKSPACES = true
223+ const dir = yield * tmpdirScoped ( { git : true } )
224+ const project = yield * Project . use . fromDirectory ( dir )
225+ registerAdapter ( project . project . id , "local-test" , localAdapter ( path . join ( dir , ".workspace" ) ) )
226+
227+ const created = yield * request (
228+ WorkspacePaths . list ,
229+ dir ,
230+ {
231+ method : "POST" ,
232+ headers : { "content-type" : "application/json" } ,
233+ body : JSON . stringify ( { type : "local-test" , branch : null } ) ,
234+ } ,
235+ false ,
236+ )
237+
238+ expect ( created . status ) . toBe ( 200 )
239+ expect ( ( yield * Effect . promise ( ( ) => created . json ( ) ) ) as Workspace . Info ) . toMatchObject ( {
240+ type : "local-test" ,
241+ name : "local-test" ,
242+ extra : null ,
243+ } )
244+ } ) ,
245+ )
246+
198247 it . live ( "routes local workspace requests through the workspace target directory" , ( ) =>
199248 Effect . gen ( function * ( ) {
200249 Flag . OPENCODE_EXPERIMENTAL_WORKSPACES = true
0 commit comments