@@ -6,8 +6,7 @@ import { useSync } from "@tui/context/sync"
66import { useProject } from "@tui/context/project"
77import { createMemo , createSignal , onMount } from "solid-js"
88import { setTimeout as sleep } from "node:timers/promises"
9- import { errorData , errorMessage } from "@/util/error"
10- import * as Log from "@opencode-ai/core/util/log"
9+ import { errorMessage } from "@/util/error"
1110import { useSDK } from "../context/sdk"
1211import { useToast } from "../ui/toast"
1312
@@ -17,8 +16,6 @@ type Adaptor = {
1716 description : string
1817}
1918
20- const log = Log . Default . clone ( ) . tag ( "service" , "tui-workspace" )
21-
2219function scoped ( sdk : ReturnType < typeof useSDK > , sync : ReturnType < typeof useSync > , workspaceID : string ) {
2320 return createOpencodeClient ( {
2421 baseUrl : sdk . url ,
@@ -37,43 +34,21 @@ export async function openWorkspaceSession(input: {
3734 workspaceID : string
3835} ) {
3936 const client = scoped ( input . sdk , input . sync , input . workspaceID )
40- log . info ( "workspace session create requested" , {
41- workspaceID : input . workspaceID ,
42- } )
4337
4438 while ( true ) {
45- const result = await client . session . create ( { workspace : input . workspaceID } ) . catch ( ( err ) => {
46- log . error ( "workspace session create request failed" , {
47- workspaceID : input . workspaceID ,
48- error : errorData ( err ) ,
49- } )
50- return undefined
51- } )
39+ const result = await client . session . create ( { workspace : input . workspaceID } ) . catch ( ( ) => undefined )
5240 if ( ! result ) {
5341 input . toast . show ( {
5442 message : "Failed to create workspace session" ,
5543 variant : "error" ,
5644 } )
5745 return
5846 }
59- log . info ( "workspace session create response" , {
60- workspaceID : input . workspaceID ,
61- status : result . response ?. status ,
62- sessionID : result . data ?. id ,
63- } )
6447 if ( result . response ?. status && result . response . status >= 500 && result . response . status < 600 ) {
65- log . warn ( "workspace session create retrying after server error" , {
66- workspaceID : input . workspaceID ,
67- status : result . response . status ,
68- } )
6948 await sleep ( 1000 )
7049 continue
7150 }
7251 if ( ! result . data ) {
73- log . error ( "workspace session create returned no data" , {
74- workspaceID : input . workspaceID ,
75- status : result . response ?. status ,
76- } )
7752 input . toast . show ( {
7853 message : "Failed to create workspace session" ,
7954 variant : "error" ,
@@ -85,10 +60,6 @@ export async function openWorkspaceSession(input: {
8560 type : "session" ,
8661 sessionID : result . data . id ,
8762 } )
88- log . info ( "workspace session create complete" , {
89- workspaceID : input . workspaceID ,
90- sessionID : result . data . id ,
91- } )
9263 input . dialog . clear ( )
9364 return
9465 }
@@ -104,61 +75,22 @@ export async function restoreWorkspaceSession(input: {
10475 sessionID : string
10576 done ?: ( ) => void
10677} ) {
107- log . info ( "session restore requested" , {
108- workspaceID : input . workspaceID ,
109- sessionID : input . sessionID ,
110- } )
11178 const result = await input . sdk . client . experimental . workspace
11279 . sessionRestore ( { id : input . workspaceID , sessionID : input . sessionID } )
113- . catch ( ( err ) => {
114- log . error ( "session restore request failed" , {
115- workspaceID : input . workspaceID ,
116- sessionID : input . sessionID ,
117- error : errorData ( err ) ,
118- } )
119- return undefined
120- } )
80+ . catch ( ( ) => undefined )
12181 if ( ! result ?. data ) {
122- log . error ( "session restore failed" , {
123- workspaceID : input . workspaceID ,
124- sessionID : input . sessionID ,
125- status : result ?. response ?. status ,
126- error : result ?. error ? errorData ( result . error ) : undefined ,
127- } )
12882 input . toast . show ( {
12983 message : `Failed to restore session: ${ errorMessage ( result ?. error ?? "no response" ) } ` ,
13084 variant : "error" ,
13185 } )
13286 return
13387 }
13488
135- log . info ( "session restore response" , {
136- workspaceID : input . workspaceID ,
137- sessionID : input . sessionID ,
138- status : result . response ?. status ,
139- total : result . data . total ,
140- } )
141-
14289 input . project . workspace . set ( input . workspaceID )
14390
144- try {
145- await input . sync . bootstrap ( { fatal : false } )
146- } catch ( e ) { }
91+ await input . sync . bootstrap ( { fatal : false } ) . catch ( ( ) => undefined )
14792
148- await Promise . all ( [ input . project . workspace . sync ( ) , input . sync . session . sync ( input . sessionID ) ] ) . catch ( ( err ) => {
149- log . error ( "session restore refresh failed" , {
150- workspaceID : input . workspaceID ,
151- sessionID : input . sessionID ,
152- error : errorData ( err ) ,
153- } )
154- throw err
155- } )
156-
157- log . info ( "session restore complete" , {
158- workspaceID : input . workspaceID ,
159- sessionID : input . sessionID ,
160- total : result . data . total ,
161- } )
93+ await Promise . all ( [ input . project . workspace . sync ( ) , input . sync . session . sync ( input . sessionID ) ] )
16294
16395 input . toast . show ( {
16496 message : "Session restored into the new workspace" ,
@@ -230,47 +162,26 @@ export function DialogWorkspaceCreate(props: { onSelect: (workspaceID: string) =
230162 const create = async ( type : string ) => {
231163 if ( creating ( ) ) return
232164 setCreating ( type )
233- log . info ( "workspace create requested" , {
234- type,
235- } )
236165
237- const result = await sdk . client . experimental . workspace . create ( { type, branch : null } ) . catch ( ( err ) => {
166+ const result = await sdk . client . experimental . workspace . create ( { type, branch : null } ) . catch ( ( ) => {
238167 toast . show ( {
239168 message : "Creating workspace failed" ,
240169 variant : "error" ,
241170 } )
242- log . error ( "workspace create request failed" , {
243- type,
244- error : errorData ( err ) ,
245- } )
246171 return undefined
247172 } )
248173
249174 const workspace = result ?. data
250175 if ( ! workspace ) {
251176 setCreating ( undefined )
252- log . error ( "workspace create failed" , {
253- type,
254- status : result ?. response . status ,
255- error : result ?. error ? errorData ( result . error ) : undefined ,
256- } )
257177 toast . show ( {
258178 message : `Failed to create workspace: ${ errorMessage ( result ?. error ?? "no response" ) } ` ,
259179 variant : "error" ,
260180 } )
261181 return
262182 }
263- log . info ( "workspace create response" , {
264- type,
265- workspaceID : workspace . id ,
266- status : result . response ?. status ,
267- } )
268183
269184 await project . workspace . sync ( )
270- log . info ( "workspace create synced" , {
271- type,
272- workspaceID : workspace . id ,
273- } )
274185 await props . onSelect ( workspace . id )
275186 setCreating ( undefined )
276187 }
0 commit comments