77 < meta http-equiv ="Expires " content ="0 ">
88 < title > AION · Ada‑VELA</ title >
99 < style >
10+ * {
11+ box-sizing : border-box;
12+ }
1013 body {
1114 font-family : system-ui, -apple-system, sans-serif;
1215 max-width : 800px ;
1316 margin : 0 auto;
1417 padding : 20px ;
1518 background : # 0a0a0f ;
1619 color : # f0f0f8 ;
20+ position : relative;
1721 }
1822 # chat {
1923 height : 500px ;
20- overflow : auto;
24+ overflow-y : auto;
2125 border : 1px solid # 2a2a3a ;
2226 margin : 10px 0 ;
2327 padding : 10px ;
2428 background : # 0f0f14 ;
2529 border-radius : 8px ;
30+ scroll-behavior : smooth;
2631 }
2732 .message {
2833 margin : 8px 0 ;
2934 padding : 10px ;
3035 border-radius : 8px ;
36+ word-wrap : break-word;
3137 }
3238 .user {
3339 background : # 1e3a5f ;
102108 border-top : 1px solid # 2a2a3a ;
103109 flex-wrap : wrap;
104110 }
105- .action-buttons {
106- display : flex;
107- gap : 8px ;
108- margin-top : 8px ;
109- flex-wrap : wrap;
110- }
111- .small-btn {
112- background : # 2a2a3a ;
113- color : # c9a028 ;
114- padding : 6px 12px ;
115- font-size : 12px ;
116- }
117111 .mode-indicator {
118112 display : inline-block;
119113 padding : 4px 12px ;
209203 border-radius : 8px ;
210204 margin-top : 8px ;
211205 }
206+ /* Modal for trace/validate results */
207+ .modal-overlay {
208+ position : fixed;
209+ top : 0 ;
210+ left : 0 ;
211+ right : 0 ;
212+ bottom : 0 ;
213+ background : rgba (0 , 0 , 0 , 0.8 );
214+ display : flex;
215+ align-items : center;
216+ justify-content : center;
217+ z-index : 1000 ;
218+ }
219+ .modal {
220+ background : # 1e1e2d ;
221+ border : 1px solid # c9a028 ;
222+ border-radius : 16px ;
223+ max-width : 90% ;
224+ width : 500px ;
225+ max-height : 80% ;
226+ overflow : auto;
227+ padding : 20px ;
228+ position : relative;
229+ }
230+ .modal h3 {
231+ color : # c9a028 ;
232+ margin-bottom : 12px ;
233+ }
234+ .modal pre {
235+ background : # 0a0a0f ;
236+ padding : 12px ;
237+ border-radius : 8px ;
238+ overflow-x : auto;
239+ font-size : 12px ;
240+ }
241+ .modal button {
242+ margin-top : 16px ;
243+ background : # c9a028 ;
244+ color : # 0a0a0f ;
245+ padding : 8px 16px ;
246+ }
212247 @keyframes fadeOut {
213248 0% { opacity : 1 ; }
214249 70% { opacity : 1 ; }
@@ -412,6 +447,7 @@ <h2>AION · Ada‑VELA</h2>
412447
413448 const assistantOp = new AdaOperation ( 'ASSISTANT_CALL' ) ;
414449 assistantOp . setFunction ( async ( message ) => {
450+ // The API expects a 'message' field that is a string
415451 const res = await fetch ( `${ API } /api/assistant` , {
416452 method : 'POST' ,
417453 headers : { 'Content-Type' : 'application/json' } ,
@@ -536,11 +572,30 @@ <h2>AION · Ada‑VELA</h2>
536572 background: ${ isError ? '#5f1a1a' : '#1e4620' } ; color: white;
537573 padding: 8px 16px; border-radius: 20px; font-size: 12px;
538574 z-index: 1000; animation: fadeOut 2s forwards;
575+ pointer-events: none;
539576 ` ;
540577 document . body . appendChild ( toast ) ;
541578 setTimeout ( ( ) => toast . remove ( ) , 2000 ) ;
542579 }
543580
581+ function showModal ( title , content ) {
582+ const overlay = document . createElement ( 'div' ) ;
583+ overlay . className = 'modal-overlay' ;
584+ overlay . innerHTML = `
585+ <div class="modal">
586+ <h3>${ title } </h3>
587+ <pre>${ escapeHtml ( content ) } </pre>
588+ <button id="closeModalBtn">Close</button>
589+ </div>
590+ ` ;
591+ document . body . appendChild ( overlay ) ;
592+ overlay . querySelector ( '#closeModalBtn' ) . onclick = ( ) => overlay . remove ( ) ;
593+ // Close on backdrop click
594+ overlay . addEventListener ( 'click' , ( e ) => {
595+ if ( e . target === overlay ) overlay . remove ( ) ;
596+ } ) ;
597+ }
598+
544599 async function sealMessage ( content ) {
545600 try {
546601 const { result } = await sealOp . execute ( content ) ;
@@ -562,19 +617,35 @@ <h2>AION · Ada‑VELA</h2>
562617 const statusClass = result . status === 'BLOCKED' ? 'vela-block' : ( result . status === 'FLAGGED' ? 'vela-flag' : 'vela-pass' ) ;
563618 velaDisplay . className = `vela-badge ${ statusClass } ` ;
564619 velaDisplay . innerHTML = `⚖️ VELA: ${ result . status } ` ;
565- showToast ( `VELA: ${ result . status } | Fidelity: ${ ( ( result . screen1Result ?. fidelity_estimate || 0 ) * 100 ) . toFixed ( 0 ) } %` ) ;
620+ // Show detailed result in modal
621+ const details = JSON . stringify ( result , null , 2 ) ;
622+ showModal ( 'VELA Validation Result' , details ) ;
566623 } catch ( err ) {
567624 showToast ( `Validation failed: ${ err . message } ` , true ) ;
568625 }
569626 }
570627
628+ function showTrace ( ) {
629+ const traceData = {
630+ session : sessionVar . trace ( ) ,
631+ chatHistory : chatHistory . trace ( ) ,
632+ assistantCalls : assistantOp . getExecutions ( ) ,
633+ sealCalls : sealOp . getExecutions ( ) ,
634+ velaCalls : velaOp . getExecutions ( )
635+ } ;
636+ showModal ( 'Ada‑VELA Trace' , JSON . stringify ( traceData , null , 2 ) ) ;
637+ }
638+
571639 // ========== Main Send (handles both modes) ==========
572640 async function send ( ) {
641+ if ( isSending ) {
642+ showToast ( 'Already sending, please wait...' ) ;
643+ return ;
644+ }
573645 const message = inputField . value . trim ( ) ;
574646 if ( ! message ) return ;
575- if ( isSending ) return ;
576647
577- // Clear input field
648+ // Clear input field and disable temporarily
578649 inputField . value = '' ;
579650 inputField . disabled = true ;
580651 isSending = true ;
@@ -607,13 +678,15 @@ <h2>AION · Ada‑VELA</h2>
607678 // Add user message with checkpoint info if any
608679 addMessage ( 'user' , message , { checkpoints : checkpointsInfo } ) ;
609680
681+ // Add thinking indicator
610682 const thinking = document . createElement ( 'div' ) ;
611683 thinking . className = 'message ai' ;
612684 thinking . innerHTML = '<strong>AI:</strong> ...' ;
613685 chatDiv . appendChild ( thinking ) ;
614686 chatDiv . scrollTop = chatDiv . scrollHeight ;
615687
616688 try {
689+ // Send the payload (either plain text or JSON string)
617690 const { result } = await assistantOp . execute ( payload ) ;
618691
619692 if ( result && result . response ) {
@@ -640,11 +713,12 @@ <h2>AION · Ada‑VELA</h2>
640713 }
641714 } catch ( err ) {
642715 thinking . innerHTML = `<strong>AI:</strong> Error: ${ err . message } ` ;
716+ console . error ( 'Send error:' , err ) ;
717+ } finally {
718+ inputField . disabled = false ;
719+ inputField . focus ( ) ;
720+ isSending = false ;
643721 }
644-
645- inputField . disabled = false ;
646- inputField . focus ( ) ;
647- isSending = false ;
648722 }
649723
650724 // ========== Mode Toggle ==========
@@ -679,16 +753,6 @@ <h2>AION · Ada‑VELA</h2>
679753 sealMessage ( text ) ;
680754 }
681755
682- function showTrace ( ) {
683- console . log ( '=== Ada‑VELA Trace ===' ) ;
684- console . log ( 'Session:' , sessionVar . trace ( ) ) ;
685- console . log ( 'Chat History:' , chatHistory . trace ( ) ) ;
686- console . log ( 'API Calls:' , assistantOp . getExecutions ( ) ) ;
687- console . log ( 'Seal Calls:' , sealOp . getExecutions ( ) ) ;
688- console . log ( 'VELA Calls:' , velaOp . getExecutions ( ) ) ;
689- showToast ( 'Trace logged to console (F12)' ) ;
690- }
691-
692756 // ========== Event Listeners ==========
693757 sendBtn . onclick = send ;
694758 plusBtn . onclick = ( e ) => {
0 commit comments