Lara Monteagudo Tubau commited on
Commit Β·
7d23ffa
1
Parent(s): e8a5038
style: remove emojis, restore system font, three-card session layout
Browse files124 unmodified lines12512612712812812913013113 unmodified lines145146147148149148149150151151153152153154155156151 unmodified lines3083093103113113123133133143153169 unmodified lines3263273283293303313323333293303313323333343353363373353363373383393393403413423438 unmodified lines35235335435435535635735823 unmodified lines3823833843843853863873873883883893903913928 unmodified lines40140240340340440540640740740840940941041141141241341341441541641641741841741841942042142222 unmodified lines44544644744744844945045145145245345445524 unmodified lines48048148248248348448548614 unmodified lines5015025035035045055065076 unmodified lines51451551651651751851952062 unmodified lines58358458558558658758758858959059138 unmodified lines63063163263263363463563631 unmodified lines66866967067067167267367418 unmodified lines69369469569569669769869928 unmodified lines72872973073073173273373485 unmodified lines82082182282282382482582610 unmodified lines83783883983984084184284284384484584636 unmodified lines88388488588588688788888951 unmodified lines94194294394394494594694721 unmodified lines9699709719719729739749751 unmodified line97797897997998098198298398498598698698798898999054 unmodified lines1045104610471047104810491049105010511052105319 unmodified lines1073107410751075107610771078107910801080108110821083108483 unmodified lines1168116911701170117111721173117410 unmodified lines11851186118711871188118911901191524 unmodified lines1716171717181718171917201721172229 unmodified lines1752175317541755175617551756175717581759176017571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797176217631764176517661798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930177219311932177419331934193519361937193819391940177919411942194319441945194619473 unmodified lines1951195219531789179019541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420051793179417951796179717982006180020072008200918032010201120121806180720132014180920152016201718121813201820192020202120222023202421 unmodified lines204620472048184120492050205120521 unmodified line2054205520561849205720582059206020 unmodified lines20812082208318762084208520862087208820892090188320912092209320947 unmodified lines2102210321041897210521062107210810 unmodified lines211921202121191421222123212421252126212721281921212921302131213221 unmodified lines2154215521561949215721582159216034 unmodified lines219521962197199021982199220022011 unmodified line2203220422051998220622072208220910 unmodified lines222022212222201522232224222522269 unmodified lines223622372238203122392240224122424 unmodified lines2247224822492042225022512252225355 unmodified lines230923102311210423122313231423152 unmodified lines23182319232021132321232223232324211723252326232723281 unmodified line2330233123322125233323342335233625 unmodified lines2362236323642157236523662367216023682369237023716 unmodified lines237823792380217321742381238223832384238520 unmodified lines240624072408220124092410241124121 unmodified line241424152416220924172418241924203 unmodified lines2424242524262219222024272428242924302431124 unmodified lines
# SSRL metacognitive phases β shown alongside D1-D9 in Review tabSSRL_PHASES = [ ("M-MON", "Metacognitive Monitoring", "#4338ca", "#eef2ff"), ("M-MON", "Metacognitive Monitoring", "#ea580c", "#fff7ed"), ("M-REG", "Metacognitive Regulation", "#065f46", "#ecfdf5"), ("CO-REG", "Co-Regulation", "#b45309", "#fffbeb"), ("SSRL", "Socially Shared Regulation", "#9a3412", "#fff7ed"),13 unmodified linesSEC_ID_FROM_CHOICE = {SEC_NONE: None, **DIM_ID_FROM_CHOICE}
SPEAKER_PALETTE = [ ("#4338ca", "#eef2ff", "#c7d2fe", "π΅"), ("#b45309", "#fffbeb", "#fde68a", "π‘"), ("#ea580c", "#fff7ed", "#fed7aa", "π "), ("#0e7490", "#ecfeff", "#a5f3fc", "π·"), ("#065f46", "#ecfdf5", "#a7f3d0", "π’"), ("#9a3412", "#fff7ed", "#fed7aa", "π "), ("#6b21a8", "#faf5ff", "#e9d5ff", "π£"), ("#0e7490", "#ecfeff", "#a5f3fc", "π·"), ("#b45309", "#fffbeb", "#fde68a", "π‘"), ("#be123c", "#fff1f2", "#fecdd3", "π΄"),]
151 unmodified lines if i < cur_idx: bg, tc, border, dot = "#dcfce7", "#15803d", "#86efac", "β" elif i == cur_idx: bg, tc, border, dot = "#eff6ff", "#1d4ed8", "#93c5fd", "βΆ" bg, tc, border, dot = "#fff7ed", "#c2410c", "#fdba74", "βΆ" else: bg, tc, border, dot = "#f8fafc", "#94a3b8", "#e2e8f0", "β" bg, tc, border, dot = "#fafaf9", "#a8a29e", "#e7e5e4", "β" steps.append( f'<div style="display:flex;flex-direction:column;align-items:center;' f'gap:3px;padding:6px 12px;border-radius:8px;background:{bg};'9 unmodified lines n_wins = len(screener["candidate_windows"]) if screener else "β"
return ( f'<div style="background:#fff;border-bottom:2px solid #e2e8f0;' f'padding:12px 20px;display:flex;align-items:center;gap:16px;' f'flex-wrap:wrap;font-family:system-ui,sans-serif">' f'<div style="display:flex;align-items:center;gap:8px;margin-right:8px">' f'<span style="font-size:1.1em">π¬</span>' f'<div style="background:white;padding:10px 24px;display:flex;' f'align-items:center;gap:16px;flex-wrap:wrap;font-family:Inter,system-ui,sans-serif">' f'<div style="display:flex;align-items:center;gap:10px;margin-right:8px">' f'<div style="width:8px;height:8px;border-radius:50%;' f'background:#ea580c;box-shadow:0 0 0 3px #ffedd5"></div>' f'<div style="line-height:1.3">' f'<div style="font-weight:800;color:#1e293b;font-size:0.9em">{session}</div>' f'<div style="font-size:0.72em;color:#94a3b8">' f'{turns} turns Β· screener: {n_wins} windows Β· ~{savings} LLM savings' f'<div style="font-weight:800;color:#1c1917;font-size:0.88em;' f'letter-spacing:-0.01em">{session}</div>' f'<div style="font-size:0.7em;color:#a8a29e">' f'{turns} turns Β· {n_wins} candidate windows Β· ~{savings} LLM savings' f'</div></div></div>' f'<div style="display:flex;gap:6px;flex-wrap:wrap">{"".join(steps)}</div>' f'<div style="display:flex;gap:5px;flex-wrap:wrap">{"".join(steps)}</div>' f'</div>' )
8 unmodified lines "success": ("#f0fdf4", "#065f46", "#86efac", "β"), "error": ("#fef2f2", "#991b1b", "#fca5a5", "β"), "warning": ("#fffbeb", "#78350f", "#fbbf24", "β "), "processing": ("#eff6ff", "#1e40af", "#93c5fd", "β³"), "processing": ("#fff7ed", "#9a3412", "#fdba74", "β³"), } bg, tc, bc, icon = colors.get(status, colors["success"]) detail_html = ""23 unmodified lines
def _loading_card(title: str, subtitle: str = "Please waitβ¦", spin: str = "β") -> str: return ( '<div style="background:#eff6ff;border:2px solid #93c5fd;border-radius:12px;' '<div style="background:#fff7ed;border:2px solid #fdba74;border-radius:12px;' 'padding:18px 20px;margin:10px 0;font-family:system-ui,sans-serif">' '<div style="display:flex;align-items:center;gap:12px">' f'<div style="font-size:1.35em;color:#1e3a8a">{spin}</div>' f'<div><div style="font-weight:800;color:#1e3a8a;font-size:1.02em">{_h(title)}</div>' f'<div style="font-size:1.35em;color:#7c2d12">{spin}</div>' f'<div><div style="font-weight:800;color:#7c2d12;font-size:1.02em">{_h(title)}</div>' f'<div style="margin-top:4px;font-size:0.86em;color:#475569">{_h(subtitle)}</div></div>' '</div></div>' )8 unmodified lines circ_icon = "β" if circ == "CLOSED" else "β " if circ == "HALF_OPEN" else "β" eta_str = f"~{remaining}s" if remaining > 5 else "finishingβ¦" return ( f'<div style="background:#eff6ff;border:2px solid #93c5fd;' f'<div style="background:#fff7ed;border:2px solid #fdba74;' f'border-radius:12px;padding:16px 20px;font-family:system-ui,sans-serif">' f'<div style="display:flex;align-items:center;gap:10px;margin-bottom:12px">' f'<span style="font-size:1.3em">{spinner}</span>' f'<span style="font-weight:700;color:#1e3a8a;font-size:0.94em">{_h(message)}</span>' f'<span style="font-weight:700;color:#7c2d12;font-size:0.94em">{_h(message)}</span>' f'<span style="margin-left:auto;font-family:monospace;font-size:0.84em;' f'background:#dbeafe;padding:3px 9px;border-radius:6px;color:#1e40af">' f'background:#ffedd5;padding:3px 9px;border-radius:6px;color:#9a3412">' f'{elapsed}s elapsed</span></div>' f'<div style="background:#dbeafe;border-radius:5px;height:9px;' f'<div style="background:#ffedd5;border-radius:5px;height:9px;' f'margin-bottom:10px;overflow:hidden">' f'<div style="height:100%;width:{pct}%;background:#4338ca;border-radius:5px"></div>' f'<div style="height:100%;width:{pct}%;background:#ea580c;border-radius:5px"></div>' f'</div>' f'<div style="display:flex;flex-wrap:wrap;gap:14px;font-size:0.8em;color:#475569">' f'<span>β± Est: ~{est_total}s</span>' f'<span>β ETA: {eta_str}</span>' f'<span>π’ ~{tokens_in:,} tokens</span>' f'<span>Est: ~{est_total}s</span>' f'<span>ETA: {eta_str}</span>' f'<span>~{tokens_in:,} tokens</span>' f'<span style="color:{circ_color};font-weight:600">' f'Circuit: {circ_icon} {circ}</span>' f'</div></div>'22 unmodified lines f'<div style="border:1px solid #e2e8f0;border-radius:8px;' f'padding:10px 12px;margin-bottom:8px;background:white">' f'<div style="display:flex;justify-content:space-between;margin-bottom:4px">' f'<span style="font-weight:700;font-size:0.88em;color:#1e293b">{agent}</span>' f'<span style="font-weight:700;font-size:0.88em;color:#1c1917">{agent}</span>' f'<span style="font-size:0.72em;color:#94a3b8">{ts} Β· {runtime}s</span>' f'</div>' f'<div style="font-size:0.76em;color:#94a3b8">model: ' f'<strong style="color:#4338ca">{model}</strong></div>' f'<strong style="color:#ea580c">{model}</strong></div>' f'{extra_lines}' f'</div>' )24 unmodified lines f'<span style="font-family:monospace;font-size:0.7em;color:#94a3b8">{ts}</span>' f'<span style="font-family:monospace;font-size:0.67em;color:#cbd5e1">#{turn_id}</span>' f'</div>' f'<div style="line-height:1.6;color:#1e293b;font-size:0.93em">{text}</div>' f'<div style="line-height:1.6;color:#1c1917;font-size:0.93em">{text}</div>' f'</div></div>' ) return f'<div style="font-family:system-ui,sans-serif">{"".join(parts)}</div>'14 unmodified lines if score >= 0.40: return "#fef9c3", "#854d0e" if score >= 0.2: return "#eff6ff", "#1d4ed8" return "#fff7ed", "#c2410c" return "#f8fafc", "#94a3b8"
6 unmodified lines return ( f'<div style="display:flex;gap:12px;flex-wrap:wrap;' f'font-family:system-ui,sans-serif;margin-bottom:16px">' + _stat_chip(str(total), "Total turns", "#4338ca", "#eef2ff") + _stat_chip(str(total), "Total turns", "#ea580c", "#fff7ed") + _stat_chip(str(flagged), "Flagged turns", "#065f46", "#dcfce7") + _stat_chip(str(windows), "Candidate windows", "#b45309", "#fffbeb") + _stat_chip(f"{savings:.0%}", "LLM savings", "#be123c", "#fef2f2")62 unmodified lines ph = hit.get("phase", "") lbl = hit.get("category_label", "") tier = hit.get("tier", 1) tchip_bg = {"planning": "#eff6ff", "monitoring": "#f0fdf4", tchip_bg = {"planning": "#fff7ed", "monitoring": "#f0fdf4", "evaluating": "#fff7ed", "ssrl": "#faf5ff"}.get(ph, "#f8fafc") tchip_c = {"planning": "#1d4ed8", "monitoring": "#15803d", tchip_c = {"planning": "#c2410c", "monitoring": "#15803d", "evaluating": "#c2410c", "ssrl": "#7c3aed"}.get(ph, "#64748b") tier_mark = "β¨2β©" if tier == 2 else "β¨3?β©" if tier == 3 else "" trigger_chips += (38 unmodified lines f'</div>'
# Text f'<div style="font-size:0.85em;color:#1e293b;line-height:1.5">' f'<div style="font-size:0.85em;color:#1c1917;line-height:1.5">' f'{display_text}</div>'
# Triggers31 unmodified lines f'font-family:monospace;min-width:44px;text-align:center">' f'{i:02d}</div>' f'<div style="flex:1">' f'<div style="font-weight:700;font-size:0.9em;color:#1e293b">' f'<div style="font-weight:700;font-size:0.9em;color:#1c1917">' f'Turns {_h(str(start))}β{_h(str(end))} ' f'<span style="font-weight:400;color:#64748b">({n} turns)</span></div>' f'<div style="font-size:0.8em;color:#475569;margin-top:2px">'18 unmodified lines return '<p style="color:#94a3b8">Lexicon file not found.</p>'
phase_colors = { "planning": ("#1d4ed8", "#eff6ff", "#dbeafe"), "planning": ("#c2410c", "#fff7ed", "#ffedd5"), "monitoring": ("#15803d", "#f0fdf4", "#dcfce7"), "evaluating": ("#c2410c", "#fff7ed", "#fed7aa"), "ssrl": ("#7c3aed", "#faf5ff", "#e9d5ff"),28 unmodified lines f'<div style="display:flex;align-items:baseline;gap:10px;margin-bottom:6px">' f'<span style="font-family:monospace;font-size:0.8em;font-weight:700;' f'background:{bg};color:{tc};padding:2px 8px;border-radius:4px">{cat_id}</span>' f'<span style="font-weight:700;color:#1e293b">{label}</span>' f'<span style="font-weight:700;color:#1c1917">{label}</span>' f'<span style="margin-left:auto;font-size:0.78em;color:{tc};font-weight:600">' f'w={weight} Β· {_h(phase)}</span>' f'</div>'85 unmodified lines f'padding:12px 16px;margin-bottom:10px;background:#fffbeb">' f'<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px">' f'<span style="font-size:0.82em;font-weight:700;color:#b45309">β³ Pending</span>' f'<span style="font-weight:700;color:#1e293b">{label}</span>' f'<span style="font-weight:700;color:#1c1917">{label}</span>' f'<span style="margin-left:auto;font-size:0.72em;color:#94a3b8">{session}</span>' f'</div>' f'<div style="margin-bottom:8px">{term_chips}</div>'10 unmodified lines
def _dim_badge(did: str) -> str: colors = { "D1": ("#4338ca","#eef2ff"), "D2": ("#0e7490","#ecfeff"), "D1": ("#ea580c","#fff7ed"), "D2": ("#0e7490","#ecfeff"), "D3": ("#065f46","#ecfdf5"), "D4": ("#b45309","#fffbeb"), "D5": ("#6b21a8","#faf5ff"), "D6": ("#9a3412","#fff7ed"), "D7": ("#1e40af","#dbeafe"), "D8": ("#be123c","#fef2f2"), "D7": ("#9a3412","#ffedd5"), "D8": ("#be123c","#fef2f2"), "D9": ("#374151","#f3f4f6"), "NS": ("#78716c","#f5f5f4"), "NA": ("#94a3b8","#f8fafc"), }36 unmodified lines screener_tag = ( '<span style="background:#d1fae5;color:#065f46;font-size:0.72em;' 'padding:2px 6px;border-radius:4px;margin-left:6px">' 'π screener hit</span>' 'screener hit</span>' )
uncertain_tag = ""51 unmodified lines
header = ( f'<div style="display:flex;gap:10px;margin-bottom:14px;flex-wrap:wrap">' + _stat_chip(str(total), "Segments", "#4338ca", "#eef2ff") + _stat_chip(str(total), "Segments", "#ea580c", "#fff7ed") + _stat_chip(str(coded), "D1-D9 coded", "#065f46", "#dcfce7") + _stat_chip(str(ssrl_ct), "SSRL tagged", "#7c3aed", "#faf5ff") + f'</div>'21 unmodified lines cards.append( f'<div style="border:2px solid #e2e8f0;border-radius:10px;' f'padding:14px 16px;background:white">' f'<div style="font-weight:800;color:#1e293b;font-size:0.92em">' f'<div style="font-weight:800;color:#1c1917;font-size:0.92em">' f'{_h(s["label"])}</div>' f'<div style="font-family:monospace;font-size:0.75em;color:#94a3b8;' f'margin:4px 0">{_h(s["start_time"])}β{_h(s["end_time"])}</div>'1 unmodified line f'{s["end_turn_id"]} ({n} turns Β· {pct}%)</div>' f'<div style="height:4px;background:#e2e8f0;border-radius:2px;' f'margin-top:8px;overflow:hidden">' f'<div style="height:100%;width:{pct}%;background:#4338ca;border-radius:2px">' f'<div style="height:100%;width:{pct}%;background:#ea580c;border-radius:2px">' f'</div></div>' f'</div>' ) return ( f'<div style="font-family:system-ui,sans-serif">' f'<div style="display:flex;gap:8px;margin-bottom:10px;flex-wrap:wrap">' + _stat_chip(str(n_turns), "Turns", "#4338ca", "#eef2ff") + _stat_chip(str(n_turns), "Turns", "#ea580c", "#fff7ed") + _stat_chip(str(len(sections)), "Sections", "#065f46", "#dcfce7") + _stat_chip(str(n_speakers), "Speakers", "#b45309", "#fffbeb") + _stat_chip(f"{elapsed}s", "Agent 0", "#7c3aed", "#faf5ff")54 unmodified lines if not desc: return "" return ( f'<div style="background:#eff6ff;border-left:3px solid #4338ca;' f'<div style="background:#fff7ed;border-left:3px solid #ea580c;' f'border-radius:0 6px 6px 0;padding:7px 12px;font-size:0.85em;' f'color:#1e40af;margin-top:6px">{_h(desc)}</div>' f'color:#9a3412;margin-top:6px">{_h(desc)}</div>' )
19 unmodified lines f'padding:12px 16px;margin-bottom:12px">' f'<div style="display:flex;justify-content:space-between;align-items:baseline;' f'margin-bottom:6px">' f'<div style="font-size:0.88em;font-weight:700;color:#1e293b">' f'<div style="font-size:0.88em;font-weight:700;color:#1c1917">' f'Section {idx+1}/{len(sections)} β {_h(sec.get("label",""))}</div>' f'<div style="font-size:0.82em;color:#64748b">Episode {min(cidx,total-1)+1} of {total}</div>' f'</div>' f'<div style="height:6px;background:#e2e8f0;border-radius:3px;overflow:hidden">' f'<div style="height:100%;width:{pct}%;background:#4338ca;border-radius:3px"></div>' f'<div style="height:100%;width:{pct}%;background:#ea580c;border-radius:3px"></div>' f'</div>' f'<div style="display:flex;justify-content:space-between;margin-top:4px;' f'font-size:0.75em;color:#94a3b8">'83 unmodified lines
seg_map = {s["segment_id"]: s for s in all_segs} parts = [f'<div style="font-family:system-ui,sans-serif">' f'<div style="font-weight:700;margin-bottom:10px;color:#1e293b">' f'<div style="font-weight:700;margin-bottom:10px;color:#1c1917">' f'{len(disags)} unresolved disagreements</div>']
for d in disags:10 unmodified lines f'<span style="background:#fff7ed;color:#c2410c;font-weight:700;' f'padding:2px 8px;border-radius:4px">R1: {r1}</span>' f'<span style="color:#94a3b8">vs</span>' f'<span style="background:#eff6ff;color:#1d4ed8;font-weight:700;' f'<span style="background:#fff7ed;color:#c2410c;font-weight:700;' f'padding:2px 8px;border-radius:4px">R2: {r2}</span>' f'</div>' f'<div style="font-size:0.82em;color:#64748b;font-style:italic">{rat}</div>'524 unmodified lines f'padding:12px 14px;margin-bottom:8px">' f'<div style="font-family:monospace;font-size:0.78em;' f'color:#94a3b8;margin-bottom:4px">{rid}</div>' f'<div style="font-size:0.9em;color:#1e293b">{desc}</div>' f'<div style="font-size:0.9em;color:#1c1917">{desc}</div>' f'<div style="font-size:0.75em;color:#64748b;margin-top:4px">' f'From sessions: {src}</div>' f'</div>'29 unmodified lines# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
CUSTOM_CSS = """/* ββ Brand palette βββββββββββββββββββββββββββββββββββββ */:root { --primary: #4338ca; --primary-light: #eef2ff; --surface: #ffffff; --border: #e2e8f0; --text: #1e293b; --muted: #64748b; --primary: #ea580c; --primary-dark: #c2410c; --primary-darker: #7c2d12; --primary-light: #fff7ed; --primary-border: #fed7aa; --primary-mid: #fdba74; --surface: #ffffff; --surface-alt: #fafaf9; --border: #e7e5e4; --text: #1c1917; --text-muted: #78716c; --text-faint: #a8a29e;}
/* ββ Global reset & type βββββββββββββββββββββββββββββββ */body, .gradio-container { font-family: system-ui, -apple-system, sans-serif !important; background: #fafaf9 !important; color: #1c1917 !important;}
/* ββ App shell β remove Gradio's default grey box ββββ */.gradio-container > .main > .wrap { padding: 0 !important; }.gradio-container { max-width: 100% !important; padding: 0 !important; }footer { display: none !important; }
/* ββ Branded top header βββββββββββββββββββββββββββββββββ */.cc-header { background: linear-gradient(135deg, #7c2d12 0%, #ea580c 60%, #f97316 100%); padding: 18px 32px; display: flex; align-items: center; gap: 16px; box-shadow: 0 2px 12px rgba(234,88,12,0.25);}.cc-header-logo { font-size: 1.6em; font-weight: 900; color: white; letter-spacing: -0.03em;}body { font-family: system-ui, -apple-system, sans-serif; }.gr-box { border-radius: 10px !important; }.pipeline-header { position: sticky; top: 0; z-index: 100; }.tab-nav button { font-weight: 600 !important; }.screener-table { overflow-x: auto; }.cc-header-logo span { opacity: 0.7; font-weight: 400; }.cc-header-tag { font-size: 0.72em; background: rgba(255,255,255,0.18); color: white; padding: 3px 10px; border-radius: 20px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;}.cc-header-right { margin-left: auto; font-size: 0.78em; color: rgba(255,255,255,0.65);}
/* ββ Pipeline status bar βββββββββββββββββββββββββββββββ */.pipeline-header { position: sticky; top: 0; z-index: 100; background: white; border-bottom: 2px solid var(--primary-border); box-shadow: 0 2px 8px rgba(234,88,12,0.08);}
/* ββ Tabs βββββββββββββββββββββββββββββββββββββββββββββββ */.tabs > .tab-nav { border-bottom: 2px solid var(--primary-border) !important; }.tabs > .tab-nav button { font-weight: 700 !important; font-size: 0.88em !important; color: var(--text-muted) !important; padding: 10px 18px !important; border-radius: 0 !important; transition: color 0.15s, border-color 0.15s !important;}.tabs > .tab-nav button.selected { color: var(--primary) !important; border-bottom: 3px solid var(--primary) !important; background: transparent !important;}.tabs > .tab-nav button:hover { color: var(--primary-dark) !important; }
/* ββ Cards / containers βββββββββββββββββββββββββββββββββ */.gr-box, .gr-panel, .gr-form { border-radius: 12px !important; border-color: var(--border) !important; box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;}
/* ββ Inputs βββββββββββββββββββββββββββββββββββββββββββββ */input[type=text], textarea, .gr-input { border-color: var(--border) !important; border-radius: 8px !important; font-size: 0.9em !important;}input[type=text]:focus, textarea:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(234,88,12,0.12) !important; outline: none !important;}
/* ββ Buttons ββββββββββββββββββββββββββββββββββββββββββββ */.gr-button-primary, button[class*="primary"] { background: linear-gradient(135deg, var(--primary-dark), var(--primary)) !important; border: none !important; color: white !important; font-weight: 700 !important; border-radius: 8px !important; box-shadow: 0 2px 8px rgba(234,88,12,0.3) !important; transition: opacity 0.15s, box-shadow 0.15s !important;}.gr-button-primary:hover, button[class*="primary"]:hover { opacity: 0.93 !important; box-shadow: 0 4px 14px rgba(234,88,12,0.4) !important;}
/* ββ Dropdowns ββββββββββββββββββββββββββββββββββββββββββ */.gr-dropdown { border-radius: 8px !important; }
/* ββ Sliders ββββββββββββββββββββββββββββββββββββββββββββ */input[type=range]::-webkit-slider-thumb { background: var(--primary) !important; }input[type=range]::-webkit-slider-runnable-track { background: var(--primary-border) !important; }
/* ββ Scrollbars βββββββββββββββββββββββββββββββββββββββββ */::-webkit-scrollbar { width: 6px; height: 6px; }::-webkit-scrollbar-track { background: #f5f5f4; }::-webkit-scrollbar-thumb { background: var(--primary-border); border-radius: 3px; }::-webkit-scrollbar-thumb:hover { background: var(--primary-mid); }
/* ββ Markdown headings ββββββββββββββββββββββββββββββββββ */.gr-markdown h2 { font-size: 1.25em !important; font-weight: 800 !important; color: var(--primary-darker) !important; border-bottom: 2px solid var(--primary-border) !important; padding-bottom: 8px !important; margin-bottom: 12px !important;}.gr-markdown h3 { font-size: 1.02em !important; font-weight: 700 !important; color: var(--primary-dark) !important;}
/* ββ Accordion ββββββββββββββββββββββββββββββββββββββββββ */.gr-accordion { border-color: var(--primary-border) !important; border-radius: 10px !important; }.gr-accordion > .label { color: var(--primary-dark) !important; font-weight: 700 !important; }""" + _load_css()
_BRANDED_HEADER = """<div class="cc-header"> <div class="cc-header-logo">Collab<span>Code</span></div> <div class="cc-header-tag">Research Preview</div> <div style="display:flex;gap:10px;margin-left:12px"> <span style="background:rgba(255,255,255,0.15);color:white;font-size:0.72em; padding:3px 10px;border-radius:20px;font-weight:600"> Metacognitive Talk Detector </span> <span style="background:rgba(255,255,255,0.15);color:white;font-size:0.72em; padding:3px 10px;border-radius:20px;font-weight:600"> SSRL Β· D1-D9 </span> </div> <div class="cc-header-right">v5 Β· Qwen2.5-72B</div></div>"""
def build_ui(): with gr.Blocks( title="CollabCode v5", title="CollabCode β Metacognitive Talk Detector", css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="indigo", neutral_hue="slate"), theme=gr.themes.Soft( primary_hue="orange", neutral_hue="stone", ), ) as demo:
state = gr.State(_empty_state())
# ββ Persistent pipeline header ββββββββββββββββββββββββββββββββββββββββ # ββ Branded top header ββββββββββββββββββββββββββββββββββββββββββββββββ gr.HTML(value=_BRANDED_HEADER)
# ββ Persistent pipeline status ββββββββββββββββββββββββββββββββββββββββ with gr.Row(elem_classes=["pipeline-header"]): pipeline_header = gr.HTML(value=_pipeline_status_html(_empty_state()))
3 unmodified lines # ================================================================ # TAB 1 β SESSION # ================================================================ with gr.Tab("π Session"): gr.Markdown("## Session Setup\nLoad a transcript and identify yourself as a researcher.") with gr.Tab("Session"): gr.Markdown("## Session Setup") gr.HTML("""<div style="font-family:system-ui,sans-serif;font-size:0.9em;color:#78716c; margin-bottom:20px;max-width:600px"> Enter your researcher ID, then choose how to load a transcript below. Your ID is used to namespace codings and keep sessions separate across researchers.</div>""") researcher_id = gr.Textbox( label="Researcher ID", placeholder="e.g. R1_Lara", info="Used to namespace your codings and Drive sessions.", scale=1, )
# Three cards gr.HTML("""<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:16px; margin:20px 0;font-family:system-ui,sans-serif"> <div style="background:white;border:2px solid #fed7aa;border-radius:14px; padding:20px 20px 14px;box-shadow:0 2px 8px rgba(234,88,12,0.08)"> <div style="font-size:0.68em;font-weight:800;letter-spacing:0.1em; text-transform:uppercase;color:#ea580c;margin-bottom:6px">Option A</div> <div style="font-weight:800;font-size:1.05em;color:#1c1917;margin-bottom:4px"> Upload local file</div> <div style="font-size:0.82em;color:#78716c;line-height:1.5"> Upload a .txt, .vtt, or .srt transcript file from your computer.</div> </div> <div style="background:white;border:2px solid #e7e5e4;border-radius:14px; padding:20px 20px 14px;box-shadow:0 2px 8px rgba(0,0,0,0.04)"> <div style="font-size:0.68em;font-weight:800;letter-spacing:0.1em; text-transform:uppercase;color:#78716c;margin-bottom:6px">Option B</div> <div style="font-weight:800;font-size:1.05em;color:#1c1917;margin-bottom:4px"> Load from Drive</div> <div style="font-size:0.82em;color:#78716c;line-height:1.5"> Connect to Google Drive and pick a transcript from your shared folder.</div> </div> <div style="background:white;border:2px solid #e7e5e4;border-radius:14px; padding:20px 20px 14px;box-shadow:0 2px 8px rgba(0,0,0,0.04)"> <div style="font-size:0.68em;font-weight:800;letter-spacing:0.1em; text-transform:uppercase;color:#78716c;margin-bottom:6px">Option C</div> <div style="font-weight:800;font-size:1.05em;color:#1c1917;margin-bottom:4px"> Restore session</div> <div style="font-size:0.82em;color:#78716c;line-height:1.5"> Continue a previous coding session saved to Drive.</div> </div></div>""")
with gr.Row(): with gr.Column(scale=1): researcher_id = gr.Textbox( label="Researcher ID", placeholder="e.g. R1_Lara", info="Used to namespace your codings and Drive sessions." ) gr.Markdown("### Upload transcript (local file)") local_file = gr.File( label="Upload .txt or .vtt transcript", label="A β Upload .txt / .vtt / .srt transcript", file_types=[".txt", ".vtt", ".srt"], ) upload_btn = gr.Button("β¬ Load local file", variant="primary") upload_btn = gr.Button("Load local file", variant="primary")
with gr.Column(scale=1): gr.Markdown("### Or load from Google Drive") refresh_drive_btn = gr.Button("π Connect to Drive") refresh_drive_btn = gr.Button("Connect to Drive") drive_dropdown = gr.Dropdown( label="Select transcript from Drive", label="B β Select transcript from Drive", choices=[], interactive=False, ) drive_load_btn = gr.Button("β¬ Load from Drive") load_session_btn = gr.Button("π Restore previous session") drive_load_btn = gr.Button("Load from Drive")
with gr.Column(scale=1): load_session_btn = gr.Button("C β Restore previous session")
session_status = gr.HTML()
21 unmodified lines # ================================================================ # TAB 2 β SCREENER # ================================================================ with gr.Tab("π Screener"): with gr.Tab("Screener"): gr.Markdown( "## Metacognitive Talk Screener\n" "Scans every turn with the research-backed trigger lexicon before any LLM call. "1 unmodified line "Yellow β structural signal (question mark, interruption, rapid exchange)." ) with gr.Row(): run_screener_btn = gr.Button("βΆ Run Screener", variant="primary", scale=2) run_screener_btn = gr.Button("Run Screener", variant="primary", scale=2) screener_info = gr.HTML(scale=3)
screener_status = gr.HTML()20 unmodified lines # ================================================================ # TAB 3 β SECTIONS # ================================================================ with gr.Tab("π Sections"): with gr.Tab("Sections"): gr.Markdown( "## Structural Sections (Agent 0)\n" "Agent 0 detects the high-level structure of the session " "(e.g. warm-up, main task, wrap-up). Review and edit labels before coding." ) with gr.Row(): run_agent0_btn = gr.Button("βΆ Run Agent 0 β Detect sections", variant="primary") run_agent0_btn = gr.Button("Run Agent 0 β Detect sections", variant="primary") sections_status = gr.HTML() sections_display = gr.HTML()
7 unmodified lines lines=6, placeholder="Introduction\nMain Task\nWrap-up" ) with gr.Row(): confirm_sections_btn = gr.Button("β Confirm sections", variant="primary") confirm_sections_btn = gr.Button("Confirm sections", variant="primary") sections_confirm_status = gr.HTML()
run_agent0_btn.click(10 unmodified lines # ================================================================ # TAB 4 β PIPELINE # ================================================================ with gr.Tab("β Pipeline"): with gr.Tab("Pipeline"): gr.Markdown( "## Coding Pipeline (Agent 1a + 1b)\n" "Runs boundary detection and dimension coding on all confirmed sections. " "Uses screener windows to focus LLM calls on metacognitive candidate turns." ) with gr.Row(): run_pipeline_btn = gr.Button("βΆ Run full pipeline", variant="primary", scale=2) run_pipeline_btn = gr.Button("Run full pipeline", variant="primary", scale=2) pipeline_info = gr.HTML(scale=3)
pipeline_status_out = gr.HTML()21 unmodified lines sec_dropdown = gr.Dropdown(label="Secondary dimension (optional)", choices=SEC_DIM_CHOICES, value=SEC_NONE) coding_note = gr.Textbox(label="Note (optional)", lines=2) save_btn = gr.Button("πΎ Save coding", variant="primary") save_btn = gr.Button("Save coding", variant="primary") save_status_out = gr.HTML() manual_btn_visible = gr.Column(visible=False)
34 unmodified lines # ================================================================ # TAB 5 β REVIEW # ================================================================ with gr.Tab("π Review"): with gr.Tab("Review"): gr.Markdown( "## Segment Review & Editing\n" "All coded segments. Green π badge = screener flagged this segment "1 unmodified line )
with gr.Row(): refresh_review_btn = gr.Button("βΊ Refresh view", scale=1) refresh_review_btn = gr.Button("Refresh view", scale=1) review_info = gr.HTML(scale=4)
review_display = gr.HTML()10 unmodified lines choices=SSRL_CHOICES, value=SSRL_CHOICES[-1], # NONE ) save_ssrl_btn = gr.Button("πΎ Save SSRL tag", variant="secondary") save_ssrl_btn = gr.Button("Save SSRL tag", variant="secondary") ssrl_status = gr.HTML()
refresh_review_btn.click(9 unmodified lines # ================================================================ # TAB 6 β AGREEMENT # ================================================================ with gr.Tab("π€ Agreement"): with gr.Tab("Agreement"): gr.Markdown( "## Inter-Rater Reliability\n" "Upload coding files from both researchers. "4 unmodified lines r1_file = gr.File(label="R1 codings (.json)", file_types=[".json"]) r2_file = gr.File(label="R2 codings (.json)", file_types=[".json"])
calc_kappa_btn = gr.Button("π Calculate agreement", variant="primary") calc_kappa_btn = gr.Button("Calculate agreement", variant="primary") kappa_status_out = gr.HTML() kappa_summary_out = gr.HTML() disagreement_out = gr.HTML()55 unmodified lines # ================================================================ # TAB 7 β LEXICON # ================================================================ with gr.Tab("π Lexicon"): with gr.Tab("Lexicon"): gr.Markdown( "## Trigger Word Lexicon\n" "The research-backed vocabulary used to screen turns before LLM coding. "2 unmodified lines "Tier 3 holds candidates proposed by the system β review and approve or reject them." ) with gr.Row(): load_lexicon_btn = gr.Button("π Load / refresh lexicon", variant="primary") load_lexicon_btn = gr.Button("Load / refresh lexicon", variant="primary") lexicon_status = gr.HTML()
with gr.Tabs(): with gr.Tab("π Tier 1 β Research-locked"): with gr.Tab("Tier 1 β Research-locked"): gr.Markdown( "Source: Halmo et al. 2022, Zimmerman SRL model, " "JΓ€rvelΓ€ & Hadwin SSRL, LIWC cognitive categories, "1 unmodified line ) tier1_html = gr.HTML()
with gr.Tab("β Tier 2 β Your validated terms"): with gr.Tab("Tier 2 β Validated terms"): gr.Markdown( "Terms you've validated in your specific participant population. " "These are used at full weight by the screener."25 unmodified lines ) t2_note = gr.Textbox(label="Note / source", lines=2, placeholder="Observed in Session 3 and 4.") add_t2_btn = gr.Button("β Add to Tier 2", variant="primary") add_t2_btn = gr.Button("Add to Tier 2", variant="primary") add_t2_status = gr.HTML()
with gr.Tab("β³ Tier 3 β Candidates (system-proposed)"): with gr.Tab("Tier 3 β Candidates"): gr.Markdown( "Words that appeared in LLM-coded metacognitive segments but " "aren't in Tier 1 or 2 yet. Review each one: approve to move to Tier 2, "6 unmodified lines t3_term = gr.Textbox(label="Term to approve/reject") t3_note = gr.Textbox(label="Rejection note (optional)") with gr.Row(): approve_t3_btn = gr.Button("β Approve", variant="primary") reject_t3_btn = gr.Button("β Reject") approve_t3_btn = gr.Button("Approve", variant="primary") reject_t3_btn = gr.Button("Reject") t3_action_status = gr.HTML()
load_lexicon_btn.click(20 unmodified lines # ================================================================ # TAB 8 β LEARNING # ================================================================ with gr.Tab("π§ Learning"): with gr.Tab("Learning"): gr.Markdown( "## Agent 2 β Rule Learning\n" "After sessions accumulate disagreements, Agent 2 proposes coding rules "1 unmodified line "before they become active in Tier 2." ) with gr.Row(): load_rules_btn = gr.Button("π Load pending rules", variant="primary") load_rules_btn = gr.Button("Load pending rules", variant="primary") learning_status = gr.HTML()
pending_rules_html = gr.HTML()3 unmodified lines rule_id_box = gr.Textbox(label="Rule ID") rule_note_box = gr.Textbox(label="Rejection note (optional)") with gr.Row(): approve_rule_btn = gr.Button("β Approve rule", variant="primary") reject_rule_btn = gr.Button("β Reject rule") approve_rule_btn = gr.Button("Approve rule", variant="primary") reject_rule_btn = gr.Button("Reject rule") rule_action_status = gr.HTML()
load_rules_btn.click(app.py+316-108