Accounts have no user-controlled order today: AccountDao (data/local/dao/AccountDao.kt)
queries SELECT * FROM accounts ORDER BY email for both observeAll() and getAll(), and AccountEntity (data/local/entity/AccountEntity.kt) has no ordering column. Every place that
lists multiple accounts consumes that same alphabetical order: the drawer's account switcher
(AccountSwitcher in ui/mailbox/FolderDrawer.kt), the unified-inbox account chips
(AccountFilterRow in ui/mailbox/MailboxScreen.kt, "the sliding buttons in the message
selection/home view" per the ticket), and SettingsScreen.kt's account list. This ticket adds an
explicit, user-editable order that all of these follow.
Scope
Add a sortOrder: Int column to AccountEntity, with a Room migration
(MIGRATION_17_18, following the established pattern in data/local/Migrations.kt — e.g. MIGRATION_16_17/MIGRATION_14_15: a nullable-or-defaulted column added via ALTER TABLE,
with the fresh-install schema in AccountDatabase.kt matching exactly so migrated and clean
installs validate identically). Export the updated schema under app/schemas and add a
migration test.
Assign sortOrder on account creation (append to the end — e.g. current max + 1) and change AccountDao.observeAll() / getAll() to ORDER BY sortOrder.
Add a DAO method to persist a new order (e.g. a batch update given an ordered list of ids).
Add drag-to-reorder UI for the account list in SettingsScreen.kt (no existing
reorderable-list component or dependency in this codebase — this is new UI work; a
long-press-and-drag LazyColumn reorder is the common Compose pattern, implemented with pointerInput/Modifier.offset rather than pulling in a new library, consistent with this
repo's preference for no unnecessary dependencies).
Confirm the new order propagates, with no additional per-surface logic needed, to:
The drawer's AccountSwitcher dropdown (FolderDrawer.kt) — consumes accounts: List<Account>
from the same repository query.
The unified-inbox AccountFilterRow chips (MailboxScreen.kt) — same.
SettingsScreen.kt's own account list.
Acceptance criteria
Reordering accounts in Settings persists across app restarts.
The new order is reflected, without further per-screen changes, in the drawer's account
switcher and the unified-inbox account filter chips.
A Room migration test covers MIGRATION_17_18; existing accounts get a stable initial order
(e.g. their current alphabetical order) on upgrade rather than an undefined one.
Related to #163 (default account) — see that ticket's note on whether "default" and "first in
this order" should be linked or independent concepts.
## Context
Accounts have no user-controlled order today: `AccountDao` (`data/local/dao/AccountDao.kt`)
queries `SELECT * FROM accounts ORDER BY email` for both `observeAll()` and `getAll()`, and
`AccountEntity` (`data/local/entity/AccountEntity.kt`) has no ordering column. Every place that
lists multiple accounts consumes that same alphabetical order: the drawer's account switcher
(`AccountSwitcher` in `ui/mailbox/FolderDrawer.kt`), the unified-inbox account chips
(`AccountFilterRow` in `ui/mailbox/MailboxScreen.kt`, "the sliding buttons in the message
selection/home view" per the ticket), and `SettingsScreen.kt`'s account list. This ticket adds an
explicit, user-editable order that all of these follow.
## Scope
- [ ] Add a `sortOrder: Int` column to `AccountEntity`, with a Room migration
(`MIGRATION_17_18`, following the established pattern in `data/local/Migrations.kt` — e.g.
`MIGRATION_16_17`/`MIGRATION_14_15`: a nullable-or-defaulted column added via `ALTER TABLE`,
with the fresh-install schema in `AccountDatabase.kt` matching exactly so migrated and clean
installs validate identically). Export the updated schema under `app/schemas` and add a
migration test.
- [ ] Assign `sortOrder` on account creation (append to the end — e.g. current max + 1) and change
`AccountDao.observeAll()` / `getAll()` to `ORDER BY sortOrder`.
- [ ] Add a DAO method to persist a new order (e.g. a batch update given an ordered list of ids).
- [ ] Add drag-to-reorder UI for the account list in `SettingsScreen.kt` (no existing
reorderable-list component or dependency in this codebase — this is new UI work; a
long-press-and-drag `LazyColumn` reorder is the common Compose pattern, implemented with
`pointerInput`/`Modifier.offset` rather than pulling in a new library, consistent with this
repo's preference for no unnecessary dependencies).
- [ ] Confirm the new order propagates, with no additional per-surface logic needed, to:
- The drawer's `AccountSwitcher` dropdown (`FolderDrawer.kt`) — consumes `accounts: List<Account>`
from the same repository query.
- The unified-inbox `AccountFilterRow` chips (`MailboxScreen.kt`) — same.
- `SettingsScreen.kt`'s own account list.
## Acceptance criteria
- Reordering accounts in Settings persists across app restarts.
- The new order is reflected, without further per-screen changes, in the drawer's account
switcher and the unified-inbox account filter chips.
- A Room migration test covers `MIGRATION_17_18`; existing accounts get a stable initial order
(e.g. their current alphabetical order) on upgrade rather than an undefined one.
## Relevant files
- `data/local/entity/AccountEntity.kt`, `data/local/dao/AccountDao.kt`,
`data/local/Migrations.kt`, `data/local/AccountDatabase.kt`, `app/schemas`,
`ui/settings/SettingsScreen.kt`, `ui/mailbox/FolderDrawer.kt`, `ui/mailbox/MailboxScreen.kt`.
## Dependencies
Related to #163 (default account) — see that ticket's note on whether "default" and "first in
this order" should be linked or independent concepts.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Context
Accounts have no user-controlled order today:
AccountDao(data/local/dao/AccountDao.kt)queries
SELECT * FROM accounts ORDER BY emailfor bothobserveAll()andgetAll(), andAccountEntity(data/local/entity/AccountEntity.kt) has no ordering column. Every place thatlists multiple accounts consumes that same alphabetical order: the drawer's account switcher
(
AccountSwitcherinui/mailbox/FolderDrawer.kt), the unified-inbox account chips(
AccountFilterRowinui/mailbox/MailboxScreen.kt, "the sliding buttons in the messageselection/home view" per the ticket), and
SettingsScreen.kt's account list. This ticket adds anexplicit, user-editable order that all of these follow.
Scope
sortOrder: Intcolumn toAccountEntity, with a Room migration(
MIGRATION_17_18, following the established pattern indata/local/Migrations.kt— e.g.MIGRATION_16_17/MIGRATION_14_15: a nullable-or-defaulted column added viaALTER TABLE,with the fresh-install schema in
AccountDatabase.ktmatching exactly so migrated and cleaninstalls validate identically). Export the updated schema under
app/schemasand add amigration test.
sortOrderon account creation (append to the end — e.g. current max + 1) and changeAccountDao.observeAll()/getAll()toORDER BY sortOrder.SettingsScreen.kt(no existingreorderable-list component or dependency in this codebase — this is new UI work; a
long-press-and-drag
LazyColumnreorder is the common Compose pattern, implemented withpointerInput/Modifier.offsetrather than pulling in a new library, consistent with thisrepo's preference for no unnecessary dependencies).
AccountSwitcherdropdown (FolderDrawer.kt) — consumesaccounts: List<Account>from the same repository query.
AccountFilterRowchips (MailboxScreen.kt) — same.SettingsScreen.kt's own account list.Acceptance criteria
switcher and the unified-inbox account filter chips.
MIGRATION_17_18; existing accounts get a stable initial order(e.g. their current alphabetical order) on upgrade rather than an undefined one.
Relevant files
data/local/entity/AccountEntity.kt,data/local/dao/AccountDao.kt,data/local/Migrations.kt,data/local/AccountDatabase.kt,app/schemas,ui/settings/SettingsScreen.kt,ui/mailbox/FolderDrawer.kt,ui/mailbox/MailboxScreen.kt.Dependencies
Related to #163 (default account) — see that ticket's note on whether "default" and "first in
this order" should be linked or independent concepts.