π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(ensu): address latest PR review
Prateek Sunale1b8001d04a7
diff --git a/rust/apps/ensu/src-tauri/src/commands.rs b/rust/apps/ensu/src-tauri/src/commands.rsindex 27a915beca..52b5c83218 100644--- a/rust/apps/ensu/src-tauri/src/commands.rs+++ b/rust/apps/ensu/src-tauri/src/commands.rs@@ -1873,6 +1873,7 @@ fn migrate_legacy_chat_db(let mut source_session_ids = Vec::new();let mut source_message_ids_by_session = HashMap::new();let mut expected_attachment_ids = Vec::new();+ let legacy_sessions = legacy_db.list_all_sessions().map_err(ApiError::from)?;for meta_key in [SYNC_CURSOR_META_KEY,@@ -1890,7 +1891,7 @@ fn migrate_legacy_chat_db(}}- for session in legacy_db.list_all_sessions().map_err(ApiError::from)? {+ for session in legacy_sessions {source_session_ids.push(session.uuid);target_db.upsert_session(diff --git a/web/apps/ensu/src/pages/chat.tsx b/web/apps/ensu/src/pages/chat.tsxindex 098c8daa2e..60c52f1ed7 100644--- a/web/apps/ensu/src/pages/chat.tsx+++ b/web/apps/ensu/src/pages/chat.tsx@@ -1887,13 +1887,15 @@ const Page: React.FC = () => {[sessions, currentSessionId],);+ const currentRootSessionUuid = currentSession?.rootSessionUuid;+useEffect(() => {- if (!currentSession) {+ if (!currentRootSessionUuid) {setBranchSelections({});return;}let cancelled = false;- void getBranchSelections(currentSession.rootSessionUuid)+ void getBranchSelections(currentRootSessionUuid).then((selections) => {if (!cancelled) {setBranchSelections(selections);@@ -1909,7 +1911,7 @@ const Page: React.FC = () => {return () => {cancelled = true;};- }, [currentSession, currentSession?.rootSessionUuid]);+ }, [currentRootSessionUuid]);useEffect(() => {if (isTauriRuntime) return;diff --git a/web/apps/ensu/src/services/chat/store.ts b/web/apps/ensu/src/services/chat/store.tsindex d9f1079a39..3f40d995d9 100644--- a/web/apps/ensu/src/services/chat/store.ts+++ b/web/apps/ensu/src/services/chat/store.ts@@ -834,8 +834,10 @@ const migrateLegacyChatStoreToNative = async (chatKey: string) => {log.info("Finished migrating legacy local chat store to native DB");};-const migrateLegacyNativeChatStoreToV2 = async (chatKey: string) => {- if (!isTauriRuntime()) return;+const migrateLegacyNativeChatStoreToV2 = async (+ chatKey: string,+): Promise<boolean> => {+ if (!isTauriRuntime()) return true;// Collect all known key candidates. allLegacyKeyCandidates returns every// key found across secure storage, native file, AND localStorage. This is@@ -859,7 +861,7 @@ const migrateLegacyNativeChatStoreToV2 = async (chatKey: string) => {);log.info("Migrated legacy native chat store to v2 DB", result);}- return;+ return true;} catch (error) {const code = getErrorCode(error);if (@@ -876,6 +878,7 @@ const migrateLegacyNativeChatStoreToV2 = async (chatKey: string) => {log.warn("Skipping legacy native chat migration because the available legacy keys could not decrypt the legacy DB",);+ return false;};export const initializeChatStorePersistence = async (chatKey: string) => {@@ -887,11 +890,14 @@ export const initializeChatStorePersistence = async (chatKey: string) => {const initPromise = (async () => {if (isTauriRuntime()) {if (!isNativeMigrationDone()) {- await migrateLegacyNativeChatStoreToV2(chatKey);+ const didResolveNativeMigration =+ await migrateLegacyNativeChatStoreToV2(chatKey);if (hasLegacyChatStore()) {await migrateLegacyChatStoreToNative(chatKey);}- markNativeMigrationDone();+ if (didResolveNativeMigration) {+ markNativeMigrationDone();+ }}return;}