Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions ui/desktop/src/recipe/recipeStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,6 @@ function getRecipeFilePath(recipeName: string, isGlobal: boolean): string {
return `${dir}/${recipeName}.yaml`;
}

/**
* Load recipe from file
*/
async function loadRecipeFromFile(
recipeName: string,
isGlobal: boolean
): Promise<SavedRecipe | null> {
const filePath = getRecipeFilePath(recipeName, isGlobal);

try {
const result = await window.electron.readFile(filePath);
if (!result.found || result.error) {
return null;
}

const recipeData = yaml.parse(result.file) as SavedRecipe;

// Convert lastModified string to Date if needed
recipeData.lastModified = parseLastModified(recipeData.lastModified);

return {
...recipeData,
isGlobal: isGlobal,
filename: recipeName,
};
} catch (error) {
console.warn(`Failed to load recipe from ${filePath}:`, error);
return null;
}
}

/**
* Save recipe to file
*/
Expand Down Expand Up @@ -144,34 +113,6 @@ export async function saveRecipe(recipe: Recipe, options: SaveRecipeOptions): Pr
}
}

/**
* Load a recipe by name from file.
*/
export async function loadRecipe(recipeName: string, isGlobal: boolean): Promise<Recipe> {
try {
const savedRecipe = await loadRecipeFromFile(recipeName, isGlobal);

if (!savedRecipe) {
throw new Error('Recipe not found');
}

// Validate the loaded recipe has required fields
if (!savedRecipe.recipe.title || !savedRecipe.recipe.description) {
throw new Error('Loaded recipe is missing required fields');
}

if (!savedRecipe.recipe.instructions && !savedRecipe.recipe.prompt) {
throw new Error('Loaded recipe must have either instructions or prompt');
}

return savedRecipe.recipe;
} catch (error) {
throw new Error(
`Failed to load recipe: ${error instanceof Error ? error.message : 'Unknown error'}`
);
}
}

export async function listSavedRecipes(): Promise<RecipeManifestResponse[]> {
try {
const listRecipeResponse = await listRecipes();
Expand Down
Loading