@@ -2115,6 +2115,77 @@ window.pathApp = {
21152115 }
21162116 } ,
21172117
2118+ runLearningWorkbenchRetestSession : async function ( ) {
2119+ if ( this . learningWorkbench . loading ) {
2120+ return ;
2121+ }
2122+ const userId = this . _normalizeLearningWorkbenchUserId ( this . learningWorkbench . userId ) ;
2123+ const existingExecution = this . learningWorkbench . sessionExecution || null ;
2124+ const retestActions = Array . isArray ( existingExecution ?. retestPlan ?. actions )
2125+ ? existingExecution . retestPlan . actions
2126+ : [ ] ;
2127+ if ( retestActions . length === 0 ) {
2128+ this . _setLearningWorkbenchStatus ( 'No immediate retest actions available. Run a session first.' , true ) ;
2129+ return ;
2130+ }
2131+ const answersByActionId = this . _collectOptionalAnswersForSessionActions ( retestActions ) ;
2132+ const answerCount = Object . keys ( answersByActionId ) . length ;
2133+ const autoAnalyzeAnswer = answerCount > 0 ;
2134+ const generatedAt = new Date ( ) . toISOString ( ) ;
2135+ const totalEstimatedMinutes = retestActions . reduce (
2136+ ( sum , action ) => sum + Number ( action ?. estimatedMinutes || 0 ) ,
2137+ 0
2138+ ) ;
2139+ const retestSessionPlan = {
2140+ userId,
2141+ generatedAt,
2142+ actions : retestActions ,
2143+ signals : {
2144+ misconceptions : [ ] ,
2145+ dueRetrainAtoms : Array . from ( new Set ( retestActions . map ( ( action ) => String ( action . atomId || '' ) . trim ( ) ) ) ) ,
2146+ masteryPathTargets : [ ] ,
2147+ divergenceTargets : [ ] ,
2148+ } ,
2149+ summary : {
2150+ totalActions : retestActions . length ,
2151+ totalEstimatedMinutes,
2152+ evidenceCoverageRatio : 1 ,
2153+ } ,
2154+ } ;
2155+
2156+ this . learningWorkbench . loading = true ;
2157+ this . _setLearningWorkbenchStatus ( `Running immediate retest for ${ retestActions . length } actions...` ) ;
2158+ this . _renderLearningWorkbenchState ( ) ;
2159+ try {
2160+ const result = await this . _requestLearningApi ( '/api/knowledge/session/execute' , {
2161+ userId,
2162+ sessionPlan : retestSessionPlan ,
2163+ actionLimit : retestActions . length ,
2164+ answersByActionId,
2165+ autoAnalyzeAnswer,
2166+ autoUpdateMasteryFromAnswer : autoAnalyzeAnswer ,
2167+ persistMemory : true ,
2168+ memoryLayer : 'session' ,
2169+ includeRetestPlan : false ,
2170+ } ) ;
2171+ this . learningWorkbench . sessionExecution = {
2172+ ...result ,
2173+ receivedAt : new Date ( ) . toISOString ( ) ,
2174+ } ;
2175+ const summary = result ?. summary || { } ;
2176+ this . _setLearningWorkbenchStatus (
2177+ `Retest execution finished: executed ${ Number ( summary . executedCount || 0 ) } /${ Number ( summary . attemptedActions || 0 ) } , mastery delta ${ Number ( summary . averageMasteryDelta || 0 ) . toFixed ( 3 ) } .`
2178+ ) ;
2179+ } catch ( error ) {
2180+ const message = String ( error ?. message || error || 'Unknown retest execution error' ) ;
2181+ this . learningWorkbench . lastError = message ;
2182+ this . _setLearningWorkbenchStatus ( `Retest execution failed: ${ message } ` , true ) ;
2183+ } finally {
2184+ this . learningWorkbench . loading = false ;
2185+ this . _renderLearningWorkbenchState ( ) ;
2186+ }
2187+ } ,
2188+
21182189 _renderLearningWorkbenchState : function ( ) {
21192190 const userIdInput = document . getElementById ( 'learning-user-id' ) ;
21202191 if ( userIdInput && userIdInput . value !== this . learningWorkbench . userId ) {
@@ -2931,6 +3002,7 @@ window.pathApp = {
29313002 const workbenchRefreshBtn = document . getElementById ( 'btn-refresh-learning-workbench' ) ;
29323003 const workbenchIngestBtn = document . getElementById ( 'btn-ingest-focus-node' ) ;
29333004 const workbenchRunSessionBtn = document . getElementById ( 'btn-run-learning-session' ) ;
3005+ const workbenchRunRetestBtn = document . getElementById ( 'btn-run-retest-session' ) ;
29343006 const workbenchUserIdInput = document . getElementById ( 'learning-user-id' ) ;
29353007 const workbenchActionsList = document . getElementById ( 'learning-session-actions' ) ;
29363008
@@ -2993,6 +3065,12 @@ window.pathApp = {
29933065 } ) ;
29943066 }
29953067
3068+ if ( workbenchRunRetestBtn ) {
3069+ workbenchRunRetestBtn . addEventListener ( 'click' , ( ) => {
3070+ void this . runLearningWorkbenchRetestSession ( ) ;
3071+ } ) ;
3072+ }
3073+
29963074 if ( workbenchUserIdInput ) {
29973075 workbenchUserIdInput . value = this . learningWorkbench . userId || 'path_user_default' ;
29983076 workbenchUserIdInput . addEventListener ( 'change' , ( event ) => {
0 commit comments