Fix create new model provider action not being shown in form#1542
Fix create new model provider action not being shown in form#1542dan-niles wants to merge 4 commits intowso2:release/bi-1.8.xfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded PROMPT as an expression-editor-triggering field, introduced isSaving state and try/catch around post-submit navigation in form components, and updated several form/config schemas to use ACTION_EXPRESSION types or add types entries for fields. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
09f0e2e to
8fa2ad1
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
workspaces/ballerina/ballerina-visualizer/src/views/BI/TestFunctionForm/index.tsx (1)
105-129:⚠️ Potential issue | 🟠 MajorReset
isSavingfor all submit outcomes.
Line 106 setsisSavingto true, but only the openView error path clears it (Line 128). If add/update fails or after a successful submit, the UI can remain stuck in a saving state. Wrap the whole submit flow in try/catch/finally and clear the flag infinally.🛠️ Suggested fix
const onFormSubmit = async (data: FormValues, formImports: FormImports) => { setIsSaving(true); console.log("Test Function Form Data: ", data); const updatedTestFunction = fillFunctionModel(data, formImports); console.log("Test Function: ", updatedTestFunction); - if (serviceType === 'UPDATE_TEST') { - await rpcClient.getTestManagerRpcClient().updateTestFunction({ function: updatedTestFunction, filePath }); - } else { - await rpcClient.getTestManagerRpcClient().addTestFunction({ function: updatedTestFunction, filePath }); - } - try { - const res = await rpcClient.getTestManagerRpcClient().getTestFunction( - { functionName: updatedTestFunction.functionName.value, filePath }); - const nodePosition = { - startLine: res.function.codedata.lineRange.startLine.line, - startColumn: res.function.codedata.lineRange.startLine.offset, - endLine: res.function.codedata.lineRange.endLine.line, - endColumn: res.function.codedata.lineRange.endLine.offset - }; - await rpcClient.getVisualizerRpcClient().openView( - { type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } }) - } catch (error) { - console.error("Error opening test function in editor: ", error); - setIsSaving(false); - } + try { + if (serviceType === 'UPDATE_TEST') { + await rpcClient.getTestManagerRpcClient().updateTestFunction({ function: updatedTestFunction, filePath }); + } else { + await rpcClient.getTestManagerRpcClient().addTestFunction({ function: updatedTestFunction, filePath }); + } + const res = await rpcClient.getTestManagerRpcClient().getTestFunction( + { functionName: updatedTestFunction.functionName.value, filePath }); + const nodePosition = { + startLine: res.function.codedata.lineRange.startLine.line, + startColumn: res.function.codedata.lineRange.startLine.offset, + endLine: res.function.codedata.lineRange.endLine.line, + endColumn: res.function.codedata.lineRange.endLine.offset + }; + await rpcClient.getVisualizerRpcClient().openView( + { type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } }) + } catch (error) { + console.error("Error submitting or opening test function in editor: ", error); + } finally { + setIsSaving(false); + } };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@workspaces/ballerina/ballerina-visualizer/src/views/BI/TestFunctionForm/index.tsx` around lines 105 - 129, The onFormSubmit handler sets setIsSaving(true) but only clears it in one error branch; wrap the entire submit flow in a try/catch/finally around the calls to fillFunctionModel and rpcClient methods (rpcClient.getTestManagerRpcClient().addTestFunction / updateTestFunction, getTestFunction, and rpcClient.getVisualizerRpcClient().openView) so that setIsSaving(false) is executed in the finally block; keep existing error logging in catch blocks but ensure every exit path resets isSaving by moving the setIsSaving(false) into finally.workspaces/ballerina/ballerina-visualizer/src/views/BI/AIEvaluationForm/index.tsx (1)
237-264:⚠️ Potential issue | 🟠 MajorWrap submit flow in try-catch-finally to ensure
isSavingclears on all paths.
Line 238 setsisSavingtrue but only clears it in the inner catch block (line 263); add/update failures (lines 245–248) won't be caught, and successful saves won't reset the state. Move the add/update calls into the try block and use finally to unconditionally clearisSaving. Note:openViewreturnsvoid(a notification, not a Promise), so it should not be awaited.🛠️ Suggested fix
const onFormSubmit = async (data: FormValues, formImports: FormImports) => { setIsSaving(true); - const formData = { - ...data, - dataProviderMode: dataProviderMode - }; - const updatedTestFunction = fillFunctionModel(formData, formImports); - if (serviceType === 'UPDATE_TEST') { - await rpcClient.getTestManagerRpcClient().updateTestFunction({ function: updatedTestFunction, filePath }); - } else { - await rpcClient.getTestManagerRpcClient().addTestFunction({ function: updatedTestFunction, filePath }); - } - try { - const res = await rpcClient.getTestManagerRpcClient().getTestFunction( - { functionName: updatedTestFunction.functionName.value, filePath }); - const nodePosition = { - startLine: res.function.codedata.lineRange.startLine.line, - startColumn: res.function.codedata.lineRange.startLine.offset, - endLine: res.function.codedata.lineRange.endLine.line, - endColumn: res.function.codedata.lineRange.endLine.offset - }; - rpcClient.getVisualizerRpcClient().openView( - { type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } }) - } - catch (error) { - console.error('Failed to open function in diagram:', error); - setIsSaving(false); - } + try { + const formData = { + ...data, + dataProviderMode: dataProviderMode + }; + const updatedTestFunction = fillFunctionModel(formData, formImports); + if (serviceType === 'UPDATE_TEST') { + await rpcClient.getTestManagerRpcClient().updateTestFunction({ function: updatedTestFunction, filePath }); + } else { + await rpcClient.getTestManagerRpcClient().addTestFunction({ function: updatedTestFunction, filePath }); + } + const res = await rpcClient.getTestManagerRpcClient().getTestFunction( + { functionName: updatedTestFunction.functionName.value, filePath }); + const nodePosition = { + startLine: res.function.codedata.lineRange.startLine.line, + startColumn: res.function.codedata.lineRange.startLine.offset, + endLine: res.function.codedata.lineRange.endLine.line, + endColumn: res.function.codedata.lineRange.endLine.offset + }; + rpcClient.getVisualizerRpcClient().openView( + { type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } }) + } catch (error) { + console.error('Failed to submit or open function in diagram:', error); + } finally { + setIsSaving(false); + } };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@workspaces/ballerina/ballerina-visualizer/src/views/BI/AIEvaluationForm/index.tsx` around lines 237 - 264, The submit flow in onFormSubmit sets setIsSaving(true) but doesn't clear it on all paths; wrap the add/update/getTestFunction and subsequent openView calls in a try block and use a finally block to always call setIsSaving(false). Specifically, move the rpcClient.getTestManagerRpcClient().updateTestFunction / addTestFunction and the getTestFunction + rpcClient.getVisualizerRpcClient().openView calls into the try, catch errors as needed, and ensure finally { setIsSaving(false); } is present; also do not await openView since it returns void/notification.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@workspaces/ballerina/ballerina-visualizer/src/views/BI/AIEvaluationForm/index.tsx`:
- Around line 237-264: The submit flow in onFormSubmit sets setIsSaving(true)
but doesn't clear it on all paths; wrap the add/update/getTestFunction and
subsequent openView calls in a try block and use a finally block to always call
setIsSaving(false). Specifically, move the
rpcClient.getTestManagerRpcClient().updateTestFunction / addTestFunction and the
getTestFunction + rpcClient.getVisualizerRpcClient().openView calls into the
try, catch errors as needed, and ensure finally { setIsSaving(false); } is
present; also do not await openView since it returns void/notification.
In
`@workspaces/ballerina/ballerina-visualizer/src/views/BI/TestFunctionForm/index.tsx`:
- Around line 105-129: The onFormSubmit handler sets setIsSaving(true) but only
clears it in one error branch; wrap the entire submit flow in a
try/catch/finally around the calls to fillFunctionModel and rpcClient methods
(rpcClient.getTestManagerRpcClient().addTestFunction / updateTestFunction,
getTestFunction, and rpcClient.getVisualizerRpcClient().openView) so that
setIsSaving(false) is executed in the finally block; keep existing error logging
in catch blocks but ensure every exit path resets isSaving by moving the
setIsSaving(false) into finally.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
workspaces/ballerina/ballerina-side-panel/src/components/editors/EditorFactory.tsxworkspaces/ballerina/ballerina-visualizer/src/views/BI/AIEvaluationForm/index.tsxworkspaces/ballerina/ballerina-visualizer/src/views/BI/TestFunctionForm/index.tsx
Purpose
Fixes wso2/product-ballerina-integrator#2545
Fixes the
Create New Model Providerbutton not showing in the reusable model provider form.Summary by CodeRabbit
Bug Fixes
New Features