Lara Monteagudo Tubau commited on
Commit Β·
fa5ff78
1
Parent(s): 7d23ffa
style: restore original hero + three-card home screen and cc-* palette
Browse files124 unmodified lines12512612712812913013113213313410 unmodified lines145146147148149150151156 unmodified lines30830931031131231331415 unmodified lines33033133233333433533615 unmodified lines35235335435535635735823 unmodified lines38238338438538638738812 unmodified lines40140240340440540640740840941041141241341441541641731 unmodified lines44945045145245345445545 unmodified lines5015025035045055065076 unmodified lines51451551651751851952062 unmodified lines583584585586587588589590591592100 unmodified lines693694695696697698699700701135 unmodified lines83783883984084184284384484584694 unmodified lines94194294394494594694729 unmodified lines97797897998098198298398498598698798898999054 unmodified lines10451046104710481049105010511052105324 unmodified lines107810791080108110821083108497 unmodified lines1182118311841185118611871188118911901191560 unmodified lines1752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190942 unmodified lines1952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024124 unmodified lines# SSRL metacognitive phases β shown alongside D1-D9 in Review tabSSRL_PHASES = [("M-MON", "Metacognitive Monitoring", "#ea580c", "#fff7ed"),("M-REG", "Metacognitive Regulation", "#065f46", "#ecfdf5"),("CO-REG", "Co-Regulation", "#b45309", "#fffbeb"),("SSRL", "Socially Shared Regulation", "#9a3412", "#fff7ed"),("NONE", "Not Metacognitive", "#64748b", "#f8fafc"),]10 unmodified linesSEC_ID_FROM_CHOICE = {SEC_NONE: None, **DIM_ID_FROM_CHOICE}SPEAKER_PALETTE = [("#ea580c", "#fff7ed", "#fed7aa", "π "),("#0e7490", "#ecfeff", "#a5f3fc", "π·"),("#065f46", "#ecfdf5", "#a7f3d0", "π’"),("#6b21a8", "#faf5ff", "#e9d5ff", "π£"),156 unmodified linesif i < cur_idx:bg, tc, border, dot = "#dcfce7", "#15803d", "#86efac", "β"elif i == cur_idx:bg, tc, border, dot = "#fff7ed", "#c2410c", "#fdba74", "βΆ"else:bg, tc, border, dot = "#fafaf9", "#a8a29e", "#e7e5e4", "β"steps.append(15 unmodified linesf'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:#1c1917;font-size:0.88em;'f'letter-spacing:-0.01em">{session}</div>'15 unmodified lines"success": ("#f0fdf4", "#065f46", "#86efac", "β"),"error": ("#fef2f2", "#991b1b", "#fca5a5", "β"),"warning": ("#fffbeb", "#78350f", "#fbbf24", "β "),"processing": ("#fff7ed", "#9a3412", "#fdba74", "β³"),}bg, tc, bc, icon = colors.get(status, colors["success"])detail_html = ""23 unmodified linesdef _loading_card(title: str, subtitle: str = "Please waitβ¦", spin: str = "β") -> str:return ('<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:#7c2d12">{spin}</div>'12 unmodified linescirc_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:#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:#7c2d12;font-size:0.94em">{_h(message)}</span>'f'<span style="margin-left:auto;font-family:monospace;font-size:0.84em;'f'background:#ffedd5;padding:3px 9px;border-radius:6px;color:#9a3412">'f'{elapsed}s elapsed</span></div>'f'<div style="background:#ffedd5;border-radius:5px;height:9px;'f'margin-bottom:10px;overflow:hidden">'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>'31 unmodified linesf'<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:#ea580c">{model}</strong></div>'f'{extra_lines}'f'</div>')45 unmodified linesif score >= 0.40:return "#fef9c3", "#854d0e"if score >= 0.2:return "#fff7ed", "#c2410c"return "#f8fafc", "#94a3b8"6 unmodified linesreturn (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", "#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 linesph = hit.get("phase", "")lbl = hit.get("category_label", "")tier = hit.get("tier", 1)tchip_bg = {"planning": "#fff7ed", "monitoring": "#f0fdf4","evaluating": "#fff7ed", "ssrl": "#faf5ff"}.get(ph, "#f8fafc")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 += (f'<span style="background:{tchip_bg};color:{tchip_c};font-size:0.68em;'100 unmodified linesreturn '<p style="color:#94a3b8">Lexicon file not found.</p>'phase_colors = {"planning": ("#c2410c", "#fff7ed", "#ffedd5"),"monitoring": ("#15803d", "#f0fdf4", "#dcfce7"),"evaluating": ("#c2410c", "#fff7ed", "#fed7aa"),"ssrl": ("#7c3aed", "#faf5ff", "#e9d5ff"),}135 unmodified linesdef _dim_badge(did: str) -> str:colors = {"D1": ("#ea580c","#fff7ed"), "D2": ("#0e7490","#ecfeff"),"D3": ("#065f46","#ecfdf5"), "D4": ("#b45309","#fffbeb"),"D5": ("#6b21a8","#faf5ff"), "D6": ("#9a3412","#fff7ed"),"D7": ("#9a3412","#ffedd5"), "D8": ("#be123c","#fef2f2"),"D9": ("#374151","#f3f4f6"), "NS": ("#78716c","#f5f5f4"),"NA": ("#94a3b8","#f8fafc"),}94 unmodified linesheader = (f'<div style="display:flex;gap:10px;margin-bottom:14px;flex-wrap:wrap">'+ _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>'29 unmodified linesf'{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:#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", "#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 linesif not desc:return ""return (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:#9a3412;margin-top:6px">{_h(desc)}</div>')24 unmodified linesf'<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:#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">'97 unmodified linesf'padding:12px 14px;margin-bottom:8px;background:#fffbeb">'f'<div style="display:flex;align-items:center;gap:10px;margin-bottom:6px">'f'<span style="font-family:monospace;font-size:0.8em;color:#78350f">{_h(sid)}</span>'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:#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>'560 unmodified lines# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββCUSTOM_CSS = """/* ββ Brand palette βββββββββββββββββββββββββββββββββββββ */:root {--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;}.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()42 unmodified lines# TAB 1 β SESSION# ================================================================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 cardsgr.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):local_file = gr.File(label="A β Upload .txt / .vtt / .srt transcript",file_types=[".txt", ".vtt", ".srt"],)upload_btn = gr.Button("Load local file", variant="primary")with gr.Column(scale=1):refresh_drive_btn = gr.Button("Connect to Drive")drive_dropdown = gr.Dropdown(label="B β Select transcript from Drive",choices=[], interactive=False,)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()124 unmodified lines12512612712812913013113213313410 unmodified lines145146147148149150151156 unmodified lines30830931031131231331415 unmodified lines33033133233333433533615 unmodified lines35235335435535635735823 unmodified lines38238338438538638738812 unmodified lines40140240340440540640740840941041141241341441541641731 unmodified lines44945045145245345445545 unmodified lines5015025035045055065076 unmodified lines51451551651751851952062 unmodified lines583584585586587588589590591592100 unmodified lines693694695696697698699700701135 unmodified lines83783883984084184284384484584694 unmodified lines94194294394494594694729 unmodified lines97797897998098198298398498598698798898999054 unmodified lines10451046104710481049105010511052105324 unmodified lines107810791080108110821083108497 unmodified lines1182118311841185118611871188118911901191560 unmodified lines175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193842 unmodified lines1981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053124 unmodified lines# SSRL metacognitive phases β shown alongside D1-D9 in Review tabSSRL_PHASES = [("M-MON", "Metacognitive Monitoring", "#ff5a3d", "#fff5f2"),("M-REG", "Metacognitive Regulation", "#065f46", "#ecfdf5"),("CO-REG", "Co-Regulation", "#b45309", "#fffbeb"),("SSRL", "Socially Shared Regulation", "#7c2d12", "#fff5f2"),("NONE", "Not Metacognitive", "#64748b", "#f8fafc"),]10 unmodified linesSEC_ID_FROM_CHOICE = {SEC_NONE: None, **DIM_ID_FROM_CHOICE}SPEAKER_PALETTE = [("#ff5a3d", "#fff5f2", "#ffc5b5", "π "),("#0e7490", "#ecfeff", "#a5f3fc", "π·"),("#065f46", "#ecfdf5", "#a7f3d0", "π’"),("#6b21a8", "#faf5ff", "#e9d5ff", "π£"),156 unmodified linesif i < cur_idx:bg, tc, border, dot = "#dcfce7", "#15803d", "#86efac", "β"elif i == cur_idx:bg, tc, border, dot = "#fff5f2", "#ea4425", "#ff8c75", "βΆ"else:bg, tc, border, dot = "#fafaf9", "#a8a29e", "#e7e5e4", "β"steps.append(15 unmodified linesf'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:#ff5a3d;box-shadow:0 0 0 3px #fff5f2"></div>'f'<div style="line-height:1.3">'f'<div style="font-weight:800;color:#1c1917;font-size:0.88em;'f'letter-spacing:-0.01em">{session}</div>'15 unmodified lines"success": ("#f0fdf4", "#065f46", "#86efac", "β"),"error": ("#fef2f2", "#991b1b", "#fca5a5", "β"),"warning": ("#fffbeb", "#78350f", "#fbbf24", "β "),"processing": ("#fff5f2", "#7c2d12", "#ff8c75", "β³"),}bg, tc, bc, icon = colors.get(status, colors["success"])detail_html = ""23 unmodified linesdef _loading_card(title: str, subtitle: str = "Please waitβ¦", spin: str = "β") -> str:return ('<div style="background:#fff5f2;border:2px solid #ff8c75;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:#7c2d12">{spin}</div>'12 unmodified linescirc_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:#fff5f2;border:2px solid #ff8c75;'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:#7c2d12;font-size:0.94em">{_h(message)}</span>'f'<span style="margin-left:auto;font-family:monospace;font-size:0.84em;'f'background:#fff5f2;padding:3px 9px;border-radius:6px;color:#7c2d12">'f'{elapsed}s elapsed</span></div>'f'<div style="background:#fff5f2;border-radius:5px;height:9px;'f'margin-bottom:10px;overflow:hidden">'f'<div style="height:100%;width:{pct}%;background:#ff5a3d;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>'31 unmodified linesf'<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:#ff5a3d">{model}</strong></div>'f'{extra_lines}'f'</div>')45 unmodified linesif score >= 0.40:return "#fef9c3", "#854d0e"if score >= 0.2:return "#fff5f2", "#ea4425"return "#f8fafc", "#94a3b8"6 unmodified linesreturn (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", "#ff5a3d", "#fff5f2")+ _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 linesph = hit.get("phase", "")lbl = hit.get("category_label", "")tier = hit.get("tier", 1)tchip_bg = {"planning": "#fff5f2", "monitoring": "#f0fdf4","evaluating": "#fff5f2", "ssrl": "#faf5ff"}.get(ph, "#f8fafc")tchip_c = {"planning": "#ea4425", "monitoring": "#15803d","evaluating": "#ea4425", "ssrl": "#7c3aed"}.get(ph, "#64748b")tier_mark = "β¨2β©" if tier == 2 else "β¨3?β©" if tier == 3 else ""trigger_chips += (f'<span style="background:{tchip_bg};color:{tchip_c};font-size:0.68em;'100 unmodified linesreturn '<p style="color:#94a3b8">Lexicon file not found.</p>'phase_colors = {"planning": ("#ea4425", "#fff5f2", "#fff5f2"),"monitoring": ("#15803d", "#f0fdf4", "#dcfce7"),"evaluating": ("#ea4425", "#fff5f2", "#ffc5b5"),"ssrl": ("#7c3aed", "#faf5ff", "#e9d5ff"),}135 unmodified linesdef _dim_badge(did: str) -> str:colors = {"D1": ("#ff5a3d","#fff5f2"), "D2": ("#0e7490","#ecfeff"),"D3": ("#065f46","#ecfdf5"), "D4": ("#b45309","#fffbeb"),"D5": ("#6b21a8","#faf5ff"), "D6": ("#7c2d12","#fff5f2"),"D7": ("#7c2d12","#fff5f2"), "D8": ("#be123c","#fef2f2"),"D9": ("#374151","#f3f4f6"), "NS": ("#78716c","#f5f5f4"),"NA": ("#94a3b8","#f8fafc"),}94 unmodified linesheader = (f'<div style="display:flex;gap:10px;margin-bottom:14px;flex-wrap:wrap">'+ _stat_chip(str(total), "Segments", "#ff5a3d", "#fff5f2")+ _stat_chip(str(coded), "D1-D9 coded", "#065f46", "#dcfce7")+ _stat_chip(str(ssrl_ct), "SSRL tagged", "#7c3aed", "#faf5ff")+ f'</div>'29 unmodified linesf'{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:#ff5a3d;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", "#ff5a3d", "#fff5f2")+ _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 linesif not desc:return ""return (f'<div style="background:#fff5f2;border-left:3px solid #ff5a3d;'f'border-radius:0 6px 6px 0;padding:7px 12px;font-size:0.85em;'f'color:#7c2d12;margin-top:6px">{_h(desc)}</div>')24 unmodified linesf'<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:#ff5a3d;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">'97 unmodified linesf'padding:12px 14px;margin-bottom:8px;background:#fffbeb">'f'<div style="display:flex;align-items:center;gap:10px;margin-bottom:6px">'f'<span style="font-family:monospace;font-size:0.8em;color:#78350f">{_h(sid)}</span>'f'<span style="background:#fff5f2;color:#ea4425;font-weight:700;'f'padding:2px 8px;border-radius:4px">R1: {r1}</span>'f'<span style="color:#94a3b8">vs</span>'f'<span style="background:#fff5f2;color:#ea4425;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>'560 unmodified lines# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββCUSTOM_CSS = """/* ββ Palette (matches original) βββββββββββββββββββββββ */:root {--cc-bg: #ececee;--cc-surface: #f6f6f7;--cc-paper: #ffffff;--cc-ink: #111217;--cc-muted: #6b6f76;--cc-border: #d8dade;--cc-accent: #ff5a3d;--cc-accent-deep: #ea4425;}/* ββ Global ββββββββββββββββββββββββββββββββββββββββββββ */.gradio-container {max-width: 1200px !important;margin: 0 auto !important;background: var(--cc-bg) !important;font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;}footer { display: none !important; }:focus-visible { outline: 2px solid var(--cc-accent) !important; outline-offset: 2px; }:focus { outline: none; }/* ββ Buttons βββββββββββββββββββββββββββββββββββββββββββ */.gradio-container button.primary {background: var(--cc-accent) !important;border-color: var(--cc-accent) !important;color: #fff !important;font-weight: 700 !important;}.gradio-container button.primary:hover {background: var(--cc-accent-deep) !important;border-color: var(--cc-accent-deep) !important;}.gradio-container button:not(.primary) { border-color: #c9cdd3 !important; }/* ββ Pipeline header βββββββββββββββββββββββββββββββββββ */.pipeline-header {position: sticky;top: 0;z-index: 100;background: white;border-bottom: 2px solid var(--cc-border);box-shadow: 0 2px 8px rgba(234,88,12,0.07);}/* ββ Tabs ββββββββββββββββββββββββββββββββββββββββββββββ */.tabs > .tab-nav { border-bottom: 2px solid var(--cc-border) !important; }.tabs > .tab-nav button {font-weight: 700 !important;font-size: 0.88em !important;color: var(--cc-muted) !important;padding: 10px 18px !important;border-radius: 0 !important;transition: color 0.15s !important;}.tabs > .tab-nav button.selected {color: var(--cc-accent) !important;border-bottom: 3px solid var(--cc-accent) !important;background: transparent !important;}.tabs > .tab-nav button:hover { color: var(--cc-accent-deep) !important; }/* ββ Hero (original) βββββββββββββββββββββββββββββββββββ */.cc-hero {text-align: center;padding: 56px 24px 40px;}.cc-hero-title {font-size: clamp(3.5rem, 10vw, 7rem);font-weight: 900;letter-spacing: -0.06em;color: var(--cc-ink);line-height: 0.88;margin: 0 0 16px;}.cc-hero-sub {font-size: 1rem;color: var(--cc-muted);max-width: 44ch;margin: 0 auto 48px;line-height: 1.55;}/* ββ Entry cards (original) ββββββββββββββββββββββββββββ */.cc-entry-card {background: var(--cc-paper);border: 1px solid var(--cc-border);border-radius: 16px;padding: 24px;min-height: 190px;position: relative;overflow: hidden;}.cc-entry-card::after {content: "";position: absolute;right: -24px; bottom: -24px;width: 96px; height: 96px;border-radius: 999px;background: rgba(255,90,61,0.1);}.cc-entry-kicker {font-size: 0.7rem;font-weight: 800;text-transform: uppercase;letter-spacing: 0.1em;color: var(--cc-accent-deep);margin-bottom: 10px;display: block;}.cc-entry-title {font-size: 1.28rem;font-weight: 800;letter-spacing: -0.025em;color: var(--cc-ink);margin: 0 0 8px;line-height: 1.1;}.cc-entry-desc {font-size: 0.87rem;color: #434852;line-height: 1.55;max-width: 32ch;}/* ββ Top header bar ββββββββββββββββββββββββββββββββββββ */.cc-header {background: linear-gradient(135deg, #7c2d12 0%, #ff5a3d 60%, #ff7a5a 100%);padding: 18px 32px;display: flex;align-items: center;gap: 16px;box-shadow: 0 2px 12px rgba(234,88,12,0.22);}.cc-header-logo {font-size: 1.6em;font-weight: 900;color: white;letter-spacing: -0.03em;}.cc-header-logo span { opacity: 0.65; 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.6); }/* ββ Inputs ββββββββββββββββββββββββββββββββββββββββββββ */input[type=text]:focus, textarea:focus {border-color: var(--cc-accent) !important;box-shadow: 0 0 0 3px rgba(255,90,61,0.12) !important;outline: none !important;}/* ββ Scrollbars ββββββββββββββββββββββββββββββββββββββββ */::-webkit-scrollbar { width: 6px; height: 6px; }::-webkit-scrollbar-track { background: #f5f5f4; }::-webkit-scrollbar-thumb { background: #d8dade; border-radius: 3px; }::-webkit-scrollbar-thumb:hover { background: #ff5a3d; }/* ββ Markdown headings βββββββββββββββββββββββββββββββββ */.gr-markdown h2 {font-size: 1.22em !important;font-weight: 800 !important;color: var(--cc-ink) !important;border-bottom: 2px solid var(--cc-border) !important;padding-bottom: 8px !important;margin-bottom: 12px !important;}.gr-markdown h3 {font-size: 1.0em !important;font-weight: 700 !important;color: var(--cc-accent-deep) !important;}""" + _load_css()42 unmodified lines# TAB 1 β SESSION# ================================================================with gr.Tab("Session"):# ββ Hero βββββββββββββββββββββββββββββββββββββββββββββββββgr.HTML('<div class="cc-hero">''<h1 class="cc-hero-title">CollabCode</h1>''<p class="cc-hero-sub">Human-in-the-loop metacognitive talk detection ''for collaborative learning research</p>''</div>')# ββ Three entry cards βββββββββββββββββββββββββββββββββββββwith gr.Row(equal_height=True):with gr.Column(scale=2):gr.HTML('<div class="cc-entry-card">''<span class="cc-entry-kicker">Primary workflow</span>''<h3 class="cc-entry-title">Code a Transcript</h3>''<p class="cc-entry-desc">Upload a Zoom transcript, run the ''metacognitive screener, let AI detect sections and segment ''boundaries, then code each episode against SSRL and D1-D9 dimensions.</p>''</div>')gr.Markdown("**Researcher ID** β enter before loading a transcript")researcher_id = gr.Textbox(placeholder="e.g. R1_Lara",show_label=False,)local_file = gr.File(label="Upload .txt / .vtt / .srt transcript",file_types=[".txt", ".vtt", ".srt"],)upload_btn = gr.Button("Load local file", variant="primary", size="lg")with gr.Column(scale=1):gr.HTML('<div class="cc-entry-card">''<span class="cc-entry-kicker">From Drive</span>''<h3 class="cc-entry-title">Load from Drive</h3>''<p class="cc-entry-desc">Connect to Google Drive and pick a ''transcript from your shared research folder.</p>''</div>')refresh_drive_btn = gr.Button("Connect to Drive")drive_dropdown = gr.Dropdown(label="Select transcript",choices=[], interactive=False,)drive_load_btn = gr.Button("Load from Drive")with gr.Column(scale=1):gr.HTML('<div class="cc-entry-card">''<span class="cc-entry-kicker">Continue</span>''<h3 class="cc-entry-title">Restore Session</h3>''<p class="cc-entry-desc">Pick up a previous coding session ''saved to Drive β all codings and screener results restored.</p>''</div>')load_session_btn = gr.Button("Restore previous session")gr.HTML('<div style="text-align:center;padding:28px 0 12px;''font-size:0.75rem;color:#94a3b8;font-family:system-ui">'f'Model: <strong>{MODEL_ID.split("/")[-1]}</strong> Β· 'f'Temperature: {TEMPERATURE} Β· ''Frameworks: Iiskala et al. 2011 (SSRL) Β· Meier, Spada & Rummel 2007 (D1-D9)''</div>')session_status = gr.HTML()
app.py+221-192