@@ -43,11 +43,36 @@ export function showSidebarContent(d, fromHover = false) {
4343 return `<pre class="sidebar-code-pre">${ d . code } </pre>` ;
4444 }
4545 if ( tabName === 'Prompts' ) {
46- let html = '' ;
46+ // --- Prompt select logic ---
47+ let promptOptions = [ ] ;
48+ let promptMap = { } ;
4749 for ( const [ k , v ] of Object . entries ( d . prompts ) ) {
48- html += `<div style="margin-bottom:0.7em;"><b>${ k } :</b><pre class="sidebar-pre">${ v } </pre></div>` ;
50+ if ( v && typeof v === 'object' && ! Array . isArray ( v ) ) {
51+ for ( const [ subKey , subVal ] of Object . entries ( v ) ) {
52+ const optLabel = `${ k } - ${ subKey } ` ;
53+ promptOptions . push ( optLabel ) ;
54+ promptMap [ optLabel ] = subVal ;
55+ }
56+ } else {
57+ const optLabel = `${ k } ` ;
58+ promptOptions . push ( optLabel ) ;
59+ promptMap [ optLabel ] = v ;
60+ }
61+ }
62+ // Get last selected prompt from localStorage, or default to first
63+ let lastPromptKey = localStorage . getItem ( 'sidebarPromptSelect' ) || promptOptions [ 0 ] || '' ;
64+ if ( ! promptMap [ lastPromptKey ] ) lastPromptKey = promptOptions [ 0 ] || '' ;
65+ // Build select box
66+ let selectHtml = '' ;
67+ if ( promptOptions . length > 1 ) {
68+ selectHtml = `<select id="sidebar-prompt-select" style="margin-bottom:0.7em;max-width:100%;font-size:1em;">
69+ ${ promptOptions . map ( opt => `<option value="${ opt } "${ opt === lastPromptKey ?' selected' :'' } >${ opt } </option>` ) . join ( '' ) }
70+ </select>` ;
4971 }
50- return html ;
72+ // Show only the selected prompt
73+ let promptVal = promptMap [ lastPromptKey ] ;
74+ let promptHtml = `<pre class="sidebar-pre">${ promptVal ?? '' } </pre>` ;
75+ return selectHtml + promptHtml ;
5176 }
5277 if ( tabName === 'Children' ) {
5378 const metric = ( document . getElementById ( 'metric-select' ) && document . getElementById ( 'metric-select' ) . value ) || 'combined_score' ;
@@ -103,6 +128,20 @@ export function showSidebarContent(d, fromHover = false) {
103128 lastSidebarTab = tabName ;
104129 const tabContent = document . getElementById ( 'sidebar-tab-content' ) ;
105130 tabContent . innerHTML = renderSidebarTabContent ( tabName , d , children ) ;
131+ // Add prompt select event if Prompts tab
132+ if ( tabName === 'Prompts' ) {
133+ const promptSelect = document . getElementById ( 'sidebar-prompt-select' ) ;
134+ if ( promptSelect ) {
135+ promptSelect . onchange = function ( ) {
136+ localStorage . setItem ( 'sidebarPromptSelect' , promptSelect . value ) ;
137+ // Re-render Prompts tab with new selection
138+ tabContent . innerHTML = renderSidebarTabContent ( 'Prompts' , d , children ) ;
139+ // Re-attach event
140+ const newPromptSelect = document . getElementById ( 'sidebar-prompt-select' ) ;
141+ if ( newPromptSelect ) newPromptSelect . onchange = promptSelect . onchange ;
142+ } ;
143+ }
144+ }
106145 setTimeout ( ( ) => {
107146 document . querySelectorAll ( '.child-link' ) . forEach ( link => {
108147 link . onclick = function ( e ) {
@@ -128,6 +167,18 @@ export function showSidebarContent(d, fromHover = false) {
128167 } ) ;
129168 }
130169 setTimeout ( ( ) => {
170+ const promptSelect = document . getElementById ( 'sidebar-prompt-select' ) ;
171+ if ( promptSelect ) {
172+ promptSelect . onchange = function ( ) {
173+ localStorage . setItem ( 'sidebarPromptSelect' , promptSelect . value ) ;
174+ // Re-render Prompts tab with new selection
175+ const tabContent = document . getElementById ( 'sidebar-tab-content' ) ;
176+ tabContent . innerHTML = renderSidebarTabContent ( 'Prompts' , d , children ) ;
177+ // Re-attach event
178+ const newPromptSelect = document . getElementById ( 'sidebar-prompt-select' ) ;
179+ if ( newPromptSelect ) newPromptSelect . onchange = promptSelect . onchange ;
180+ } ;
181+ }
131182 document . querySelectorAll ( '.child-link' ) . forEach ( link => {
132183 link . onclick = function ( e ) {
133184 e . preventDefault ( ) ;
0 commit comments