Repository navigation
feat: pin conversations like Messages on iOS and macOS - #15
Merged
Merged
Conversation
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
Pin up to nine bots or group chats, like in Messages, on iOS and macOS. Pins are saved on the account through crumble-project/bot#144, so both apps and the web show the same pins in the same order, and a change on one reaches the others' open apps within about two seconds.
PinnedConversationsholds the pin rules as a pure value over orderedagent:<id>/group:<id>keys (limit, pin, unpin, move, split), and every change drops keys for conversations that don't exist.PinBoardholds the account's pins: a change shows right away, writes run one at a time with only the newest waiting, a failed write rolls back, and an incomingpinsevent is ignored while a write is pending. Nothing can change before the account's pins are read; a server too old for pins never reports any, so pinning stays unavailable there.APIClientgainsaccountPins()andsetAccountPins(_:session:), andactivityEvents(onEvent:onPins:)delivers the newpinsSSE event. The contract is regenerated from the bot PR.Some choices that look odd at first:
Listdoesn't deliver system drops to views in its rows or headers, so the drag is a long press followed by a drag gesture. In a row, all pins would share one context menu, so they live in the list's header instead. A header shows no context menu, so holding a pin opens a small dialog. Rows open with a tap gesture rather than aButton, which loses its tap to the drag. Rows drag from their portrait only, because a drag gesture on the whole row blocks the swipe actions..contextMenudoesn't report when it opens.Why
There was no way to keep a few conversations at hand, and pins kept on one device wouldn't match the other apps.
Evidence
swift testpasses, 344 tests. New tests cover the pin rules,PinBoard(loading, a server without pins, rollback after a failed write, one write at a time ending on the newest, ignoring events during a write, refusing a change before load, reset), and the parser deliveringpinsseparately fromactivity.swift buildandswift testpass, 119 tests.ios/scripts/build.shsucceeds. The iOS unit tests were not run: they run on a physical iPhone here, and signing failed with no Xcode account for team ZMF32TXKBT.update-usershowed in the app within about two seconds.Risk and rollback
Reversibility: Reversible. Pins live on the account, so reverting only removes the UI.
Blast radius: apfelkern's shared SSE parser (its
dispatchis split intodispatchandvalidate, and gainsfeedEvent), the iOS conversation list and rows, and the macOS sidebar. Merge after crumble-project/bot#144, since the contract and thepinsevent come from it.Button, so they don't flash on press.