@@ -784,9 +784,14 @@ describe('register', () => {
784784
785785 expect ( world . reads , "the edit's read is under way" ) . toEqual ( [ 0 ] )
786786
787- expect ( await $ . command . run ( Fixtures . DIFF ) ) . toEqual ( {
788- text : 'Diff panel shown' ,
789- } )
787+ const shown = $ . command . run ( Fixtures . DIFF )
788+
789+ await world . clock . advance ( 1 )
790+
791+ expect (
792+ await shown ,
793+ '/diff reads before it opens, as the edit does' ,
794+ ) . toEqual ( { text : 'Diff panel shown' } )
790795
791796 expect ( await $ . command . run ( Fixtures . DIFF ) ) . toEqual ( {
792797 text : 'Diff panel hidden' ,
@@ -816,7 +821,11 @@ describe('register', () => {
816821 } )
817822
818823 await world . clock . settle ( )
819- await $ . command . run ( Fixtures . DIFF )
824+
825+ const shown = $ . command . run ( Fixtures . DIFF )
826+
827+ await world . clock . advance ( 1 )
828+ await shown
820829 await $ . command . run ( Fixtures . DIFF )
821830 await $ . tool . call ( { tool : 'Bash' , command : 'make' } )
822831 await world . clock . advance ( Fixtures . SETTLE_MS )
@@ -843,8 +852,11 @@ describe('register', () => {
843852 } )
844853
845854 await world . clock . settle ( )
846- await $ . command . run ( Fixtures . DIFF )
855+
856+ const shown = $ . command . run ( Fixtures . DIFF )
857+
847858 await world . clock . advance ( Fixtures . SETTLE_MS )
859+ await shown
848860
849861 expect (
850862 world . opened . map ( pane => pane . id ) ,
@@ -1029,6 +1041,12 @@ describe('register', () => {
10291041 'and withdrew the pane the engine left waiting, so no resize seats it' ,
10301042 ) . toEqual ( [ 'diff' ] )
10311043
1044+ expect (
1045+ world . runs . map ( run => Fixtures . gitWordOf ( run . argv ) ) . slice ( 0 , 2 ) ,
1046+ 'the repository was found and read once before the open, as the ' +
1047+ 'built-in primes; nothing polls for a pane no one sees' ,
1048+ ) . toEqual ( [ 'rev-parse --show-toplevel' , 'status' ] )
1049+
10321050 expect (
10331051 world . runs . map ( run => Fixtures . gitWordOf ( run . argv ) ) ,
10341052 'the repository was found and read once to decide, no hunks fetched ' +
@@ -1041,6 +1059,11 @@ describe('register', () => {
10411059 'ls-files' ,
10421060 ] )
10431061
1062+ expect (
1063+ world . runs . map ( run => Fixtures . gitWordOf ( run . argv ) ) ,
1064+ 'no HEAD poll for a withdrawn pane' ,
1065+ ) . not . toContain ( Fixtures . POLL_WORD )
1066+
10441067 isNarrow = false
10451068
10461069 expect (
@@ -1094,6 +1117,59 @@ describe('register', () => {
10941117 ) . toEqual ( [ 'diff' ] )
10951118 } )
10961119
1120+ test ( 'a docked pane opens once its first fetch settled' , async ( $ , on ) => {
1121+ const opened : string [ ] = [ ]
1122+ const clock = Fixtures . startsSession ( on )
1123+
1124+ on ( 'process.run' , async ( $ , e ) => {
1125+ if ( e . argv . includes ( '--shortstat' ) ) {
1126+ await clock . sleep ( Fixtures . SLOW_DIFF_MS )
1127+ }
1128+
1129+ return { value : Fixtures . gitIn ( e . argv ) }
1130+ } )
1131+
1132+ on ( 'ui.open' , ( $ , e ) => {
1133+ opened . push ( e . id )
1134+
1135+ return { value : undefined }
1136+ } )
1137+
1138+ on ( 'ui.close' , ( ) => ( { value : undefined } ) )
1139+ on ( 'ui.invalidate' , ( ) => ( { value : undefined } ) )
1140+ on ( 'ui.render' , { component : 'PromptHint' } , ( ) => Fixtures . HINT_DRAWN )
1141+ on ( 'session.messages' , ( ) => ( { value : [ ] } ) )
1142+ on ( 'settings.read' , ( ) => ( { value : { } } ) )
1143+ on ( 'tool.call' , ( ) => ( { result : 'edited' } ) )
1144+ mock . store ( on )
1145+ mock . env ( on , { } )
1146+
1147+ await $ . session . start ( Fixtures . SESSION )
1148+ await $ . ui . render ( Fixtures . HINT )
1149+
1150+ await $ . tool . call ( {
1151+ tool : 'Edit' ,
1152+ file_path : '/work/app.ts' ,
1153+ old_string : '1' ,
1154+ new_string : '2' ,
1155+ } )
1156+
1157+ await clock . advance ( Fixtures . SLOW_DIFF_MS - 1 )
1158+
1159+ expect ( opened , 'git has not answered: no pane, no Loading frame' ) . toEqual (
1160+ [ ] ,
1161+ )
1162+
1163+ await clock . advance ( Fixtures . SETTLE_MS )
1164+
1165+ expect ( opened , 'the fetch settled: the pane opens filled' ) . toEqual ( [ 'diff' ] )
1166+
1167+ const drawn = Fixtures . textOf ( await $ . ui . render ( Fixtures . PANE ) )
1168+
1169+ expect ( drawn ) . toContain ( '1 file changed' )
1170+ expect ( drawn ) . not . toContain ( 'Loading diff' )
1171+ } )
1172+
10971173 test ( '/clear closes the pane it finds open' , async ( $ , on ) => {
10981174 const world = Fixtures . inRepository ( on )
10991175
0 commit comments