account-state

Documents Account state objects and LocalCache event store patterns in Amethyst.

1.6k|222|Updated Jan 11, 2023
One-click install
npx skills add https://github.com/vitorpamplona/amethyst --skill account-state
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: account-state
Source: https://github.com/vitorpamplona/amethyst/tree/main/.claude/skills/account-state
Command: npx skills add https://github.com/vitorpamplona/amethyst --skill account-state

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Amethyst's client state is spread across a singleton LocalCache event store and roughly 50 per-account state objects, making it hard for developers to know where to read user state, how relay events cascade into UI, and how to add a new account-scoped setting correctly.

Core Features & Use Cases

  • State Architecture Map: Explains the flow from relay frames through LocalCache insertion to Account StateFlows and Compose rendering.
  • State Object Catalog: Documents each Account property (kind3FollowList, nip65RelayList, muteList, bookmarkState, and more) with its backing Nostr kind and package location.
  • New Setting Recipe: Provides a step-by-step pattern for adding a new account-scoped NIP-based setting with pinned addressable notes, decryption caches, and signed mutation helpers.
  • Use Case: When adding a new NIP-51 list feature, follow the recipe to create an XState class modeled on MuteListState, wire it into Account.kt, and expose a StateFlow the UI collects.

Quick Start

Ask the assistant to explain how to add a new account-scoped encrypted list setting to Amethyst using the account-state patterns.

Frequently Asked Questions about account-state

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new account-scoped setting in Amethyst?

Create an XState class under model/nipXX modeled on MuteListState or BookmarkListState, pin the addressable note with cache.getOrCreateAddressableNote, expose a StateFlow via stateIn, and instantiate it in Account.kt. Mutation helpers build and sign the updated event, which the caller publishes.

When should I read from LocalCache versus an Account StateFlow?

Use LocalCache.getOrCreateNote when rendering a specific note or user by id. Use account.<feature>.flow when rendering user-specific state like follows, mutes, or relay lists. For feeds, use a FeedFilter with FeedViewModel instead of scanning LocalCache.

How does LocalCache store Nostr events in Amethyst?

LocalCache is a singleton holding LargeCache maps of notes, users, and addressables. Incoming relay events are parsed into typed Event subclasses, inserted via insertOrUpdateNote, and indexed by hashtag, address, and deletion status.

Does switching accounts clear the LocalCache in Amethyst?

No, LocalCache is a process-global singleton shared across accounts. Switching accounts does not wipe it; the new Account re-derives its StateFlows from the same underlying cache.

Why might a previously loaded Note disappear in Amethyst?

MemoryTrimmingService evicts least-recently-used notes and users from LocalCache under Android memory pressure. Previously returned Note references remain usable but detached, so do not assume a seen note stays resident.