MCPcopy Create free account
hub / github.com/error311/FileRise / saveRecipeDraft

Function saveRecipeDraft

public/js/aiChat.js:659–697  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

657 };
658
659 const saveRecipeDraft = async () => {
660 const promptText = String(inputEl?.value || '').trim() || String(lastRecipeDraft?.prompt || '').trim();
661 if (!promptText) {
662 showToast('Type or send a prompt first');
663 inputEl?.focus();
664 return;
665 }
666
667 const suggestedName = inferRecipeTitle(
668 lastRecipeDraft?.meta?.suggestedRecipeName || promptText,
669 'Saved recipe'
670 );
671 const chosenName = window.prompt('Recipe name', suggestedName);
672 if (chosenName === null) return;
673
674 const trimmedName = String(chosenName || '').trim();
675 if (!trimmedName) {
676 showToast('Recipe name is required');
677 return;
678 }
679
680 const saveToCurrentScope = window.confirm('Bind this recipe to the current source/folder scope? Click Cancel to keep it runnable in the current chat scope only.');
681 const recipePayload = {
682 name: trimmedName,
683 prompt: promptText,
684 scopeMode: saveToCurrentScope ? 'saved' : 'current',
685 sourceId: workspace().sourceId,
686 rootPath: workspace().rootPath,
687 workflowHint: String(lastRecipeDraft?.meta?.workflowName || '')
688 };
689
690 try {
691 await apiPost('/api/pro/ai/recipes/save.php', { recipe: recipePayload });
692 showToast('Recipe saved');
693 await loadRecipes();
694 } catch (err) {
695 showToast(err?.message || 'Failed to save recipe');
696 }
697 };
698
699 const deleteRecipe = async (recipe) => {
700 if (!recipe || recipe.builtin) return;

Callers

nothing calls this directly

Calls 5

inferRecipeTitleFunction · 0.85
workspaceFunction · 0.85
loadRecipesFunction · 0.85
showToastFunction · 0.70
apiPostFunction · 0.70

Tested by

no test coverage detected