Spruce up problems UX more (#593)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { useState } from "react";
|
||||||
import { useAtom, useAtomValue } from "jotai";
|
import { useAtom, useAtomValue } from "jotai";
|
||||||
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
|
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
|
||||||
import { selectedAppIdAtom } from "@/atoms/appAtoms";
|
import { selectedAppIdAtom } from "@/atoms/appAtoms";
|
||||||
@@ -7,6 +8,7 @@ import {
|
|||||||
FileText,
|
FileText,
|
||||||
Wrench,
|
Wrench,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
|
Check,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Problem, ProblemReport } from "@/ipc/ipc_types";
|
import { Problem, ProblemReport } from "@/ipc/ipc_types";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -15,8 +17,6 @@ import { useStreamChat } from "@/hooks/useStreamChat";
|
|||||||
import { useCheckProblems } from "@/hooks/useCheckProblems";
|
import { useCheckProblems } from "@/hooks/useCheckProblems";
|
||||||
import { createProblemFixPrompt } from "@/shared/problem_prompt";
|
import { createProblemFixPrompt } from "@/shared/problem_prompt";
|
||||||
import { showError } from "@/lib/toast";
|
import { showError } from "@/lib/toast";
|
||||||
import { useSettings } from "@/hooks/useSettings";
|
|
||||||
import { AutoFixProblemsSwitch } from "../AutoFixProblemsSwitch";
|
|
||||||
|
|
||||||
interface ProblemItemProps {
|
interface ProblemItemProps {
|
||||||
problem: Problem;
|
problem: Problem;
|
||||||
@@ -64,45 +64,37 @@ const RecheckButton = ({
|
|||||||
variant = "outline",
|
variant = "outline",
|
||||||
className = "h-7 px-3 text-xs",
|
className = "h-7 px-3 text-xs",
|
||||||
}: RecheckButtonProps) => {
|
}: RecheckButtonProps) => {
|
||||||
const { settings } = useSettings();
|
|
||||||
const { checkProblems, isChecking } = useCheckProblems(appId);
|
const { checkProblems, isChecking } = useCheckProblems(appId);
|
||||||
|
const [showingFeedback, setShowingFeedback] = useState(false);
|
||||||
|
|
||||||
const handleRecheck = async () => {
|
const handleRecheck = async () => {
|
||||||
|
setShowingFeedback(true);
|
||||||
|
|
||||||
const res = await checkProblems();
|
const res = await checkProblems();
|
||||||
|
|
||||||
|
setShowingFeedback(false);
|
||||||
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
showError(res.error);
|
showError(res.error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!settings?.enableAutoFixProblems) {
|
const isShowingChecking = isChecking || showingFeedback;
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center h-full text-center p-8">
|
|
||||||
<div className="w-16 h-16 rounded-full bg-[var(--background-darkest)] flex items-center justify-center mb-4">
|
|
||||||
<Wrench size={24} className="text-muted-foreground" />
|
|
||||||
</div>
|
|
||||||
<h3 className="text-lg font-medium mb-2">Enable Auto-Fix Problems</h3>
|
|
||||||
<p className="text-sm text-muted-foreground max-w-md mb-4">
|
|
||||||
You need to enable autofix problems to use the Problem pane.
|
|
||||||
</p>
|
|
||||||
<AutoFixProblemsSwitch showToast={true} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
size={size}
|
size={size}
|
||||||
variant={variant}
|
variant={variant}
|
||||||
onClick={handleRecheck}
|
onClick={handleRecheck}
|
||||||
disabled={isChecking}
|
disabled={isShowingChecking}
|
||||||
className={className}
|
className={className}
|
||||||
data-testid="recheck-button"
|
data-testid="recheck-button"
|
||||||
>
|
>
|
||||||
<RefreshCw
|
<RefreshCw
|
||||||
size={14}
|
size={14}
|
||||||
className={`mr-1 ${isChecking ? "animate-spin" : ""}`}
|
className={`mr-1 ${isShowingChecking ? "animate-spin" : ""}`}
|
||||||
/>
|
/>
|
||||||
{isChecking ? "Checking..." : "Recheck"}
|
{isShowingChecking ? "Checking..." : "Run checks"}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -130,10 +122,13 @@ const ProblemsSummary = ({ problemReport, appId }: ProblemsSummaryProps) => {
|
|||||||
if (problems.length === 0) {
|
if (problems.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-32 text-center">
|
<div className="flex flex-col items-center justify-center h-32 text-center">
|
||||||
|
<p className="mt-6 text-sm font-medium text-muted-foreground mb-3">
|
||||||
|
No problems found
|
||||||
|
</p>
|
||||||
<div className="w-12 h-12 rounded-full bg-green-100 dark:bg-green-900/20 flex items-center justify-center mb-3">
|
<div className="w-12 h-12 rounded-full bg-green-100 dark:bg-green-900/20 flex items-center justify-center mb-3">
|
||||||
<div className="w-6 h-6 rounded-full bg-green-500"></div>
|
<Check size={20} className="text-green-600 dark:text-green-400" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-muted-foreground mb-3">No problems found</p>
|
|
||||||
<RecheckButton appId={appId} />
|
<RecheckButton appId={appId} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -197,6 +192,13 @@ export function _Problems() {
|
|||||||
if (!problemReport) {
|
if (!problemReport) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-full text-center p-8">
|
<div className="flex flex-col items-center justify-center h-full text-center p-8">
|
||||||
|
<div className="w-16 h-16 rounded-full bg-[var(--background-darkest)] flex items-center justify-center mb-4">
|
||||||
|
<AlertTriangle size={24} className="text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<h3 className="text-lg font-medium mb-2">No Problems Report</h3>
|
||||||
|
<p className="text-sm text-muted-foreground max-w-md mb-4">
|
||||||
|
Run checks to scan your app for TypeScript errors and other problems.
|
||||||
|
</p>
|
||||||
<RecheckButton appId={selectedAppId} />
|
<RecheckButton appId={selectedAppId} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user