From 79d15a9304faa77cf09f93d8d704ad1e4cb2dd3d Mon Sep 17 00:00:00 2001 From: aaniya22 Date: Sun, 31 May 2026 08:55:07 +0530 Subject: [PATCH 1/3] feat: add scan history sidebar to Findings page --- frontend/src/components/ScanHistory.tsx | 63 +++++++++++++++++++++++++ frontend/src/pages/Findings.tsx | 23 +++++++-- 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 frontend/src/components/ScanHistory.tsx diff --git a/frontend/src/components/ScanHistory.tsx b/frontend/src/components/ScanHistory.tsx new file mode 100644 index 00000000..74946f68 --- /dev/null +++ b/frontend/src/components/ScanHistory.tsx @@ -0,0 +1,63 @@ +import { useEffect, useState } from "react"; +import { getTasks } from "../api"; + +interface ScanMeta { + task_id: string; + tool_name: string; + target: string; + status: string; + created_at: string; + duration_seconds?: number; +} + +interface Props { + onSelect: (taskId: string) => void; + activeTaskId?: string; +} + +export function ScanHistory({ onSelect, activeTaskId }: Props) { + const [history, setHistory] = useState([]); + + useEffect(() => { + const params = new URLSearchParams({ per_page: "20", page: "1" }); + getTasks(params) + .then((data: any) => setHistory(data.tasks || [])) + .catch(console.error); + }, []); + + if (history.length === 0) { + return ( +
+ No past scans found. +
+ ); + } + + return ( +
+

+ Scan History +

+ {history.map((scan) => ( + + ))} +
+ ); +} diff --git a/frontend/src/pages/Findings.tsx b/frontend/src/pages/Findings.tsx index fb9f849b..2f20bdf9 100644 --- a/frontend/src/pages/Findings.tsx +++ b/frontend/src/pages/Findings.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useMemo, useState } from 'react' import { motion } from 'framer-motion' -import { getFindings } from '../api' +import { getFindings, getTaskResult } from '../api' +import { ScanHistory } from '../components/ScanHistory' import { formatLocaleDate, parseDateSafe, getCurrentTimeZone } from '../utils/date' type RiskFactor = { factor: string @@ -118,6 +119,7 @@ export default function Findings() { const [selectedFindingId, setSelectedFindingId] = useState(null) const [reviewState, setReviewState] = useState({}) const [copiedFindingId, setCopiedFindingId] = useState(null) + const [activeTaskId, setActiveTaskId] = useState() useEffect(() => { setLoading(true) @@ -130,6 +132,16 @@ export default function Findings() { .finally(() => setLoading(false)) }, []) + useEffect(() => { + if (!activeTaskId) return + getTaskResult(activeTaskId) + .then((data: any) => { + const nextFindings = data.findings || [] + setFindings(nextFindings) + }) + .catch(console.error) + }, [activeTaskId]) + useEffect(() => { try { const saved = localStorage.getItem('secuscan-finding-review-state') @@ -397,7 +409,11 @@ export default function Findings() { return (
-
+
+ +
Triage Workspace v5.1 @@ -788,7 +804,8 @@ export default function Findings() {
+
) -} +} \ No newline at end of file From b241579b810d73bea087760a5e54e1e1f0491dad Mon Sep 17 00:00:00 2001 From: aaniya22 Date: Sun, 31 May 2026 09:12:38 +0530 Subject: [PATCH 2/3] fix: add getTasks mock to test files for ScanHistory component --- frontend/testing/unit/AppRoutes.test.tsx | 2 ++ frontend/testing/unit/pages/Findings.test.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/frontend/testing/unit/AppRoutes.test.tsx b/frontend/testing/unit/AppRoutes.test.tsx index 031ac013..fa0f3be4 100644 --- a/frontend/testing/unit/AppRoutes.test.tsx +++ b/frontend/testing/unit/AppRoutes.test.tsx @@ -3,6 +3,8 @@ import { MemoryRouter, useLocation } from 'react-router-dom' import { AppRoutes } from '../../src/App' vi.mock('../../src/api', () => ({ + getTasks: vi.fn(() => Promise.resolve({ tasks: [] })), + getTaskResult: vi.fn(() => Promise.resolve({ findings: [] })), getHealth: vi.fn().mockResolvedValue({ status: 'operational' }), getDashboardSummary: vi.fn().mockResolvedValue({ total_findings: 0, diff --git a/frontend/testing/unit/pages/Findings.test.tsx b/frontend/testing/unit/pages/Findings.test.tsx index 561ae086..fc4672c5 100644 --- a/frontend/testing/unit/pages/Findings.test.tsx +++ b/frontend/testing/unit/pages/Findings.test.tsx @@ -6,6 +6,8 @@ import { getFindings } from '../../../src/api' import * as dateUtils from '../../../src/utils/date' vi.mock('../../../src/api', () => ({ + getTasks: vi.fn(() => Promise.resolve({ tasks: [] })), + getTaskResult: vi.fn(() => Promise.resolve({ findings: [] })), getFindings: vi.fn(), API_BASE: 'http://127.0.0.1:8000', })) From 8ded186b21f846e7f038cf12df7053e4b4934603 Mon Sep 17 00:00:00 2001 From: aaniya22 Date: Sun, 31 May 2026 19:01:15 +0530 Subject: [PATCH 3/3] fix: address review feedback on scan history sidebar (#276) - Fix design tokens in ScanHistory to match SecuScan styling - Replace replacement-character separator with middle dot - Preserve selectedFindingId reset when switching scans - Add focused tests for ScanHistory scan selection --- frontend/src/components/ScanHistory.tsx | 18 ++-- frontend/src/pages/Findings.tsx | 17 ++-- frontend/testing/unit/pages/Findings.test.tsx | 90 ++++++++++++++++++- 3 files changed, 106 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/ScanHistory.tsx b/frontend/src/components/ScanHistory.tsx index 74946f68..6da4e8cd 100644 --- a/frontend/src/components/ScanHistory.tsx +++ b/frontend/src/components/ScanHistory.tsx @@ -27,7 +27,7 @@ export function ScanHistory({ onSelect, activeTaskId }: Props) { if (history.length === 0) { return ( -
+
No past scans found.
); @@ -35,23 +35,23 @@ export function ScanHistory({ onSelect, activeTaskId }: Props) { return (
-

- Scan History -

+

+ Load Past Scan +

{history.map((scan) => (