@@ -91,6 +91,7 @@ vi.mock("./DiffFilePathCopyButton", () => ({ DiffFilePathCopyButton: () => null
9191
9292import DiffPanel from "./DiffPanel" ;
9393import { useDiffPanelSessionStore , useDiffPanelStore } from "~/diffPanelStore" ;
94+ import { selectThreadRightPanelState , useRightPanelStore } from "~/rightPanelStore" ;
9495
9596const cwd = "/project-worktree" ;
9697const errorMessage = "Could not find a common commit between 'origin/orphan' and HEAD." ;
@@ -124,6 +125,7 @@ function setup(failedBaseRef: string | null) {
124125 keepSelectionOnOpenThreadKey : null ,
125126 } ) ;
126127 useDiffPanelSessionStore . setState ( { collapsedFileKeysByScopeKey : { } } ) ;
128+ useRightPanelStore . setState ( { byThreadKey : { } , threadPanelVisibilityByThreadKey : { } } ) ;
127129 } ;
128130 reset ( ) ;
129131 state . diffFilesCollapsed = false ;
@@ -229,6 +231,36 @@ it.each([
229231 } ,
230232) ;
231233
234+ it ( "opens a repository-relative file from a nested project without a remote" , async ( ) => {
235+ using context = setup ( "origin/orphan" ) ;
236+ state . thread = { ...state . thread ! , worktreePath : null } ;
237+ const path = "project/back\\slash.txt" ;
238+ const metadata = preview ( ) ;
239+ const source = {
240+ ...metadata . sources [ 0 ] ! ,
241+ files : [ { path, previousPath : null , additions : 1 , deletions : 0 } ] ,
242+ } ;
243+ state . previews . set ( "main" , Atom . make ( AsyncResult . success ( { ...metadata , sources : [ source ] } ) ) ) ;
244+ state . status = Atom . make (
245+ AsyncResult . success ( {
246+ ...AsyncResult . getOrElse ( context . registry . get ( state . status ) , ( ) => {
247+ throw new Error ( "Missing status" ) ;
248+ } ) ,
249+ workingTree : { rootPath : "/" , files : [ ] , insertions : 0 , deletions : 0 } ,
250+ } ) ,
251+ ) ;
252+ useDiffPanelStore . getState ( ) . selectBranchBaseRef ( context . threadRef , "main" ) ;
253+ await using screen = await render (
254+ < RegistryContext . Provider value = { context . registry } >
255+ < DiffPanel composerDraftTarget = { context . threadRef } workspaceMutationId = { null } visible />
256+ </ RegistryContext . Provider > ,
257+ ) ;
258+ await userEvent . click ( screen . getByText ( path , { exact : true } ) ) ;
259+ expect (
260+ selectThreadRightPanelState ( useRightPanelStore . getState ( ) . byThreadKey , context . threadRef ) ,
261+ ) . toMatchObject ( { activeSurfaceId : "file:back\\slash.txt" } ) ;
262+ } ) ;
263+
232264it . each ( [ false , true ] ) (
233265 "expands an unloaded file on the first click with default collapse %s" ,
234266 async ( collapsed ) => {
0 commit comments