horriblecpp commited on
Commit
799bf6b
·
1 Parent(s): 065760f

Refine Intents tab with nested expanders and layout stability

Browse files
Files changed (1) hide show
  1. frontend/app.py +26 -8
frontend/app.py CHANGED
@@ -833,6 +833,24 @@ with tab_intents:
833
  st.caption("● YAML utterances · ◆ scenario utterances · ★ your query")
834
 
835
  with info_col_i:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  if classified:
837
  conf = classified.get("confidence", "?")
838
  conf_color = {"high": "#34d399", "medium": "#f59e0b", "low": "#f87171"}.get(conf, "#aaa")
@@ -851,23 +869,23 @@ with tab_intents:
851
  domain_counts[r["domain"]] = domain_counts.get(r["domain"], 0) + 1
852
 
853
  for dom in unique_domains:
854
- hex_c = domain_color[dom]
855
  intent_labels = list(dict.fromkeys(
856
  r["intent"] for r in rows_i if r["domain"] == dom
857
  ))
858
  with st.expander(
859
- f"**{dom}** — {domain_counts[dom]} utterances",
860
  expanded=classified is not None and classified.get("domain") == dom,
861
  ):
862
  for il in intent_labels:
863
  count = sum(1 for r in rows_i if r["domain"] == dom and r["intent"] == il)
864
  is_match = classified and classified.get("intent") == il and classified.get("domain") == dom
865
- prefix = "→ " if is_match else ""
866
- weight = "**" if is_match else ""
867
- st.markdown(
868
- f"{prefix}{weight}`{il}`{weight} <small style='color:#888'>({count})</small>",
869
- unsafe_allow_html=True,
870
- )
 
871
 
872
 
873
  # ---------------------------------------------------------------------------
 
833
  st.caption("● YAML utterances · ◆ scenario utterances · ★ your query")
834
 
835
  with info_col_i:
836
+ # Stabilize layout to prevent scrollbar flicker
837
+ st.markdown(
838
+ """
839
+ <style>
840
+ /* Ensure the side column doesn't jump when content expands */
841
+ div[data-testid="column"]:nth-of-type(2) {
842
+ overflow-x: hidden;
843
+ }
844
+ .stExpander {
845
+ border: 1px solid rgba(255, 255, 255, 0.1);
846
+ border-radius: 4px;
847
+ margin-bottom: 0.5rem;
848
+ }
849
+ </style>
850
+ """,
851
+ unsafe_allow_html=True
852
+ )
853
+
854
  if classified:
855
  conf = classified.get("confidence", "?")
856
  conf_color = {"high": "#34d399", "medium": "#f59e0b", "low": "#f87171"}.get(conf, "#aaa")
 
869
  domain_counts[r["domain"]] = domain_counts.get(r["domain"], 0) + 1
870
 
871
  for dom in unique_domains:
 
872
  intent_labels = list(dict.fromkeys(
873
  r["intent"] for r in rows_i if r["domain"] == dom
874
  ))
875
  with st.expander(
876
+ f"**{dom}** ({domain_counts[dom]})",
877
  expanded=classified is not None and classified.get("domain") == dom,
878
  ):
879
  for il in intent_labels:
880
  count = sum(1 for r in rows_i if r["domain"] == dom and r["intent"] == il)
881
  is_match = classified and classified.get("intent") == il and classified.get("domain") == dom
882
+ prefix = "🎯 " if is_match else ""
883
+
884
+ # Show utterances in a nested expander
885
+ with st.expander(f"{prefix}`{il}` ({count})", expanded=is_match):
886
+ utts = [r["utterance"] for r in rows_i if r["domain"] == dom and r["intent"] == il]
887
+ for u in utts:
888
+ st.markdown(f"<small>• {u}</small>", unsafe_allow_html=True)
889
 
890
 
891
  # ---------------------------------------------------------------------------