Update Planning Exercise Suggestion and Context Handling
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 33s
Test Suite / playwright-tests (push) Successful in 1m13s
Test Suite / pytest-backend (pull_request) Successful in 37s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 13s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m15s
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 33s
Test Suite / playwright-tests (push) Successful in 1m13s
Test Suite / pytest-backend (pull_request) Successful in 37s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 13s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m15s
- Incremented version to 0.8.183, reflecting the implementation of Phase C1 enhancements. - Added support for progression graph auto-matching and variant-aware successors in exercise suggestions. - Updated request and response structures to include `anchor_exercise_variant_id`, `progression_graph_name`, and `suggested_variant_id`. - Enhanced frontend components to integrate planning AI search capabilities, including a new modal for exercise creation and improved context display in the exercise list. - Updated changelog to document these significant improvements in planning AI functionality.
This commit is contained in:
1 parent
50aff849d8
commit
b2157d8a40
16 files changed
+985
-136
No files matched your search
@@ -6,7 +6,7 @@ export const EXERCISE_LIST_PAGE_SIZE = 100
|
||||
/**
|
||||
* Lädt Kataloge für Filter/Bulk einmalig und hält die Übungsliste (Offset + Keyset „Mehr laden“) synchron zu queryBase.
|
||||
*/
|
||||
export function useExerciseListCatalogsAndQuery({ queryBase, pageTab, tenantClubDepKey }) {
|
||||
export function useExerciseListCatalogsAndQuery({ queryBase, pageTab, tenantClubDepKey, skipListFetch = false }) {
|
||||
const [catalogs, setCatalogs] = useState({
|
||||
focusAreas: [],
|
||||
styleDirections: [],
|
||||
@@ -55,7 +55,14 @@ export function useExerciseListCatalogsAndQuery({ queryBase, pageTab, tenantClub
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!catalogsReady || pageTab !== 'list') return
|
||||
if (!catalogsReady || pageTab !== 'list' || skipListFetch) {
|
||||
if (skipListFetch) {
|
||||
setExercises([])
|
||||
setHasMore(false)
|
||||
setListFetching(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
let cancelled = false
|
||||
const run = async () => {
|
||||
setListFetching(true)
|
||||
@@ -81,7 +88,7 @@ export function useExerciseListCatalogsAndQuery({ queryBase, pageTab, tenantClub
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [queryBase, catalogsReady, pageTab, tenantClubDepKey])
|
||||
}, [queryBase, catalogsReady, pageTab, tenantClubDepKey, skipListFetch])
|
||||
|
||||
const loadMore = useCallback(async () => {
|
||||
if (loadingMore || !hasMore) return
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import api from '../utils/api'
|
||||
import { PLANNING_LLM_INTENT_MIN_CHARS, PLANNING_SUGGEST_LIMIT } from '../constants/planningExerciseSuggest'
|
||||
|
||||
export function mapPlanningHitsToListRows(hits) {
|
||||
return (Array.isArray(hits) ? hits : []).map((h) => ({
|
||||
id: h.id,
|
||||
title: h.title,
|
||||
summary: h.summary,
|
||||
focus_area: h.focus_area,
|
||||
focus_area_names: h.focus_area ? [h.focus_area] : [],
|
||||
updated_at: new Date().toISOString(),
|
||||
_planningScore: h.score,
|
||||
_planningReasons: Array.isArray(h.reasons) ? h.reasons : [],
|
||||
suggested_variant_id: h.suggested_variant_id ?? null,
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Freie Planungs-KI-Suche (ohne unit_id) — z. B. Übungsliste im KI-Assistent-Modus.
|
||||
*/
|
||||
export function usePlanningExerciseSuggestSearch({ enabled, groupId = null } = {}) {
|
||||
const [searchInput, setSearchInput] = useState('')
|
||||
const [submittedQuery, setSubmittedQuery] = useState('')
|
||||
const [searchTick, setSearchTick] = useState(0)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [hasSearched, setHasSearched] = useState(false)
|
||||
const [rows, setRows] = useState([])
|
||||
const [contextSummary, setContextSummary] = useState(null)
|
||||
const [targetProfileSummary, setTargetProfileSummary] = useState(null)
|
||||
const [retrievalPhase, setRetrievalPhase] = useState('')
|
||||
const [error, setError] = useState('')
|
||||
|
||||
const reset = useCallback(() => {
|
||||
setSearchInput('')
|
||||
setSubmittedQuery('')
|
||||
setSearchTick(0)
|
||||
setHasSearched(false)
|
||||
setRows([])
|
||||
setContextSummary(null)
|
||||
setTargetProfileSummary(null)
|
||||
setRetrievalPhase('')
|
||||
setError('')
|
||||
}, [])
|
||||
|
||||
const submitSearch = useCallback(
|
||||
(queryOverride) => {
|
||||
const q =
|
||||
queryOverride !== undefined && queryOverride !== null
|
||||
? String(queryOverride).trim()
|
||||
: searchInput.trim()
|
||||
setSubmittedQuery(q)
|
||||
setHasSearched(true)
|
||||
setSearchTick((t) => t + 1)
|
||||
},
|
||||
[searchInput],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) {
|
||||
reset()
|
||||
}
|
||||
}, [enabled, reset])
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled || searchTick === 0) return undefined
|
||||
let cancelled = false
|
||||
;(async () => {
|
||||
setLoading(true)
|
||||
setError('')
|
||||
try {
|
||||
const query = submittedQuery
|
||||
const body = {
|
||||
query,
|
||||
include_llm_intent: query.length >= PLANNING_LLM_INTENT_MIN_CHARS || !query,
|
||||
include_llm_rank: true,
|
||||
intent_hint: query ? 'free_search' : 'suggest_next',
|
||||
limit: PLANNING_SUGGEST_LIMIT,
|
||||
}
|
||||
const gid = Number(groupId)
|
||||
if (Number.isFinite(gid) && gid > 0) body.group_id = gid
|
||||
const res = await api.suggestPlanningExercises(body)
|
||||
if (cancelled) return
|
||||
setContextSummary(res?.context_summary || null)
|
||||
setTargetProfileSummary(res?.target_profile_summary || null)
|
||||
setRetrievalPhase(res?.retrieval_phase || '')
|
||||
setRows(mapPlanningHitsToListRows(res?.hits))
|
||||
} catch (e) {
|
||||
if (!cancelled) {
|
||||
console.error(e)
|
||||
setError(e.message || 'Planungs-KI-Suche fehlgeschlagen')
|
||||
setRows([])
|
||||
setContextSummary(null)
|
||||
setTargetProfileSummary(null)
|
||||
setRetrievalPhase('')
|
||||
}
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false)
|
||||
}
|
||||
})()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [enabled, searchTick, submittedQuery, groupId])
|
||||
|
||||
return {
|
||||
searchInput,
|
||||
setSearchInput,
|
||||
submittedQuery,
|
||||
submitSearch,
|
||||
loading,
|
||||
hasSearched,
|
||||
rows,
|
||||
contextSummary,
|
||||
targetProfileSummary,
|
||||
retrievalPhase,
|
||||
error,
|
||||
reset,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user