relay-client
БесплатноБез исполняемых скриптовНе проверенCompose-scoped relay subscriptions in commons/relayClient: observeUser*/EventFinder, FilterAssemblers, EOSE managers, ComposeSubscriptionManager. Use when a…
от vitorpamplona★ 1 630 звёзд на GitHubОб этом скилле
Relay client: screen-scoped subscriptions
How a composable gets events from relays only while it is on screen. Headless code (amy,
geode, tests, one-shot fetches) does not use this layer: it uses the INostrClient
extensions — see AGENTS.md › Feature Workflow ("Relay client ops already exist").
Where it lives
commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/— the headless half: one package per feature (chess/,communities/,home/,thread/,user/,event/, …) holding query states, filter assemblers and sub-assemblers;composeSubscriptionManagers/,eoseManagers/,subscriptions/(ExplainedFilter,SubPurpose),assemblers/(shared ones:FeedMetadataCoordinator,CashuMintDirectoryFilterAssembler,ContactCardFilters.kt),oneshot/,paging/,preload/.reqCommand/RelaySubscriptionsCoordinator.kt— owns one instance of every assembler (account,home,userFinder,eventFinder,chess,community, …). Screens reach it asaccountViewModel.dataSources()(BaseAccountViewModel.dataSources).commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/— the@Composableentry points, same package names:observeUser*,EventFinderFilterAssemblerSubscription,KeyDataSourceSubscription,LifecycleAwareKeyDataSourceSubscription, and per-feature*FilterAssemblerSubscriptions.
First choice: observeUser* and EventFinder
Before writing any assembler, check whether these already load what you need:
- Users (
commonsUI/.../relayClient/user/UserMetadataObservers.kt):observeUserInfo,observeUserPicture,observeUserBanner,observeUserAboutMe,observeUserName(user)each openUserFinderFilterAssemblerSubscription(user)and return aState. Metadata, relay lists, reports and contact cards load for on-screen users only, batched into one REQ per relay for the whole visible set. ALazyColumncomposes only the visible window, so this is "load what's on screen" for free. - Notes (
commonsUI/.../relayClient/event/EventFinderFilterAssemblerSubscription.kt):EventFinderFilterAssemblerSubscription(note)loads the note's reactions, zaps, reposts and replies while composed; the observers inevent/EventObservers.kt/AccountEventObservers.ktsit on top of it. - Both read
LocalUserFinder,LocalUserFinderAccountandLocalEventFinder, provided once incommonsUI/.../ui/app/AmethystApp.ktfromdataSources(). Their defaults areerror(...), so they must never be reached from a composition with no relay client (e.g. the Android:nappletprocess).
Don't hand-roll "load metadata for this list". FeedMetadataCoordinator and
MetadataPreloader (assemblers/, preload/) still exist but have no production caller;
prefer the observers.
The building blocks
// composeSubscriptionManagers/ComposeSubscriptionManager.kt
interface Subscribable<T> {
fun subscribe(query: T?) // called on main: keep it fast
fun unsubscribe(query: T?)
fun subscribe(query: List<T>)
fun unsubscribe(query: List<T>)
}
abstract class ComposeSubscriptionManager<T> : ComposeSubscriptionManagerControls, Subscribable<T>
// keeps the live query states; allKeys() snapshots them; each change calls invalidateKeys()
interface ComposeSubscriptionManagerControls { fun invalidateKeys(); fun invalidateFilters(); fun destroy() }
MutableComposeSubscriptionManager<T : MutableQueryState> is the variant for query states
that change over time (it collects their flow).
A filter assembler is a ComposeSubscriptionManager that groups sub-assemblers; each
sub-assembler is an EOSE manager that turns the current keys into relay filters. They are
not pure: they own subscriptions on the INostrClient and per-relay EOSE cursors. Real shape
(chess/ChessGameFilterAssembler.kt):
class ChessGameFilterAssembler(cache: ICacheProvider, client: INostrClient) : ComposeSubscriptionManager<ChessGameQueryState>() {
val group = listOf(ChessGameSubAssembler(cache, client, ::allKeys))
override fun invalidateKeys() = invalidateFilters()
override fun invalidateFilters() = group.forEach { it.invalidateFilters() }
override fun destroy() = group.forEach { it.destroy() }
}
EOSE managers (eoseManagers/, all on BaseEoseManager(client, allKeys, sampleTime = 500),
which batches invalidations): SingleSubEoseManager (one REQ for all keys), PerUserEoseManager,
PerUniqueIdEoseManager, PerUserAndFollowListEoseManager, SingleSubNoEoseCacheEoseManager,
AccountScopedSingleSubNoEoseCacheEoseManager. Pick by how the REQs are split. The EOSE cursors
never live in the manager: they live on the object that holds the notes (cursorHoldersOf(key):
a feed, a Channel, a User, a Note's children, the Account, or the key itself via
KeyHeldCursors). A key that names no holder is asked from scratch, and `CursorHolderCoverageTest
Установить relay-client в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл relay-client?
Compose-scoped relay subscriptions in commons/relayClient: observeUser*/EventFinder, FilterAssemblers, EOSE managers, ComposeSubscriptionManager. Use when a screen must load events from relays while visible.
Как установить скилл relay-client?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл relay-client запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic