@@ -251,6 +251,70 @@ describe("CopilotClient", () => {
251251 expect ( resumePayload . expAssignments ) . toBeUndefined ( ) ;
252252 } ) ;
253253
254+ it ( "forwards internalCorrelationIds in session.create and session.resume" , async ( ) => {
255+ const client = new CopilotClient ( ) ;
256+ await client . start ( ) ;
257+ onTestFinished ( ( ) => client . forceStop ( ) ) ;
258+
259+ const spy = vi
260+ . spyOn ( ( client as any ) . connection ! , "sendRequest" )
261+ . mockImplementation ( async ( method : string , params : any ) => {
262+ if ( method === "session.create" ) return { sessionId : params . sessionId } ;
263+ if ( method === "session.resume" ) return { sessionId : params . sessionId } ;
264+ throw new Error ( `Unexpected method: ${ method } ` ) ;
265+ } ) ;
266+
267+ const correlationIds = {
268+ cca_job_id : "job-123" ,
269+ owner_id : "1" ,
270+ repo_id : "2" ,
271+ } ;
272+
273+ const session = await client . createSession ( {
274+ onPermissionRequest : approveAll ,
275+ internalCorrelationIds : correlationIds ,
276+ } ) ;
277+ await client . resumeSession ( session . sessionId , {
278+ onPermissionRequest : approveAll ,
279+ internalCorrelationIds : correlationIds ,
280+ } ) ;
281+
282+ const createPayload = spy . mock . calls . find (
283+ ( [ method ] ) => method === "session.create"
284+ ) ! [ 1 ] as any ;
285+ const resumePayload = spy . mock . calls . find (
286+ ( [ method ] ) => method === "session.resume"
287+ ) ! [ 1 ] as any ;
288+ expect ( createPayload . internalCorrelationIds ) . toEqual ( correlationIds ) ;
289+ expect ( resumePayload . internalCorrelationIds ) . toEqual ( correlationIds ) ;
290+ } ) ;
291+
292+ it ( "omits internalCorrelationIds from session.create and session.resume when unset" , async ( ) => {
293+ const client = new CopilotClient ( ) ;
294+ await client . start ( ) ;
295+ onTestFinished ( ( ) => client . forceStop ( ) ) ;
296+
297+ const spy = vi
298+ . spyOn ( ( client as any ) . connection ! , "sendRequest" )
299+ . mockImplementation ( async ( method : string , params : any ) => {
300+ if ( method === "session.create" ) return { sessionId : params . sessionId } ;
301+ if ( method === "session.resume" ) return { sessionId : params . sessionId } ;
302+ throw new Error ( `Unexpected method: ${ method } ` ) ;
303+ } ) ;
304+
305+ const session = await client . createSession ( { onPermissionRequest : approveAll } ) ;
306+ await client . resumeSession ( session . sessionId , { onPermissionRequest : approveAll } ) ;
307+
308+ const createPayload = spy . mock . calls . find (
309+ ( [ method ] ) => method === "session.create"
310+ ) ! [ 1 ] as any ;
311+ const resumePayload = spy . mock . calls . find (
312+ ( [ method ] ) => method === "session.resume"
313+ ) ! [ 1 ] as any ;
314+ expect ( createPayload . internalCorrelationIds ) . toBeUndefined ( ) ;
315+ expect ( resumePayload . internalCorrelationIds ) . toBeUndefined ( ) ;
316+ } ) ;
317+
254318 it ( "forwards capi options in session.create and session.resume" , async ( ) => {
255319 const client = new CopilotClient ( ) ;
256320 await client . start ( ) ;
0 commit comments