Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
remove autoprune
Browse files
src/components/filtering-panel.tsx
CHANGED
|
@@ -40,102 +40,6 @@ function FlagAllBtn({ ids, label }: { ids: number[]; label?: string }) {
|
|
| 40 |
);
|
| 41 |
}
|
| 42 |
|
| 43 |
-
// βββ Auto-Prune ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 44 |
-
|
| 45 |
-
function AutoPruneSection({ data }: { data: CrossEpisodeVarianceData }) {
|
| 46 |
-
const { addMany } = useFlaggedEpisodes();
|
| 47 |
-
const [pct, setPct] = useState(5);
|
| 48 |
-
const [copied, setCopied] = useState(false);
|
| 49 |
-
|
| 50 |
-
const result = useMemo(() => {
|
| 51 |
-
const allIds = new Set<number>();
|
| 52 |
-
const movementMap = new Map<number, number>();
|
| 53 |
-
const jerkyMap = new Map<number, number>();
|
| 54 |
-
|
| 55 |
-
for (const e of data.speedDistribution) { allIds.add(e.episodeIndex); movementMap.set(e.episodeIndex, e.speed); }
|
| 56 |
-
for (const e of data.jerkyEpisodes) { allIds.add(e.episodeIndex); jerkyMap.set(e.episodeIndex, e.meanAbsDelta); }
|
| 57 |
-
if (allIds.size === 0) return null;
|
| 58 |
-
|
| 59 |
-
const normalize = (map: Map<number, number>, invert: boolean) => {
|
| 60 |
-
const vals = [...map.values()];
|
| 61 |
-
if (vals.length === 0) return map;
|
| 62 |
-
const min = Math.min(...vals), max = Math.max(...vals);
|
| 63 |
-
const range = max - min || 1;
|
| 64 |
-
const out = new Map<number, number>();
|
| 65 |
-
for (const [k, v] of map) out.set(k, invert ? 1 - (v - min) / range : (v - min) / range);
|
| 66 |
-
return out;
|
| 67 |
-
};
|
| 68 |
-
|
| 69 |
-
const movNorm = normalize(movementMap, true);
|
| 70 |
-
const jerkNorm = normalize(jerkyMap, false);
|
| 71 |
-
|
| 72 |
-
const scored = [...allIds].map(id => {
|
| 73 |
-
let score = 0, weights = 0;
|
| 74 |
-
if (movNorm.has(id)) { score += movNorm.get(id)!; weights++; }
|
| 75 |
-
if (jerkNorm.has(id)) { score += jerkNorm.get(id)!; weights++; }
|
| 76 |
-
return { id, score: weights > 0 ? score / weights : 0 };
|
| 77 |
-
}).sort((a, b) => b.score - a.score);
|
| 78 |
-
|
| 79 |
-
const n = Math.max(1, Math.round(scored.length * pct / 100));
|
| 80 |
-
return { scored, pruneIds: scored.slice(0, n).map(s => s.id), total: scored.length };
|
| 81 |
-
}, [data, pct]);
|
| 82 |
-
|
| 83 |
-
if (!result) return null;
|
| 84 |
-
|
| 85 |
-
const handleCopy = () => {
|
| 86 |
-
navigator.clipboard.writeText(result.pruneIds.join(", "));
|
| 87 |
-
setCopied(true);
|
| 88 |
-
setTimeout(() => setCopied(false), 1500);
|
| 89 |
-
};
|
| 90 |
-
|
| 91 |
-
return (
|
| 92 |
-
<div className="bg-slate-800/60 rounded-lg p-5 border border-orange-500/30 space-y-4">
|
| 93 |
-
<div>
|
| 94 |
-
<h3 className="text-sm font-semibold text-orange-400">Auto-Prune</h3>
|
| 95 |
-
<p className="text-xs text-slate-400 mt-1">
|
| 96 |
-
Automatically identify the worst episodes based on a composite score combining:
|
| 97 |
-
low movement (Β½) and jerkiness (Β½).
|
| 98 |
-
Each metric is min-max normalized to [0,1] and averaged.
|
| 99 |
-
</p>
|
| 100 |
-
</div>
|
| 101 |
-
|
| 102 |
-
<div className="flex items-center gap-4">
|
| 103 |
-
<label className="text-xs text-slate-400 shrink-0">Prune worst</label>
|
| 104 |
-
<input type="range" min={1} max={50} value={pct} onChange={e => setPct(Number(e.target.value))}
|
| 105 |
-
className="flex-1 h-1.5 rounded appearance-none bg-slate-700 accent-orange-500" />
|
| 106 |
-
<span className="text-sm font-bold text-orange-400 tabular-nums w-10 text-right">{pct}%</span>
|
| 107 |
-
</div>
|
| 108 |
-
|
| 109 |
-
<div className="flex items-center justify-between">
|
| 110 |
-
<p className="text-xs text-slate-400">
|
| 111 |
-
{result.pruneIds.length} episode{result.pruneIds.length !== 1 ? "s" : ""} out of {result.total} scored
|
| 112 |
-
</p>
|
| 113 |
-
<div className="flex items-center gap-2">
|
| 114 |
-
<button onClick={handleCopy}
|
| 115 |
-
className="text-xs text-slate-400 hover:text-slate-200 transition-colors flex items-center gap-1">
|
| 116 |
-
{copied ? (
|
| 117 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="text-green-400"><polyline points="20 6 9 17 4 12" /></svg>
|
| 118 |
-
) : (
|
| 119 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><rect x="9" y="9" width="13" height="13" rx="2" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" /></svg>
|
| 120 |
-
)}
|
| 121 |
-
Copy IDs
|
| 122 |
-
</button>
|
| 123 |
-
<button onClick={() => addMany(result.pruneIds)}
|
| 124 |
-
className="text-xs bg-orange-500/20 text-orange-400 border border-orange-500/40 rounded px-2 py-1 hover:bg-orange-500/30 transition-colors">
|
| 125 |
-
Flag all {result.pruneIds.length}
|
| 126 |
-
</button>
|
| 127 |
-
</div>
|
| 128 |
-
</div>
|
| 129 |
-
|
| 130 |
-
<div className="bg-slate-900/70 rounded-md border border-slate-700 p-3 max-h-32 overflow-y-auto">
|
| 131 |
-
<p className="text-xs text-slate-300 tabular-nums leading-relaxed">
|
| 132 |
-
{result.pruneIds.sort((a, b) => a - b).join(", ")}
|
| 133 |
-
</p>
|
| 134 |
-
</div>
|
| 135 |
-
</div>
|
| 136 |
-
);
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
// βββ Lowest-Movement Episodes ββββββββββββββββββββββββββββββββββββ
|
| 140 |
|
| 141 |
function LowMovementSection({ episodes }: { episodes: LowMovementEpisode[] }) {
|
|
@@ -321,8 +225,6 @@ const FilteringPanel: React.FC<FilteringPanelProps> = ({
|
|
| 321 |
|
| 322 |
<FlaggedIdsCopyBar repoId={repoId} onViewEpisodes={onViewFlaggedEpisodes} />
|
| 323 |
|
| 324 |
-
{crossEpisodeData && <AutoPruneSection data={crossEpisodeData} />}
|
| 325 |
-
|
| 326 |
{episodeLengthStats?.allEpisodeLengths && (
|
| 327 |
<EpisodeLengthFilter episodes={episodeLengthStats.allEpisodeLengths} />
|
| 328 |
)}
|
|
|
|
| 40 |
);
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
// βββ Lowest-Movement Episodes ββββββββββββββββββββββββββββββββββββ
|
| 44 |
|
| 45 |
function LowMovementSection({ episodes }: { episodes: LowMovementEpisode[] }) {
|
|
|
|
| 225 |
|
| 226 |
<FlaggedIdsCopyBar repoId={repoId} onViewEpisodes={onViewFlaggedEpisodes} />
|
| 227 |
|
|
|
|
|
|
|
| 228 |
{episodeLengthStats?.allEpisodeLengths && (
|
| 229 |
<EpisodeLengthFilter episodes={episodeLengthStats.allEpisodeLengths} />
|
| 230 |
)}
|