feat: migrate community default to system settings

This commit is contained in:
Derek Ross committed 2025-12-10 18:51:40 -05:00
1 parent 7d58595f58
commit 0f8fe50e65
17 files changed
+172 -24

No files matched your search

+1
View File
@@ -137,6 +137,7 @@ const defaultConfig: AppConfig = {
fsPathTemplates: electronPaths.fsPathTemplates,
sentryDsn: import.meta.env.VITE_SENTRY_DSN || "",
sentryEnabled: true,
communityFollowPack: "nevent1qvzqqqr4xypzpyexz3t34l966ngh5xg7u2q788hthdqmj0av3lv8s2tz9t43zt6dqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsz9nhwden5te0wfjkccte9ehx7um5wghxyctwvsq3gamnwvaz7tmwdaehgu3wdau8gu3wv3jhvqgawaehxw309ahx7um5wgkhqatz9emk2mrvdaexgetj9ehx2aqpp4mhxue69uhkummn9ekx7mqpzemhxue69uhhyetvv9ujuurjd9kkzmpwdejhgqgwwaehxw309ahx7uewd3hkctcpz9mhxue69uhkummnw3ezuamfdejj7qghwaehxw309aex2mrp0yhxummnw3ezucnpdejz7qgmwaehxw309aex2mrp0yhxummnw3e8qmr9vfejucm0d5hsz8mhwden5te0dehhxarj94ex2mrp0yhxgetjv44hymmnwvhx6ef0qyt8wumn8ghj7mn0wd68yetvd96x2uewdaexwtcprfmhxue69uhhq7tjv9kkjepwve5kzar2v9nzucm0d5hszfthwden5te0dehhxarj94ex2mrp0yhxgetjv44hymmnwvhx6ef0d9hxymmc9uqzqq6casgsyhj2c29rjlcy3tu3devp3akg7j6zqr296met9gz98np3qkwsg5",
};
// Initialize filesystem adapter based on environment
+1
View File
@@ -50,6 +50,7 @@ const AppConfigSchema = z.object({
sentryDsn: z.string(),
sentryEnabled: z.boolean(),
systemPrompt: z.string(),
communityFollowPack: z.string(),
}) satisfies z.ZodType<AppConfig>;
export function AppProvider(props: AppProviderProps) {
+4
View File
@@ -40,6 +40,7 @@ describe('SentryProvider', () => {
fsPathTmp: '/tmp',
fsPathPlugins: '/plugins',
fsPathTemplates: '/templates',
communityFollowPack: '',
};
render(
@@ -77,6 +78,7 @@ describe('SentryProvider', () => {
fsPathTmp: '/tmp',
fsPathPlugins: '/plugins',
fsPathTemplates: '/templates',
communityFollowPack: '',
};
render(
@@ -115,6 +117,7 @@ describe('SentryProvider', () => {
fsPathTmp: '/tmp',
fsPathPlugins: '/plugins',
fsPathTemplates: '/templates',
communityFollowPack: '',
};
render(
@@ -156,6 +159,7 @@ describe('SentryProvider', () => {
fsPathTmp: '/tmp',
fsPathPlugins: '/plugins',
fsPathTemplates: '/templates',
communityFollowPack: '',
};
render(
+2
View File
@@ -57,6 +57,8 @@ export interface AppConfig {
sentryEnabled: boolean;
/** System prompt EJS template */
systemPrompt?: string;
/** Nostr follow pack naddr for community events (e.g., "naddr1...") */
communityFollowPack: string;
}
export interface AppContextType {
+85 -23
View File
@@ -1,14 +1,8 @@
import { type NostrEvent, NRelay1 } from '@nostrify/nostrify';
import { useNostr } from '@nostrify/react';
import { useQuery } from '@tanstack/react-query';
// Soapbox Follow Pack naddr for team members
// naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m
const SOAPBOX_FOLLOW_PACK = {
pubkey: '932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d',
kind: 39089,
identifier: 'k4p5w0n22suf',
};
import { nip19 } from 'nostr-tools';
import { useAppContext } from '@/hooks/useAppContext';
// ShakespeareGitCommits bot npub
// npub1msc06u2v3y3z2awdxlc7k2tnjlc78xg8awvha5rsaphd8py7ussqd0phxu
@@ -56,25 +50,91 @@ function hasShakespeareInTitle(event: NostrEvent): boolean {
}
/**
* Hook to fetch the Soapbox Follow Pack to get team member pubkeys
* Decoded follow pack data - either from naddr or nevent
*/
export function useSoapboxFollowPack() {
type FollowPackData = {
/** For naddr: query by author, kind, and d-tag */
type: 'naddr';
pubkey: string;
kind: number;
identifier: string;
} | {
/** For nevent: query by event id */
type: 'nevent';
id: string;
relays?: string[];
};
/**
* Decode a follow pack identifier (naddr or nevent) to get its components
*/
function decodeFollowPackIdentifier(identifier: string): FollowPackData | null {
try {
const decoded = nip19.decode(identifier);
if (decoded.type === 'naddr') {
return {
type: 'naddr',
pubkey: decoded.data.pubkey,
kind: decoded.data.kind,
identifier: decoded.data.identifier,
};
}
if (decoded.type === 'nevent') {
return {
type: 'nevent',
id: decoded.data.id,
relays: decoded.data.relays,
};
}
} catch {
// Invalid identifier
}
return null;
}
/**
* Hook to fetch the community follow pack to get team member pubkeys
* Uses the communityFollowPack setting from the app config
* Supports both naddr and nevent identifiers
*/
export function useCommunityFollowPack() {
const { nostr } = useNostr();
const { config } = useAppContext();
const followPackData = decodeFollowPackIdentifier(config.communityFollowPack);
return useQuery<string[]>({
queryKey: ['soapbox-follow-pack'],
queryKey: ['community-follow-pack', config.communityFollowPack],
queryFn: async (c) => {
if (!followPackData) {
return [];
}
const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
const events = await nostr.query(
[{
kinds: [SOAPBOX_FOLLOW_PACK.kind],
authors: [SOAPBOX_FOLLOW_PACK.pubkey],
'#d': [SOAPBOX_FOLLOW_PACK.identifier],
limit: 1,
}],
{ signal }
);
let events: NostrEvent[];
if (followPackData.type === 'naddr') {
// Query by author, kind, and d-tag for addressable events
events = await nostr.query(
[{
kinds: [followPackData.kind],
authors: [followPackData.pubkey],
'#d': [followPackData.identifier],
limit: 1,
}],
{ signal }
);
} else {
// Query by event id for nevent
events = await nostr.query(
[{
ids: [followPackData.id],
limit: 1,
}],
{ signal }
);
}
if (events.length === 0) {
return [];
@@ -88,20 +148,22 @@ export function useSoapboxFollowPack() {
return pubkeys;
},
staleTime: 300000, // 5 minutes
enabled: !!followPackData,
});
}
/**
* Hook to fetch calendar events from Soapbox Follow Pack members (NIP-52)
* Hook to fetch calendar events from community follow pack members (NIP-52)
* Filtered to only show events with "shakespeare" in the title
* Fetches both date-based (31922) and time-based (31923) calendar events
*/
export function useCommunityEvents(limit = 10) {
const { nostr } = useNostr();
const { data: teamPubkeys } = useSoapboxFollowPack();
const { config } = useAppContext();
const { data: teamPubkeys } = useCommunityFollowPack();
return useQuery<NostrEvent[]>({
queryKey: ['community-events', limit, teamPubkeys],
queryKey: ['community-events', limit, config.communityFollowPack, teamPubkeys],
queryFn: async (c) => {
if (!teamPubkeys || teamPubkeys.length === 0) {
return [];
+2
View File
@@ -75,6 +75,7 @@ describe('useGenerateProjectInfo', () => {
fsPathTemplates: '/templates',
sentryDsn: '',
sentryEnabled: false,
communityFollowPack: '',
};
mockUseAppContext.mockReturnValue({
config,
@@ -228,6 +229,7 @@ describe('useGenerateProjectInfo', () => {
fsPathTemplates: '/templates',
sentryDsn: '',
sentryEnabled: false,
communityFollowPack: '',
};
mockUseAppContext.mockReturnValue({
config,
+1
View File
@@ -52,6 +52,7 @@ function createWrapper(corsProxy: string) {
fsPathTemplates: '/templates',
sentryDsn: '',
sentryEnabled: false,
communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m',
};
return createElement(
+1
View File
@@ -56,6 +56,7 @@ const testConfig: AppConfig = {
fsPathTemplates: '/templates',
sentryDsn: '',
sentryEnabled: false,
communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m',
};
describe('SessionManager', () => {
+1
View File
@@ -43,6 +43,7 @@ const testConfig: AppConfig = {
fsPathTemplates: '/templates',
sentryDsn: '',
sentryEnabled: false,
communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m',
};
describe('makeSystemPrompt', () => {
+2
View File
@@ -51,6 +51,8 @@
"showcaseEnabledDescription": "Display the app showcase section on the home page",
"showcaseModerator": "Showcase Moderator",
"showcaseModeratorDescription": "Nostr public key (npub) of the user who can moderate showcase submissions",
"communityFollowPack": "Community",
"communityFollowPackDescription": "Nostr event of the follow pack used for the Community Events section of the Community page",
"filesystemPaths": "Filesystem Paths",
"projectsDirectory": "Projects Directory",
"projectsDirectoryDescription": "Filesystem path where projects are stored",
+2
View File
@@ -51,6 +51,8 @@
"showcaseEnabledDescription": "Nuna sashen nuni na aikace-aikace a shafin gida",
"showcaseModerator": "Mai Kula da Nuni",
"showcaseModeratorDescription": "Maɓallin jama'a na Nostr (npub) na mai amfani wanda zai iya kula da ƙaddamarwar nuni",
"communityFollowPack": "Al'umma",
"communityFollowPackDescription": "Taron Nostr na fakitin bi da ake amfani da shi don sashen Ayyukan Al'umma a shafin Al'umma",
"filesystemPaths": "Hanyoyin Tsarin Fayil",
"projectsDirectory": "Kundin Ayyuka",
"projectsDirectoryDescription": "Hanyar tsarin fayil inda ake adana ayyuka",
+2
View File
@@ -51,6 +51,8 @@
"showcaseEnabledDescription": "Gosipụta ngalaba ngosipụta ngwa na ibe ụlọ",
"showcaseModerator": "Onye Nlekọta Ngosipụta",
"showcaseModeratorDescription": "Igodo ọha Nostr (npub) nke onye ọrụ nwere ike ilekọta ntinye ngosipụta",
"communityFollowPack": "Obodo",
"communityFollowPackDescription": "Ihe omume Nostr nke ngwugwu eso a na-eji maka ngalaba Mmemme Obodo na ibe Obodo",
"filesystemPaths": "Ụzọ Sistemu Faịlụ",
"projectsDirectory": "Ndekọ Ọrụ",
"projectsDirectoryDescription": "Ụzọ sistemu faịlụ ebe echekwara ọrụ",
+2
View File
@@ -51,6 +51,8 @@
"showcaseEnabledDescription": "Exibir a seção de vitrine de aplicativos na página inicial",
"showcaseModerator": "Moderador da Vitrine",
"showcaseModeratorDescription": "Chave pública Nostr (npub) do usuário que pode moderar envios da vitrine",
"communityFollowPack": "Comunidade",
"communityFollowPackDescription": "Evento Nostr do pacote de seguir usado para a seção de Eventos da Comunidade na página da Comunidade",
"filesystemPaths": "Caminhos do Sistema de Arquivos",
"projectsDirectory": "Diretório de Projetos",
"projectsDirectoryDescription": "Caminho do sistema de arquivos onde os projetos são armazenados",
+2
View File
@@ -51,6 +51,8 @@
"showcaseEnabledDescription": "Ṣafihan apakan ifihan ohun elo lori oju-iwe ile",
"showcaseModerator": "Oluṣakoso Ifihan",
"showcaseModeratorDescription": "Bọtini gbangba Nostr (npub) ti olumulo ti o le ṣakoso awọn ifisilẹ ifihan",
"communityFollowPack": "Agbegbe",
"communityFollowPackDescription": "Iṣẹlẹ Nostr ti apo atẹle ti a lo fun apakan Awọn Iṣẹlẹ Agbegbe lori oju-iwe Agbegbe",
"filesystemPaths": "Awọn Ọna Eto Faili",
"projectsDirectory": "Itọsọna Awọn iṣẹ akanṣe",
"projectsDirectoryDescription": "Ọna eto faili nibiti a tọju awọn iṣẹ akanṣe",
+2
View File
@@ -51,6 +51,8 @@
"showcaseEnabledDescription": "在主页上显示应用展示部分",
"showcaseModerator": "展示管理员",
"showcaseModeratorDescription": "可以审核展示提交的用户的Nostr公钥(npub)",
"communityFollowPack": "社区",
"communityFollowPackDescription": "用于社区页面社区活动部分的关注包的Nostr事件",
"filesystemPaths": "文件系统路径",
"projectsDirectory": "项目目录",
"projectsDirectoryDescription": "存储项目的文件系统路径",
+61 -1
View File
@@ -1,4 +1,4 @@
import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon } from "lucide-react";
import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon, Users } from "lucide-react";
import { useTranslation } from 'react-i18next';
import { useState, useEffect, useMemo } from "react";
import { Button } from "@/components/ui/button";
@@ -26,6 +26,7 @@ export function SystemSettings() {
const [faviconUrlInput, setFaviconUrlInput] = useState(config.faviconUrl);
const [previewDomainInput, setPreviewDomainInput] = useState(config.previewDomain);
const [showcaseModeratorInput, setShowcaseModeratorInput] = useState(config.showcaseModerator);
const [communityFollowPackInput, setCommunityFollowPackInput] = useState(config.communityFollowPack);
const [fsPathProjectsInput, setFsPathProjectsInput] = useState(config.fsPathProjects);
const [fsPathConfigInput, setFsPathConfigInput] = useState(config.fsPathConfig);
const [fsPathTmpInput, setFsPathTmpInput] = useState(config.fsPathTmp);
@@ -41,6 +42,7 @@ export function SystemSettings() {
previewDomain: config.previewDomain !== defaultConfig.previewDomain,
showcaseEnabled: config.showcaseEnabled !== defaultConfig.showcaseEnabled,
showcaseModerator: config.showcaseModerator !== defaultConfig.showcaseModerator,
communityFollowPack: config.communityFollowPack !== defaultConfig.communityFollowPack,
fsPathProjects: config.fsPathProjects !== defaultConfig.fsPathProjects,
fsPathConfig: config.fsPathConfig !== defaultConfig.fsPathConfig,
fsPathTmp: config.fsPathTmp !== defaultConfig.fsPathTmp,
@@ -102,6 +104,15 @@ export function SystemSettings() {
});
};
const restoreCommunityFollowPack = () => {
const defaultValue = defaultConfig.communityFollowPack;
setCommunityFollowPackInput(defaultValue);
updateConfig((current) => {
const { communityFollowPack, ...rest } = current;
return rest;
});
};
const restoreFsPathProjects = () => {
const defaultValue = defaultConfig.fsPathProjects;
setFsPathProjectsInput(defaultValue);
@@ -680,6 +691,55 @@ export function SystemSettings() {
</AccordionItem>
</Accordion>
{/* Community Follow Pack Configuration */}
<Accordion type="single" collapsible className="w-full">
<AccordionItem value="community-follow-pack">
<AccordionTrigger className="px-4 py-3 hover:no-underline">
<div className="flex items-center gap-2">
<Users className="h-4 w-4 text-muted-foreground" />
<h4 className="text-sm font-medium">{t('communityFollowPack')}</h4>
{isModified.communityFollowPack && (
<div className="h-2 w-2 rounded-full bg-yellow-500" title={t('modified')} />
)}
</div>
</AccordionTrigger>
<AccordionContent className="px-4 pb-4">
<div className="py-1 space-y-2">
<div className="flex gap-2">
<Input
id="community-follow-pack"
type="text"
placeholder="naddr1..."
value={communityFollowPackInput}
onChange={(e) => {
const value = e.target.value;
setCommunityFollowPackInput(value);
updateConfig((current) => ({
...current,
communityFollowPack: value,
}));
}}
className="flex-1"
/>
{isModified.communityFollowPack && (
<Button
variant="outline"
size="icon"
onClick={restoreCommunityFollowPack}
title={t('restoreToDefault')}
>
<RotateCcw className="h-4 w-4" />
</Button>
)}
</div>
<p className="text-xs text-muted-foreground">
{t('communityFollowPackDescription')}
</p>
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
{/* Sentry DSN Configuration */}
<Accordion type="single" collapsible className="w-full">
<AccordionItem value="sentry-dsn">
+1
View File
@@ -57,6 +57,7 @@ export function TestApp({ children }: TestAppProps) {
fsPathTemplates: '/templates',
sentryDsn: '',
sentryEnabled: false,
communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m',
};
// Initialize LightningFS for testing