-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emable to trigger GitAuto by checking the checkbox #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @hiroshinishio - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding user-visible error handling instead of just console.error() when the GitAuto trigger fails
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
try { | ||
await invoke("triggerGitAuto", { cloudId, projectId, issueId, selectedRepo }); | ||
} catch (error) { | ||
console.error("Error triggering GitAuto:", error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Add user-visible error feedback instead of just logging to console
Consider adding an error state and displaying a message to the user when the operation fails
Suggested implementation:
const [isChecked, setIsChecked] = useState(false);
const [isTriggering, setIsTriggering] = useState(false);
const [error, setError] = useState(null);
setIsTriggering(true);
setError(null);
} catch (error) {
console.error("Error triggering GitAuto:", error);
setError("Failed to trigger GitAuto. Please try again or contact support if the problem persists.");
<Stack space="space.075">
{error && (
<Text appearance="danger">
{error}
</Text>
)}
// Determine the API endpoint based on environment | ||
const endpoint = process.env.GITAUTO_URL + "/webhook"; | ||
console.log("Endpoint", endpoint); | ||
const response = await forge.fetch(endpoint, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): Consider adding a timeout to the external API call
External API calls should have a reasonable timeout to prevent hanging operations
Suggested implementation:
const response = await forge.fetch(endpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
timeout: 10000, // 10 second timeout
=======
Note: If the forge.fetch implementation doesn't support the timeout option directly, you may need to implement the timeout using Promise.race() with a timeout promise. Let me know if you need that alternative implementation.
if (!response.ok) throw new Error(`Failed to trigger GitAuto: ${response.status}`); | ||
|
||
return await response.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Enhance error message with more context from the response
Include response body or more specific error details to help with debugging
if (!response.ok) throw new Error(`Failed to trigger GitAuto: ${response.status}`); | |
return await response.json(); | |
if (!response.ok) { | |
const errorBody = await response.text(); | |
throw new Error( | |
`Failed to trigger GitAuto: ${response.status} - ${response.statusText}\nResponse: ${errorBody}` | |
); | |
} | |
return await response.json(); |
forge variables set --encrypt SUPABASE_URL <value> | ||
forge variables set --encrypt SUPABASE_API_KEY <value> | ||
forge variables set --environment development --encrypt SUPABASE_URL <value> | ||
forge variables set --environment development --encrypt SUPABASE_API_KEY <value> | ||
``` | ||
|
||
For production, you have to do the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider adding the explicit commands for production environment variables
For consistency with the development section, consider adding the explicit commands for setting production variables using --environment production
. This would make the documentation more complete and prevent any potential confusion.
// Handle checkbox | ||
const [isChecked, setIsChecked] = useState(false); | ||
const [isTriggering, setIsTriggering] = useState(false); | ||
const handleCheckboxChange = async (event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider flattening the control flow in the checkbox handler to improve code readability
The checkbox handling logic can be simplified by flattening the control flow while maintaining the same functionality. Here's a suggested refactor:
const handleCheckboxChange = async (event) => {
const checked = event.target.checked;
setIsChecked(checked);
if (!checked || !selectedRepo) {
setIsTriggering(false);
return;
}
setIsTriggering(true);
try {
await invoke("triggerGitAuto", {
cloudId,
projectId,
issueId,
selectedRepo
});
} catch (error) {
console.error("Error triggering GitAuto:", error);
}
setIsTriggering(false);
};
This version:
- Uses a single guard clause at the top
- Removes the need for finally block by setting isTriggering directly
- Maintains the same functionality with clearer flow control
- Keeps necessary state management for UI feedback
No description provided.