import 'package:riverpod_annotation/riverpod_annotation.dart'; import '../features/assistant/agent_conversation_service.dart'; import '../workspace/projects.dart'; import 'app_update_bridge.dart'; Future prepareForAppUpdateQuit(Ref ref) async { await ref.read(agentConversationRegistryProvider).cancelAll(); await ref.read(projectsProvider.notifier).prepareToQuit(); } // Keep the saved workspace recoverable if the updater cannot be launched. Future installWindowsUpdate(Ref ref) async { final bridge = ref.read(appUpdateBridgeProvider); await bridge.validateInstall(); final registry = ref.read(agentConversationRegistryProvider); await registry.cancelAll(); await registry.whilePaused(() async { final projects = ref.read(projectsProvider.notifier); await ref.read(projectsProvider.future); final snapshot = ref.read(projectsProvider).requireValue; await projects.prepareToQuit(); try { await bridge.install(); } catch (_) { ref.invalidate(projectsProvider); if (snapshot.activeProject case final project?) { await ref .read(projectsProvider.notifier) .open( project.path, expectedId: project.id, timelineId: snapshot.timeline?.id, ); } rethrow; } }); }