fix(cli): invalidate preferences cache before applying owner profile on sync

The sync module creates its own PreferencesManager at server startup,
separate from the one shared by web routes. When the user configures their
identity through the web UI, the web routes' manager writes to disk and
updates its own cache, but the sync module's manager retains a stale cache
from startup. Subsequent pull imports then call tryApplyOwnerProfile with
the stale cache, returning no_profile and skipping owner assignment even
though a profile exists on disk.

Fix: invalidate the sync manager's cache before each onSessionImported
callback so the fresh profile is always read from disk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
diguaandClaude Sonnet 4.6 committed 2026-06-13 13:16:52 +08:00
1 parent 68cc5ffcee
commit 968cb39e87
1 file changed
+1
+1
View File
@@ -53,6 +53,7 @@ export function initSync(
dsManager,
logger: syncLogger,
onSessionImported: (localSessionId) => {
preferences.invalidateCache()
const result = ownerProfileService.tryApplyOwnerProfile(sessionAdapter, preferences, localSessionId)
if (result.applied) {
syncLogger.info(`[Pull] Applied owner profile to session ${localSessionId} (owner: ${result.ownerId})`)