fix(FN-1989): display all generated insight categories

- Expand canonical insight category list in useInsights to include every supported category
- Update InsightsView icon mapping and typing to cover all InsightCategory values
- Make useInsights section initialization test assert against INSIGHT_CATEGORIES length
This commit is contained in:
Fusion
2026-04-17 02:58:01 -07:00
committed by gsxdsm
parent 3582383837
commit 9c02bc3d33
3 changed files with 27 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
* InsightsView - Dashboard component for displaying and managing project insights
*
* Features:
* - Displays insights grouped by category (features, architecture, competitive analysis, research, trends)
* - Displays insights grouped by all supported insight categories
* - Manual insight generation trigger
* - Per-insight dismiss action
* - Per-insight task creation action
@@ -29,6 +29,7 @@ import {
Clock,
} from "lucide-react";
import { useInsights, INSIGHT_CATEGORIES, CATEGORY_LABELS, type InsightSection } from "../hooks/useInsights";
import type { InsightCategory } from "@fusion/core";
import type { ToastType } from "../hooks/useToast";
import { createTask } from "../api";
@@ -40,12 +41,22 @@ interface InsightsViewProps {
}
// Category icons mapping
const CATEGORY_ICONS: Record<string, React.ComponentType<{ size?: number; className?: string }>> = {
features: Lightbulb,
const CATEGORY_ICONS: Record<InsightCategory, React.ComponentType<{ size?: number; className?: string }>> = {
architecture: Building,
quality: CheckCircle,
workflow: Clock,
performance: TrendingUp,
reliability: RefreshCw,
security: AlertCircle,
ux: Users,
testability: Archive,
documentation: ExternalLink,
dependency: Plus,
features: Lightbulb,
competitive_analysis: Users,
research: LineChart,
trends: TrendingUp,
other: Sparkles,
};
export function InsightsView({ projectId, addToast, onClose, onCreateTask }: InsightsViewProps) {

View File

@@ -71,7 +71,7 @@ describe("useInsights", () => {
expect(result.current.isRunInFlight).toBe(false);
});
it("should initialize with all five canonical sections", async () => {
it("should initialize with all canonical sections", async () => {
mockFetchInsights.mockResolvedValue({ insights: [], count: 0 });
mockFetchInsightRuns.mockResolvedValue({ runs: [] });
@@ -81,7 +81,7 @@ describe("useInsights", () => {
expect(result.current.loading).toBe(false);
});
expect(result.current.sections).toHaveLength(5);
expect(result.current.sections).toHaveLength(INSIGHT_CATEGORIES.length);
expect(result.current.sections.map((s) => s.category)).toEqual(INSIGHT_CATEGORIES);
});
});

View File

@@ -20,11 +20,21 @@ import {
// Canonical insight categories (in display order)
export const INSIGHT_CATEGORIES: InsightCategory[] = [
"features",
"architecture",
"quality",
"workflow",
"performance",
"reliability",
"security",
"ux",
"testability",
"documentation",
"dependency",
"features",
"competitive_analysis",
"research",
"trends",
"other",
];
// Human-readable labels for categories