Fix React hook anti-patterns, incorrect mock paths, and unused code

- Replace useState+useEffect sync pattern with useMemo in
  EdgeSettingsPanel.tsx to eliminate cascading re-renders
- Remove redundant draft state in NodeSettingsPanel.tsx and use
  store data directly, eliminating useEffect sync loop
- Fix mock paths in test_tools.py: patch tavily.TavilyClient and
  pypdf.PdfReader at their source modules (lazy imports)
- Remove unused variable assignment in routes.py (god mode reject)
- Remove unused node_lookup dicts in dynamic_graph_builder.py
- Remove unused imports across test files (Blueprint, CouncilState,
  pytest, llm assignments)
- Remove unused CouncilBlueprint type import in types.test.ts
- Run npm audit fix to resolve moderate vulnerability

All 107 backend tests and 26 frontend tests pass. Ruff, ESLint,
and TypeScript checks are clean.

https://claude.ai/code/session_01XqzyT6fhS8sUe9P5fCmuVU
This commit is contained in:
Claude 2026-02-22 10:29:54 +00:00
parent fb0d3ae8f1
commit 7becffcc89
No known key found for this signature in database
11 changed files with 2332 additions and 65 deletions

View file

@ -1,6 +1,6 @@
"use client";
import { useEffect, useState } from "react";
import { useMemo } from "react";
import { X, ArrowRight } from "lucide-react";
import { EdgeType } from "@/app/types/council";
import { useCouncilStore } from "@/app/store/council-store";
@ -15,15 +15,15 @@ export function EdgeSettingsPanel() {
const edge = edges.find((e) => e.id === selectedEdgeId);
const [edgeType, setEdgeType] = useState<EdgeType>("linear");
const [condition, setCondition] = useState("");
useEffect(() => {
if (edge) {
setEdgeType((edge.data?.type as EdgeType) ?? "linear");
setCondition((edge.data?.condition as string) ?? "");
}
}, [selectedEdgeId, edge]);
// Derive state directly from the store instead of syncing via useEffect
const edgeType = useMemo(
() => (edge?.data?.type as EdgeType) ?? "linear",
[edge?.data?.type]
);
const condition = useMemo(
() => (edge?.data?.condition as string) ?? "",
[edge?.data?.condition]
);
if (!selectedEdgeId || !edge) return null;
@ -31,12 +31,10 @@ export function EdgeSettingsPanel() {
const targetNode = nodes.find((n) => n.id === edge.target);
const handleTypeChange = (newType: EdgeType) => {
setEdgeType(newType);
updateEdgeData(selectedEdgeId, newType, newType === "conditional" ? condition : undefined);
};
const handleConditionChange = (value: string) => {
setCondition(value);
updateEdgeData(selectedEdgeId, edgeType, value);
};