AI-powered assignment generation with enriched data and streaming UI
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m19s
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m19s
- Add aiPreview mutation with full project/juror data (bios, descriptions, documents, categories, ocean issues, countries, team sizes) - Increase AI description limit from 300 to 2000 chars for richer context - Update GPT system prompt to use all available data fields - Add mode toggle (AI default / Algorithm fallback) in assignment preview - Lift AI mutation to parent page for background generation persistence - Show visual indicator on page while AI generates (spinner + progress card) - Toast notification with "Review" action when AI completes - Staggered reveal animation for assignment results (streaming feel) - Fix assignment balance with dynamic penalty (25pts per existing assignment) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useParams, useRouter } from 'next/navigation'
|
||||
import { ArrowLeft, PlayCircle } from 'lucide-react'
|
||||
import { ArrowLeft, Loader2, PlayCircle, Zap } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { trpc } from '@/lib/trpc/client'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
@@ -26,6 +27,16 @@ export default function AssignmentsDashboardPage() {
|
||||
const [selectedRoundId, setSelectedRoundId] = useState<string>('')
|
||||
const [previewSheetOpen, setPreviewSheetOpen] = useState(false)
|
||||
|
||||
const aiAssignmentMutation = trpc.roundAssignment.aiPreview.useMutation({
|
||||
onSuccess: () => {
|
||||
toast.success('AI assignments ready!', {
|
||||
action: { label: 'Review', onClick: () => setPreviewSheetOpen(true) },
|
||||
duration: 10000,
|
||||
})
|
||||
},
|
||||
onError: (err) => toast.error(`AI generation failed: ${err.message}`),
|
||||
})
|
||||
|
||||
const { data: competition, isLoading: isLoadingCompetition } = trpc.competition.getById.useQuery({
|
||||
id: competitionId,
|
||||
})
|
||||
@@ -104,11 +115,24 @@ export default function AssignmentsDashboardPage() {
|
||||
|
||||
{selectedRoundId && (
|
||||
<div className="space-y-6">
|
||||
<div className="flex justify-end">
|
||||
<Button onClick={() => setPreviewSheetOpen(true)}>
|
||||
<PlayCircle className="mr-2 h-4 w-4" />
|
||||
Generate Assignments
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button
|
||||
onClick={() => {
|
||||
aiAssignmentMutation.mutate({ roundId: selectedRoundId, requiredReviews })
|
||||
}}
|
||||
disabled={aiAssignmentMutation.isPending}
|
||||
>
|
||||
{aiAssignmentMutation.isPending ? (
|
||||
<><Loader2 className="mr-2 h-4 w-4 animate-spin" />Generating...</>
|
||||
) : (
|
||||
<><Zap className="mr-2 h-4 w-4" />{aiAssignmentMutation.data ? 'Regenerate' : 'Generate with AI'}</>
|
||||
)}
|
||||
</Button>
|
||||
{aiAssignmentMutation.data && (
|
||||
<Button variant="outline" onClick={() => setPreviewSheetOpen(true)}>
|
||||
Review Assignments
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Tabs defaultValue="coverage" className="w-full">
|
||||
@@ -170,6 +194,10 @@ export default function AssignmentsDashboardPage() {
|
||||
open={previewSheetOpen}
|
||||
onOpenChange={setPreviewSheetOpen}
|
||||
requiredReviews={requiredReviews}
|
||||
aiResult={aiAssignmentMutation.data ?? null}
|
||||
isAIGenerating={aiAssignmentMutation.isPending}
|
||||
onGenerateAI={() => aiAssignmentMutation.mutate({ roundId: selectedRoundId, requiredReviews })}
|
||||
onResetAI={() => aiAssignmentMutation.reset()}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user