Skip to content

Commit 67282f5

Browse files
authored
fix: display recipes without metadata in the recipe list in ui (#4608)
1 parent 2c5b0b4 commit 67282f5

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

crates/goose-server/src/routes/recipe_utils.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn short_id_from_path(path: &str) -> String {
3131
format!("{:016x}", h)
3232
}
3333

34-
fn load_recipes_from_path(path: &PathBuf) -> Result<Vec<RecipeManifestWithPath>> {
34+
fn load_recipes_from_path(path: &PathBuf, is_global: bool) -> Result<Vec<RecipeManifestWithPath>> {
3535
let mut recipe_manifests_with_path = Vec::new();
3636
if path.exists() {
3737
for entry in fs::read_dir(path)? {
@@ -43,14 +43,18 @@ fn load_recipes_from_path(path: &PathBuf) -> Result<Vec<RecipeManifestWithPath>>
4343
let Ok(recipe) = Recipe::from_content(&recipe_file.content) else {
4444
continue;
4545
};
46-
let Ok(recipe_metadata) = RecipeManifestMetadata::from_yaml_file(&path) else {
47-
continue;
48-
};
4946
let Ok(last_modified) = fs::metadata(path.clone()).map(|m| {
5047
chrono::DateTime::<chrono::Utc>::from(m.modified().unwrap()).to_rfc3339()
5148
}) else {
5249
continue;
5350
};
51+
let recipe_metadata =
52+
RecipeManifestMetadata::from_yaml_file(&path).unwrap_or_else(|_| {
53+
RecipeManifestMetadata {
54+
name: recipe.title.clone(),
55+
is_global,
56+
}
57+
});
5458

5559
let manifest_with_path = RecipeManifestWithPath {
5660
id: short_id_from_path(recipe_file.file_path.to_string_lossy().as_ref()),
@@ -78,8 +82,8 @@ pub fn get_all_recipes_manifests() -> Result<Vec<RecipeManifestWithPath>> {
7882

7983
let mut recipe_manifests_with_path = Vec::new();
8084

81-
recipe_manifests_with_path.extend(load_recipes_from_path(&local_recipe_path)?);
82-
recipe_manifests_with_path.extend(load_recipes_from_path(&global_recipe_path)?);
85+
recipe_manifests_with_path.extend(load_recipes_from_path(&local_recipe_path, false)?);
86+
recipe_manifests_with_path.extend(load_recipes_from_path(&global_recipe_path, true)?);
8387
recipe_manifests_with_path.sort_by(|a, b| b.last_modified.cmp(&a.last_modified));
8488

8589
Ok(recipe_manifests_with_path)

0 commit comments

Comments
 (0)