iOS: Settings lists the accounts kept, switching between them as the web does
MergedThis adds an Accounts list to Settings on iOS and lets you switch accounts from it. It reads each account's row with that account's own tokens, via the new restore(inUse: false), and keeps the rows 10 minutes. A switch flushes feedback, then unregisters push as the old account. It then restores the new account, restarts every tab, and .id(shell.starts) redraws the tab view. I read every changed file. Every symbol I checked exists (page, Push.signingOut, AccountSession.kept), and I didn't build it. The HUD vendor changes are covered by new tests.
I found nothing that must change. Two small things for you to check:
- In
use,restore(..., did:)marks the new account in use beforepush?.signingOut()runs. Unregistering still works, because Push keeps the old account's client. If the app dies between those two steps, the Keychain says the new account is in use while push is still registered as the old one. That window is short, and the nextstart()registers push as the account in use. - In
readAccounts, each row-read Task writesrowsandaccountsafter an await. If the accounts changed in the meantime, such as a sign-out of that account, the write can bring back a row for an account no longer kept until the nextlistAccounts.rows[account.did] = ...runs unconditionally, whileaccountsis only updated if the account is still listed. This is harmless for the display, butrowsmay keep a stale entry.
The vendor update goes through the repository's just vendor-hud path, as AGENTS.md asks.
Since my approval at 8d97bc5, the only change is in readAccounts. The Task now returns early if the account is no longer listed, so a signed-out account can't leave a stale rows entry. That answers the second point I raised last round. The first point, the short window in use, is unchanged and still harmless. I found nothing new.
5 passed, 2 skipped
- iOS: Settings lists the accounts kept, switching between them as the web does
- main
What changes
Settings lists every account kept on the device. Each row shows the account's picture, name and @handle, and the one in use has a tick, as next.grain.social and grain-ios show them. Names and pictures come from each account's own profile (
frame.account.picturein the app file), read with that account's own tokens and kept for 10 minutes, as the web shell does. The rows stay in the order the accounts were first kept: using one doesn't move it to the top. Until now, HUDKit'sAccountsdrew its children on iOS, so only the current account showed.Tapping another account switches to it, as the web does with a fresh page load. Anything already reported to feeds is sent as the previous account first. Push is unregistered as that account and registered as the new one, then every tab starts again:
LastTreeis cleared, the stacks, stories, sheets and badge are reset, and the tab view is drawn anew (Shell.starts). No screen, open form or scroll position from the previous account stays.Add account signs in to one more account. If the account is already kept, its tokens are replaced (HUDKit's
KeptAccounts.keep) rather than a second row being added. Sign out, and the sign-out at the end of Delete account, remove only the account in use, and the app moves to the account used before it.HUD 0e21d81 (vendored) makes three HUDKit changes.
ViewContext.accountsis now observed, so rows read after the screen draws appear as they arrive.AccountSession.restore(inUse: false)gives a session for a kept account without making it the one in use, so another account's row can be read with its own tokens. VoiceOver treats another account's row as a button. The vendor also brings in ab46d11, which only changes HUDKit'sResolvedCompose.Why
The iOS app already kept several accounts in the Keychain, and it already moved to another one when a session ended, but nothing let you see them or switch between them. The web (
@hud/shellSessions) and grain-ios both offer this.How it was checked
just ios-testin HUD, including new tests for the observed accounts and for reading a kept account's entry without using it.unregisterPushas the account leaving, thenregisterPushas the account in use. Every getProfile was made as the account it describes, including another account's row read while bob was in use (inUse: false).Shortcomings
{host: signOut}path as Sign out, which was checked.Review
Start at
Shell.useandShell.listAccounts/readAccounts, and the.id(shell.starts)on the tab view.