mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 14:22:02 +00:00
refactor: Simplify validation handling in GitHubIssuesView
- Removed the isValidating prop from GitHubIssuesView and ValidationDialog components to streamline validation logic. - Updated handleValidateIssue function to eliminate unnecessary dialog options, focusing on background validation notifications. - Enhanced user feedback by notifying users when validation starts, improving overall experience during issue analysis.
This commit is contained in:
@@ -214,7 +214,6 @@ export function GitHubIssuesView() {
|
||||
onOpenChange={setShowValidationDialog}
|
||||
issue={selectedIssue}
|
||||
validationResult={validationResult}
|
||||
isValidating={selectedIssue ? validatingIssues.has(selectedIssue.number) : false}
|
||||
onConvertToTask={handleConvertToTask}
|
||||
/>
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
FileCode,
|
||||
Lightbulb,
|
||||
AlertTriangle,
|
||||
Loader2,
|
||||
Plus,
|
||||
} from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -32,7 +31,6 @@ interface ValidationDialogProps {
|
||||
onOpenChange: (open: boolean) => void;
|
||||
issue: GitHubIssue | null;
|
||||
validationResult: IssueValidationResult | null;
|
||||
isValidating: boolean;
|
||||
onConvertToTask?: (issue: GitHubIssue, validation: IssueValidationResult) => void;
|
||||
}
|
||||
|
||||
@@ -79,7 +77,6 @@ export function ValidationDialog({
|
||||
onOpenChange,
|
||||
issue,
|
||||
validationResult,
|
||||
isValidating,
|
||||
onConvertToTask,
|
||||
}: ValidationDialogProps) {
|
||||
if (!issue) return null;
|
||||
@@ -101,12 +98,7 @@ export function ValidationDialog({
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{isValidating ? (
|
||||
<div className="flex flex-col items-center justify-center py-12 space-y-4">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
<p className="text-sm text-muted-foreground">Analyzing codebase to validate issue...</p>
|
||||
</div>
|
||||
) : validationResult ? (
|
||||
{validationResult ? (
|
||||
<div className="space-y-6 py-4">
|
||||
{/* Verdict Badge */}
|
||||
<div className="flex items-center justify-between">
|
||||
|
||||
@@ -205,11 +205,8 @@ export function useIssueValidation({
|
||||
}, []);
|
||||
|
||||
const handleValidateIssue = useCallback(
|
||||
async (
|
||||
issue: GitHubIssue,
|
||||
options: { showDialog?: boolean; forceRevalidate?: boolean } = {}
|
||||
) => {
|
||||
const { showDialog = true, forceRevalidate = false } = options;
|
||||
async (issue: GitHubIssue, options: { forceRevalidate?: boolean } = {}) => {
|
||||
const { forceRevalidate = false } = options;
|
||||
|
||||
if (!currentProject?.path) {
|
||||
toast.error('No project selected');
|
||||
@@ -224,21 +221,17 @@ export function useIssueValidation({
|
||||
|
||||
// Check for cached result - if fresh, show it directly (unless force revalidate)
|
||||
const cached = cachedValidations.get(issue.number);
|
||||
if (cached && showDialog && !forceRevalidate) {
|
||||
// Check if validation is stale
|
||||
if (!isValidationStale(cached.validatedAt)) {
|
||||
// Show cached result directly
|
||||
onValidationResultChange(cached.result);
|
||||
onShowValidationDialogChange(true);
|
||||
return;
|
||||
}
|
||||
if (cached && !forceRevalidate && !isValidationStale(cached.validatedAt)) {
|
||||
// Show cached result directly
|
||||
onValidationResultChange(cached.result);
|
||||
onShowValidationDialogChange(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Start async validation
|
||||
onValidationResultChange(null);
|
||||
if (showDialog) {
|
||||
onShowValidationDialogChange(true);
|
||||
}
|
||||
// Start async validation in background (no dialog - user will see badge when done)
|
||||
toast.info(`Starting validation for issue #${issue.number}`, {
|
||||
description: 'You will be notified when the analysis is complete',
|
||||
});
|
||||
|
||||
try {
|
||||
const api = getElectronAPI();
|
||||
@@ -256,18 +249,12 @@ export function useIssueValidation({
|
||||
|
||||
if (!result.success) {
|
||||
toast.error(result.error || 'Failed to start validation');
|
||||
if (showDialog) {
|
||||
onShowValidationDialogChange(false);
|
||||
}
|
||||
}
|
||||
// On success, the result will come through the event stream
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[GitHubIssuesView] Validation error:', err);
|
||||
toast.error(err instanceof Error ? err.message : 'Failed to validate issue');
|
||||
if (showDialog) {
|
||||
onShowValidationDialogChange(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user