feat(settings): reorder accounts by drag in settings #240

Merged
JMR-dev merged 19 commits from feat-164-reorder-accounts into main 2026-07-04 01:48:45 +00:00
19 Commits
Author SHA1 Message Date
Jason Ross 52636fd459 Merge main into feat-164-reorder-accounts 2026-07-03 20:31:00 -05:00
JMR-devandClaude Opus 4.8 64d89d1e2a fix(accounts): break AccountDao sortOrder ties by email
AccountDaoTest (added by #270's coverage lane) asserts email ordering,
but AccountDao.observeAll()/getAll() now order by the user-defined
sortOrder (#164) with no tiebreaker. Two accounts inserted via plain
upsert() both land on the default sortOrder (0), so they came back in
rowid/insertion order instead — failing the test deterministically on
CI (API 30 & 31): expected [ada, zed], got [zed, ada].

Add `email` as a secondary ORDER BY key. Real accounts always get
distinct sortOrders via insertAtEnd()/reorder(), so drag order is
untouched; only equal-sortOrder rows now fall back to a stable,
deterministic email order. This also matches the "rank by email"
convention already used to seed sortOrder in ACCOUNT_MIGRATION_1_2 and
AccountDataMigrator.copyAccountTables, so the existing coverage test
passes unchanged. No schema/migration change is needed since this
only edits a @Query string, not the entity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 20:24:25 -05:00
Jason Ross fa0c7c48c8 Merge main into feat-164-reorder-accounts 2026-07-03 20:01:32 -05:00
Jason Ross 1ed94f9ea0 Merge main into feat-164-reorder-accounts 2026-07-03 19:47:41 -05:00
JMR-devandClaude Opus 4.8 53f600369b fix(test): stub the new insertAtEnd DAO call in AccountRepositoryImplTest
The #164 reorder-accounts feature switched addImapAccount/addOutlookAccount from accountDao.upsert(...) to accountDao.insertAtEnd(...) (a @Transaction default method that stamps sortOrder before delegating to upsert), but the test's mocks/verifies still targeted upsert directly. Since MockK doesn't invoke a mocked interface's default method body, the unstubbed insertAtEnd call threw MockKException. Updated the stub/verify pairs in both add-account happy-path tests and the exactly-0 verifies in both failure-path tests to reference insertAtEnd.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 18:45:45 -05:00
Jason Ross 5705e0e7f8 Merge main into feat-164-reorder-accounts 2026-07-03 18:29:36 -05:00
Jason Ross 579d4864b9 Merge main into feat-164-reorder-accounts 2026-07-03 17:38:55 -05:00
Jason Ross 358dcc788e Merge main into feat-164-reorder-accounts 2026-07-03 17:24:58 -05:00
Jason Ross dad3345ce0 Merge main into feat-164-reorder-accounts 2026-07-03 17:11:11 -05:00
Jason Ross e7158f344d Merge main into feat-164-reorder-accounts 2026-07-03 16:49:26 -05:00
Jason Ross 91e267bb44 Merge main into feat-164-reorder-accounts 2026-07-03 16:17:06 -05:00
Jason Ross 3fedc854de Merge main into feat-164-reorder-accounts 2026-07-03 16:09:16 -05:00
Jason Ross cc77611d43 Merge main into feat-164-reorder-accounts 2026-07-03 14:53:30 -05:00
Jason Ross 02a0082c7f Merge main into feat-164-reorder-accounts 2026-07-03 14:48:12 -05:00
Jason Ross d3f8136f12 Merge main into feat-164-reorder-accounts 2026-07-03 14:10:09 -05:00
Jason Ross 4a3a360471 Merge main into feat-164-reorder-accounts 2026-07-03 13:15:27 -05:00
Jason Ross f10129c4c6 Merge main into feat-164-reorder-accounts 2026-07-03 12:55:51 -05:00
Jason Ross c5dd42b94b Merge main into feat-164-reorder-accounts 2026-07-03 12:43:06 -05:00
JMR-devandClaude Opus 4.8 9a69d175a8 feat(settings): reorder accounts by drag in settings
Give accounts a user-controlled order (issue #164). Every surface that
lists accounts -- the Settings list, the drawer account switcher, and the
compose account picker -- reads the same `ORDER BY sortOrder` query, so a
reorder in Settings is honored app-wide. In Settings a row can be
long-pressed and dragged to a new position; the order persists and
survives restart.

Data layer:
- AccountEntity gains `sortOrder` (@ColumnInfo defaultValue "0"); AccountDao
  orders by it and adds insertAtEnd / reorder / nextSortOrder / setSortOrder,
  the mutations wrapped in transactions.
- New accounts are appended (current max + 1) via insertAtEnd.

Migration (AccountDatabase v1 -> v2):
- ACCOUNT_MIGRATION_1_2 adds the column and backfills existing accounts by
  their previous alphabetical (email) rank, so the already-shown order does
  not shuffle on upgrade. Registered in AccountDatabaseModule; 2.json is
  exported and AccountMigrationTest replays and validates it.
- AccountDataMigrator (the pre-#111 cache->account-db move) creates the
  v2-shaped table and applies the same email-rank backfill, since
  ACCOUNT_MIGRATION_1_2 does not run for that path.

UI:
- AccountReorderList drives long-press drag over a plain Column (no nested
  lazy list inside the scrolling settings column, no extra dependency); the
  pure reorder-index maths (commitDrag) is unit-tested.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 12:22:16 -05:00