@@ -193,6 +193,13 @@ final class _HeldListingConnection extends RecordingConnection
193193 _sessionStamp = Object ();
194194 emit (ConnState .ready);
195195 }
196+
197+ void beginInPlaceReconnect () {
198+ _sessionStamp = Object ();
199+ emit (ConnState .connecting);
200+ }
201+
202+ void finishInPlaceReconnect () => emit (ConnState .ready);
196203}
197204
198205void main () {
@@ -1169,6 +1176,44 @@ void main() {
11691176 await pumpEventQueue ();
11701177 });
11711178
1179+ test (
1180+ 'ready -> connecting clears stale rows before the successor reloads' ,
1181+ () async {
1182+ final h = await heldInitialList ();
1183+ h.connection.listRequests.single.result.complete (< RemoteEntry > [
1184+ const RemoteEntry (name: 'old.py' , isDir: false , size: 3 ),
1185+ ]);
1186+ await pumpEventQueue ();
1187+ expect (names (h.c), < String > {'old.py' });
1188+ expect (state (h.c).hasReportedFsRoot, isTrue);
1189+
1190+ h.connection.beginInPlaceReconnect ();
1191+ await pumpEventQueue ();
1192+
1193+ expect (state (h.c).entries, isEmpty);
1194+ expect (state (h.c).fsRoot, '/' );
1195+ expect (state (h.c).cwd, '/' );
1196+ expect (state (h.c).hasReportedFsRoot, isFalse);
1197+ expect (state (h.c).loading, isFalse);
1198+
1199+ h.connection.scriptedDeviceInfo = currentInfo;
1200+ h.connection.finishInPlaceReconnect ();
1201+ await pumpEventQueue ();
1202+ await pumpEventQueue ();
1203+ expect (h.connection.listRequests, hasLength (2 ));
1204+ h.connection.listRequests[1 ].result.complete (< RemoteEntry > [
1205+ const RemoteEntry (name: 'current.py' , isDir: false , size: 7 ),
1206+ ]);
1207+ await pumpEventQueue ();
1208+
1209+ expect (state (h.c).fsRoot, '/flash' );
1210+ expect (state (h.c).cwd, '/flash' );
1211+ expect (state (h.c).hasReportedFsRoot, isTrue);
1212+ expect (names (h.c), < String > {'current.py' });
1213+ expect (state (h.c).error, isNull);
1214+ },
1215+ );
1216+
11721217 test (
11731218 'listing auto-loads when a connection becomes ready AFTER first build' ,
11741219 () async {
0 commit comments