fix(raycast): allow scoped keys on supported commands (#1513)

This commit is contained in:
shamAnimates 2026-10-12 22:13:40 -07:00 • committed by Mahesh Sanikommu
parent 87af03a55f
commit 848e5ac369
3 changed files with 7 additions and 22 deletions

View file

@ -214,9 +214,3 @@ export async function searchMemories(
throw error
}
}
// Helper function to check if API key is configured and valid
export async function fetchSettings(): Promise<object> {
const response = await makeAuthenticatedRequest<object>("/v3/settings")
return response
}

View file

@ -11,15 +11,15 @@ import { fetchProjects, addProject } from "./api"
import {
FormValidation,
showFailureToast,
useCachedPromise,
useForm,
usePromise,
} from "@raycast/utils"
import { withSupermemory } from "./withSupermemory"
export default withSupermemory(Command)
function Command() {
const { isLoading, data: projects, mutate } = useCachedPromise(fetchProjects)
const { isLoading, data: projects, mutate } = usePromise(fetchProjects)
return (
<List isLoading={isLoading} searchBarPlaceholder="Search your projects">

View file

@ -1,9 +1,7 @@
import { usePromise } from "@raycast/utils"
import { fetchSettings } from "./api"
import {
Action,
ActionPanel,
Detail,
getPreferenceValues,
Icon,
List,
openExtensionPreferences,
@ -12,18 +10,11 @@ import type { ComponentType } from "react"
export function withSupermemory<P extends object>(Component: ComponentType<P>) {
return function SupermemoryWrappedComponent(props: P) {
const { isLoading, data } = usePromise(fetchSettings, [], {
failureToastOptions: {
title: "Invalid API Key",
message:
"Invalid API key. Please check your API key in preferences. Get a new one from https://supermemory.link/raycast",
},
})
// Let each command enforce its own endpoint-specific permissions and rate limit.
const { apiKey } = getPreferenceValues<Preferences>()
if (!data) {
return isLoading ? (
<Detail isLoading />
) : (
if (!apiKey.trim()) {
return (
<List>
<List.EmptyView
icon={Icon.ExclamationMark}