fix: KB Accelerator tree builder, approve all, canvas delete button

- Fix _build_troubleshooting_tree() to handle deep nesting, warning nodes,
  and DAG deduplication (placed set prevents duplicate IDs)
- Fix step_sync VARCHAR(255) overflow on publish by truncating title
- Add "Approve All" button to KB review screen
- Add delete button (hover-reveal) to flow canvas nodes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-03-11 01:59:03 -04:00
parent 71ff4a8c35
commit 91d2bc6df3
9 changed files with 143 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
import { memo } from 'react'
import { Handle, Position, type NodeProps } from '@xyflow/react'
import { HelpCircle, Zap, CheckCircle, ChevronDown, ChevronRight, AlertCircle } from 'lucide-react'
import { HelpCircle, Zap, CheckCircle, ChevronDown, ChevronRight, AlertCircle, Trash2 } from 'lucide-react'
import { cn } from '@/lib/utils'
import type { TreeStructure, NodeType } from '@/types'
@@ -40,14 +40,16 @@ export interface FlowCanvasNodeData {
isCollapsed: boolean
hasValidationErrors: boolean
isNew: boolean
isRoot: boolean
onToggleCollapse: (nodeId: string) => void
onDelete?: (nodeId: string) => void
onContextMenu?: (e: React.MouseEvent, nodeId: string) => void
onAcceptSuggestion?: (nodeId: string) => void
onDismissSuggestion?: (nodeId: string) => void
}
function FlowCanvasNodeComponent({ data, selected }: NodeProps) {
const { node, hasChildren, isCollapsed, hasValidationErrors, isNew, onToggleCollapse, onContextMenu, onAcceptSuggestion, onDismissSuggestion } = data as unknown as FlowCanvasNodeData
const { node, hasChildren, isCollapsed, hasValidationErrors, isNew, isRoot, onToggleCollapse, onDelete, onContextMenu, onAcceptSuggestion, onDismissSuggestion } = data as unknown as FlowCanvasNodeData
const isGhost = !!(node as unknown as Record<string, unknown>)._suggestion
const nodeType = node.type as Exclude<NodeType, 'answer'>
const config = NODE_TYPE_CONFIG[nodeType] ?? NODE_TYPE_CONFIG.decision
@@ -67,7 +69,7 @@ function FlowCanvasNodeComponent({ data, selected }: NodeProps) {
<div
onContextMenu={(e) => onContextMenu?.(e, node.id)}
className={cn(
'w-[280px] rounded-xl border border-border bg-card shadow-xs cursor-pointer transition-all',
'group w-[280px] rounded-xl border border-border bg-card shadow-xs cursor-pointer transition-all',
config.borderClass,
selected && 'ring-1 ring-primary shadow-md',
isGhost && 'border-dashed border-primary/40! opacity-60'
@@ -94,6 +96,21 @@ function FlowCanvasNodeComponent({ data, selected }: NodeProps) {
{hasValidationErrors && (
<AlertCircle className="h-3.5 w-3.5 shrink-0 text-red-400" />
)}
{/* Delete button — visible on hover, hidden for root */}
{!isRoot && !isGhost && onDelete && (
<button
type="button"
onClick={(e) => {
e.stopPropagation()
onDelete(node.id)
}}
className="shrink-0 rounded-md p-1 text-muted-foreground opacity-0 group-hover:opacity-100 hover:bg-red-500/20 hover:text-red-400 transition-all"
title="Delete node"
>
<Trash2 className="h-3.5 w-3.5" />
</button>
)}
</div>
{/* Decision options preview */}