fix(identity): sync default sender identity per account (#507)#606
Merged
rathlinus merged 1 commit intoJul 13, 2026
Merged
Conversation
) The default sender identity (`preferredPrimaryId`) lived only in the browser-local `identity-storage` store and was never written to the synced settings, so the choice was lost on clearing site data / switching browsers and never appeared in exported settings. Persist it in the synced settings store, keyed **per account** (`preferredIdentityIds: Record<accountId, identityId>`), mirroring the existing per-account `allMailFolderIds`. Per-account keying is required because JMAP identity ids are account-scoped and would otherwise collide across accounts / the unified mailbox. This supersedes the earlier username-keyed fix that had landed on main: the username-keyed map, `loadIdentities()` fallback write, and the `applyPreferredIdentityOrdering` store action (plus its settings-store hook) are removed so a single account-keyed mechanism remains. - settings-store: `preferredIdentityIds` (accountId -> identityId) in state, defaults, export, import (non-record guard), rehydrate coercion, v6 migration. - auth-store: `applyPreferredIdentity(accountId?)` reorders the active account's identities once synced settings load, and performs the one-time migration of the pre-bulwarkmail#507 browser-local default into the synced map (keyed by accountId). Invoked from every `loadFromServer().finally()` (login / OAuth / SSO / switch / restore). `loadIdentities()` now only applies the local fallback ordering. - identity-manager-modal: the star action writes the choice by `activeAccountId`. - identity-store: `preferredPrimaryId` kept as a local (sync-off) fallback. - tests: per-account independence, export/import round-trip, import guard, and applyPreferredIdentity reorder / active-account gating / local-default migration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The default sender identity (
preferredPrimaryId) lived only in the browser-localidentity-storagestore and was never written to the synced settings, so the choice was lost on clearing site data / switching browsers and never appeared in exported settings.Persist it in the synced settings store, keyed per account (
preferredIdentityIds: Record<accountId, identityId>), mirroring the existing per-accountallMailFolderIds. Per-account keying is required because JMAP identity ids are account-scoped and would otherwise collide across accounts / the unified mailbox.This supersedes the earlier username-keyed fix that had landed on main: the username-keyed map,
loadIdentities()fallback write, and theapplyPreferredIdentityOrderingstore action (plus its settings-store hook) are removed so a single account-keyed mechanism remains.Changes
settings-store:
preferredIdentityIds(accountId -> identityId) in state, defaults, export, import (non-record guard), rehydrate coercion, v6 migration.auth-store:
applyPreferredIdentity(accountId?)reorders the active account's identities once synced settings load, and performs the one-time migration of the pre-[Bug]: Default identity (preferredPrimaryId) persists only in browser localStorage, not synced settings — lost on a new browser / after clearing site data #507 browser-local default into the synced map (keyed by accountId). Invoked from everyloadFromServer().finally()(login / OAuth / SSO / switch / restore).loadIdentities()now only applies the local fallback ordering.identity-manager-modal: the star action writes the choice by
activeAccountId.identity-store:
preferredPrimaryIdkept as a local (sync-off) fallback.tests: per-account independence, export/import round-trip, import guard, and applyPreferredIdentity reorder / active-account gating / local-default migration.
Related Issues
Closes #507
Type of Change
Checklist
npm run typecheck && npm run lintand there are no errorsnpm run build)locales/) if my changes affect user-facing textScreenshots / Demo
Notes for Reviewers