fix: regressions

This commit is contained in:
cogwheel0
2025-08-28 19:17:05 +05:30
parent 729ab45ee7
commit a686d8d6a8
6 changed files with 90 additions and 0 deletions

View File

@@ -299,6 +299,59 @@ final _settingsWatcherProvider = Provider<void>((ref) {
});
});
// Auto-apply default model from settings when it changes (and not manually overridden)
final defaultModelAutoSelectionProvider = Provider<void>((ref) {
ref.listen<AppSettings>(appSettingsProvider, (previous, next) {
// Only react when default model value changes
if (previous?.defaultModel == next.defaultModel) return;
// Do not override manual selections
if (ref.read(isManualModelSelectionProvider)) return;
final desired = next.defaultModel;
if (desired == null || desired.isEmpty) return;
// Resolve the desired model against available models
Future(() async {
try {
// Prefer already-loaded models to avoid unnecessary fetches
List<Model> models;
final modelsAsync = ref.read(modelsProvider);
if (modelsAsync.hasValue) {
models = modelsAsync.value!;
} else {
models = await ref.read(modelsProvider.future);
}
Model? selected;
try {
selected = models.firstWhere(
(model) =>
model.id == desired ||
model.name == desired ||
model.id.contains(desired) ||
model.name.contains(desired),
);
} catch (_) {}
// Fallback: keep current selection or pick first available
selected ??= ref.read(selectedModelProvider) ??
(models.isNotEmpty ? models.first : null);
if (selected != null) {
ref.read(selectedModelProvider.notifier).state = selected;
foundation.debugPrint(
'DEBUG: Auto-applied default model from settings: ${selected.name}',
);
}
} catch (e) {
foundation.debugPrint(
'DEBUG: defaultModel auto-selection listener failed: $e',
);
}
});
});
});
// Cache timestamp for conversations to prevent rapid re-fetches
final _conversationsCacheTimestamp = StateProvider<DateTime?>((ref) => null);

View File

@@ -68,6 +68,9 @@ class _ConduitAppState extends ConsumerState<ConduitApp> {
// Ensure API service auth integration is active
ref.read(authApiIntegrationProvider);
// Initialize auto-selection listener for default model changes in settings
ref.read(defaultModelAutoSelectionProvider);
// Initialize OS share receiver so users can share text/files to Conduit
ref.read(shareReceiverInitializerProvider);
}

View File

@@ -382,6 +382,15 @@ class _AnimatedThemeWrapperState extends State<AnimatedThemeWrapper>
super.deactivate();
}
@override
void activate() {
super.activate();
// If a theme transition was in progress, resume it
if (_controller.value < 1.0 && !_controller.isAnimating) {
_controller.forward();
}
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(

View File

@@ -475,6 +475,14 @@ class _ShimmerLoaderState extends State<ShimmerLoader>
super.deactivate();
}
@override
void activate() {
super.activate();
if (!_shimmerController.isAnimating) {
_shimmerController.repeat();
}
}
@override
Widget build(BuildContext context) {
final theme = context.conduitTheme;

View File

@@ -236,6 +236,14 @@ class _SkeletonLoaderState extends State<_SkeletonLoader>
super.deactivate();
}
@override
void activate() {
super.activate();
if (!_controller.isAnimating) {
_controller.repeat();
}
}
@override
Widget build(BuildContext context) {
return Container(

View File

@@ -62,6 +62,15 @@ class _SkeletonLoaderState extends State<SkeletonLoader>
super.deactivate();
}
@override
void activate() {
super.activate();
if (!_controller.isAnimating) {
// Resume shimmer after re-activation
_controller.repeat();
}
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(