mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +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}
|
onOpenChange={setShowValidationDialog}
|
||||||
issue={selectedIssue}
|
issue={selectedIssue}
|
||||||
validationResult={validationResult}
|
validationResult={validationResult}
|
||||||
isValidating={selectedIssue ? validatingIssues.has(selectedIssue.number) : false}
|
|
||||||
onConvertToTask={handleConvertToTask}
|
onConvertToTask={handleConvertToTask}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
FileCode,
|
FileCode,
|
||||||
Lightbulb,
|
Lightbulb,
|
||||||
AlertTriangle,
|
AlertTriangle,
|
||||||
Loader2,
|
|
||||||
Plus,
|
Plus,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
@@ -32,7 +31,6 @@ interface ValidationDialogProps {
|
|||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
issue: GitHubIssue | null;
|
issue: GitHubIssue | null;
|
||||||
validationResult: IssueValidationResult | null;
|
validationResult: IssueValidationResult | null;
|
||||||
isValidating: boolean;
|
|
||||||
onConvertToTask?: (issue: GitHubIssue, validation: IssueValidationResult) => void;
|
onConvertToTask?: (issue: GitHubIssue, validation: IssueValidationResult) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +77,6 @@ export function ValidationDialog({
|
|||||||
onOpenChange,
|
onOpenChange,
|
||||||
issue,
|
issue,
|
||||||
validationResult,
|
validationResult,
|
||||||
isValidating,
|
|
||||||
onConvertToTask,
|
onConvertToTask,
|
||||||
}: ValidationDialogProps) {
|
}: ValidationDialogProps) {
|
||||||
if (!issue) return null;
|
if (!issue) return null;
|
||||||
@@ -101,12 +98,7 @@ export function ValidationDialog({
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
{isValidating ? (
|
{validationResult ? (
|
||||||
<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 ? (
|
|
||||||
<div className="space-y-6 py-4">
|
<div className="space-y-6 py-4">
|
||||||
{/* Verdict Badge */}
|
{/* Verdict Badge */}
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
|
|||||||
@@ -205,11 +205,8 @@ export function useIssueValidation({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleValidateIssue = useCallback(
|
const handleValidateIssue = useCallback(
|
||||||
async (
|
async (issue: GitHubIssue, options: { forceRevalidate?: boolean } = {}) => {
|
||||||
issue: GitHubIssue,
|
const { forceRevalidate = false } = options;
|
||||||
options: { showDialog?: boolean; forceRevalidate?: boolean } = {}
|
|
||||||
) => {
|
|
||||||
const { showDialog = true, forceRevalidate = false } = options;
|
|
||||||
|
|
||||||
if (!currentProject?.path) {
|
if (!currentProject?.path) {
|
||||||
toast.error('No project selected');
|
toast.error('No project selected');
|
||||||
@@ -224,21 +221,17 @@ export function useIssueValidation({
|
|||||||
|
|
||||||
// Check for cached result - if fresh, show it directly (unless force revalidate)
|
// Check for cached result - if fresh, show it directly (unless force revalidate)
|
||||||
const cached = cachedValidations.get(issue.number);
|
const cached = cachedValidations.get(issue.number);
|
||||||
if (cached && showDialog && !forceRevalidate) {
|
if (cached && !forceRevalidate && !isValidationStale(cached.validatedAt)) {
|
||||||
// Check if validation is stale
|
// Show cached result directly
|
||||||
if (!isValidationStale(cached.validatedAt)) {
|
onValidationResultChange(cached.result);
|
||||||
// Show cached result directly
|
onShowValidationDialogChange(true);
|
||||||
onValidationResultChange(cached.result);
|
return;
|
||||||
onShowValidationDialogChange(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start async validation
|
// Start async validation in background (no dialog - user will see badge when done)
|
||||||
onValidationResultChange(null);
|
toast.info(`Starting validation for issue #${issue.number}`, {
|
||||||
if (showDialog) {
|
description: 'You will be notified when the analysis is complete',
|
||||||
onShowValidationDialogChange(true);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const api = getElectronAPI();
|
const api = getElectronAPI();
|
||||||
@@ -256,18 +249,12 @@ export function useIssueValidation({
|
|||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
toast.error(result.error || 'Failed to start validation');
|
toast.error(result.error || 'Failed to start validation');
|
||||||
if (showDialog) {
|
|
||||||
onShowValidationDialogChange(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// On success, the result will come through the event stream
|
// On success, the result will come through the event stream
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[GitHubIssuesView] Validation error:', err);
|
console.error('[GitHubIssuesView] Validation error:', err);
|
||||||
toast.error(err instanceof Error ? err.message : 'Failed to validate issue');
|
toast.error(err instanceof Error ? err.message : 'Failed to validate issue');
|
||||||
if (showDialog) {
|
|
||||||
onShowValidationDialogChange(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user