Repository navigation
feat: sync pinned conversations across apps - #144
Merged
Merged
Conversation
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
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
Pinned conversations are now saved on the account, so every client shows the same pins in the same order. The pinned list is a Better Auth user field next to
theme, and/v1/eventssends apinsevent to the account's open clients when it changes. The web sidebar gets a Pinned group.pinnedConversationsis an ordered list of up to nine uniqueagent:<id>orgroup:<id>keys.get-sessionreturns it, andupdate-usersaves the whole list. It's a"json"field, not"string[]", because SQLite storesstring[]as TEXT and Better Auth then logs a type mismatch on every start. Accounts from before the column existed hold NULL; an output transform reports that as[], so clients can tell "no pins yet" from "server too old for pins" (field missing).PinsEventis its own SSE event name (pins), not a newActivityEventmember, so existing clients that treat the union as closed ignore it. It isn't replayed; clients read the session when they connect.createAuthtakes anonPinsChangedhook. The server passes the tenant pool'sannouncePins, which forwards to a tenant only if it's already running, and the tenant uses the existing botsannounce.usePins(apps/web/lib/pins.ts) shows changes right away, saves one write at a time, and rolls back to the session's list on failure. It refuses changes until bots, groups, and the session's list have all loaded. The sidebar shows a Pinned group above the bots, a row menu with Pin and Unpin, and drag to reorder (native HTML drag and drop). Thepinsevent and a stream reconnect refresh the session.The Apple clients are in crumble-project/apple#15.
Why
Pins were only implemented on iOS and kept on the device, so they didn't match across the iPhone, the Mac, and the web.
Evidence
bun run checkpasses on the branch: lint, format, typecheck,openapi:check, and 1311 tests, 0 failing.[];update-usercallsonPinsChanged;/v1/eventssendsevent: pinsand not anactivityframe; with two signed-in users, only the one who changed pins receives the event.apps/web/lib/pins.dom.test.tsx): pin, unpin, move, dropping keys for missing conversations, refusing a tenth pin, refusing changes before bots and groups load or before the session's list loads, and rolling back after a failed write.update-userupdated the iOS app (feat: pin conversations like Messages on iOS and macOS apple#15) within about two seconds, and pinning and reordering on iOS left the server with the same order.Risk and rollback
Reversibility: Reversible. The new column stays in
auth.sqliteafter a revert, and nothing reads it then.Blast radius: Better Auth's user table and session response,
/v1/events, the generated OpenAPI contract (addsPinsEvent), and the web sidebar.user.update.afterhook, including theme changes; it then sends the unchanged pin list again, which clients apply idempotently.