diff --git a/.cursor/rules/version_control.mdc b/.cursor/rules/version_control.mdc index c486997d..b1a53c33 100644 --- a/.cursor/rules/version_control.mdc +++ b/.cursor/rules/version_control.mdc @@ -1,7 +1,13 @@ --- alwaysApply: true --- - do not add or commit for the user; let him control that process +# Rules for peaceful co-existence with developers + +do not add or commit for the user; let him control that process + +the content of commit messages should be from the files awaiting staging +and those which have been staged. use the differences in those files +to inform the content of the commit message always preview changes and commit message to use and allow me to copy and paste ✅ Preferred Commit Message Format diff --git a/src/services/AbsurdSqlDatabaseService.ts b/src/services/AbsurdSqlDatabaseService.ts index bd601755..083d3076 100644 --- a/src/services/AbsurdSqlDatabaseService.ts +++ b/src/services/AbsurdSqlDatabaseService.ts @@ -134,7 +134,7 @@ class AbsurdSqlDatabaseService implements DatabaseService { // An error is thrown without this pragma: "File has invalid page size. (the first block of a new file must be written first)" await this.db.exec(`PRAGMA journal_mode=MEMORY;`); - + // Create wrapper functions that match the expected signatures const sqlExec = async (sql: string, params?: unknown[]): Promise => { await this.db!.run(sql, params); diff --git a/src/services/platforms/CapacitorPlatformService.ts b/src/services/platforms/CapacitorPlatformService.ts index 18262f2a..bd22ef8d 100644 --- a/src/services/platforms/CapacitorPlatformService.ts +++ b/src/services/platforms/CapacitorPlatformService.ts @@ -492,10 +492,7 @@ export class CapacitorPlatformService implements PlatformService { * @param params - Optional parameters for prepared statements * @returns Promise resolving to execution results */ - const sqlExec = async ( - sql: string, - params?: unknown[], - ): Promise => { + const sqlExec = async (sql: string, params?: unknown[]): Promise => { logger.debug(`🔧 [CapacitorMigration] Executing SQL:`, sql); if (params && params.length > 0) { diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index 6afe5d18..6baa8cc6 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/src/utils/PlatformServiceMixin.ts @@ -459,13 +459,10 @@ export const PlatformServiceMixin = { return settings; } catch (error) { - logger.error( - `[${(this as unknown as VueComponentWithMixin).$options.name}] Failed to get settings:`, - { - key, - error, - }, - ); + logger.error(`[Settings Trace] ❌ Failed to get settings:`, { + key, + error, + }); return fallback; } }, @@ -533,14 +530,11 @@ export const PlatformServiceMixin = { return mergedSettings; } catch (error) { - logger.error( - `[${(this as unknown as VueComponentWithMixin).$options.name}] Failed to get merged settings:`, - { - defaultKey, - accountDid, - error, - }, - ); + logger.error(`[Settings Trace] ❌ Failed to get merged settings:`, { + defaultKey, + accountDid, + error, + }); return defaultFallback; } }, @@ -748,25 +742,20 @@ export const PlatformServiceMixin = { ); mergedSettings.apiServer = DEFAULT_ENDORSER_API_SERVER; - - logger.debug( - `[Electron Settings] Forced API server to: ${DEFAULT_ENDORSER_API_SERVER}`, - ); } // Merge with any provided defaults (these take highest precedence) - const finalSettings = { ...mergedSettings, ...defaults }; - - console.log( - "[PlatformServiceMixin] $accountSettings", - JSON.stringify(finalSettings, null, 2), + // Filter out undefined and empty string values to prevent overriding real settings + const filteredDefaults = Object.fromEntries( + Object.entries(defaults).filter( + ([_, value]) => value !== undefined && value !== "", + ), ); + + const finalSettings = { ...mergedSettings, ...filteredDefaults }; return finalSettings; } catch (error) { - logger.error( - "[PlatformServiceMixin] Error in $accountSettings:", - error, - ); + logger.error("[Settings Trace] ❌ Error in $accountSettings:", error); // Fallback to defaults on error return defaults; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 228fcc3c..8bffb03a 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -309,7 +309,6 @@ import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify"; import { NOTIFY_CONTACT_LOADING_ISSUE, - NOTIFY_FEED_LOADING_ISSUE, NOTIFY_CONFIRMATION_ERROR, } from "@/constants/notifications"; import * as Package from "../../package.json"; @@ -485,6 +484,10 @@ export default class HomeView extends Vue { if (newDid !== oldDid) { // Re-initialize identity with new settings (loads settings internally) await this.initializeIdentity(); + } else { + logger.info( + "[HomeView Settings Trace] 📍 DID unchanged, skipping re-initialization", + ); } } @@ -527,11 +530,7 @@ export default class HomeView extends Vue { // Load settings with better error context using ultra-concise mixin let settings; try { - settings = await this.$settings({ - apiServer: "", - activeDid: "", - isRegistered: false, - }); + settings = await this.$accountSettings(); } catch (error) { this.$logAndConsole( `[HomeView] Failed to retrieve settings: ${error}`, @@ -599,65 +598,21 @@ export default class HomeView extends Vue { // Ultra-concise settings update with automatic cache invalidation! await this.$saveMySettings({ isRegistered: true }); this.isRegistered = true; - // Force Vue to re-render the template - await this.$nextTick(); } } catch (error) { - // Consolidate logging: Only log unexpected errors, not expected 400s - const axiosError = error as any; - if (axiosError?.response?.status !== 400) { - this.$logAndConsole( - `[HomeView] Registration check failed: ${error}`, - true, - ); - } - // Continue as unregistered - this is expected for new users - } - } - - // Initialize feed and offers - try { - // Start feed update in background - this.updateAllFeed().catch((error) => { - this.$logAndConsole( - `[HomeView] Background feed update failed: ${error}`, - true, + logger.warn( + "[HomeView Settings Trace] ⚠️ Registration check failed", + { + error: error instanceof Error ? error.message : String(error), + }, ); - }); - - // Load new offers if we have an active DID - if (this.activeDid) { - const [offersToUser, offersToProjects] = await Promise.all([ - getNewOffersToUser( - this.axios, - this.apiServer, - this.activeDid, - this.lastAckedOfferToUserJwtId, - ), - getNewOffersToUserProjects( - this.axios, - this.apiServer, - this.activeDid, - this.lastAckedOfferToUserProjectsJwtId, - ), - ]); - - this.numNewOffersToUser = offersToUser.data.length; - this.newOffersToUserHitLimit = offersToUser.hitLimit; - this.numNewOffersToUserProjects = offersToProjects.data.length; - this.newOffersToUserProjectsHitLimit = offersToProjects.hitLimit; } - } catch (error) { - this.$logAndConsole( - `[HomeView] Failed to initialize feed/offers: ${error}`, - true, - ); - // Don't throw - we can continue with empty feed - this.notify.warning(NOTIFY_FEED_LOADING_ISSUE.message, TIMEOUTS.LONG); } - } catch (error) { - this.handleError(error); - throw error; // Re-throw to be caught by mounted() + } catch (err: unknown) { + logger.error("[HomeView Settings Trace] ❌ initializeIdentity() failed", { + error: err instanceof Error ? err.message : String(err), + }); + throw err; } } @@ -682,10 +637,8 @@ export default class HomeView extends Vue { } /** - * Loads user settings from storage using ultra-concise mixin utilities - * Sets component state for: - * - API server, Active DID, Feed filters and view settings - * - Registration status, Notification acknowledgments + * Loads user settings from database using ultra-concise mixin + * Used for displaying settings in feed and actions * * @internal * Called by mounted() and reloadFeedOnChange() @@ -815,7 +768,7 @@ export default class HomeView extends Vue { * Called by mounted() */ private async checkOnboarding() { - const settings = await this.$settings(); + const settings = await this.$accountSettings(); if (!settings.finishedOnboarding) { (this.$refs.onboardingDialog as OnboardingDialog).open(OnboardPage.Home); } diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index 2926c00a..59eedbdf 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -214,7 +214,10 @@ export default class IdentitySwitcherView extends Vue { } } catch (err) { this.notify.error(NOTIFY_ERROR_LOADING_ACCOUNTS.message, TIMEOUTS.LONG); - logger.error("Telling user to clear cache at page create because:", err); + logger.error( + "[IdentitySwitcher Settings Trace] ❌ Error loading accounts:", + err, + ); } } @@ -225,12 +228,35 @@ export default class IdentitySwitcherView extends Vue { // Check if we need to load user-specific settings for the new DID if (did) { try { - await this.$accountSettings(did); + const newSettings = await this.$accountSettings(did); + logger.info( + "[IdentitySwitcher Settings Trace] ✅ New account settings loaded", + { + did, + settingsKeys: Object.keys(newSettings).filter( + (k) => (newSettings as any)[k] !== undefined, + ), + }, + ); } catch (error) { + logger.warn( + "[IdentitySwitcher Settings Trace] ⚠️ Error loading new account settings", + { + did, + error: error instanceof Error ? error.message : String(error), + }, + ); // Handle error silently - user settings will be loaded when needed } } + logger.info( + "[IdentitySwitcher Settings Trace] 🔄 Navigating to home to trigger watcher", + { + newDid: did, + }, + ); + // Navigate to home page to trigger the watcher this.$router.push({ name: "home" }); } diff --git a/src/views/ImportDerivedAccountView.vue b/src/views/ImportDerivedAccountView.vue index 182c9449..4c48fa20 100644 --- a/src/views/ImportDerivedAccountView.vue +++ b/src/views/ImportDerivedAccountView.vue @@ -166,10 +166,8 @@ export default class ImportAccountView extends Vue { ] as string; const newDerivPath = nextDerivationPath(maxDerivPath); - const mne = selectedArray[0].mnemonic as string; const [address, privateHex, publicHex] = deriveAddress(mne, newDerivPath); - const newId = newIdentifier(address, publicHex, privateHex, newDerivPath); try { @@ -187,7 +185,10 @@ export default class ImportAccountView extends Vue { ); this.$router.push({ name: "account" }); } catch (err) { - logger.error("Error saving mnemonic & updating settings:", err); + logger.error( + "[ImportDerived Settings Trace] ❌ Error saving mnemonic & updating settings:", + err, + ); this.notify.error(NOTIFY_ACCOUNT_DERIVATION_ERROR.message, TIMEOUTS.LONG); } }