Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Show migration status in debug

laurenspriem7f79df9e2f62
diff --git a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
index a41d429544..bd2405e567 100644
--- a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
@@ -5,6 +5,7 @@ import "package:hugeicons/hugeicons.dart";
import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/db/ml/clip_vector_db.dart";
+import "package:photos/db/ml/cluster_centroid_vector_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/events/people_changed_event.dart";
import "package:photos/models/ml/face/person.dart";
@@ -114,6 +115,8 @@ class _MLDebugSettingsPageState extends State<MLDebugSettingsPage> {
children: [
_buildMLControlsCard(context),
const SizedBox(height: 8),
+ _buildVectorDbMigrationCard(context),
+ const SizedBox(height: 8),
_buildThresholdsCard(context),
const SizedBox(height: 8),
_buildMLActionsCard(context),
@@ -249,6 +252,104 @@ class _MLDebugSettingsPageState extends State<MLDebugSettingsPage> {
);
}
+ Widget _buildVectorDbMigrationCard(BuildContext context) {
+ return FutureBuilder<({bool clipDone, bool clusterCentroidDone})>(
+ future: _getVectorDbMigrationStatus(),
+ builder: (context, snapshot) {
+ final status = snapshot.data;
+ return SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: "Clip vector DB migration",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedAiSearch,
+ ),
+ trailingWidget: _buildMigrationStatusWidget(
+ context,
+ isDone: status?.clipDone,
+ hasError: snapshot.hasError,
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Cluster centroid migration",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUserMultiple,
+ ),
+ trailingWidget: _buildMigrationStatusWidget(
+ context,
+ isDone: status?.clusterCentroidDone,
+ hasError: snapshot.hasError,
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Refresh migration status",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedReload,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ if (mounted) {
+ setState(() {});
+ }
+ },
+ ),
+ ],
+ );
+ },
+ );
+ }
+
+ Widget _buildMigrationStatusWidget(
+ BuildContext context, {
+ required bool? isDone,
+ required bool hasError,
+ }) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final String label;
+ final Color color;
+
+ if (hasError) {
+ label = "Error";
+ color = colorScheme.warning500;
+ } else if (isDone == null) {
+ label = "Loading";
+ color = colorScheme.textMuted;
+ } else if (isDone) {
+ label = "Done";
+ color = colorScheme.greenBase;
+ } else {
+ label = "Pending";
+ color = colorScheme.warning500;
+ }
+
+ return Text(
+ label,
+ style: textTheme.miniBold.copyWith(color: color),
+ );
+ }
+
+ Future<({bool clipDone, bool clusterCentroidDone})>
+ _getVectorDbMigrationStatus() async {
+ final clipVectorDB =
+ isOfflineMode ? ClipVectorDB.offlineInstance : ClipVectorDB.instance;
+ final clusterCentroidVectorDB = isOfflineMode
+ ? ClusterCentroidVectorDB.offlineInstance
+ : ClusterCentroidVectorDB.instance;
+ final migrationStatus = await Future.wait<bool>([
+ clipVectorDB.checkIfMigrationDone(),
+ clusterCentroidVectorDB.checkIfMigrationDone(),
+ ]);
+ return (
+ clipDone: migrationStatus[0],
+ clusterCentroidDone: migrationStatus[1],
+ );
+ }
+
Widget _buildThresholdsCard(BuildContext context) {
return SettingsGroupedCard(
children: [
@@ -776,6 +877,9 @@ class _MLDebugSettingsPageState extends State<MLDebugSettingsPage> {
: ClipVectorDB.instance;
await vectorDB.deleteIndexFile();
showShortToast(context, "Done");
+ if (mounted) {
+ setState(() {});
+ }
} catch (e, s) {
logger.warning('reset usearch index failed ', e, s);
await showGenericErrorDialog(context: context, error: e);