diff --git a/packages/bruno-app/src/components/AIAssist/index.js b/packages/bruno-app/src/components/AIAssist/index.js index c6362267a..0238dac98 100644 --- a/packages/bruno-app/src/components/AIAssist/index.js +++ b/packages/bruno-app/src/components/AIAssist/index.js @@ -21,18 +21,29 @@ const SUGGESTIONS = { { label: 'Save token', prompt: 'Extract a token from the response body and save it to an environment variable' }, { label: 'Save id', prompt: 'Extract the primary id from the response body and save it to a variable' }, { label: 'Log response', prompt: 'Log the response status and a short summary of the body' } + ], + 'docs': [ + { label: 'Overview', prompt: 'Write an overview section describing the purpose and key features' }, + { label: 'Request', prompt: 'Document the request method, URL, headers, parameters, and body' }, + { label: 'Examples', prompt: 'Add request and response examples with sample JSON' }, + { label: 'Errors', prompt: 'Document common error responses and status codes' } ] }; const TITLES = { 'tests': 'Generate Tests', 'pre-request': 'Generate Pre-Request Script', - 'post-response': 'Generate Post-Response Script' + 'post-response': 'Generate Post-Response Script', + 'docs': 'Generate Documentation' +}; + +const PREVIEW_LABELS = { + docs: 'Preview · replaces current documentation' }; const isValidType = (t) => SUGGESTIONS[t] !== undefined; -const AIAssist = ({ scriptType, currentScript, requestContext, onApply }) => { +const AIAssist = ({ scriptType, currentScript, requestContext, docsContext, onApply }) => { const [isOpen, setIsOpen] = useState(false); const [prompt, setPrompt] = useState(''); const [isLoading, setIsLoading] = useState(false); @@ -49,6 +60,7 @@ const AIAssist = ({ scriptType, currentScript, requestContext, onApply }) => { const suggestions = useMemo(() => SUGGESTIONS[scriptType] || [], [scriptType]); const title = TITLES[scriptType] || 'Generate with AI'; + const previewLabel = PREVIEW_LABELS[scriptType] || 'Preview · replaces current script'; const close = useCallback(() => { setIsOpen(false); @@ -85,7 +97,8 @@ const AIAssist = ({ scriptType, currentScript, requestContext, onApply }) => { scriptType, prompt: text, currentScript: currentScript || '', - requestContext + requestContext, + docsContext }); if (result?.error) { setError(result.error); @@ -102,7 +115,7 @@ const AIAssist = ({ scriptType, currentScript, requestContext, onApply }) => { setIsLoading(false); } }, - [prompt, isLoading, scriptType, currentScript, requestContext] + [prompt, isLoading, scriptType, currentScript, requestContext, docsContext] ); const handleApply = useCallback(() => { @@ -206,7 +219,7 @@ const AIAssist = ({ scriptType, currentScript, requestContext, onApply }) => { <>
{generated}