Address greptile review feedback (greploop iteration 2)

- Memoize promptsForSource with useMemo for consistency
- Extract getTestSourceOptions to pipeline_utils.tsx, removing
  direct getFrameworks import from pipeline_test_drawer.tsx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-03-23 22:31:58 -07:00
parent c397bc83fc
commit 23a9a4190b
2 changed files with 11 additions and 7 deletions

View file

@ -4,12 +4,12 @@ import { Button } from "@tremor/react";
import { GuardrailPipeline, PipelineStep, PipelineTestResult } from "./types";
import { testPipelineCall } from "../networking";
import type { CompliancePrompt } from "../../data/compliancePrompts";
import { getFrameworks } from "../../data/compliancePrompts";
import {
TEST_SOURCE_QUICK,
TEST_SOURCE_ALL,
ACTION_LABELS,
getPromptsForTestSource,
getTestSourceOptions,
complianceMatchExpected,
} from "./pipeline_utils";
@ -62,14 +62,10 @@ export const PipelineTestPanel: React.FC<PipelineTestPanelProps> = ({
const [error, setError] = useState<string | null>(null);
const [complianceResults, setComplianceResults] = useState<ComplianceRunEntry[]>([]);
const testSourceOptions = useMemo(() => [
{ value: TEST_SOURCE_QUICK, label: "Quick chat (custom message)" },
...getFrameworks().map((f) => ({ value: f.name, label: f.name })),
{ value: TEST_SOURCE_ALL, label: "All compliance datasets" },
], []);
const testSourceOptions = useMemo(() => getTestSourceOptions(), []);
const isQuickChat = testSource === TEST_SOURCE_QUICK;
const promptsForSource = getPromptsForTestSource(testSource);
const promptsForSource = useMemo(() => getPromptsForTestSource(testSource), [testSource]);
const isDataset = promptsForSource.length > 0;
const handleRunTest = async () => {

View file

@ -37,6 +37,14 @@ export function getPromptsForTestSource(source: string): CompliancePrompt[] {
return fw ? fw.categories.flatMap((c) => c.prompts) : [];
}
export function getTestSourceOptions(): { value: string; label: string }[] {
return [
{ value: TEST_SOURCE_QUICK, label: "Quick chat (custom message)" },
...getFrameworks().map((f) => ({ value: f.name, label: f.name })),
{ value: TEST_SOURCE_ALL, label: "All compliance datasets" },
];
}
export function createDefaultStep(): PipelineStep {
return {
guardrail: "",