Enhance Progression Path Comparison and Slot Evaluation Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m12s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m12s
- Introduced new fields in `ProgressionPathSuggestRequest` for baseline evaluation and incremental scoring, improving the assessment of proposed paths. - Implemented `_apply_slot_diff_to_steps` and `_score_incremental_slot_diffs` functions to manage slot differences and evaluate their impact on quality scores. - Updated `ProgressionGraphEditor` to streamline the match comparison flow, integrating new evaluation parameters and improving user notifications. - Enhanced `ProgressionOptimizeCompareModal` to better display proposed path suggestions, including pro/con evaluations and quality delta metrics. - Refactored utility functions for clearer handling of slot differences and improved overall data management in the progression graph editor.
This commit is contained in:
1 parent
19bbcdaf50
commit
85fccdd093
5 files changed
+1098
-282
No files matched your search
@@ -28,11 +28,13 @@ import {
|
||||
applyEvaluateResponseToDraft,
|
||||
applyGapOfferToDraft,
|
||||
applySelectedCompareSteps,
|
||||
applySelectedSlotSuggestions,
|
||||
applyResolvedStructuredToDraft,
|
||||
buildPlanningArtifactFromDraft,
|
||||
buildProgressionComparePayload,
|
||||
collectGapOffersFromApiResponse,
|
||||
compareSlotDiffs,
|
||||
compareDiffsForDialog,
|
||||
dedupeGapOffersBySlot,
|
||||
draftHasLibrarySlotAssignments,
|
||||
draftRetrievalBoostExerciseIds,
|
||||
@@ -47,7 +49,7 @@ import {
|
||||
patchSlotInDraft,
|
||||
pathQaQualityPercent,
|
||||
planningCatalogContextToApi,
|
||||
recommendedCompareDiffs,
|
||||
rejectedCompareDiffs,
|
||||
removeSlotFromDraft,
|
||||
saveProgressionGraphDraft,
|
||||
setCatalogSelectItems,
|
||||
@@ -491,24 +493,20 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
}
|
||||
}
|
||||
|
||||
const fetchFullMatch = async (synced) =>
|
||||
api.suggestProgressionPath({
|
||||
const runMatchCompareFlow = async (synced, { source = 'match' } = {}) => {
|
||||
setMatchNotice('Pfad bewerten und je Slot passende Verbesserungen prüfen…')
|
||||
const reviewRes = await api.suggestProgressionPath({
|
||||
...buildMatchRequestBase(synced),
|
||||
preserve_slot_assignments: false,
|
||||
unified_slot_review: true,
|
||||
baseline_evaluate_steps: slotsToEvaluateSteps(synced),
|
||||
include_llm_intent: false,
|
||||
include_llm_path_qa: false,
|
||||
auto_rematch_after_qa: false,
|
||||
})
|
||||
setPathQa(reviewRes?.path_qa || null)
|
||||
|
||||
const runMatchCompareFlow = async (synced, { source = 'match' } = {}) => {
|
||||
setMatchNotice('Schritt 1/2: Aktuellen Pfad bewerten…')
|
||||
const baselineRes = await fetchPathEvaluate(synced)
|
||||
setPathQa(baselineRes?.path_qa || null)
|
||||
|
||||
setMatchNotice('Schritt 2/2: Match für alle Slots (Bibliothek + Lücken)…')
|
||||
const matchRes = await fetchFullMatch(synced)
|
||||
|
||||
const compareRes = buildProgressionComparePayload(baselineRes, matchRes)
|
||||
setGapFillOffers(mergeGapOffersForDraft(synced, baselineRes, matchRes))
|
||||
const compareRes = buildProgressionComparePayload(null, reviewRes)
|
||||
setGapFillOffers(mergeGapOffersForDraft(synced, reviewRes, reviewRes))
|
||||
presentMatchCompare(compareRes, { source })
|
||||
return compareRes
|
||||
}
|
||||
@@ -522,31 +520,20 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
setCompareOpen(true)
|
||||
|
||||
const baselineQa = res?.baseline_path_qa || null
|
||||
const proposedQa = res?.proposed_path_qa || res?.path_qa || null
|
||||
const diffCount =
|
||||
res?.slot_diff_count_recommended
|
||||
?? recommendedCompareDiffs(res).length
|
||||
?? res?.slot_diff_count
|
||||
?? compareSlotDiffs(res, { actionableOnly: true }).length
|
||||
const replaceCount = (res?.slot_diffs || []).filter(
|
||||
(d) => d?.diff_kind === 'replace',
|
||||
).length
|
||||
const diffCount = res?.slot_diff_count ?? compareDiffsForDialog(res).length
|
||||
const rejectedCount = res?.slot_diff_count_rejected ?? rejectedCompareDiffs(res).length
|
||||
const bPct = pathQaQualityPercent(baselineQa)
|
||||
const pPct = pathQaQualityPercent(proposedQa)
|
||||
let notice =
|
||||
diffCount > 0
|
||||
? `Match: ${diffCount} Lückenfüllung(en) im Dialog — nur diese sind vorausgewählt.`
|
||||
: 'Match: Keine Bibliotheks-Lückenfüllungen — Dialog zur Kontrolle geöffnet.'
|
||||
if (replaceCount > 0) {
|
||||
notice += ` ${replaceCount} optionale Ersetzung(en) bestehender Slots — standardmäßig abgewählt.`
|
||||
? `Match: ${diffCount} Verbesserung(en) — je Slot gegen deinen Pfad (${bPct != null ? `${bPct} %` : 'QS'}) geprüft.`
|
||||
: 'Match: Keine messbare Verbesserung gegenüber deinem Pfad.'
|
||||
if (rejectedCount > 0) {
|
||||
notice += ` ${rejectedCount} Vorschlag/Vorschläge verworfen (Verschlechterung oder neutral).`
|
||||
}
|
||||
const gapCount = collectGapOffersFromApiResponse(res).length
|
||||
if (gapCount > 0) {
|
||||
notice += ` ${gapCount} KI-Angebot(e) für leere Slots im Panel „Graph-Bewertung“.`
|
||||
}
|
||||
if (bPct != null && pPct != null && pPct !== bPct) {
|
||||
notice += ` Pfad-QS Vorschlag fair bewertet: ${bPct} % → ${pPct} %.`
|
||||
}
|
||||
setMatchNotice(notice)
|
||||
}
|
||||
|
||||
@@ -603,11 +590,13 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
setCompareApplying(true)
|
||||
try {
|
||||
const synced = syncProgressionRoadmapFromSlots(draft)
|
||||
const nextDraft = applySelectedCompareSteps(
|
||||
synced,
|
||||
comparePayload.proposed_steps || comparePayload.steps,
|
||||
selectedMajorIndices,
|
||||
)
|
||||
const nextDraft = comparePayload?.unified_slot_review
|
||||
? applySelectedSlotSuggestions(synced, comparePayload, selectedMajorIndices)
|
||||
: applySelectedCompareSteps(
|
||||
synced,
|
||||
comparePayload.proposed_steps || comparePayload.steps,
|
||||
selectedMajorIndices,
|
||||
)
|
||||
const syncedNext = syncProgressionRoadmapFromSlots(nextDraft)
|
||||
const evalRes = await fetchPathEvaluate(syncedNext)
|
||||
const { draft: evaluated, remainingOffers } = applyEvaluateResult(syncedNext, evalRes)
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/**
|
||||
* Gegenüberstellung: bestehender Pfad vs. optimierter Match-Vorschlag.
|
||||
* Gegenüberstellung: Verbesserungsvorschläge mit Slot-Bewertung (Pro/Contra).
|
||||
*/
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import {
|
||||
compareDiffsForDialog,
|
||||
defaultSelectedCompareDiffs,
|
||||
gapOnlyCompareDiffs,
|
||||
optionalReplaceCompareDiffs,
|
||||
pathQaQualityPercent,
|
||||
recommendedCompareDiffs,
|
||||
qualityDeltaPercent,
|
||||
rejectedCompareDiffs,
|
||||
} from '../utils/progressionGraphDraft'
|
||||
|
||||
function qaLabel(pathQa) {
|
||||
@@ -18,25 +17,44 @@ function qaLabel(pathQa) {
|
||||
return ok ? 'OK' : 'Hinweise'
|
||||
}
|
||||
|
||||
function DiffRow({ diff, checked, onToggle, applying, tone = 'neutral' }) {
|
||||
function deltaLabel(diff) {
|
||||
const pct = qualityDeltaPercent(diff)
|
||||
if (pct == null) return null
|
||||
if (pct > 0) return `+${pct} % Pfad-QS`
|
||||
if (pct === 0) return '±0 % Pfad-QS'
|
||||
return `${pct} % Pfad-QS`
|
||||
}
|
||||
|
||||
function ProContraList({ title, items, tone = 'neutral' }) {
|
||||
if (!items?.length) return null
|
||||
const color =
|
||||
tone === 'pro' ? 'var(--accent-dark)' : tone === 'contra' ? 'var(--danger)' : 'var(--text2)'
|
||||
return (
|
||||
<div style={{ marginTop: '6px' }}>
|
||||
<div style={{ fontSize: '10px', fontWeight: 600, color: 'var(--text3)' }}>{title}</div>
|
||||
<ul style={{ margin: '4px 0 0', paddingLeft: '16px', color, fontSize: '11px' }}>
|
||||
{items.map((text, i) => (
|
||||
<li key={`${title}-${i}`}>{text}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function DiffRow({ diff, checked, onToggle, applying }) {
|
||||
const midx = Number(diff.roadmap_major_step_index)
|
||||
const border =
|
||||
tone === 'warn'
|
||||
? '1px solid color-mix(in srgb, var(--danger) 35%, var(--border))'
|
||||
: '1px solid var(--border)'
|
||||
const bg = checked
|
||||
? tone === 'warn'
|
||||
? 'color-mix(in srgb, var(--danger) 6%, var(--surface2))'
|
||||
: 'var(--surface2)'
|
||||
: 'var(--surface)'
|
||||
const delta = deltaLabel(diff)
|
||||
const pc = diff.pro_contra || {}
|
||||
const isAi = diff.suggestion_type === 'ai_gap' || diff.proposed_is_ai_proposal
|
||||
const isFill = diff.baseline_exercise_id == null && !isAi
|
||||
|
||||
return (
|
||||
<li
|
||||
style={{
|
||||
padding: '10px 12px',
|
||||
borderRadius: '8px',
|
||||
border,
|
||||
background: bg,
|
||||
border: '1px solid var(--border)',
|
||||
background: checked ? 'var(--surface2)' : 'var(--surface)',
|
||||
fontSize: '12px',
|
||||
}}
|
||||
>
|
||||
@@ -49,28 +67,60 @@ function DiffRow({ diff, checked, onToggle, applying, tone = 'neutral' }) {
|
||||
style={{ marginTop: '3px' }}
|
||||
/>
|
||||
<span style={{ flex: 1 }}>
|
||||
<strong>Slot {midx + 1}</strong>
|
||||
{tone === 'warn' ? (
|
||||
<span style={{ marginLeft: '6px', fontSize: '10px', color: 'var(--danger)' }}>
|
||||
Ersetzt deine Zuordnung
|
||||
</span>
|
||||
) : null}
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px', alignItems: 'center' }}>
|
||||
<strong>Slot {midx + 1}</strong>
|
||||
{isFill ? (
|
||||
<span style={{ fontSize: '10px', color: 'var(--accent-dark)' }}>Lücke füllen</span>
|
||||
) : isAi ? (
|
||||
<span style={{ fontSize: '10px', color: 'var(--accent-dark)' }}>KI-Alternative</span>
|
||||
) : diff.off_topic ? (
|
||||
<span style={{ fontSize: '10px', color: 'var(--danger)' }}>Passt nicht — Ersatz</span>
|
||||
) : (
|
||||
<span style={{ fontSize: '10px', color: 'var(--text2)' }}>Bessere Übung</span>
|
||||
)}
|
||||
{delta ? (
|
||||
<span
|
||||
style={{
|
||||
fontSize: '10px',
|
||||
fontWeight: 600,
|
||||
color: qualityDeltaPercent(diff) > 0 ? 'var(--accent-dark)' : 'var(--text2)',
|
||||
}}
|
||||
>
|
||||
{delta}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: '1fr 1fr',
|
||||
gap: '8px',
|
||||
marginTop: '6px',
|
||||
gap: '10px',
|
||||
marginTop: '8px',
|
||||
}}
|
||||
>
|
||||
<span style={{ color: 'var(--text2)' }}>
|
||||
Bisher: {diff.baseline_title || '— leer —'}
|
||||
{diff.baseline_exercise_id != null ? ` (#${diff.baseline_exercise_id})` : ''}
|
||||
</span>
|
||||
<span style={{ color: tone === 'warn' ? 'var(--danger)' : 'var(--accent-dark)' }}>
|
||||
Neu: {diff.proposed_title || '— leer —'}
|
||||
{diff.proposed_exercise_id != null ? ` (#${diff.proposed_exercise_id})` : ''}
|
||||
</span>
|
||||
<div>
|
||||
<div style={{ fontSize: '10px', fontWeight: 600, color: 'var(--text3)', marginBottom: '4px' }}>
|
||||
Aktuell
|
||||
</div>
|
||||
<div style={{ color: 'var(--text2)' }}>
|
||||
{diff.baseline_title || '— leer —'}
|
||||
{diff.baseline_exercise_id != null ? ` (#${diff.baseline_exercise_id})` : ''}
|
||||
</div>
|
||||
<ProContraList title="Pro" items={pc.current_pro} tone="pro" />
|
||||
<ProContraList title="Contra" items={pc.current_contra} tone="contra" />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: '10px', fontWeight: 600, color: 'var(--text3)', marginBottom: '4px' }}>
|
||||
Vorschlag
|
||||
</div>
|
||||
<div style={{ color: 'var(--accent-dark)' }}>
|
||||
{diff.proposed_title || '—'}
|
||||
{diff.proposed_exercise_id != null ? ` (#${diff.proposed_exercise_id})` : isAi ? ' (KI)' : ''}
|
||||
</div>
|
||||
<ProContraList title="Pro" items={pc.proposed_pro} tone="pro" />
|
||||
<ProContraList title="Contra" items={pc.proposed_contra} tone="contra" />
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</label>
|
||||
@@ -86,16 +136,8 @@ export default function ProgressionOptimizeCompareModal({
|
||||
onApplySelected,
|
||||
applying = false,
|
||||
}) {
|
||||
const recommended = useMemo(
|
||||
() => recommendedCompareDiffs(comparison),
|
||||
[comparison],
|
||||
)
|
||||
const optionalReplace = useMemo(
|
||||
() => optionalReplaceCompareDiffs(comparison),
|
||||
[comparison],
|
||||
)
|
||||
const gapOnly = useMemo(() => gapOnlyCompareDiffs(comparison), [comparison])
|
||||
const dialogDiffs = useMemo(() => compareDiffsForDialog(comparison), [comparison])
|
||||
const rejected = useMemo(() => rejectedCompareDiffs(comparison), [comparison])
|
||||
const defaultSelected = useMemo(
|
||||
() => defaultSelectedCompareDiffs(comparison),
|
||||
[comparison],
|
||||
@@ -111,18 +153,8 @@ export default function ProgressionOptimizeCompareModal({
|
||||
if (!open || !comparison) return null
|
||||
|
||||
const baselineQa = comparison.baseline_path_qa
|
||||
const pipelineQa = comparison.proposed_path_qa_pipeline
|
||||
const baselinePct = pathQaQualityPercent(baselineQa)
|
||||
const pipelinePct = pathQaQualityPercent(pipelineQa)
|
||||
const rematchRounds = pipelineQa?.rematch_rounds
|
||||
const rematchCount = Array.isArray(pipelineQa?.rematch_log) ? pipelineQa.rematch_log.length : 0
|
||||
const refineCount = Array.isArray(pipelineQa?.refine_log) ? pipelineQa.refine_log.length : 0
|
||||
const hintCount = Number(pipelineQa?.optimization_hint_count || 0)
|
||||
const tierCount = Array.isArray(pipelineQa?.qa_tiers) ? pipelineQa.qa_tiers.length : 0
|
||||
|
||||
const selectedReplaceCount = optionalReplace.filter((d) =>
|
||||
selected.has(Number(d.roadmap_major_step_index)),
|
||||
).length
|
||||
const rejectedCount = rejected.length
|
||||
|
||||
const toggle = (midx) => {
|
||||
setSelected((prev) => {
|
||||
@@ -133,20 +165,12 @@ export default function ProgressionOptimizeCompareModal({
|
||||
})
|
||||
}
|
||||
|
||||
const toggleGroup = (diffs, on) => {
|
||||
setSelected((prev) => {
|
||||
const next = new Set(prev)
|
||||
for (const d of diffs) {
|
||||
const midx = Number(d.roadmap_major_step_index)
|
||||
if (on) next.add(midx)
|
||||
else next.delete(midx)
|
||||
}
|
||||
return next
|
||||
})
|
||||
const toggleAll = (on) => {
|
||||
setSelected(on ? new Set(dialogDiffs.map((d) => Number(d.roadmap_major_step_index))) : new Set())
|
||||
}
|
||||
|
||||
const title =
|
||||
mode === 'match' ? 'Übungs-Match — Vorschläge prüfen' : 'Optimierung vergleichen'
|
||||
mode === 'match' ? 'Übungs-Match — Verbesserungen' : 'Optimierung vergleichen'
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -161,201 +185,90 @@ export default function ProgressionOptimizeCompareModal({
|
||||
>
|
||||
<div
|
||||
className="card modal-content"
|
||||
style={{ maxWidth: '720px', width: '100%', maxHeight: '90vh', overflow: 'auto' }}
|
||||
style={{ maxWidth: '760px', width: '100%', maxHeight: '90vh', overflow: 'auto' }}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<h3 id="optimize-compare-title" style={{ marginTop: 0 }}>
|
||||
{title}
|
||||
</h3>
|
||||
<p style={{ fontSize: '12px', color: 'var(--text3)', marginTop: 0, lineHeight: 1.45 }}>
|
||||
Übernimm nur, was deinen Pfad verbessert. Leere Slots mit Bibliotheks-Treffer sind
|
||||
vorausgewählt; Ersetzungen bestehender Übungen sind optional und oft schlechter.
|
||||
KI-Entwürfe ohne Bibliotheks-ID gehören ins Panel „KI-Angebote“, nicht hierher.
|
||||
Bewertung und Vorschläge in einem Durchlauf: je Slot wird geprüft, ob eine passendere
|
||||
Übung (Bibliothek oder KI) den Pfad verbessert. Nur messbare Verbesserungen erscheinen
|
||||
hier — mit Pro- und Contra-Punkten auf Slot-Ebene.
|
||||
</p>
|
||||
|
||||
<div
|
||||
style={{
|
||||
marginBottom: '12px',
|
||||
padding: '10px 12px',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid color-mix(in srgb, var(--accent) 30%, var(--border))',
|
||||
background: 'color-mix(in srgb, var(--accent) 6%, var(--surface2))',
|
||||
border: '1px solid var(--border)',
|
||||
background: 'var(--surface2)',
|
||||
fontSize: '12px',
|
||||
lineHeight: 1.45,
|
||||
}}
|
||||
>
|
||||
<strong>Warum nicht einfach alles übernehmen?</strong>
|
||||
<p style={{ margin: '6px 0 0', color: 'var(--text2)' }}>
|
||||
Der Match-Lauf optimiert den <em>gesamten</em> Pfad neu (inkl. Rematch). Das kann
|
||||
bereits gute Slots verschlechtern. Die Prozentzahl rechts bezieht sich auf diesen
|
||||
Ganzpfad — nicht darauf, dass deine Auswahl besser ist. Nimm deshalb standardmäßig
|
||||
nur Lückenfüllungen an.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: '1fr 1fr',
|
||||
gap: '12px',
|
||||
marginBottom: '14px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
padding: '10px 12px',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid var(--border)',
|
||||
background: 'var(--surface2)',
|
||||
fontSize: '12px',
|
||||
}}
|
||||
>
|
||||
<strong>Dein Pfad (bewertet)</strong>
|
||||
<div style={{ marginTop: '6px' }}>{qaLabel(baselineQa)}</div>
|
||||
{baselineQa?.topic_coverage ? (
|
||||
<p style={{ margin: '6px 0 0', color: 'var(--text2)' }}>{baselineQa.topic_coverage}</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
padding: '10px 12px',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid color-mix(in srgb, var(--text3) 35%, var(--border))',
|
||||
background: 'var(--surface2)',
|
||||
fontSize: '12px',
|
||||
}}
|
||||
>
|
||||
<strong>Match-Ganzpfad (nur Info)</strong>
|
||||
<div style={{ marginTop: '6px', color: 'var(--text2)' }}>
|
||||
{pipelineQa ? qaLabel(pipelineQa) : '—'}
|
||||
</div>
|
||||
<p style={{ margin: '6px 0 0', fontSize: '11px', color: 'var(--text3)' }}>
|
||||
Rematch-Prozess — kein Versprechen für deine Checkbox-Auswahl.
|
||||
{pipelinePct != null && baselinePct != null && pipelinePct < baselinePct
|
||||
? ` (${pipelinePct} % < ${baselinePct} % bei voller Übernahme).`
|
||||
: ''}
|
||||
</p>
|
||||
</div>
|
||||
<strong>Dein Pfad</strong>
|
||||
<div style={{ marginTop: '6px' }}>{qaLabel(baselineQa)}</div>
|
||||
{baselineQa?.topic_coverage ? (
|
||||
<p style={{ margin: '6px 0 0', color: 'var(--text2)' }}>{baselineQa.topic_coverage}</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{tierCount > 0 || rematchCount > 0 || refineCount > 0 || hintCount > 0 ? (
|
||||
{rejectedCount > 0 ? (
|
||||
<p style={{ fontSize: '11px', color: 'var(--text2)', margin: '0 0 14px', lineHeight: 1.45 }}>
|
||||
Rematch-Protokoll
|
||||
{tierCount > 0 ? ` · ${tierCount} QS-Stufen` : ''}
|
||||
{rematchCount > 0
|
||||
? ` · ${rematchRounds != null ? `${rematchRounds} Runde(n)` : ''}: ${rematchCount} Anpassung(en)`
|
||||
: ''}
|
||||
{refineCount > 0 ? ` · ${refineCount} Stufen-Spec verfeinert` : ''}
|
||||
{hintCount > 0 ? ` · ${hintCount} Handlungshinweis(e)` : ''}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{gapOnly.length > 0 ? (
|
||||
<p style={{ fontSize: '11px', color: 'var(--text2)', margin: '0 0 14px', lineHeight: 1.45 }}>
|
||||
Slot{gapOnly.length > 1 ? 's' : ''}{' '}
|
||||
{gapOnly.map((d) => Number(d.roadmap_major_step_index) + 1).join(', ')}: kein
|
||||
Bibliotheks-Treffer — bitte „KI-Angebote“ im Panel nutzen (eigenständig pro Slot).
|
||||
{rejectedCount} Alternative(n) verworfen — kein QS-Gewinn gegenüber deinem Pfad
|
||||
{baselinePct != null ? ` (${baselinePct} %)` : ''}.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{dialogDiffs.length === 0 ? (
|
||||
<p style={{ fontSize: '12px', color: 'var(--text2)' }}>
|
||||
Keine übernehmbaren Bibliotheks-Änderungen. Leere Slots ggf. über KI-Angebote im Panel
|
||||
befüllen — nichts am Pfad ändern ist oft die richtige Wahl.
|
||||
Keine Verbesserung gefunden — dein Pfad ist für alle Slots bereits optimal bewertet
|
||||
oder es fehlen passende Bibliotheks-Treffer (KI-Angebote im Bewertungs-Panel).
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
{recommended.length > 0 ? (
|
||||
<>
|
||||
<h4 style={{ margin: '0 0 8px', fontSize: '0.9rem' }}>
|
||||
Lücken füllen (empfohlen)
|
||||
</h4>
|
||||
<div style={{ display: 'flex', gap: '8px', marginBottom: '8px', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px' }}
|
||||
onClick={() => toggleGroup(recommended, true)}
|
||||
>
|
||||
Alle Lücken wählen
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px' }}
|
||||
onClick={() => toggleGroup(recommended, false)}
|
||||
>
|
||||
Keine
|
||||
</button>
|
||||
</div>
|
||||
<ul
|
||||
style={{
|
||||
listStyle: 'none',
|
||||
padding: 0,
|
||||
margin: '0 0 16px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
{recommended.map((diff) => (
|
||||
<DiffRow
|
||||
key={`fill-${diff.roadmap_major_step_index}`}
|
||||
diff={diff}
|
||||
checked={selected.has(Number(diff.roadmap_major_step_index))}
|
||||
onToggle={toggle}
|
||||
applying={applying}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{optionalReplace.length > 0 ? (
|
||||
<>
|
||||
<h4 style={{ margin: '0 0 8px', fontSize: '0.9rem', color: 'var(--danger)' }}>
|
||||
Bestehende Slots ersetzen (optional — oft Verschlechterung)
|
||||
</h4>
|
||||
<p style={{ fontSize: '11px', color: 'var(--text2)', margin: '0 0 8px' }}>
|
||||
Standard: abgewählt. Nur aktivieren, wenn du die konkrete Übung bewusst tauschen
|
||||
willst.
|
||||
</p>
|
||||
<ul
|
||||
style={{
|
||||
listStyle: 'none',
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
{optionalReplace.map((diff) => (
|
||||
<DiffRow
|
||||
key={`replace-${diff.roadmap_major_step_index}`}
|
||||
diff={diff}
|
||||
checked={selected.has(Number(diff.roadmap_major_step_index))}
|
||||
onToggle={toggle}
|
||||
applying={applying}
|
||||
tone="warn"
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
<div style={{ display: 'flex', gap: '8px', marginBottom: '8px', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px' }}
|
||||
onClick={() => toggleAll(true)}
|
||||
>
|
||||
Alle wählen
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px' }}
|
||||
onClick={() => toggleAll(false)}
|
||||
>
|
||||
Keine
|
||||
</button>
|
||||
</div>
|
||||
<ul
|
||||
style={{
|
||||
listStyle: 'none',
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
{dialogDiffs.map((diff) => (
|
||||
<DiffRow
|
||||
key={`improve-${diff.roadmap_major_step_index}-${diff.suggestion_type || 'lib'}`}
|
||||
diff={diff}
|
||||
checked={selected.has(Number(diff.roadmap_major_step_index))}
|
||||
onToggle={toggle}
|
||||
applying={applying}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
|
||||
{selectedReplaceCount > 0 ? (
|
||||
<p
|
||||
className="form-error"
|
||||
style={{ marginTop: '12px', fontSize: '11px' }}
|
||||
>
|
||||
{selectedReplaceCount} Ersetzung(en) gewählt — kann Pfad-QS senken. Lückenfüllungen
|
||||
sind unkritischer.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
|
||||
@@ -997,6 +997,12 @@ export function compareDiffKind(diff) {
|
||||
return 'skip'
|
||||
}
|
||||
|
||||
export function qualityDeltaPercent(diff) {
|
||||
const delta = diff?.quality_delta
|
||||
if (delta == null || !Number.isFinite(Number(delta))) return null
|
||||
return Math.round(Number(delta) * 100)
|
||||
}
|
||||
|
||||
export function annotateCompareDiffKinds(diffs) {
|
||||
return (diffs || []).map((d) => ({
|
||||
...d,
|
||||
@@ -1004,20 +1010,57 @@ export function annotateCompareDiffKinds(diffs) {
|
||||
}))
|
||||
}
|
||||
|
||||
/** Nur übernehmbare Bibliotheks-Diffs (kein reines Titel-/Gap-Geplänkel). */
|
||||
/** Nur übernehmbare Verbesserungsvorschläge (Bibliothek oder KI-Angebot). */
|
||||
export function compareDiffsForDialog(comparison) {
|
||||
const fromSuggestions = (comparison?.slot_suggestions || []).filter((s) => s?.improves_path)
|
||||
if (fromSuggestions.length > 0) {
|
||||
return fromSuggestions
|
||||
.map((s) => ({ ...s, diff_kind: suggestionDiffKind(s) }))
|
||||
.filter(
|
||||
(d) =>
|
||||
d.proposed_exercise_id != null
|
||||
|| (d.suggestion_type === 'ai_gap' && d.gap_offer),
|
||||
)
|
||||
}
|
||||
if (Array.isArray(comparison?.slot_diffs_improving)) {
|
||||
return comparison.slot_diffs_improving.filter(
|
||||
(d) => d?.proposed_exercise_id != null && !d?.trivial_id_swap,
|
||||
)
|
||||
}
|
||||
const diffs = annotateCompareDiffKinds(
|
||||
compareSlotDiffs(comparison, { actionableOnly: true }),
|
||||
)
|
||||
return diffs.filter((d) => d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
return diffs.filter(
|
||||
(d) =>
|
||||
(d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
&& d.proposed_exercise_id != null,
|
||||
)
|
||||
}
|
||||
|
||||
export function suggestionDiffKind(suggestion) {
|
||||
if (!suggestion) return 'skip'
|
||||
if (suggestion.suggestion_type === 'ai_gap') return 'ai_gap'
|
||||
if (suggestion.baseline_exercise_id == null && suggestion.proposed_exercise_id != null) {
|
||||
return 'fill'
|
||||
}
|
||||
if (suggestion.baseline_exercise_id != null && suggestion.proposed_exercise_id != null) {
|
||||
return 'replace'
|
||||
}
|
||||
return 'skip'
|
||||
}
|
||||
|
||||
export function recommendedCompareDiffs(comparison) {
|
||||
return compareDiffsForDialog(comparison).filter((d) => d.diff_kind === 'fill')
|
||||
return compareDiffsForDialog(comparison)
|
||||
}
|
||||
|
||||
export function optionalReplaceCompareDiffs(comparison) {
|
||||
return compareDiffsForDialog(comparison).filter((d) => d.diff_kind === 'replace')
|
||||
return []
|
||||
}
|
||||
|
||||
export function rejectedCompareDiffs(comparison) {
|
||||
return Array.isArray(comparison?.slot_diffs_rejected)
|
||||
? comparison.slot_diffs_rejected
|
||||
: []
|
||||
}
|
||||
|
||||
export function gapOnlyCompareDiffs(comparison) {
|
||||
@@ -1027,7 +1070,7 @@ export function gapOnlyCompareDiffs(comparison) {
|
||||
}
|
||||
|
||||
export function defaultSelectedCompareDiffs(comparison) {
|
||||
return recommendedCompareDiffs(comparison).map((d) => Number(d.roadmap_major_step_index))
|
||||
return compareDiffsForDialog(comparison).map((d) => Number(d.roadmap_major_step_index))
|
||||
}
|
||||
|
||||
function mergeGapFillOffersFromSteps(steps, offers) {
|
||||
@@ -1044,29 +1087,43 @@ function mergeGapFillOffersFromSteps(steps, offers) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Vergleich aus zwei kaskadierten Antworten (Evaluate → Match) — spiegelt Backend-Compare.
|
||||
* Vergleich aus unified_slot_review oder kaskadierten Antworten (Evaluate → Match).
|
||||
*/
|
||||
export function buildProgressionComparePayload(baselineRes, proposedRes) {
|
||||
if (proposedRes?.unified_slot_review) {
|
||||
return buildUnifiedSlotReviewComparePayload(proposedRes)
|
||||
}
|
||||
|
||||
const baselineSteps = Array.isArray(baselineRes?.steps) ? baselineRes.steps : []
|
||||
const proposedSteps = Array.isArray(proposedRes?.steps) ? proposedRes.steps : []
|
||||
const baselineQa = baselineRes?.path_qa || null
|
||||
const pipelineQa = proposedRes?.path_qa || null
|
||||
const slotDiffs = annotateCompareDiffKinds(
|
||||
const scoring = proposedRes?.slot_diff_scoring
|
||||
const rawDiffs = annotateCompareDiffKinds(
|
||||
annotateCompareSlotDiffs(
|
||||
buildProgressionSlotDiffs(baselineSteps, proposedSteps),
|
||||
),
|
||||
)
|
||||
const actionableDiffs = actionableCompareSlotDiffs(slotDiffs)
|
||||
const dialogDiffs = actionableDiffs.filter(
|
||||
(d) => d.diff_kind === 'fill' || d.diff_kind === 'replace',
|
||||
const improvingDiffs = annotateCompareDiffKinds(
|
||||
(scoring?.improvement_diffs || []).filter((d) => d?.proposed_exercise_id != null),
|
||||
)
|
||||
const recommendedDiffs = dialogDiffs.filter((d) => d.diff_kind === 'fill')
|
||||
const rejectedDiffs = annotateCompareDiffKinds(scoring?.rejected_diffs || [])
|
||||
const dialogDiffs = improvingDiffs.length > 0
|
||||
? improvingDiffs
|
||||
: rawDiffs.filter(
|
||||
(d) =>
|
||||
!d.trivial_id_swap
|
||||
&& (d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
&& d.proposed_exercise_id != null
|
||||
&& d.improves_path !== false,
|
||||
)
|
||||
const actionableDiffs = dialogDiffs
|
||||
const gapFillOffers = mergeGapFillOffersFromSteps(
|
||||
proposedSteps,
|
||||
proposedRes?.gap_fill_offers || [],
|
||||
)
|
||||
const proposedQa =
|
||||
actionableDiffs.length === 0 && baselineQa ? baselineQa : pipelineQa
|
||||
const baselineScore = scoring?.baseline_quality_score ?? baselineQa?.quality_score
|
||||
const proposedQa = baselineQa
|
||||
|
||||
return {
|
||||
...proposedRes,
|
||||
@@ -1078,19 +1135,110 @@ export function buildProgressionComparePayload(baselineRes, proposedRes) {
|
||||
proposed_path_qa: proposedQa,
|
||||
proposed_path_qa_pipeline: pipelineQa,
|
||||
gap_fill_offers: gapFillOffers,
|
||||
slot_diffs: slotDiffs,
|
||||
slot_diffs: rawDiffs,
|
||||
slot_diffs_actionable: actionableDiffs,
|
||||
slot_diffs_improving: improvingDiffs,
|
||||
slot_diffs_rejected: rejectedDiffs,
|
||||
slot_diffs_dialog: dialogDiffs,
|
||||
slot_diffs_recommended: recommendedDiffs,
|
||||
slot_diffs_recommended: dialogDiffs,
|
||||
slot_diff_count: dialogDiffs.length,
|
||||
slot_diff_count_recommended: recommendedDiffs.length,
|
||||
slot_diff_count_including_trivial: slotDiffs.length,
|
||||
slot_diffs_source: 'steps',
|
||||
slot_diff_count_recommended: dialogDiffs.length,
|
||||
slot_diff_count_rejected: rejectedDiffs.length,
|
||||
slot_diff_count_including_trivial: rawDiffs.length,
|
||||
slot_diffs_source: scoring ? 'incremental_scoring' : 'steps',
|
||||
slot_diff_scoring: scoring,
|
||||
baseline_quality_score: baselineScore,
|
||||
path_qa: proposedQa,
|
||||
steps: proposedSteps,
|
||||
}
|
||||
}
|
||||
|
||||
/** Einheitlicher Match-Review (Bewertung + Slot-Vorschläge in einem Lauf). */
|
||||
export function buildUnifiedSlotReviewComparePayload(res) {
|
||||
const baselineSteps = Array.isArray(res?.baseline_steps) ? res.baseline_steps : (res?.steps || [])
|
||||
const baselineQa = res?.baseline_path_qa || res?.path_qa || null
|
||||
const scoring = res?.slot_diff_scoring
|
||||
const suggestions = Array.isArray(res?.slot_suggestions) ? res.slot_suggestions : []
|
||||
const improving = suggestions.filter((s) => s?.improves_path)
|
||||
const rejected = Array.isArray(scoring?.rejected_diffs) ? scoring.rejected_diffs : []
|
||||
const proposedSteps = improving.map(suggestionToApplyStep).filter(Boolean)
|
||||
const gapFillOffers = Array.isArray(res?.gap_fill_offers) ? res.gap_fill_offers : []
|
||||
|
||||
return {
|
||||
...res,
|
||||
comparison_mode: true,
|
||||
unified_slot_review: true,
|
||||
baseline_steps: baselineSteps,
|
||||
baseline_path_qa: baselineQa,
|
||||
proposed_steps: proposedSteps,
|
||||
proposed_steps_pipeline: proposedSteps,
|
||||
proposed_path_qa: baselineQa,
|
||||
proposed_path_qa_pipeline: null,
|
||||
gap_fill_offers: gapFillOffers,
|
||||
slot_suggestions: suggestions,
|
||||
slot_diffs: improving,
|
||||
slot_diffs_improving: improving,
|
||||
slot_diffs_rejected: rejected,
|
||||
slot_diffs_dialog: improving,
|
||||
slot_diffs_recommended: improving,
|
||||
slot_diff_count: improving.length,
|
||||
slot_diff_count_recommended: improving.length,
|
||||
slot_diff_count_rejected: rejected.length,
|
||||
slot_diffs_source: 'unified_slot_review',
|
||||
slot_diff_scoring: scoring,
|
||||
baseline_quality_score: scoring?.baseline_quality_score ?? baselineQa?.quality_score,
|
||||
path_qa: baselineQa,
|
||||
steps: baselineSteps,
|
||||
}
|
||||
}
|
||||
|
||||
function suggestionToApplyStep(suggestion) {
|
||||
if (!suggestion || suggestion.roadmap_major_step_index == null) return null
|
||||
const midx = Number(suggestion.roadmap_major_step_index)
|
||||
if (suggestion.suggestion_type === 'ai_gap' && suggestion.gap_offer) {
|
||||
const offer = suggestion.gap_offer
|
||||
return {
|
||||
roadmap_major_step_index: midx,
|
||||
exercise_id: null,
|
||||
title: offer.title_hint || suggestion.proposed_title || `Slot ${midx + 1}`,
|
||||
is_ai_proposal: true,
|
||||
proposal_key: offer.offer_id || `roadmap-unfilled-${midx}`,
|
||||
gap_offer: offer,
|
||||
slot_status: 'ai_proposal',
|
||||
}
|
||||
}
|
||||
if (suggestion.proposed_exercise_id == null) return null
|
||||
return {
|
||||
roadmap_major_step_index: midx,
|
||||
exercise_id: suggestion.proposed_exercise_id,
|
||||
title: suggestion.proposed_title,
|
||||
slot_status: suggestion.proposed_slot_status || 'matched',
|
||||
is_ai_proposal: false,
|
||||
}
|
||||
}
|
||||
|
||||
/** Ausgewählte Slot-Vorschläge aus unified review übernehmen. */
|
||||
export function applySelectedSlotSuggestions(draft, comparison, selectedMajorIndices) {
|
||||
const selected = new Set(
|
||||
(selectedMajorIndices || [])
|
||||
.map((x) => Number(x))
|
||||
.filter((x) => Number.isFinite(x)),
|
||||
)
|
||||
if (!selected.size) return draft
|
||||
const steps = (comparison?.slot_suggestions || [])
|
||||
.filter((s) => selected.has(Number(s.roadmap_major_step_index)))
|
||||
.map(suggestionToApplyStep)
|
||||
.filter(Boolean)
|
||||
if (!steps.length) {
|
||||
return applySelectedCompareSteps(
|
||||
draft,
|
||||
comparison?.proposed_steps || comparison?.steps,
|
||||
selectedMajorIndices,
|
||||
)
|
||||
}
|
||||
return applyMatchStepsToSlots(draft, steps)
|
||||
}
|
||||
|
||||
/** Alle Slot-Diffs inkl. reiner ID-Tausche (gleicher Titel). */
|
||||
export function compareSlotDiffs(comparison, { actionableOnly = false } = {}) {
|
||||
if (actionableOnly && Array.isArray(comparison?.slot_diffs_actionable)) {
|
||||
|
||||
Reference in new issue
Block a user