From c0c7944f16c6f9744842e3d7e363fa1737e300df Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Tue, 2 Dec 2025 21:22:34 +0530 Subject: [PATCH] feat(startup): Optimize model tools auto-selection timing during app initialization --- lib/core/providers/app_startup_providers.dart | 9 ++++++--- lib/main.dart | 8 +++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/core/providers/app_startup_providers.dart b/lib/core/providers/app_startup_providers.dart index 8086b84..4ac5f66 100644 --- a/lib/core/providers/app_startup_providers.dart +++ b/lib/core/providers/app_startup_providers.dart @@ -173,9 +173,6 @@ class AppStartupFlow extends _$AppStartupFlow { keepAlive(appIntentCoordinatorProvider); keepAlive(quickActionsCoordinatorProvider); - // Ensure model tools auto-selection is active throughout app lifecycle - keepAlive(defaultModelAutoSelectionProvider); - // Kick background model loading flow (non-blocking) Future.delayed(const Duration(milliseconds: 120), () { if (!ref.mounted) return; @@ -279,6 +276,12 @@ class AppStartupFlow extends _$AppStartupFlow { scope: 'startup', data: {'error': e}, ); + } finally { + // Ensure model tools auto-selection is active AFTER model load attempt + // This guarantees tools are applied for the restored model + if (ref.mounted) { + keepAlive(defaultModelAutoSelectionProvider); + } } }); diff --git a/lib/main.dart b/lib/main.dart index 73b310e..23e0230 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -145,13 +145,11 @@ class _ConduitAppState extends ConsumerState { () => ref.read(authApiIntegrationProvider), delay: const Duration(milliseconds: 16), ); - queueInit( - () => ref.read(defaultModelAutoSelectionProvider), - delay: const Duration(milliseconds: 24), - ); + // Note: defaultModelAutoSelectionProvider is now initialized in + // AppStartupFlow after authentication to avoid loading tools too early queueInit( () => ref.read(shareReceiverInitializerProvider), - delay: const Duration(milliseconds: 32), + delay: const Duration(milliseconds: 24), ); SchedulerBinding.instance.addPostFrameCallback((_) {