11import type { LocationGetOutput , ModelRef , OpenCodeClient , SessionInfo } from "@opencode/client/promise"
22import { Model } from "@opencode/schema/model"
3+ import { errorMessage } from "./util/error"
34
45const SESSION_PAGE_LIMIT = 50
56
@@ -24,7 +25,7 @@ export class SessionTargetMutationError extends Error {
2425 override readonly name = "SessionTargetMutationError"
2526
2627 constructor ( cause : unknown ) {
27- super ( cause instanceof Error ? cause . message : "Session target mutation failed" , { cause } )
28+ super ( errorMessage ( cause ) , { cause } )
2829 }
2930}
3031
@@ -125,11 +126,9 @@ async function selectSession(input: {
125126 if ( ! selected ) return { session : undefined , location }
126127 return {
127128 session : input . fork
128- ? await input . client . session
129- . fork ( { sessionID : selected . id } , ...requestOptions ( input . signal ) )
130- . catch ( ( error ) => {
131- throw new SessionTargetMutationError ( error )
132- } )
129+ ? await input . client . session . fork ( { sessionID : selected . id } , ...requestOptions ( input . signal ) ) . catch ( ( error ) => {
130+ throw new SessionTargetMutationError ( error )
131+ } )
133132 : selected ,
134133 }
135134}
@@ -156,11 +155,7 @@ async function latestSession(
156155 return latestSession ( client , location , page . cursor . next , signal )
157156}
158157
159- function resolveLocation (
160- client : OpenCodeClient ,
161- location ?: { directory ?: string } ,
162- signal ?: AbortSignal ,
163- ) {
158+ function resolveLocation ( client : OpenCodeClient , location ?: { directory ?: string } , signal ?: AbortSignal ) {
164159 if ( ! location && ! signal ) return client . location . get ( )
165160 if ( ! location ) return client . location . get ( undefined , { signal } )
166161 return client . location . get ( { location } , ...requestOptions ( signal ) )
0 commit comments