feat(dashboard): show each clip's score and lead with the best one
The detail pass has always returned a predicted_score per clip and the dashboard threw it away, rendering the clips in transcript order. That buries the strongest clip wherever it happens to fall in the video, and the first card is the one people actually watch, publish and judge the product by. The cards are now ordered by score, and each one carries its number. The ORIGINAL array position is what still travels down as `index`: it is the clip's identity in clip_index on /api/subtitle, /api/edit and publishing, in the clip-N.mp4 download name and in the saved per-clip project state. Sorting the array itself would have repointed all of that at the wrong clip, silently. So the badge keeps saying "Clip 4" at the top of the list rather than "Clip 1" — the number identifies the file you download, the position tells you what to post first. Ties and clips with no score keep transcript order. Claude-Session: https://claude.ai/code/session_01KeQYCfUX2E9Q2fDgZMKEaJ
This commit is contained in:
parent
2a84049c4a
commit
6f9c01e2c6
2 changed files with 38 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useEffect, useRef } from 'react';
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||||
import { Upload, Sparkles, Youtube, Instagram, Share2, ChevronDown, Check, Activity, LayoutDashboard, Settings, Plus, History, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound, Bot, Users, Smartphone, ExternalLink, Copy, CheckCircle2, Mail, Loader2, Download, Menu } from 'lucide-react';
|
import { Upload, Sparkles, Youtube, Instagram, Share2, ChevronDown, Check, Activity, LayoutDashboard, Settings, Plus, History, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound, Bot, Users, Smartphone, ExternalLink, Copy, CheckCircle2, Mail, Loader2, Download, Menu } from 'lucide-react';
|
||||||
import KeyInput from './components/KeyInput';
|
import KeyInput from './components/KeyInput';
|
||||||
import MediaInput from './components/MediaInput';
|
import MediaInput from './components/MediaInput';
|
||||||
|
|
@ -242,6 +242,27 @@ function App() {
|
||||||
const [jobId, setJobId] = useState(null);
|
const [jobId, setJobId] = useState(null);
|
||||||
const [status, setStatus] = useState('idle'); // idle, processing, complete, error
|
const [status, setStatus] = useState('idle'); // idle, processing, complete, error
|
||||||
const [results, setResults] = useState(null);
|
const [results, setResults] = useState(null);
|
||||||
|
// Best clips first. The backend hands them back in transcript order, which
|
||||||
|
// buries the strongest one wherever it happens to fall in the video — and
|
||||||
|
// the first card is the one people actually watch and publish.
|
||||||
|
//
|
||||||
|
// The ORIGINAL array position travels with each clip and is what gets passed
|
||||||
|
// down as `index`: it is the clip's identity everywhere else (clip_index on
|
||||||
|
// /api/subtitle, /api/edit and publishing, the clip-N.mp4 download name, the
|
||||||
|
// saved per-clip project state). Sorting the array itself would silently
|
||||||
|
// repoint all of that at the wrong clip.
|
||||||
|
const rankedClips = useMemo(() => {
|
||||||
|
const clips = results?.clips;
|
||||||
|
if (!Array.isArray(clips)) return [];
|
||||||
|
return clips
|
||||||
|
.map((clip, index) => ({ clip, index }))
|
||||||
|
.sort((a, b) => {
|
||||||
|
const sa = Number.isFinite(a.clip?.predicted_score) ? a.clip.predicted_score : -1;
|
||||||
|
const sb = Number.isFinite(b.clip?.predicted_score) ? b.clip.predicted_score : -1;
|
||||||
|
// Ties (and clips with no score at all) keep transcript order.
|
||||||
|
return sb - sa || a.index - b.index;
|
||||||
|
});
|
||||||
|
}, [results]);
|
||||||
// Bulk subtitles: apply one style to every clip of the job (triggered from
|
// Bulk subtitles: apply one style to every clip of the job (triggered from
|
||||||
// within a clip's subtitle modal via "apply to all").
|
// within a clip's subtitle modal via "apply to all").
|
||||||
const [bulkSub, setBulkSub] = useState({ running: false, current: 0, total: 0, errors: 0 });
|
const [bulkSub, setBulkSub] = useState({ running: false, current: 0, total: 0, errors: 0 });
|
||||||
|
|
@ -1845,7 +1866,7 @@ function App() {
|
||||||
<div className="flex-1 overflow-y-auto custom-scrollbar p-1">
|
<div className="flex-1 overflow-y-auto custom-scrollbar p-1">
|
||||||
{results && results.clips && results.clips.length > 0 ? (
|
{results && results.clips && results.clips.length > 0 ? (
|
||||||
<div className={`grid gap-4 pb-10 ${status === 'complete' ? 'grid-cols-1 xl:grid-cols-2' : 'grid-cols-1'}`}>
|
<div className={`grid gap-4 pb-10 ${status === 'complete' ? 'grid-cols-1 xl:grid-cols-2' : 'grid-cols-1'}`}>
|
||||||
{results.clips.map((clip, i) => (
|
{rankedClips.map(({ clip, index: i }) => (
|
||||||
<ResultCard
|
<ResultCard
|
||||||
key={`${jobId}-${i}-${clip.video_url || ''}`}
|
key={`${jobId}-${i}-${clip.video_url || ''}`}
|
||||||
clip={clip}
|
clip={clip}
|
||||||
|
|
|
||||||
|
|
@ -772,9 +772,24 @@ export default function ResultCard({ clip, index, jobId, durable, uploadPostKey,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="absolute top-3 left-3 flex gap-2">
|
<div className="absolute top-3 left-3 flex gap-2">
|
||||||
|
{/* Stays the clip's own number, not its rank: the cards are
|
||||||
|
ordered by score, but this is what the downloaded file
|
||||||
|
is called (clip-N.mp4) and what every api call indexes. */}
|
||||||
<span className="bg-black/70 text-ink font-mono text-micro uppercase px-2 py-1 rounded-full">
|
<span className="bg-black/70 text-ink font-mono text-micro uppercase px-2 py-1 rounded-full">
|
||||||
Clip {index + 1}
|
Clip {index + 1}
|
||||||
</span>
|
</span>
|
||||||
|
{Number.isFinite(clip.predicted_score) && (
|
||||||
|
<span
|
||||||
|
className={`bg-black/70 font-mono text-micro uppercase px-2 py-1 rounded-full ${
|
||||||
|
clip.predicted_score >= 80 ? 'text-ok'
|
||||||
|
: clip.predicted_score >= 65 ? 'text-brass'
|
||||||
|
: 'text-muted'
|
||||||
|
}`}
|
||||||
|
title="how viral the ai predicts this clip is, 0-100"
|
||||||
|
>
|
||||||
|
{clip.predicted_score}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Auto Edit Overlay if Processing */}
|
{/* Auto Edit Overlay if Processing */}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue