11use std:: path:: Path ;
22use std:: process:: Command ;
3- use std:: sync:: Arc ;
43
5- use github_copilot_sdk:: ResumeSessionConfig ;
6- use github_copilot_sdk:: handler:: ApproveAllHandler ;
74use github_copilot_sdk:: rpc:: {
85 WorkspaceDiffFileChangeType , WorkspaceDiffMode , WorkspacesDiffRequest ,
96 WorkspacesReadCheckpointRequest , WorkspacesReadFileRequest , WorkspacesSaveLargePasteRequest ,
@@ -187,6 +184,15 @@ fn normalize_path(path: &str) -> String {
187184 path. replace ( '\\' , "/" )
188185}
189186
187+ fn canonical_normalized_path ( path : & str ) -> String {
188+ normalize_path (
189+ std:: fs:: canonicalize ( path)
190+ . expect ( "canonicalize workspace path" )
191+ . to_string_lossy ( )
192+ . as_ref ( ) ,
193+ )
194+ }
195+
190196#[ tokio:: test]
191197async fn should_record_git_context_in_a_new_session_workspace ( ) {
192198 super :: support:: with_e2e_context_no_snapshot ( |ctx| {
@@ -233,11 +239,10 @@ async fn should_record_git_context_in_a_new_session_workspace() {
233239 // The repository was created exactly at the session's working
234240 // directory, so the recorded root is that directory and not an
235241 // ancestor of it.
236- let git_root = normalize_path ( workspace. git_root . as_deref ( ) . expect ( "git root" ) ) ;
237- assert_eq ! (
238- Some ( git_root. as_str( ) ) ,
239- workspace. cwd. as_deref( ) . map( normalize_path) . as_deref( )
240- ) ;
242+ let git_root =
243+ canonical_normalized_path ( workspace. git_root . as_deref ( ) . expect ( "git root" ) ) ;
244+ let cwd = canonical_normalized_path ( workspace. cwd . as_deref ( ) . expect ( "workspace cwd" ) ) ;
245+ assert_eq ! ( git_root, cwd) ;
241246 let work_dir_name = ctx
242247 . work_dir ( )
243248 . file_name ( )
@@ -254,36 +259,7 @@ async fn should_record_git_context_in_a_new_session_workspace() {
254259 ) ;
255260 assert_eq ! ( workspace. client_name. as_deref( ) , Some ( "rust-e2e-client" ) ) ;
256261
257- // The recorded context survives a resume rather than being dropped
258- // or re-derived into something else.
259- let session_id = session. id ( ) . clone ( ) ;
260262 session. disconnect ( ) . await . expect ( "disconnect session" ) ;
261- let resumed = client
262- . resume_session (
263- ResumeSessionConfig :: new ( session_id)
264- . with_permission_handler ( Arc :: new ( ApproveAllHandler ) )
265- . with_github_token ( super :: support:: DEFAULT_TEST_TOKEN ) ,
266- )
267- . await
268- . expect ( "resume session" ) ;
269- let resumed_workspace = resumed
270- . rpc ( )
271- . workspaces ( )
272- . get_workspace ( )
273- . await
274- . expect ( "get workspace after resume" )
275- . workspace
276- . expect ( "workspace after resume" ) ;
277- assert_eq ! (
278- resumed_workspace. repository. as_deref( ) ,
279- Some ( "test-org/test-repo" )
280- ) ;
281- assert_eq ! (
282- resumed_workspace. branch. as_deref( ) ,
283- Some ( "feature/test-branch" )
284- ) ;
285-
286- resumed. disconnect ( ) . await . expect ( "disconnect resumed" ) ;
287263 client. stop ( ) . await . expect ( "stop client" ) ;
288264 } )
289265 } )
0 commit comments