AI shortlist with approve/reject, assignment reasoning, fix review count badge
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

- Rewrite AIRecommendationsDisplay: show project titles, per-project
  checkboxes, Apply and Mark as Passed button with batch transition
- Show AI jury assignment reasoning directly in rows (not tooltip)
- Fix unassigned projects badge using requiredReviews instead of hardcoded 3
- Add aiParseFiles to EvaluationConfigSchema

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-18 15:11:20 +01:00
parent cab311fbbb
commit 7e85348a6d
3 changed files with 172 additions and 76 deletions

View File

@@ -1293,7 +1293,13 @@ export default function RoundDetailPage() {
{aiRecommendations && ( {aiRecommendations && (
<AIRecommendationsDisplay <AIRecommendationsDisplay
recommendations={aiRecommendations} recommendations={aiRecommendations}
projectStates={projectStates}
roundId={roundId}
onClear={() => setAiRecommendations(null)} onClear={() => setAiRecommendations(null)}
onApplied={() => {
setAiRecommendations(null)
utils.roundEngine.getProjectStates.invalidate({ roundId })
}}
/> />
)} )}
@@ -2079,7 +2085,7 @@ function RoundUnassignedQueue({ roundId, requiredReviews = 3 }: { roundId: strin
? 'bg-red-50 text-red-700 border-red-200' ? 'bg-red-50 text-red-700 border-red-200'
: 'bg-amber-50 text-amber-700 border-amber-200', : 'bg-amber-50 text-amber-700 border-amber-200',
)}> )}>
{project.assignmentCount || 0} / 3 {project.assignmentCount || 0} / {requiredReviews}
</Badge> </Badge>
</div> </div>
))} ))}
@@ -3033,12 +3039,75 @@ type RecommendationItem = {
function AIRecommendationsDisplay({ function AIRecommendationsDisplay({
recommendations, recommendations,
projectStates,
roundId,
onClear, onClear,
onApplied,
}: { }: {
recommendations: { STARTUP: RecommendationItem[]; BUSINESS_CONCEPT: RecommendationItem[] } recommendations: { STARTUP: RecommendationItem[]; BUSINESS_CONCEPT: RecommendationItem[] }
projectStates: any[] | undefined
roundId: string
onClear: () => void onClear: () => void
onApplied: () => void
}) { }) {
const [expandedId, setExpandedId] = useState<string | null>(null) const [expandedId, setExpandedId] = useState<string | null>(null)
const [applying, setApplying] = useState(false)
// Initialize selected with all recommended project IDs
const allRecommendedIds = useMemo(() => {
const ids = new Set<string>()
for (const item of recommendations.STARTUP) ids.add(item.projectId)
for (const item of recommendations.BUSINESS_CONCEPT) ids.add(item.projectId)
return ids
}, [recommendations])
const [selectedIds, setSelectedIds] = useState<Set<string>>(() => new Set(allRecommendedIds))
// Build projectId → title map from projectStates
const projectTitleMap = useMemo(() => {
const map = new Map<string, string>()
if (projectStates) {
for (const ps of projectStates) {
if (ps.project?.id && ps.project?.title) {
map.set(ps.project.id, ps.project.title)
}
}
}
return map
}, [projectStates])
const transitionMutation = trpc.roundEngine.transitionProject.useMutation()
const toggleProject = (projectId: string) => {
setSelectedIds((prev) => {
const next = new Set(prev)
if (next.has(projectId)) next.delete(projectId)
else next.add(projectId)
return next
})
}
const selectedStartups = recommendations.STARTUP.filter((item) => selectedIds.has(item.projectId)).length
const selectedConcepts = recommendations.BUSINESS_CONCEPT.filter((item) => selectedIds.has(item.projectId)).length
const handleApply = async () => {
setApplying(true)
try {
// Transition all selected projects to PASSED
const promises = Array.from(selectedIds).map((projectId) =>
transitionMutation.mutateAsync({ projectId, roundId, newState: 'PASSED' }).catch(() => {
// Project might already be PASSED — that's OK
})
)
await Promise.all(promises)
toast.success(`Marked ${selectedIds.size} project(s) as passed`)
onApplied()
} catch (error) {
toast.error('Failed to apply recommendations')
} finally {
setApplying(false)
}
}
const renderCategory = (label: string, items: RecommendationItem[], colorClass: string) => { const renderCategory = (label: string, items: RecommendationItem[], colorClass: string) => {
if (items.length === 0) return ( if (items.length === 0) return (
@@ -3051,14 +3120,26 @@ function AIRecommendationsDisplay({
<div className="space-y-2"> <div className="space-y-2">
{items.map((item) => { {items.map((item) => {
const isExpanded = expandedId === `${item.category}-${item.projectId}` const isExpanded = expandedId === `${item.category}-${item.projectId}`
const isSelected = selectedIds.has(item.projectId)
const projectTitle = projectTitleMap.get(item.projectId) || item.projectId
return ( return (
<div <div
key={item.projectId} key={item.projectId}
className="border rounded-lg overflow-hidden" className={cn(
'border rounded-lg overflow-hidden transition-colors',
!isSelected && 'opacity-50',
)}
> >
<div className="flex items-center gap-2 p-3">
<Checkbox
checked={isSelected}
onCheckedChange={() => toggleProject(item.projectId)}
className="shrink-0"
/>
<button <button
onClick={() => setExpandedId(isExpanded ? null : `${item.category}-${item.projectId}`)} onClick={() => setExpandedId(isExpanded ? null : `${item.category}-${item.projectId}`)}
className="w-full flex items-center gap-3 p-3 text-left hover:bg-muted/30 transition-colors" className="flex-1 flex items-center gap-3 text-left hover:bg-muted/30 rounded transition-colors min-w-0"
> >
<span className={cn( <span className={cn(
'h-7 w-7 rounded-full flex items-center justify-center text-xs font-bold text-white shrink-0 shadow-sm', 'h-7 w-7 rounded-full flex items-center justify-center text-xs font-bold text-white shrink-0 shadow-sm',
@@ -3067,7 +3148,7 @@ function AIRecommendationsDisplay({
{item.rank} {item.rank}
</span> </span>
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<p className="text-sm font-medium truncate">{item.projectId}</p> <p className="text-sm font-medium truncate">{projectTitle}</p>
<p className="text-xs text-muted-foreground truncate">{item.recommendation}</p> <p className="text-xs text-muted-foreground truncate">{item.recommendation}</p>
</div> </div>
<Badge variant="outline" className="shrink-0 text-xs font-mono"> <Badge variant="outline" className="shrink-0 text-xs font-mono">
@@ -3078,6 +3159,7 @@ function AIRecommendationsDisplay({
isExpanded && 'rotate-180', isExpanded && 'rotate-180',
)} /> )} />
</button> </button>
</div>
{isExpanded && ( {isExpanded && (
<div className="px-3 pb-3 pt-0 space-y-2 border-t bg-muted/10"> <div className="px-3 pb-3 pt-0 space-y-2 border-t bg-muted/10">
<div className="pt-2"> <div className="pt-2">
@@ -3114,7 +3196,7 @@ function AIRecommendationsDisplay({
<div> <div>
<CardTitle className="text-base">AI Shortlist Recommendations</CardTitle> <CardTitle className="text-base">AI Shortlist Recommendations</CardTitle>
<CardDescription> <CardDescription>
Ranked independently per category {recommendations.STARTUP.length} startups, {recommendations.BUSINESS_CONCEPT.length} concepts Ranked independently per category {selectedStartups} of {recommendations.STARTUP.length} startups, {selectedConcepts} of {recommendations.BUSINESS_CONCEPT.length} concepts selected
</CardDescription> </CardDescription>
</div> </div>
<Button variant="ghost" size="sm" onClick={onClear}> <Button variant="ghost" size="sm" onClick={onClear}>
@@ -3123,7 +3205,7 @@ function AIRecommendationsDisplay({
</Button> </Button>
</div> </div>
</CardHeader> </CardHeader>
<CardContent> <CardContent className="space-y-6">
<div className="grid gap-6 lg:grid-cols-2"> <div className="grid gap-6 lg:grid-cols-2">
<div> <div>
<h4 className="text-sm font-semibold mb-3 flex items-center gap-2"> <h4 className="text-sm font-semibold mb-3 flex items-center gap-2">
@@ -3140,6 +3222,24 @@ function AIRecommendationsDisplay({
{renderCategory('Business Concept', recommendations.BUSINESS_CONCEPT, 'bg-purple-500')} {renderCategory('Business Concept', recommendations.BUSINESS_CONCEPT, 'bg-purple-500')}
</div> </div>
</div> </div>
{/* Apply button */}
<div className="flex items-center justify-between pt-4 border-t">
<p className="text-sm text-muted-foreground">
{selectedIds.size} project{selectedIds.size !== 1 ? 's' : ''} will be marked as <strong>Passed</strong>
</p>
<Button
onClick={handleApply}
disabled={selectedIds.size === 0 || applying}
className="bg-[#053d57] hover:bg-[#053d57]/90 text-white"
>
{applying ? (
<><Loader2 className="h-4 w-4 mr-1.5 animate-spin" />Applying...</>
) : (
<><CheckCircle2 className="h-4 w-4 mr-1.5" />Apply &amp; Mark as Passed</>
)}
</Button>
</div>
</CardContent> </CardContent>
</Card> </Card>
) )

View File

@@ -877,10 +877,26 @@ function AssignmentRow({
const a = assignment const a = assignment
return ( return (
<div className="flex items-start gap-2 px-3 py-2 group hover:bg-muted/30 transition-colors border-t first:border-t-0"> <div className="flex items-start gap-2 px-3 py-2.5 group hover:bg-muted/30 transition-colors border-t first:border-t-0">
<div className="flex-1 min-w-0 space-y-1"> <div className="flex-1 min-w-0 space-y-1.5">
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<span className="text-sm font-medium truncate">{a.projectTitle}</span> <span className="text-sm font-medium truncate">{a.projectTitle}</span>
{!a.isManual && a.score > 0 && (
<Badge
variant="outline"
className={cn(
'text-[10px] h-4 px-1 tabular-nums shrink-0',
a.score >= 50
? 'border-green-300 text-green-700'
: a.score >= 25
? 'border-amber-300 text-amber-700'
: 'border-red-300 text-red-700',
)}
>
<Sparkles className="h-2.5 w-2.5 mr-0.5" />
{Math.round(a.score)}
</Badge>
)}
{a.isManual ? ( {a.isManual ? (
<Badge <Badge
variant="outline" variant="outline"
@@ -898,39 +914,17 @@ function AssignmentRow({
) : null} ) : null}
</div> </div>
{/* Score + tags + reasoning */} {/* AI reasoning — displayed directly */}
{!a.isManual && a.reasoning.length > 0 && a.reasoning[0] !== 'Manually added by admin' && (
<p className="text-xs text-muted-foreground leading-relaxed">
{a.reasoning.join(' ')}
</p>
)}
{/* Tags */}
{a.matchingTags.length > 0 && (
<div className="flex flex-wrap items-center gap-1"> <div className="flex flex-wrap items-center gap-1">
{!a.isManual && a.score > 0 && ( {a.matchingTags.slice(0, 4).map((tag) => (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Badge
variant="outline"
className={cn(
'text-[10px] h-4 px-1 tabular-nums',
a.score >= 50
? 'border-green-300 text-green-700'
: a.score >= 25
? 'border-amber-300 text-amber-700'
: 'border-red-300 text-red-700',
)}
>
<Sparkles className="h-2.5 w-2.5 mr-0.5" />
{Math.round(a.score)}
</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" className="max-w-xs">
<p className="font-medium text-xs mb-1">Match Score Breakdown</p>
<ul className="text-xs space-y-0.5">
{a.reasoning.map((r, i) => (
<li key={i}> {r}</li>
))}
</ul>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{a.matchingTags.slice(0, 3).map((tag) => (
<Badge <Badge
key={tag} key={tag}
variant="secondary" variant="secondary"
@@ -940,12 +934,13 @@ function AssignmentRow({
{tag} {tag}
</Badge> </Badge>
))} ))}
{a.matchingTags.length > 3 && ( {a.matchingTags.length > 4 && (
<span className="text-[10px] text-muted-foreground"> <span className="text-[10px] text-muted-foreground">
+{a.matchingTags.length - 3} more +{a.matchingTags.length - 4} more
</span> </span>
)} )}
</div> </div>
)}
{/* Policy violations */} {/* Policy violations */}
{a.policyViolations.length > 0 && ( {a.policyViolations.length > 0 && (

View File

@@ -107,6 +107,7 @@ export const EvaluationConfigSchema = z.object({
aiSummaryEnabled: z.boolean().default(false), aiSummaryEnabled: z.boolean().default(false),
generateAiShortlist: z.boolean().default(false), generateAiShortlist: z.boolean().default(false),
aiParseFiles: z.boolean().default(false),
advancementMode: z advancementMode: z
.enum(['auto_top_n', 'admin_selection', 'ai_recommended']) .enum(['auto_top_n', 'admin_selection', 'ai_recommended'])