From dba6f4575d31617a13847071a1317b0e961670a1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 08:48:37 -0500 Subject: [PATCH 1/7] Actually do include a Goose recipe.yaml --- recipe.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 recipe.yaml diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 0000000..e7311bc --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,32 @@ +version: 1.0.0 +title: Nostr Client Development +description: A recipe for building Nostr client applications +instructions: Create a Nostr client application according to the user's needs. +extensions: + - type: builtin + name: developer + display_name: Developer Tools + timeout: 300 + bundled: true + - type: stdio + name: nostr + cmd: npx + args: + - -y + - xjsr + - "@nostrbook/mcp" + envs: {} + timeout: 20 + description: null + bundled: null + - type: stdio + name: fetch + cmd: uvx + args: + - mcp-server-fetch + envs: {} + timeout: 20 + description: null + bundled: null +author: + contact: Alex Gleason From 101ee6333f1fe1207b24a141f685d2b064877d8a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 10:45:38 -0500 Subject: [PATCH 2/7] Slight instructions wording --- recipe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe.yaml b/recipe.yaml index e7311bc..9529871 100644 --- a/recipe.yaml +++ b/recipe.yaml @@ -1,7 +1,7 @@ version: 1.0.0 title: Nostr Client Development description: A recipe for building Nostr client applications -instructions: Create a Nostr client application according to the user's needs. +instructions: Create a Nostr client application according to the user's request. extensions: - type: builtin name: developer From cc2c89af3657e9657834a1a37c7a5e70b986c44c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 13:38:27 -0500 Subject: [PATCH 3/7] vite: use "node:path" import --- vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index b3de935..c76ef9a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; -import path from "path"; +import path from "node:path"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ From e24d07348d1462978e3cfcbf5a0f14349142152b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 13:38:57 -0500 Subject: [PATCH 4/7] vite: remove unused variable --- vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index c76ef9a..6dafad4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,7 +3,7 @@ import react from "@vitejs/plugin-react-swc"; import path from "node:path"; // https://vitejs.dev/config/ -export default defineConfig(({ mode }) => ({ +export default defineConfig(() => ({ server: { host: "::", port: 8080, From 646508aee8dc3bda135481529c82d652e22f7acd Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 14:25:55 -0500 Subject: [PATCH 5/7] Upgrade Nostrify --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index e85fe66..f4a69ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "dependencies": { "@hookform/resolvers": "^3.9.0", - "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.43.0", + "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.44.0", "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.0", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", @@ -552,9 +552,9 @@ }, "node_modules/@nostrify/nostrify": { "name": "@jsr/nostrify__nostrify", - "version": "0.43.0", - "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.43.0.tgz", - "integrity": "sha512-rl4jDvxadeCjLsp78lpu8TtuQMiR80alTj4TF33puJgNlbJn0xW6pYWpkw6WOgsgjAvUeytMm3FvdFEnibr+iQ==", + "version": "0.44.0", + "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.44.0.tgz", + "integrity": "sha512-xkN00DJadsTZjhV7D3iQfU6NG9FCzZ/8nljzty5+BTeOyy/nNMLJo3vTrs/IG0dbutJrVn+g/fOjQ5WTW9J4kw==", "dependencies": { "@jsr/nostrify__types": "^0.36.0", "@jsr/scure__base": "^1.2.4", diff --git a/package.json b/package.json index 7bbafbd..a5483c0 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@hookform/resolvers": "^3.9.0", - "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.43.0", + "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.44.0", "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.0", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", From 99970309e208439a6867eebab89b6bdd2d94d232 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 15:06:19 -0500 Subject: [PATCH 6/7] Bump @nostrify/react --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index f4a69ed..0cfd03f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "@hookform/resolvers": "^3.9.0", "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.44.0", - "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.0", + "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.1", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-aspect-ratio": "^1.1.0", @@ -414,9 +414,9 @@ } }, "node_modules/@jsr/nostrify__nostrify": { - "version": "0.43.0", - "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.43.0.tgz", - "integrity": "sha512-rl4jDvxadeCjLsp78lpu8TtuQMiR80alTj4TF33puJgNlbJn0xW6pYWpkw6WOgsgjAvUeytMm3FvdFEnibr+iQ==", + "version": "0.44.0", + "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.44.0.tgz", + "integrity": "sha512-xkN00DJadsTZjhV7D3iQfU6NG9FCzZ/8nljzty5+BTeOyy/nNMLJo3vTrs/IG0dbutJrVn+g/fOjQ5WTW9J4kw==", "dependencies": { "@jsr/nostrify__types": "^0.36.0", "@jsr/scure__base": "^1.2.4", @@ -568,11 +568,11 @@ }, "node_modules/@nostrify/react": { "name": "@jsr/nostrify__react", - "version": "0.2.0", - "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__react/0.2.0.tgz", - "integrity": "sha512-zV3sMK0oKuwhzazr8C8cnyr6oemYVUoJ63Ik77MeANudto9EUPw8Hp/FtnMX4UDBjr8pU/JXxbEqilCz9CxHzA==", + "version": "0.2.1", + "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__react/0.2.1.tgz", + "integrity": "sha512-raKZLgyL07Mb+dtg+aPD8i3eWYMqyv/ko9MXliOvbAX1Ki5o4cBorjsGShT0LvOOgP+2l4e+ZMpl2mceVRjILQ==", "dependencies": { - "@jsr/nostrify__nostrify": "^0.43.0", + "@jsr/nostrify__nostrify": "^0.44.0", "nostr-tools": "^2.10.4", "react": "^18.0.0" } diff --git a/package.json b/package.json index a5483c0..00cbb73 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "dependencies": { "@hookform/resolvers": "^3.9.0", "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.44.0", - "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.0", + "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.1", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-aspect-ratio": "^1.1.0", From 7d81db739c2ca4b8630aae517ba510c5c943ccff Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Apr 2025 15:13:17 -0500 Subject: [PATCH 7/7] Add AbortSignal's to things --- CONTEXT.md | 5 +++-- src/hooks/useAuthor.ts | 5 +++-- src/hooks/useLoggedInAccounts.ts | 18 ++++++------------ src/hooks/useNostrPublish.ts | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/CONTEXT.md b/CONTEXT.md index 03acefb..3ad6344 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -106,8 +106,9 @@ function usePosts() { return useQuery({ queryKey: ['posts'], - queryFn: async () => { - const events = await nostr.query([{ kinds: [1], limit: 20 }]); + queryFn: async (c) => { + const signal = AbortSignal.any([c.signal, AbortSignal.timeout(1500)]); + const events = await nostr.query([{ kinds: [1], limit: 20 }], { signal }); return events; // these events could be transformed into another format }, }); diff --git a/src/hooks/useAuthor.ts b/src/hooks/useAuthor.ts index 1d85e7a..7bd9b98 100644 --- a/src/hooks/useAuthor.ts +++ b/src/hooks/useAuthor.ts @@ -14,11 +14,11 @@ export function useAuthor(pubkey: string | undefined) { const [event] = await nostr.query( [{ kinds: [0], authors: [pubkey!], limit: 1 }], - { signal: AbortSignal.any([signal, AbortSignal.timeout(500)]) }, + { signal: AbortSignal.any([signal, AbortSignal.timeout(1500)]) }, ); if (!event) { - return {}; + throw new Error('No event found'); } try { @@ -28,5 +28,6 @@ export function useAuthor(pubkey: string | undefined) { return { event }; } }, + retry: 3, }); } diff --git a/src/hooks/useLoggedInAccounts.ts b/src/hooks/useLoggedInAccounts.ts index f3f9e8f..bffdbab 100644 --- a/src/hooks/useLoggedInAccounts.ts +++ b/src/hooks/useLoggedInAccounts.ts @@ -17,17 +17,10 @@ export function useLoggedInAccounts() { const { data: authors = [] } = useQuery({ queryKey: ['logins', logins.map((l) => l.id).join(';')], queryFn: async ({ signal }) => { - let events: NostrEvent[] = []; - - try { - events = await nostr.query( - [{ kinds: [0], authors: logins.map((l) => l.pubkey) }], - { signal: AbortSignal.any([signal, AbortSignal.timeout(500)]) }, - ); - } catch (error) { - console.error('Error fetching accounts:', error); - return []; - } + const events = await nostr.query( + [{ kinds: [0], authors: logins.map((l) => l.pubkey) }], + { signal: AbortSignal.any([signal, AbortSignal.timeout(1500)]) }, + ); return logins.map(({ id, pubkey }): Account => { const event = events.find((e) => e.pubkey === pubkey); @@ -38,7 +31,8 @@ export function useLoggedInAccounts() { return { id, pubkey, metadata: {}, event }; } }); - } + }, + retry: 3, }); // Current user is the first login diff --git a/src/hooks/useNostrPublish.ts b/src/hooks/useNostrPublish.ts index d36ada4..204b6bc 100644 --- a/src/hooks/useNostrPublish.ts +++ b/src/hooks/useNostrPublish.ts @@ -23,7 +23,7 @@ export function useNostrPublish() { tags: t.tags ?? [], created_at: t.created_at ?? Math.floor(Date.now() / 1000), }); - nostr.event(event); + await nostr.event(event, { signal: AbortSignal.timeout(5000) }); } else { throw new Error("User is not logged in"); }