Enhance Planning Exercise Suggestion with Client Context and Group ID Support
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m16s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m16s
- Made `unit_id` and `group_id` optional in `PlanningExerciseSuggestRequest` to support client context without a saved unit. - Refactored `_load_group_recent_exercise_ids` to handle cases where `exclude_unit_id` is optional. - Introduced `build_client_planning_context_pack` for improved context handling in client-free searches. - Updated `suggest_planning_exercises` to utilize the new client context pack when `unit_id` is not provided. - Incremented version to 0.8.172 and updated changelog to reflect these enhancements in the planning AI capabilities.
This commit is contained in:
1 parent
f5c886fc13
commit
614c2dcfaa
7 files changed
+330
-67
No files matched your search
@@ -40,7 +40,11 @@ export default function ExercisePickerModal({
|
||||
enableQuickCreateDraft = false,
|
||||
/** Gespeicherte training_units.id — aktiviert Planungs-KI (robuster als nur planningContext). */
|
||||
planningUnitId = null,
|
||||
/** true auf TrainingUnitEditPage: Hinweis wenn Einheit noch keine ID hat. */
|
||||
/** 'planning' = Planungs-KI-API; 'library' = Volltext-Bibliothek */
|
||||
pickerMode = 'library',
|
||||
/** Planungs-KI auch ohne gespeicherte unit_id (Client-Kontext / Freitext). */
|
||||
enableFreePlanningSearch = false,
|
||||
/** true auf TrainingUnitEditPage: Hinweis wenn Planungs-KI ohne Einheit und ohne Freitext. */
|
||||
expectPlanningSearch = false,
|
||||
/** Planungs-Kontext für KI-Suche (Abschnitt, Anker, Plan …) */
|
||||
planningContext = null,
|
||||
@@ -84,9 +88,11 @@ export default function ExercisePickerModal({
|
||||
}, [planningUnitId, planningContext?.unitId])
|
||||
|
||||
const activePlanningContext = useMemo(() => {
|
||||
if (!resolvedPlanningUnitId) return null
|
||||
return {
|
||||
unitId: resolvedPlanningUnitId,
|
||||
if (pickerMode !== 'planning') return null
|
||||
const groupIdRaw = planningContext?.groupId
|
||||
const groupId = Number(groupIdRaw)
|
||||
const base = {
|
||||
groupId: Number.isFinite(groupId) && groupId > 0 ? groupId : null,
|
||||
sectionOrderIndex: planningContext?.sectionOrderIndex ?? 0,
|
||||
phaseOrderIndex: planningContext?.phaseOrderIndex ?? null,
|
||||
parallelStreamOrderIndex: planningContext?.parallelStreamOrderIndex ?? null,
|
||||
@@ -97,10 +103,24 @@ export default function ExercisePickerModal({
|
||||
: [],
|
||||
intentHint: planningContext?.intentHint ?? null,
|
||||
}
|
||||
}, [resolvedPlanningUnitId, planningContext])
|
||||
if (!resolvedPlanningUnitId) {
|
||||
if (!enableFreePlanningSearch && !planningContext) return null
|
||||
return { unitId: null, ...base }
|
||||
}
|
||||
return {
|
||||
unitId: resolvedPlanningUnitId,
|
||||
...base,
|
||||
}
|
||||
}, [pickerMode, resolvedPlanningUnitId, enableFreePlanningSearch, planningContext])
|
||||
|
||||
const usePlanningSearch = resolvedPlanningUnitId != null
|
||||
const planningSearchBlocked = Boolean(expectPlanningSearch && !usePlanningSearch)
|
||||
const usePlanningSearch = pickerMode === 'planning' && activePlanningContext != null
|
||||
const useFreePlanningSearch = usePlanningSearch && !resolvedPlanningUnitId
|
||||
const planningSearchBlocked = Boolean(
|
||||
pickerMode === 'planning' &&
|
||||
expectPlanningSearch &&
|
||||
!resolvedPlanningUnitId &&
|
||||
!enableFreePlanningSearch
|
||||
)
|
||||
|
||||
/** Gemeinsamer Suchtext — in Planung nur ein Feld; in Bibliothek beide Felder kombiniert. */
|
||||
const effectivePickerQuery = useMemo(() => {
|
||||
@@ -306,8 +326,7 @@ export default function ExercisePickerModal({
|
||||
try {
|
||||
if (usePlanningSearch && activePlanningContext) {
|
||||
const query = effectivePickerQuery
|
||||
const res = await api.suggestPlanningExercises({
|
||||
unit_id: Number(activePlanningContext.unitId),
|
||||
const requestBody = {
|
||||
section_order_index:
|
||||
activePlanningContext.sectionOrderIndex != null
|
||||
? Number(activePlanningContext.sectionOrderIndex)
|
||||
@@ -336,13 +355,20 @@ export default function ExercisePickerModal({
|
||||
.filter((x) => Number.isFinite(x) && x > 0)
|
||||
: undefined,
|
||||
include_llm_intent: Boolean(query),
|
||||
include_llm_rank: true,
|
||||
include_llm_rank: Boolean(query),
|
||||
query,
|
||||
intent_hint: activePlanningContext.intentHint || null,
|
||||
intent_hint: activePlanningContext.intentHint || (useFreePlanningSearch && query ? 'free_search' : null),
|
||||
limit: PAGE_SIZE,
|
||||
exercise_kind_any:
|
||||
Array.isArray(exerciseKindAny) && exerciseKindAny.length > 0 ? exerciseKindAny : undefined,
|
||||
})
|
||||
}
|
||||
if (resolvedPlanningUnitId) {
|
||||
requestBody.unit_id = Number(resolvedPlanningUnitId)
|
||||
}
|
||||
if (activePlanningContext.groupId) {
|
||||
requestBody.group_id = Number(activePlanningContext.groupId)
|
||||
}
|
||||
const res = await api.suggestPlanningExercises(requestBody)
|
||||
setPlanningContextSummary(res?.context_summary || null)
|
||||
setPlanningTargetProfileSummary(res?.target_profile_summary || null)
|
||||
setPlanningLlmRankApplied(Boolean(res?.llm_rank_applied))
|
||||
@@ -397,6 +423,8 @@ export default function ExercisePickerModal({
|
||||
activePlanningContext,
|
||||
effectivePickerQuery,
|
||||
exerciseKindAny,
|
||||
resolvedPlanningUnitId,
|
||||
useFreePlanningSearch,
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -643,12 +671,11 @@ export default function ExercisePickerModal({
|
||||
lineHeight: 1.45,
|
||||
}}
|
||||
>
|
||||
<strong>Planungs-KI noch nicht verfügbar.</strong> Die Einheit hat noch keine gespeicherte ID —
|
||||
bitte zuerst <strong>Speichern</strong>, dann den Übungspicker erneut öffnen. Bis dahin gilt nur die
|
||||
Bibliothekssuche (Volltext).
|
||||
<strong>Planungs-KI noch nicht verfügbar.</strong> Bitte zuerst <strong>Speichern</strong> oder den
|
||||
Menüpunkt <strong>Planungs-KI: Übung vorschlagen</strong> nutzen (Freitext ohne gespeicherte Einheit).
|
||||
</p>
|
||||
) : null}
|
||||
{!usePlanningSearch && !planningSearchBlocked ? (
|
||||
{pickerMode === 'library' && expectPlanningSearch ? (
|
||||
<p
|
||||
style={{
|
||||
margin: '0 0 10px',
|
||||
@@ -660,9 +687,40 @@ export default function ExercisePickerModal({
|
||||
color: 'var(--text2)',
|
||||
}}
|
||||
>
|
||||
<strong style={{ color: 'var(--text1)' }}>Bibliothekssuche (Volltext)</strong> — Planungs-KI mit
|
||||
Kontext (Einheit, Plan, Anker) gibt es in der{' '}
|
||||
<strong>Trainingseinheit bearbeiten</strong>, nach dem Speichern der Einheit.
|
||||
<strong style={{ color: 'var(--text1)' }}>Bibliothekssuche (Volltext)</strong> — für Planungs-KI mit
|
||||
Kontext oder Freitext-Anfrage den Menüpunkt{' '}
|
||||
<strong>Planungs-KI: Übung vorschlagen …</strong> unter dem <strong>+</strong> wählen.
|
||||
</p>
|
||||
) : null}
|
||||
{useFreePlanningSearch ? (
|
||||
<p
|
||||
style={{
|
||||
margin: '0 0 10px',
|
||||
padding: '8px 10px',
|
||||
borderRadius: '8px',
|
||||
background: 'var(--surface2)',
|
||||
border: '1px solid var(--border)',
|
||||
fontSize: '12px',
|
||||
color: 'var(--text2)',
|
||||
}}
|
||||
>
|
||||
<strong style={{ color: 'var(--text1)' }}>Freie Planungs-KI</strong> — Anker und bisherige Übungen aus
|
||||
dem Formular; nach Speichern kommen Gruppe, Historie und Rahmen dazu.
|
||||
</p>
|
||||
) : null}
|
||||
{!usePlanningSearch && !planningSearchBlocked && !expectPlanningSearch ? (
|
||||
<p
|
||||
style={{
|
||||
margin: '0 0 10px',
|
||||
padding: '8px 10px',
|
||||
borderRadius: '8px',
|
||||
background: 'var(--surface2)',
|
||||
border: '1px solid var(--border)',
|
||||
fontSize: '12px',
|
||||
color: 'var(--text2)',
|
||||
}}
|
||||
>
|
||||
<strong style={{ color: 'var(--text1)' }}>Bibliothekssuche (Volltext)</strong>
|
||||
</p>
|
||||
) : null}
|
||||
<div style={{ display: 'grid', gap: '0.65rem' }}>
|
||||
|
||||
@@ -253,6 +253,7 @@ export default function TrainingUnitSectionsEditor({
|
||||
sections,
|
||||
onSectionsChange,
|
||||
onRequestExercisePick,
|
||||
onRequestPlanningExercisePick,
|
||||
onRequestTrainingModulePick,
|
||||
onPeekExercise,
|
||||
showExecutionExtras = false,
|
||||
@@ -2591,12 +2592,23 @@ export default function TrainingUnitSectionsEditor({
|
||||
</p>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px' }}>
|
||||
{onRequestPlanningExercisePick ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary framework-ctrl framework-ctrl--xs"
|
||||
onClick={() =>
|
||||
onRequestPlanningExercisePick?.({ sectionIndex: sIdx })
|
||||
}
|
||||
>
|
||||
+ Planungs-KI
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary framework-ctrl framework-ctrl--xs"
|
||||
onClick={() => onRequestExercisePick?.({ sectionIndex: sIdx })}
|
||||
>
|
||||
+ Übung
|
||||
+ Übung (Bibliothek)
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@@ -2807,9 +2819,25 @@ export default function TrainingUnitSectionsEditor({
|
||||
ändern.
|
||||
</p>
|
||||
<div className="tu-insert-chooser-actions">
|
||||
{onRequestPlanningExercisePick ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary tu-insert-chooser-actions__full"
|
||||
onClick={() => {
|
||||
const { sIdx, beforeIx } = insertChooser
|
||||
closeInsertChooser()
|
||||
onRequestPlanningExercisePick?.({
|
||||
sectionIndex: sIdx,
|
||||
insertBeforeIndex: beforeIx,
|
||||
})
|
||||
}}
|
||||
>
|
||||
Planungs-KI: Übung vorschlagen …
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary tu-insert-chooser-actions__full"
|
||||
className={`btn ${onRequestPlanningExercisePick ? 'btn-secondary' : 'btn-primary'} tu-insert-chooser-actions__full`}
|
||||
onClick={() => {
|
||||
const { sIdx, beforeIx } = insertChooser
|
||||
closeInsertChooser()
|
||||
@@ -2819,7 +2847,7 @@ export default function TrainingUnitSectionsEditor({
|
||||
})
|
||||
}}
|
||||
>
|
||||
Übung auswählen …
|
||||
{onRequestPlanningExercisePick ? 'Übung aus Bibliothek …' : 'Übung auswählen …'}
|
||||
</button>
|
||||
{onRequestTrainingModulePick ? (
|
||||
<button
|
||||
|
||||
@@ -37,6 +37,7 @@ export default function TrainingUnitFormShell({
|
||||
onRequestSaveAsModule,
|
||||
onRequestTrainingModulePick,
|
||||
onRequestExercisePick,
|
||||
onRequestPlanningExercisePick,
|
||||
onPeekExercise,
|
||||
formId = 'planning-unit-form',
|
||||
}) {
|
||||
@@ -427,6 +428,7 @@ export default function TrainingUnitFormShell({
|
||||
}
|
||||
onRequestTrainingModulePick={onRequestTrainingModulePick}
|
||||
onRequestExercisePick={onRequestExercisePick}
|
||||
onRequestPlanningExercisePick={onRequestPlanningExercisePick}
|
||||
onPeekExercise={onPeekExercise}
|
||||
showExecutionExtras={Boolean(editingUnit) && sectionsEditMode === 'debrief'}
|
||||
enableParallelPhaseControls
|
||||
|
||||
Reference in new issue
Block a user