diff --git a/AGENTS.md b/AGENTS.md index f1aa7e3b..0ff74656 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -170,6 +170,15 @@ src/ - Do not define svelte event handlers inline, instead name them and put them in the script section of templates - Avoid using `as`, except where necessary. Instead, annotate function parameters, and ensure upstream values are typed correctly. +**Human-First Simplicity (Jon Staab Style):** + +- Prefer direct, readable code over layered abstractions. +- Do not add indirection (extra helpers, wrappers, stores, or derived state) unless it removes real repeated complexity. +- Reuse existing Welshman and Flotilla primitives before introducing new utilities or dependencies. +- Favor linear control flow and explicit naming over clever patterns. +- Remove defensive checks that do not apply in this runtime model. +- When two approaches work, pick the one that feels more human and easier to maintain. + ## Common Tasks ### Adding a New Component diff --git a/src/app/util/title.ts b/src/app/util/title.ts index f69ee091..b39864eb 100644 --- a/src/app/util/title.ts +++ b/src/app/util/title.ts @@ -1,13 +1,7 @@ import {append, identity, uniq} from "@welshman/lib" -import {displayPubkey, getTagValue, type Filter, type TrustedEvent} from "@welshman/util" -import { - PLATFORM_NAME, - decodeRelay, - getEventsForUrl, - getRoom, - makeRoomId, - splitChatId, -} from "@app/core/state" +import {repository} from "@welshman/app" +import {displayPubkey, getTagValue} from "@welshman/util" +import {PLATFORM_NAME, decodeRelay, getRoom, makeRoomId, splitChatId} from "@app/core/state" const FALLBACK_APP_NAME = "Flotilla" @@ -69,10 +63,8 @@ const getRoomTitle = (params: RouteParams) => { return getRoom(makeRoomId(url, h))?.name || "Room" } -const getEventForTitle = (routeId: string, params: RouteParams): TrustedEvent | undefined => { - const relay = params.relay - - if (!relay || !eventRoutes.has(routeId)) { +const getEventForTitle = (routeId: string, params: RouteParams) => { + if (!eventRoutes.has(routeId)) { return } @@ -82,11 +74,7 @@ const getEventForTitle = (routeId: string, params: RouteParams): TrustedEvent | return } - const url = decodeRelay(relay) - const filters: Filter[] = [{ids: [eventId], limit: 1}] - const events = Array.from(getEventsForUrl(url, filters)) - - return events[0] + return repository.getEvent(eventId) } const getChatTitle = (chatId: string | undefined, pubkey: string | undefined) => { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 79b20506..9cd3be65 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -48,10 +48,6 @@ const {children} = $props() - const pageTitle = $derived.by(() => { - return getPageTitle({page: $page, pubkey: $pubkey}) - }) - const policies = [authPolicy, blockPolicy, trustPolicy, mostlyRestrictedPolicy] // Add stuff to window for convenience @@ -207,9 +203,7 @@ }) $effect(() => { - if (typeof document !== "undefined") { - document.title = pageTitle - } + document.title = getPageTitle({page: $page, pubkey: $pubkey}) })