Refresh retained explorer when chat directory metadata arrives
This commit is contained in:
@@ -632,6 +632,11 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_repair = repair;
|
||||
unawaited(repair);
|
||||
}
|
||||
// Restored/deep-linked panes mount before the session list is fetched.
|
||||
// The same session gaining metadata must update its retained explorer.
|
||||
unawaited(
|
||||
_files.updateInitialPath('${widget.session?['directory'] ?? ''}'),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -6,7 +6,8 @@ import 'files_models.dart';
|
||||
class FilesController extends ChangeNotifier {
|
||||
FilesController({required this.gateway, required this.initialPath});
|
||||
final ApiGateway gateway;
|
||||
final String initialPath;
|
||||
String initialPath;
|
||||
bool _started = false;
|
||||
DirectoryListing? listing;
|
||||
String? error;
|
||||
bool loading = false;
|
||||
@@ -32,7 +33,24 @@ class FilesController extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> start() => open(initialPath);
|
||||
Future<void> start() {
|
||||
_started = true;
|
||||
return open(initialPath);
|
||||
}
|
||||
|
||||
/// Session metadata can arrive after the retained conversation is mounted.
|
||||
/// Keep a folder the operator navigated to; otherwise load the new root.
|
||||
Future<void> updateInitialPath(String path) async {
|
||||
if (_disposed || path.trim().isEmpty || path == initialPath) return;
|
||||
final previous = initialPath;
|
||||
initialPath = path;
|
||||
if (_started && (listing == null || listing!.path == previous)) {
|
||||
listing = null;
|
||||
await open(path);
|
||||
} else {
|
||||
_notify();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> open(String? path) async {
|
||||
if (path == null || path.trim().isEmpty) return;
|
||||
|
||||
Reference in New Issue
Block a user