diff --git a/src/components/nostr/SpellDialog.tsx b/src/components/nostr/SpellDialog.tsx index 0feffe9..2c0d2ad 100644 --- a/src/components/nostr/SpellDialog.tsx +++ b/src/components/nostr/SpellDialog.tsx @@ -10,12 +10,11 @@ import { import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Button } from "@/components/ui/button"; -import { Checkbox } from "@/components/ui/checkbox"; import { toast } from "sonner"; import { parseReqCommand } from "@/lib/req-parser"; import { reconstructCommand, detectCommandType } from "@/lib/spell-conversion"; import type { ParsedSpell, SpellEvent } from "@/types/spell"; -import { Loader2, Sparkles } from "lucide-react"; +import { Loader2 } from "lucide-react"; import { saveSpell } from "@/services/spell-storage"; import { LocalSpell } from "@/services/db"; import { PublishSpellAction } from "@/actions/publish-spell"; @@ -54,36 +53,6 @@ function filterSpellCommand(command: string): string { } } -/** - * Detect if command contains values that suggest parameterization - * Returns suggested parameter type if detected - */ -function detectParameterSuggestion( - command: string, -): "$pubkey" | "$event" | "$relay" | null { - if (!command) return null; - - // Check for $me or $contacts (suggests $pubkey parameter) - if (command.includes("$me") || command.includes("$contacts")) { - return "$pubkey"; - } - - // Check for single author hex that's not $me/$contacts - // (user might want to make it reusable) - const authorMatch = command.match(/-a\s+([a-f0-9]{64})/); - if (authorMatch) { - return "$pubkey"; - } - - // Check for event ID or naddr (suggests $event parameter) - const eventMatch = command.match(/-e\s+([a-f0-9]{64}|naddr1[a-z0-9]+)/); - if (eventMatch) { - return "$event"; - } - - return null; -} - interface SpellDialogProps { open: boolean; onOpenChange: (open: boolean) => void; @@ -109,20 +78,13 @@ export function SpellDialog({ existingSpell, onSuccess, }: SpellDialogProps) { - const { canSign, pubkey } = useAccount(); + const { canSign } = useAccount(); // Form state const [alias, setAlias] = useState(""); const [name, setName] = useState(""); const [description, setDescription] = useState(""); - // Parameter configuration - const [parameterEnabled, setParameterEnabled] = useState(false); - const [parameterType, setParameterType] = useState< - "$pubkey" | "$event" | "$relay" - >("$pubkey"); - const [parameterDefault, setParameterDefault] = useState("$me"); - // Publishing/saving state const [publishingState, setPublishingState] = useState("idle"); @@ -134,33 +96,11 @@ export function SpellDialog({ setAlias("alias" in existingSpell ? existingSpell.alias || "" : ""); setName(existingSpell.name || ""); setDescription(existingSpell.description || ""); - - // Load parameter configuration from existing spell - if ("parameterType" in existingSpell && existingSpell.parameterType) { - setParameterEnabled(true); - setParameterType(existingSpell.parameterType); - setParameterDefault(existingSpell.parameterDefault?.[0] || "$me"); - } else if ("parameter" in existingSpell && existingSpell.parameter) { - setParameterEnabled(true); - setParameterType(existingSpell.parameter.type); - setParameterDefault(existingSpell.parameter.default?.[0] || "$me"); - } else { - setParameterEnabled(false); - } } else if (mode === "create") { // Reset form for create mode setAlias(""); setName(""); setDescription(""); - - // Auto-detect parameter suggestion - const command = initialCommand || ""; - const suggestion = detectParameterSuggestion(command); - if (suggestion) { - setParameterType(suggestion); - // Don't auto-enable, let user decide - setParameterEnabled(false); - } } }, [mode, existingSpell, open, initialCommand]); @@ -208,8 +148,6 @@ export function SpellDialog({ command, description: description.trim() || undefined, isPublished: false, - parameterType: parameterEnabled ? parameterType : undefined, - parameterDefault: parameterEnabled ? [parameterDefault] : undefined, }); // Success! @@ -278,8 +216,6 @@ export function SpellDialog({ command, description: description.trim() || undefined, isPublished: false, - parameterType: parameterEnabled ? parameterType : undefined, - parameterDefault: parameterEnabled ? [parameterDefault] : undefined, }); // 2. Use PublishSpellAction to handle signing and publishing @@ -343,7 +279,7 @@ export function SpellDialog({ {mode === "create" - ? "Save this command as a spell. You can save it locally or publish it to Nostr relays." + ? "Save this command as a reusable spell. You can save it locally or publish it to Nostr." : "Edit your spell and republish it to relays."} @@ -405,136 +341,6 @@ export function SpellDialog({ /> - {/* Parameter configuration */} -
-
- - setParameterEnabled(checked as boolean) - } - disabled={isBusy} - /> - -
- - {parameterEnabled && ( -
-
- -
- {( - [ - ["$pubkey", "Profile"], - ["$event", "Event"], - ["$relay", "Relay"], - ] as const - ).map(([value, label]) => ( - - ))} -
-

- {parameterType === "$pubkey" && - "Apply this spell to any user's profile"} - {parameterType === "$event" && - "Apply this spell to any event"} - {parameterType === "$relay" && - "Apply this spell to any relay"} -

-
- - {parameterType === "$pubkey" && ( -
- - -

- Value used when no argument provided -

-
- )} -
- )} - - {!parameterEnabled && - detectParameterSuggestion( - mode === "edit" && existingSpell - ? existingSpell.command - : initialCommand || "", - ) && ( -

- 💡 This command uses{" "} - {parameterType === "$pubkey" - ? "a user" - : parameterType === "$event" - ? "an event" - : "a relay"} - . Enable this to make it work with any{" "} - {parameterType === "$pubkey" - ? "profile" - : parameterType === "$event" - ? "event" - : "relay"} - . -

- )} -
- {/* Command display (read-only, filtered to show only spell parts) */}