101101 padding : 8px ;
102102 border-top : 1px solid # 2a2a3a ;
103103 flex-wrap : wrap;
104+ align-items : center;
104105 }
105106 .mode-indicator {
106107 display : inline-block;
232233 text-align : left;
233234 cursor : pointer;
234235 }
236+ .toggle-label {
237+ display : inline-flex;
238+ align-items : center;
239+ gap : 6px ;
240+ cursor : pointer;
241+ }
242+ .toggle-label input {
243+ width : 16px ;
244+ height : 16px ;
245+ margin : 0 ;
246+ cursor : pointer;
247+ }
235248 @keyframes fadeOut { 0% { opacity : 1 ; } 70% { opacity : 1 ; } 100% { opacity : 0 ; } }
236249 @media (max-width : 600px ) {
237250 body { padding : 12px ; }
@@ -311,6 +324,9 @@ <h2>AION · Ada‑VELA</h2>
311324 < span id ="modeBadge " class ="mode-indicator "> ⚡ REGULAR</ span >
312325 < span id ="velaDisplay " class ="vela-badge vela-pass "> ⚖️ READY</ span >
313326 < span id ="lastSeal "> </ span >
327+ < label class ="toggle-label " title ="Enable ADA loop for self‑refinement (may take extra time) ">
328+ < input type ="checkbox " id ="adaLoopToggle " checked > < span > ADA Loop</ span >
329+ </ label >
314330 </ div >
315331
316332 < script >
@@ -326,6 +342,18 @@ <h2>AION · Ada‑VELA</h2>
326342 }
327343 document . getElementById ( 'sessionDisplay' ) . textContent = `Session: ${ sessionId . slice ( - 8 ) } ` ;
328344
345+ // ADA Loop toggle
346+ let adaLoopEnabled = localStorage . getItem ( 'adaLoopEnabled' ) !== 'false' ; // default true
347+ const adaLoopToggle = document . getElementById ( 'adaLoopToggle' ) ;
348+ if ( adaLoopToggle ) {
349+ adaLoopToggle . checked = adaLoopEnabled ;
350+ adaLoopToggle . addEventListener ( 'change' , ( ) => {
351+ adaLoopEnabled = adaLoopToggle . checked ;
352+ localStorage . setItem ( 'adaLoopEnabled' , adaLoopEnabled ) ;
353+ addSystemMessage ( adaLoopEnabled ? '🔄 ADA loop enabled – responses will be automatically refined.' : '⚡ ADA loop disabled – responses will be generated directly.' ) ;
354+ } ) ;
355+ }
356+
329357 // State
330358 let lastResponse = null ;
331359 let isSending = false ;
@@ -461,7 +489,8 @@ <h3>📋 Clarification Required</h3>
461489 domain : 'general' ,
462490 emotional_state : { primary : 'neutral' , intensity : 5 } ,
463491 content : { summary : `Clarification: ${ option . text } ` , details : option . text } ,
464- context : { time_sensitivity : 'now' , stage : 4 , requires : [ 'analysis' ] }
492+ context : { time_sensitivity : 'now' , stage : 4 , requires : [ 'analysis' ] } ,
493+ adaLoopEnabled // Pass the current toggle state
465494 } ;
466495 try {
467496 const res = await fetch ( `${ API } /api/structured-mode` , {
@@ -471,7 +500,7 @@ <h3>📋 Clarification Required</h3>
471500 } ) ;
472501 const result = await res . json ( ) ;
473502 if ( result . response ) {
474- addMessage ( 'ai' , result . response , { sealHash : true , receipt : result . checkpoint_receipt } ) ;
503+ addMessage ( 'ai' , result . response , { sealHash : true , receipt : result . checkpoint_receipt , adaLoop : result . ada_loop } ) ;
475504 lastResponse = result . response ;
476505 clarificationDepth = 0 ;
477506 pendingClarification = null ;
@@ -525,7 +554,13 @@ <h3>📋 Clarification Required</h3>
525554 const res = await fetch ( `${ API } /api/assistant` , {
526555 method : 'POST' ,
527556 headers : { 'Content-Type' : 'application/json' } ,
528- body : JSON . stringify ( { message, sessionId, ownerType : 'sheldon' , history : [ ] } )
557+ body : JSON . stringify ( {
558+ message,
559+ sessionId,
560+ ownerType : 'sheldon' ,
561+ history : [ ] ,
562+ adaLoopEnabled // Pass the current toggle state
563+ } )
529564 } ) ;
530565 if ( ! res . ok ) throw new Error ( await res . text ( ) ) ;
531566 return res . json ( ) ;
@@ -573,7 +608,8 @@ <h3>📋 Clarification Required</h3>
573608 domain : itlDomain . value ,
574609 emotional_state : { primary : itlEmotion . value , intensity : 5 } ,
575610 content : { summary : rawMessage . substring ( 0 , 100 ) , details : rawMessage } ,
576- context : { time_sensitivity : itlTime . value , stage : 4 , requires : [ 'analysis' ] }
611+ context : { time_sensitivity : itlTime . value , stage : 4 , requires : [ 'analysis' ] } ,
612+ adaLoopEnabled // Pass the toggle state
577613 } ;
578614 if ( replyTo ) frag . in_reply_to = replyTo ;
579615 return frag ;
@@ -705,7 +741,8 @@ <h3>📋 Clarification Required</h3>
705741 lastFragmentId,
706742 lastResponsePreview : lastResponse ?. substring ( 0 , 100 ) ,
707743 pendingClarification : pendingClarification ? true : false ,
708- clarificationDepth
744+ clarificationDepth,
745+ adaLoopEnabled
709746 } ;
710747 showModal ( 'Ada‑VELA Trace' , JSON . stringify ( traceInfo , null , 2 ) ) ;
711748 console . log ( 'Trace data:' , traceInfo ) ;
0 commit comments