Skip to content

feat: pin conversations like Messages on iOS and macOS - #15

Merged
cheetahbyte merged 6 commits into
mainfrom
feat/ios-pinned-conversations
Nov 16, 2026
Merged

cheetahbyte merged 6 commits into
mainfrom
feat/ios-pinned-conversations

Conversation

@lauragarden

Copy link
Copy Markdown
Contributor

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.

  • apfelkern: PinnedConversations holds the pin rules as a pure value over ordered agent:<id> / group:<id> keys (limit, pin, unpin, move, split), and every change drops keys for conversations that don't exist. PinBoard holds 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 incoming pins event 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. APIClient gains accountPins() and setAccountPins(_:session:), and activityEvents(onEvent:onPins:) delivers the new pins SSE event. The contract is regenerated from the bot PR.
  • iOS: pinned conversations sit above the list as large round portraits with names, three to a row. Pin with a leading swipe or the row's menu. Touch and hold a pin, then drag, to reorder; drag a row's portrait onto the pins to pin it; drag a pin into the list to unpin it. Holding a pin still shows Open and Unpin. An unread pin shows a blue dot, or its latest message in a bubble.
  • macOS: pins sit above the sidebar list as portraits with names, three to a row. The open chat's pin sits on an accent tile, as in Messages. Click to open, drop one pin on another to reorder, and right-click for Unpin, which outlines the pin the menu acts on. Rows pin from their context menu.
SwiftUI List
├─ iOS:   pins in a list header, custom long-press + drag gesture (ConversationDrag)
└─ macOS: pins in a safeAreaInset above the List, .draggable / .dropDestination,
          AppKit right-click menu (ContextMenuArea)

Some choices that look odd at first:

  • iOS drag: a List doesn'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 a Button, 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.
  • macOS: the pins aren't a list row, because right-clicking a row outlines the whole row. They also don't scroll with the conversations. The right-click menu is AppKit because SwiftUI's .contextMenu doesn't report when it opens.
  • Load guard: pins are written whole and cut down to conversations that exist, so both apps wait for the bot and group lists before allowing a change. Otherwise a write could drop pins the app hadn't loaded yet.

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

  • apfelkern: swift test passes, 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 delivering pins separately from activity.
  • macOS: swift build and swift test pass, 119 tests.
  • iOS: ios/scripts/build.sh succeeds. The iOS unit tests were not run: they run on a physical iPhone here, and signing failed with no Xcode account for team ZMF32TXKBT.
  • Simulator UI runs (temporary XCUITest, not committed) on an iPhone 17 with iOS 27.2 against a local server built from the bot branch:
    • Swipe to pin, the row menu, dragging a row's portrait onto the pins, reordering pins, unpinning by dragging into the list, the pin's Open / Unpin dialog, and tapping pins and rows to open chats all worked.
    • A pin change sent through update-user showed in the app within about two seconds.
    • After pinning and reordering in the app, the server's list matched the app's order.
  • macOS was looked at by hand against the same server: the portrait grid, the accent tile on the selected pin, and the right-click menu on a single pin.
  • Not checked: macOS Unpin taking effect and drag to reorder; live sync between the Mac and other clients; the per-pin right-click outline (added last); the unread bubble, which needs a bot that replies.

Risk and rollback

Reversibility: Reversible. Pins live on the account, so reverting only removes the UI.

Blast radius: apfelkern's shared SSE parser (its dispatch is split into dispatch and validate, and gains feedEvent), the iOS conversation list and rows, and the macOS sidebar. Merge after crumble-project/bot#144, since the contract and the pins event come from it.

  • iOS rows now open with a tap gesture rather than a Button, so they don't flash on press.
  • A group created before the first group list arrives counts as the list having loaded, so a pin change right then could drop pinned groups the app hasn't seen yet.
  • On macOS, the pins stay in place while the conversations scroll.

@lauragarden lauragarden self-assigned this Nov 15, 2026
@cheetahbyte
cheetahbyte merged commit 976d80b into main Nov 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants