From 7b7b24d41ae19907284083dcdeeed6826173194f Mon Sep 17 00:00:00 2001 From: Alejandro Date: Wed, 21 Jan 2026 23:11:25 +0100 Subject: [PATCH] feat: add client tag support to all event creation (#191) * feat: add client tag support to all event creation Implements a global settings system to control whether the Grimoire client tag should be included in all published events. This allows users to opt-in or opt-out of identifying their client in published events. Changes: - Created global settings service (src/services/settings.ts) with reactive BehaviorSubject for app-wide configuration - Created useSettings hook (src/hooks/useSettings.ts) for React components - Migrated PostViewer from local settings to global settings system - Added client tag support to: - Post publishing (PostViewer.tsx) - Spell publishing (publish-spell.ts) - Event deletion (delete-event.ts) - NIP-29 chat messages, reactions, join/leave, and group bookmarks (nip-29-adapter.ts) - Zap requests (create-zap-request.ts) The client tag setting defaults to enabled (true) for backward compatibility. Users can toggle this in the post composer settings dropdown. All event creation locations now check settingsManager.getSetting("includeClientTag") before adding the GRIMOIRE_CLIENT_TAG to event tags. * refactor: exclude client tags from NIP-29 and zap requests Remove client tag support from NIP-29 adapter events and zap requests as these events may be rejected by servers with large tags or have specific size constraints. Changes: - Removed client tag from NIP-29 chat messages (kind 9) - Removed client tag from NIP-29 reactions (kind 7) - Removed client tag from NIP-29 join/leave requests (kind 9021, 9022) - Removed client tag from NIP-29 group bookmarks (kind 10009) - Removed client tag from zap requests (kind 9734) Client tags remain enabled for: - Regular posts (kind 1) - Spell publishing (kind 777) - Event deletion (kind 5) This ensures maximum compatibility with relay servers and LNURL endpoints while still providing client identification for standard events. * feat: implement comprehensive namespaced settings system Redesigned the settings system with proper namespacing, type safety, validation, and migration support. This provides a solid foundation for all app configuration. Settings Structure: - post: Post composition settings (client tag, relay selection) - appearance: UI/theme settings (theme, compact mode, font size, animations) - relay: Relay configuration (fallback, discovery, outbox, timeouts) - privacy: Privacy settings (read receipts, content warnings, link warnings) - database: Caching settings (max events, cleanup, IndexedDB options) - notifications: Browser notifications preferences - developer: Debug and experimental features Key Features: - Fully typed with TypeScript interfaces for each namespace - Automatic validation with fallback to defaults for invalid data - Migration system from old flat structure to namespaced structure - Backwards compatible with old "grimoire-settings" localStorage key - Import/export functionality for settings backup/restore - Reactive updates via RxJS BehaviorSubject - Section-level and individual setting updates - Reset individual sections or all settings Changes: - Created comprehensive AppSettings interface with 7 namespaced sections - Implemented SettingsManager class with reactive updates and persistence - Updated useSettings hook to support namespaced API - Updated PostViewer, publish-spell, and delete-event to use new API (settingsManager.getSetting("post", "includeClientTag")) - Added extensive inline documentation for all settings Migration: - Automatically migrates old includeClientTag setting to post.includeClientTag - Moves data from "grimoire-settings" to "grimoire-settings-v2" key - Validates all loaded settings and fills in defaults for missing values This foundation will support future settings UI with tabbed interface. * feat: add comprehensive settings UI with Post and Appearance sections Created a minimal MVP settings system accessible via command palette and user menu. Settings are organized in a clean tabbed interface with two initial sections. UI Features: - SettingsViewer component with sidebar navigation - Post section: Toggle to include Grimoire client tag in published events - Appearance section: - Theme selector (light/dark/system) - Toggle to show/hide client tags in event UI ("via Grimoire" etc) Integration: - Added "settings" command to command palette - Added "Settings" option to user menu (before Support Grimoire) - Registered "settings" as new AppId in window system Display Logic: - BaseEventRenderer now honors settings.appearance.showClientTags - When disabled, "via Grimoire" and other client tags are hidden from events - Setting applies instantly across all event renderers Technical Details: - SettingsViewer uses existing UI components (Checkbox, Button, Label) - Leverages useSettings hook for reactive updates - Settings persist to localStorage via settingsManager - Simple button group for theme selection instead of dropdown - Clean two-column layout with icons for each section This provides a solid foundation for adding more settings sections later (relay config, privacy, database, notifications, developer options). * refactor: redesign settings UI with shadcn Tabs and cleaner layout Simplified the settings UI to be more minimal and follow Grimoire patterns: Changes: - Use shadcn Tabs component instead of custom sidebar navigation - Remove non-working theme selector (no theme system implemented yet) - Use regular