Lara Monteagudo Tubau commited on
Commit Β·
795a91a
1
Parent(s): 5b5a20d
Update Script for HF Space deployment
Browse filesFiles changed (7)
- app.py+158-118
- requirements.txt+1
- static/build.pyAdded+83
- static/styles/_components.scssAdded+684
- static/styles/_mixins.scssAdded+319
- static/styles/_tokens.scssAdded+355
- static/styles/main.scssAdded+165
46 unmodified lines47484950515253545556575887 unmodified lines14614714814915015143 unmodified lines1951961971981992002015 unmodified lines2072082092102112122132142152162172182192202212222232242252262272282292302312322332342351 unmodified line2372382392402412422432442452462472482492502512522532542552562572582592602612622632642658 unmodified lines27427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834917 unmodified lines36736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346410 unmodified lines47547647747847948048148248348448548648748848949046 unmodified linesfrom agent2_learner import list_pending_rules, approve_rule, reject_ruleSESSIONS_ROOT = Path("sessions")# ---------------------------------------------------------------------------# Visual design constants# ---------------------------------------------------------------------------CSS = """/* ββ Layout βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */.gradio-container { max-width: 1160px !important; margin: 0 auto !important; }footer { display: none !important; }87 unmodified lines.progress-mini-fill { height: 100%; background: #3b82f6; border-radius: 3px; }"""# ---------------------------------------------------------------------------# Dimension registry# ---------------------------------------------------------------------------43 unmodified linesdef _pipeline_html(stage: str) -> str:"""Render the pipeline progress stepper as HTML."""stages = [("upload", "1 Β· Parse"),("parsed", "2 Β· Sections"),5 unmodified linescur = order.index(stage) if stage in order else 0parts = []for i, (s, label) in enumerate(stages):if i < cur:cls = "step-done"prefix = "β "elif i == cur:cls = "step-active"prefix = "βΆ "else:cls = "step-pending"prefix = ""parts.append(f'<span class="{cls}">{prefix}{_h(label)}</span>')inner = '<span class="step-sep">β</span>'.join(parts)return (f'<div class="pipeline-bar">'f'<span style="font-size:0.78em;font-weight:700;letter-spacing:0.1em;'f'color:#94a3b8;margin-right:16px">PIPELINE</span>'f'{inner}</div>')def _section_cards_html(sections: list[dict], stages: dict, current_idx: int) -> str:"""Render section status cards as HTML."""if not sections:return ""1 unmodified linefor i, s in enumerate(sections):stage = stages.get(s["section_id"], "pending")if stage == "done":cls, icon, color = "sec-done", "β", "#16a34a"elif i == current_idx:cls, icon, color = "sec-active", "β", "#2563eb"else:cls, icon, color = "sec-pending", "β", "#94a3b8"n = s["end_turn_id"] - s["start_turn_id"] + 1cards.append(f'<div class="sec-card {cls}">'f'<div style="font-weight:700;color:{color};font-size:0.9em">'f'{icon} {_h(s["label"])}</div>'f'<div style="color:#94a3b8;font-size:0.78em;margin-top:3px">'f'{_h(s["start_time"])}β{_h(s["end_time"])} Β· {n} turns</div>'f'</div>')return f'<div class="section-cards">{"".join(cards)}</div>'def _episode_table_html(turns: list[dict], boundaries: list[dict]) -> str:"""Render proposed episodes and boundaries as an HTML table."""if not turns:return "<p><em>No turns loaded.</em></p>"turn_ids = sorted(t["turn_id"] for t in turns)bmap = {b["after_turn_id"]: b for b in boundaries}8 unmodified linesrows = ("<tr>""<th class='ep-table'>Episode</th>""<th class='ep-table'>Turns</th>""<th class='ep-table'>Count</th>""</tr>")for i, start in enumerate(cut_starts):if i + 1 < len(cut_starts):end = turn_ids[turn_ids.index(cut_starts[i + 1]) - 1]else:end = turn_ids[-1]n = end - start + 1bg = "#f8fafc" if i % 2 else "white"rows += (f'<tr style="background:{bg}">'f'<td style="font-weight:600">ep{i+1:02d}</td>'f'<td>turns {start}β{end}</td>'f'<td style="color:#64748b">{n}</td>'f'</tr>')if i < len(cut_starts) - 1:after_turn = cut_starts[i + 1] - 1b = bmap.get(after_turn, {})sig = _h(b.get("boundary_signal", "boundary"))conf = b.get("confidence", "?")rat = _h(b.get("rationale", ""))conf_color = {"high": "#16a34a", "medium": "#d97706", "low": "#dc2626"}.get(conf, "#64748b")rows += (f'<tr class="boundary-row">'f'<td colspan="3">'f'βββ after turn {after_turn} Β· <em>{sig}</em> Β· 'f'<strong style="color:{conf_color}">{conf}</strong> β {rat}'f'</td></tr>')n_eps = len(cut_starts)n_bounds = len(boundaries)return (f'<div class="card-header">{n_bounds} boundary{"" if n_bounds == 1 else "ies"}'f' β {n_eps} episode{"" if n_eps == 1 else "s"}</div>'f'<div style="overflow-x:auto">'f'<table class="ep-table" style="width:100%;border-collapse:collapse">'f'{rows}</table></div>')def _uncertainty_html(seg: dict) -> str:"""Render an uncertainty warning banner, or empty string if not uncertain."""if not seg.get("uncertain"):return ""note = _h(seg.get("uncertainty_note") or "")return (f'<div class="banner banner-warn">'f'<strong>β AI flagged uncertain</strong> β {note}'f'</div>')def _dim_desc_html(choice: str) -> str:"""Render a description box for the currently selected dimension."""if not choice:return ""did = DIM_ID_FROM_CHOICE.get(choice, "")desc = DIM_DESC_FROM_ID.get(did, "")if not desc:return ""bg = DIM_BADGE_COLOR.get(did, "#f8fafc")return (f'<div style="background:{bg};border-left:3px solid #3b82f6;'f'border-radius:0 6px 6px 0;padding:8px 12px;font-size:0.88em;color:#1e40af">'f'{_h(desc)}</div>')17 unmodified linesfor dim, k in sorted((report.get("kappa_per_dimension") or {}).items()):if k is None:continuek_pct = int(min(max(k, 0) * 100, 100))k_color = "#16a34a" if k >= 0.70 else "#f59e0b" if k >= 0.50 else "#dc2626"dim_rows += (f'<tr>'f'<td style="padding:4px 8px;font-weight:600;width:40px">{_h(dim)}</td>'f'<td style="padding:4px 8px">'f'<div class="dim-bar"><div class="dim-bar-fill" 'f'style="width:{k_pct}%;background:{k_color}"></div></div>'f'</td>'f'<td style="padding:4px 8px;color:{k_color};font-weight:600">{k:.3f}</td>'f'</tr>')if not dim_rows:dim_rows = '<tr><td colspan="3" style="color:#94a3b8;padding:4px 8px">No per-dimension data.</td></tr>'return (f'<div class="card">'f'<div style="display:flex;align-items:baseline;gap:16px;margin-bottom:6px">'f'<span class="kappa-score" style="color:{color}">{kappa:.3f}</span>'f'<div>'f'<div style="font-weight:700;color:{color};font-size:1.05em">{icon} {_h(interp)}</div>'f'<div style="color:#64748b;font-size:0.82em">threshold ΞΊ=0.70 β Landis & Koch (1977)</div>'f'</div></div>'# bar with threshold markerf'<div style="position:relative;height:10px;background:#e2e8f0;border-radius:5px;margin:10px 0">'f'<div style="position:absolute;height:100%;width:{pct}%;background:{color};border-radius:5px"></div>'f'<div style="position:absolute;left:{threshold_left}%;top:-3px;height:16px;'f'width:2px;background:#64748b"></div>'f'</div>'f'<div style="color:#64748b;font-size:0.85em;margin-bottom:14px">'f'{n_segs} segments Β· {n_dis} disagreement{"s" if n_dis != 1 else ""}'f'</div>'f'<div class="card-header">Per-Dimension Agreement</div>'f'<table style="border-collapse:collapse;font-size:0.88em">'f'<tr style="background:#f8fafc">'f'<th style="padding:4px 8px;text-align:left">Dim</th>'f'<th style="padding:4px 8px;text-align:left">Agreement</th>'f'<th style="padding:4px 8px;text-align:left">ΞΊ</th>'f'</tr>'f'{dim_rows}</table></div>')def _rules_html(rules: list[dict]) -> str:"""Render pending rules as styled cards."""if not rules:return '<div class="banner banner-success">No rules pending review.</div>'TYPE_BADGE = {"boundary_clarification": ("badge-boundary", "Boundary Clarification"),"disambiguation_rule": ("badge-disambiguation", "Disambiguation Rule"),"behavioral_marker_refinement": ("badge-marker", "Marker Refinement"),}cards = []for r in rules:rule_type = r.get("rule_type", "unknown")badge_cls, badge_label = TYPE_BADGE.get(rule_type, ("badge-marker", rule_type))dims = ", ".join(r.get("dimensions_involved") or [])desc = _h(r.get("description", ""))rat = _h(r.get("rationale", ""))conf = _h(r.get("confidence", ""))note = _h(r.get("agent2_note", ""))rid = _h(r.get("rule_id", ""))created = r.get("created_at", "")[:10]cards.append(f'<div class="rule-card">'f'<div style="display:flex;justify-content:space-between;align-items:flex-start">'f'<div>'f'<span class="rule-type-badge {badge_cls}">{badge_label}</span>'f'<span style="margin-left:8px;color:#94a3b8;font-size:0.8em">'f'{rid} Β· {created}</span>'f'</div>'f'<span style="font-size:0.82em;color:#64748b">dims: {_h(dims)}</span>'f'</div>'f'<p style="font-size:0.95em;margin:10px 0 6px 0">{desc}</p>'f'<p style="font-size:0.85em;color:#475569;margin:0 0 4px 0">'f'<strong>Rationale:</strong> {rat}</p>'f'<div style="display:flex;gap:16px;font-size:0.83em;color:#64748b">'f'<span>Confidence: <strong>{conf}</strong></span>'+ (f'<span>Note: {note}</span>' if note else '') +f'</div>'f'</div>')return "".join(cards)def _coding_progress_html(state: dict) -> str:"""Render coding progress as an HTML progress block."""sections = state.get("sections", [])idx = state.get("section_idx", 0)segs = _current_section_segments(state)10 unmodified linesep_num = min(cidx, total - 1) + 1return (f'<div>'f'<div style="font-size:0.82em;color:#64748b;margin-bottom:2px">'f'Section {idx + 1} of {len(sections)} β 'f'<strong style="color:#1e293b">{_h(sec.get("label", ""))}</strong>'f' Β· Episode {ep_num} of {total}'f'</div>'f'<div class="progress-mini">'f'<div class="progress-mini-fill" style="width:{pct}%"></div>'f'</div>'f'<div style="font-size:0.78em;color:#94a3b8">{coded} of {total} coded ({pct}%)</div>'f'</div>')46 unmodified lines474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929387 unmodified lines18118218318418518618718818943 unmodified lines2332342352362372382395 unmodified lines2452462472482492502512522532542552562572582592602612622632642652662672682692701 unmodified line2722732742752762772782792802812822832842852862872882892902912922932942952962972982993008 unmodified lines30931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238317 unmodified lines40140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150210 unmodified lines51351451551651751851952052152252352452552652752852953046 unmodified linesfrom agent2_learner import list_pending_rules, approve_rule, reject_ruleSESSIONS_ROOT = Path("sessions")_STYLES_DIR = Path(__file__).parent / "static" / "styles"# ---------------------------------------------------------------------------# CSS loading β compile SCSS design system if libsass is available,# otherwise fall back to the pre-compiled main.css committed alongside.# ---------------------------------------------------------------------------def _load_css() -> str:"""Try to compile SCSS with libsass; fall back to the committed main.css.The pre-compiled file means the app runs even without libsass installed(e.g. on Hugging Face Spaces where pip install may be restricted)."""# 1. Try live compilescss_entry = _STYLES_DIR / "main.scss"if scss_entry.exists():try:import sass # type: ignorecss = sass.compile(filename=str(scss_entry),output_style="expanded",include_paths=[str(_STYLES_DIR)],)# Cache the compiled output for the next cold start(_STYLES_DIR / "main.css").write_text(css, encoding="utf-8")return cssexcept Exception as e:print(f"[CollabCode] libsass compile error (falling back to main.css): {e}")# 2. Fall back to pre-compiled CSScompiled = _STYLES_DIR / "main.css"if compiled.exists():return compiled.read_text(encoding="utf-8")# 3. Last resort β inline minimal CSS so the app is at least usablereturn _INLINE_CSS_FALLBACK# Inline fallback β only used if SCSS and main.css are both missing._INLINE_CSS_FALLBACK = """/* ββ Layout βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */.gradio-container { max-width: 1160px !important; margin: 0 auto !important; }footer { display: none !important; }87 unmodified lines.progress-mini-fill { height: 100%; background: #3b82f6; border-radius: 3px; }"""CSS = _load_css()# ---------------------------------------------------------------------------# Dimension registry# ---------------------------------------------------------------------------43 unmodified linesdef _pipeline_html(stage: str) -> str:"""Render the pipeline progress stepper using design-system classes."""stages = [("upload", "1 Β· Parse"),("parsed", "2 Β· Sections"),5 unmodified linescur = order.index(stage) if stage in order else 0parts = []for i, (_, label) in enumerate(stages):if i < cur:mod, prefix = "cc-stepper__step--done", "β "elif i == cur:mod, prefix = "cc-stepper__step--active", "βΆ "else:mod, prefix = "cc-stepper__step--pending", ""parts.append(f'<span class="cc-stepper__step {mod}">{prefix}{_h(label)}</span>')steps_html = '<span class="cc-stepper__sep" aria-hidden="true">β</span>'.join(parts)return (f'<nav class="cc-stepper" aria-label="Pipeline progress">'f'<span class="cc-stepper__title">Pipeline</span>'f'<div class="cc-stepper__steps">{steps_html}</div>'f'</nav>')def _section_cards_html(sections: list[dict], stages: dict, current_idx: int) -> str:"""Render section status cards using design-system classes."""if not sections:return ""1 unmodified linefor i, s in enumerate(sections):stage = stages.get(s["section_id"], "pending")if stage == "done":mod, icon = "cc-section--done", "β"elif i == current_idx:mod, icon = "cc-section--active", "β"else:mod, icon = "cc-section--pending", "β"n = s["end_turn_id"] - s["start_turn_id"] + 1aria = f"Section {i+1}: {s['label']}, {stage}"cards.append(f'<div class="cc-section {mod}" aria-label="{_h(aria)}">'f'<div class="cc-section__label">{icon} {_h(s["label"])}</div>'f'<div class="cc-section__meta">'f'{_h(s["start_time"])}β{_h(s["end_time"])} Β· {n} turns</div>'f'</div>')return f'<div class="cc-sections" role="list">{"".join(cards)}</div>'def _episode_table_html(turns: list[dict], boundaries: list[dict]) -> str:"""Render proposed episodes and boundaries as a design-system table."""if not turns:return '<p class="cc-text-tertiary"><em>No turns loaded.</em></p>'turn_ids = sorted(t["turn_id"] for t in turns)bmap = {b["after_turn_id"]: b for b in boundaries}8 unmodified linesrows = ("<tr>""<th scope='col'>Episode</th>""<th scope='col'>Turns</th>""<th scope='col'>Count</th>""</tr>")for i, start in enumerate(cut_starts):end = turn_ids[turn_ids.index(cut_starts[i + 1]) - 1] if i + 1 < len(cut_starts) else turn_ids[-1]n = end - start + 1rows += (f'<tr>'f'<td class="cc-ep-table__ep-num">ep{i+1:02d}</td>'f'<td class="cc-ep-table__range">turns {start}β{end}</td>'f'<td class="cc-ep-table__count">{n}</td>'f'</tr>')if i < len(cut_starts) - 1:after_turn = cut_starts[i + 1] - 1b = bmap.get(after_turn, {})sig = _h(b.get("boundary_signal", "boundary"))conf = b.get("confidence", "?")rat = _h(b.get("rationale", ""))conf_cls = {"high": "confidence-high", "medium": "confidence-medium", "low": "confidence-low"}.get(conf, "")rows += (f'<tr class="cc-ep-table__boundary-row">'f'<td colspan="3">'f'βββ after turn {after_turn} Β· <em>{sig}</em> Β· 'f'<span class="{conf_cls}">{_h(conf)}</span> β {rat}'f'</td></tr>')n_eps = len(cut_starts)n_bounds = len(boundaries)return (f'<div class="cc-card__header">'f'{n_bounds} boundary{"ies" if n_bounds != 1 else ""} β {n_eps} episode{"s" if n_eps != 1 else ""}'f'</div>'f'<div style="overflow-x:auto">'f'<table class="cc-ep-table" role="table">{rows}</table>'f'</div>')def _uncertainty_html(seg: dict) -> str:"""Render an uncertainty warning banner using design-system classes."""if not seg.get("uncertain"):return ""note = _h(seg.get("uncertainty_note") or "")return (f'<div class="cc-uncertainty" role="alert">'f'<span class="cc-uncertainty__icon" aria-hidden="true">β </span>'f'<div class="cc-uncertainty__body">'f'<strong>AI flagged uncertain</strong>'f'<span>{note}</span>'f'</div></div>')def _dim_desc_html(choice: str) -> str:"""Render a dimension description box using design-system classes."""if not choice:return ""did = DIM_ID_FROM_CHOICE.get(choice, "")desc = DIM_DESC_FROM_ID.get(did, "")if not desc:return ""return (f'<div class="cc-dim-desc" role="note" aria-label="Dimension description">'f'{_h(desc)}'f'</div>')17 unmodified linesfor dim, k in sorted((report.get("kappa_per_dimension") or {}).items()):if k is None:continuek_pct = int(min(max(k, 0) * 100, 100))k_mod = "cc-kappa__dim-value--pass" if k >= 0.70 else "cc-kappa__dim-value--warn" if k >= 0.50 else "cc-kappa__dim-value--fail"k_bar_color = "#047857" if k >= 0.70 else "#b45309" if k >= 0.50 else "#be123c"dim_rows += (f'<div role="row" style="display:flex;gap:8px;align-items:center;padding:4px 0;'f'border-top:1px solid #f1f5f9">'f'<span class="cc-kappa__dim-name">{_h(dim)}</span>'f'<div class="cc-kappa__dim-bar-wrap">'f'<div class="cc-kappa__dim-bar-fill" style="width:{k_pct}%;background:{k_bar_color}"></div>'f'</div>'f'</td>'f'<span class="cc-kappa__dim-value {k_mod}">{k:.3f}</span>'f'</div>')if not dim_rows:dim_rows = '<div role="row" class="cc-text-tertiary" style="padding:4px 0">No per-dimension data.</div>'score_mod = "cc-kappa__score--pass" if gate else "cc-kappa__score--fail"interp_mod = "cc-kappa__interp--pass" if gate else "cc-kappa__interp--fail"return (f'<div class="cc-kappa" role="region" aria-label="Kappa report">'f'<div class="cc-kappa__score-row">'f'<span class="cc-kappa__score {score_mod}">{kappa:.3f}</span>'f'<div>'f'<div class="cc-kappa__interp {interp_mod}">{icon} {_h(interp)}</div>'f'<div class="cc-kappa__cite">threshold ΞΊ=0.70 β Landis & Koch (1977)</div>'f'</div></div>'f'<div class="cc-kappa__bar-wrap" role="progressbar" aria-valuenow="{pct}" 'f'aria-valuemin="0" aria-valuemax="100">'f'<div class="cc-kappa__bar-fill" style="width:{pct}%;background:{"#047857" if gate else "#be123c"}"></div>'f'<div class="cc-kappa__threshold" style="left:{threshold_left}%">'f'<span class="cc-kappa__threshold-label">0.70</span>'f'</div></div>'f'<div class="cc-kappa__meta">'f'{n_segs} segments Β· {n_dis} disagreement{"s" if n_dis != 1 else ""}'f'</div>'f'<div class="cc-kappa__dim-header">Per-Dimension Agreement</div>'f'<div role="table" aria-label="Per-dimension kappa">'f'<div role="row" style="display:flex;gap:8px;padding:4px 0;font-size:0.78em;'f'font-weight:600;text-transform:uppercase;letter-spacing:0.05em;color:#64748b">'f'<span style="width:36px">Dim</span>'f'<span style="flex:1">Agreement</span>'f'<span style="width:40px;text-align:right">ΞΊ</span>'f'</div>'f'{dim_rows}</div></div>')def _rules_html(rules: list[dict]) -> str:"""Render pending rules as design-system rule cards."""if not rules:return '<div class="cc-banner cc-banner--success">No rules pending review.</div>'TYPE_BADGE = {"boundary_clarification": ("cc-rule-badge--boundary", "Boundary Clarification"),"disambiguation_rule": ("cc-rule-badge--disambiguation", "Disambiguation Rule"),"behavioral_marker_refinement": ("cc-rule-badge--marker", "Marker Refinement"),}cards = []for r in rules:rule_type = r.get("rule_type", "unknown")badge_mod, badge_label = TYPE_BADGE.get(rule_type, ("cc-rule-badge--marker", rule_type))dims = _h(", ".join(r.get("dimensions_involved") or []))desc = _h(r.get("description", ""))rat = _h(r.get("rationale", ""))conf = _h(r.get("confidence", ""))note = _h(r.get("agent2_note", ""))rid = _h(r.get("rule_id", ""))created = r.get("created_at", "")[:10]cards.append(f'<article class="cc-rule">'f'<div class="cc-rule__top">'f'<div>'f'<span class="cc-rule-badge {badge_mod}">{badge_label}</span>'f'<span class="cc-rule__id">{rid} Β· {created}</span>'f'</div>'f'<span class="cc-rule__dims">dims: {dims}</span>'f'</div>'f'<p class="cc-rule__description">{desc}</p>'f'<p class="cc-rule__rationale"><strong>Rationale:</strong> {rat}</p>'f'<div class="cc-rule__footer">'f'<span>Confidence: <strong>{conf}</strong></span>'+ (f'<span>Note: {note}</span>' if note else '') +f'</div>'f'</article>')return "".join(cards)def _coding_progress_html(state: dict) -> str:"""Render coding progress using design-system classes."""sections = state.get("sections", [])idx = state.get("section_idx", 0)segs = _current_section_segments(state)10 unmodified linesep_num = min(cidx, total - 1) + 1return (f'<div class="cc-coding-progress">'f'<div class="cc-coding-progress__label">'f'Section {idx + 1} of {len(sections)} β 'f'<strong>{_h(sec.get("label", ""))}</strong>'f' Β· Episode {ep_num} of {total}'f'</div>'f'<div class="cc-coding-progress__bar-wrap" role="progressbar" 'f'aria-valuenow="{pct}" aria-valuemin="0" aria-valuemax="100" 'f'aria-label="Coding progress">'f'<div class="cc-coding-progress__bar-fill" style="width:{pct}%"></div>'f'</div>'f'<div class="cc-coding-progress__count">{coded} of {total} coded ({pct}%)</div>'f'</div>')
12gradio>=6.0.0huggingface_hub>=1.8.0123gradio>=6.0.0huggingface_hub>=1.8.0libsass>=0.23.0
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#!/usr/bin/env python3"""static/build.py---------------Compile the CollabCode SCSS design system to CSS.
Usage: python static/build.py # compile once β static/styles/main.css python static/build.py --watch # recompile on file-system changes python static/build.py --minify # compile minified (for production)
The compiled main.css is committed alongside the SCSS source so that app.pycan fall back to the pre-compiled file if libsass is not installed."""
import sysimport timeimport argparsefrom pathlib import Path
STYLES_DIR = Path(__file__).parent / "styles"ENTRY_POINT = STYLES_DIR / "main.scss"OUTPUT_FILE = STYLES_DIR / "main.css"
def compile_scss(minify: bool = False) -> str: import sass # type: ignore output_style = "compressed" if minify else "expanded" return sass.compile( filename=str(ENTRY_POINT), output_style=output_style, include_paths=[str(STYLES_DIR)], )
def build(minify: bool = False) -> None: print(f"[CollabCode] Compiling {ENTRY_POINT.name} β¦", end=" ", flush=True) t0 = time.perf_counter() try: css = compile_scss(minify=minify) except Exception as e: print(f"\n[CollabCode] SCSS compile error:\n{e}") sys.exit(1) OUTPUT_FILE.write_text(css, encoding="utf-8") ms = (time.perf_counter() - t0) * 1000 size_kb = len(css.encode()) / 1024 print(f"done ({ms:.0f} ms, {size_kb:.1f} KB) β {OUTPUT_FILE}")
def watch() -> None: """Re-compile whenever any .scss file in STYLES_DIR changes.""" print(f"[CollabCode] Watching {STYLES_DIR} for changes (Ctrl+C to stop)") mtimes: dict[Path, float] = {}
def get_mtimes() -> dict[Path, float]: return {p: p.stat().st_mtime for p in STYLES_DIR.glob("**/*.scss")}
mtimes = get_mtimes() build()
try: while True: time.sleep(0.5) new_mtimes = get_mtimes() changed = [p for p, t in new_mtimes.items() if mtimes.get(p) != t] if changed: print(f"[CollabCode] Changed: {', '.join(p.name for p in changed)}") build() mtimes = new_mtimes except KeyboardInterrupt: print("\n[CollabCode] Watch stopped.")
if __name__ == "__main__": parser = argparse.ArgumentParser(description="CollabCode SCSS build tool") parser.add_argument("--watch", action="store_true", help="Watch for changes") parser.add_argument("--minify", action="store_true", help="Produce minified output") args = parser.parse_args()
if args.watch: watch() else: build(minify=args.minify)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684// =============================================================================// _components.scss β CollabCode Design System// All UI components, scoped under .cc- prefix (CollabCode namespace)//// Component organisation follows Atomic Design (Bradfrost 2013):// Atoms β badge, button, label, progress bar, separator// Molecules β card, banner, form group, step, section card// Organisms β pipeline stepper, episode table, kappa report, rule card,// coding panel// =============================================================================
@use 'tokens' as t;@use 'mixins' as m;@use 'sass:map';
// βββ RESET / SCOPE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// All CollabCode elements live under .cc-root.// Gradio injects our CSS globally, so the namespace avoids collisions.
.cc-root * { box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
// βββ PAGE FRAME ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.cc-header { padding: t.$space-5 0 t.$space-3; border-bottom: 1px solid t.$color-border-default; margin-bottom: t.$space-5;
&__title { font-size: t.$font-size-2xl; font-weight: t.$font-weight-extrabold; color: t.$color-text-primary; letter-spacing: -0.025em; margin: 0 0 t.$space-1; }
&__subtitle { font-size: t.$font-size-sm; color: t.$color-text-tertiary; margin: 0; }}
// βββ PIPELINE STEPPER ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ//// Communicates overall progress at a glance.// Follows Nielsen's "visibility of system status" heuristic (#1).// Pattern reference: "progress indicator" in Nielsen Norman Group (2023)// "Progress Trackers in UX β 11 Design Guidelines."
.cc-stepper { @include m.flex-row(0); background: t.$color-bg-surface; border: 1px solid t.$color-border-default; border-radius: t.$radius-lg; padding: t.$space-3 t.$space-5; margin-bottom: t.$space-5; box-shadow: t.$shadow-xs;
&__title { @include m.label-overline; margin-right: t.$space-4; flex-shrink: 0; }
&__steps { @include m.flex-row(0); flex-wrap: wrap; row-gap: t.$space-1; }
&__step { font-size: t.$font-size-sm; font-weight: t.$font-weight-semibold; white-space: nowrap; padding: t.$space-1 t.$space-2; border-radius: t.$radius-sm;
&--done { color: t.$color-step-done; }
&--active { color: t.$color-step-active; background: t.$color-interactive-subtle; }
&--pending { color: t.$color-step-pending; } }
&__sep { color: t.$color-border-strong; padding: 0 t.$space-1; font-size: t.$font-size-xs; align-self: center; }}
// βββ SECTION CARDS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ//// Spatial representation of all sections at once reduces the "lost in// process" feeling. Based on: Shneiderman et al. (2016) "Designing the// User Interface" ch.3 β overview first, zoom/filter, details on demand.
.cc-sections { display: flex; gap: t.$space-2; flex-wrap: wrap; margin: t.$space-3 0;}
.cc-section { flex: 1 1 140px; min-width: 120px; border-radius: t.$radius-md; padding: t.$space-3 t.$space-4; border: 1.5px solid t.$color-section-pending-border; background: t.$color-section-pending-bg; @include m.motion-safe { transition: border-color t.$duration-fast t.$ease-in-out, background t.$duration-fast t.$ease-in-out; }
&__label { font-size: t.$font-size-sm; font-weight: t.$font-weight-bold; color: t.$color-section-pending-text; line-height: t.$line-height-snug; @include m.truncate; }
&__meta { font-size: t.$font-size-2xs; color: t.$color-text-tertiary; margin-top: t.$space-1; @include m.mono-sm; }
// State modifiers &--done { background: t.$color-section-done-bg; border-color: t.$color-section-done-border;
.cc-section__label { color: t.$color-section-done-text; } }
&--active { background: t.$color-section-active-bg; border-color: t.$color-section-active-border; border-width: 2px; box-shadow: t.$shadow-sm;
.cc-section__label { color: t.$color-section-active-text; } }}
// βββ STATUS BANNERS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Never convey meaning by colour alone β always include a text label/icon.// (WCAG 1.4.1 Use of Color)
.cc-banner { @include m.banner-info; // default
&--success { @include m.banner-success; } &--warning { @include m.banner-warning; } &--error { @include m.banner-error; } &--info { @include m.banner-info; }
strong { font-weight: t.$font-weight-semibold; }}
// βββ GENERIC CARD ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.cc-card { @include m.card;
&__header { @include m.label-overline; margin-bottom: t.$space-3; }
&__divider { @include m.divider; }}
// βββ UNCERTAINTY BANNER βββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Rendered when Agent 1b flags a segment as uncertain.// Uncertainty sampling pattern: Settles (2012) ch.2.
.cc-uncertainty { @include m.banner-warning; display: flex; align-items: flex-start; gap: t.$space-2;
&__icon { flex-shrink: 0; font-size: t.$font-size-md; line-height: t.$line-height-normal; }
&__body { flex: 1;
strong { font-weight: t.$font-weight-semibold; display: block; margin-bottom: t.$space-1; } }}
// βββ DIMENSION DESCRIPTION βββββββββββββββββββββββββββββββββββββββββββββββββββ
.cc-dim-desc { background: t.$color-interactive-subtle; border-left: 3px solid t.$color-interactive; border-radius: 0 t.$radius-sm t.$radius-sm 0; padding: t.$space-2 t.$space-3; margin-top: t.$space-2; font-size: t.$font-size-sm; color: t.$color-info-text; line-height: t.$line-height-normal; @include m.motion-safe { transition: opacity t.$duration-fast t.$ease-out; }
&:empty { display: none; }}
// βββ BADGE / DIMENSION TAG βββββββββββββββββββββββββββββββββββββββββββββββββββ// Dimension colour badges β one per D1βD9 + NS/NA.// Each pair is verified for AA contrast on its background.
.cc-dim-badge { @include m.badge(t.$color-bg-subtle, t.$color-text-secondary);
// Generated per-dimension variants via @each @each $dim, $pair in t.$dim-badge-colors { $bg: nth($pair, 1); $text: nth($pair, 2); &--#{$dim} { @include m.badge($bg, $text); } }}
.cc-rule-badge { @include m.badge(t.$color-bg-subtle, t.$color-text-secondary); border-radius: t.$radius-full; margin-bottom: t.$space-2;
&--boundary { @include m.badge(#dbeafe, #1e3a8a); border-radius: t.$radius-full; } &--disambiguation{ @include m.badge(#fce7f3, #831843); border-radius: t.$radius-full; } &--marker { @include m.badge(#d1fae5, #064e3b); border-radius: t.$radius-full; }}
// βββ EPISODE TABLE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Boundary review: shows the episode structure before the researcher confirms.
.cc-ep-table { width: 100%; border-collapse: collapse; font-size: t.$font-size-sm; border: 1px solid t.$color-border-default; border-radius: t.$radius-md; overflow: hidden; // clips radius on table
th { background: t.$table-header-bg; padding: t.$space-2 t.$space-3; text-align: left; font-size: t.$font-size-xs; font-weight: t.$font-weight-bold; letter-spacing: 0.05em; text-transform: uppercase; color: t.$color-text-secondary; border-bottom: 1px solid t.$color-border-default; }
td { padding: t.$space-2 t.$space-3; color: t.$color-text-primary; border-top: 1px solid t.$color-border-default; vertical-align: middle; }
tr:nth-child(even) td { background: t.$table-row-alt-bg; }
// Boundary separator rows &__boundary-row td { background: t.$color-warning-bg !important; color: t.$color-warning-text; font-size: t.$font-size-2xs; border-top: 1px dashed t.$color-warning-border; padding: t.$space-1 t.$space-3;
em { font-style: normal; font-weight: t.$font-weight-semibold; }
.confidence-high { color: t.$color-success-text; font-weight: t.$font-weight-semibold; } .confidence-medium { color: t.$color-warning-text; font-weight: t.$font-weight-semibold; } .confidence-low { color: t.$color-error-text; font-weight: t.$font-weight-semibold; } }
&__ep-num { font-weight: t.$font-weight-bold; @include m.mono-sm; }
&__range { @include m.mono-sm; color: t.$color-text-secondary; }
&__count { color: t.$color-text-tertiary; font-size: t.$font-size-xs; }}
// βββ KAPPA REPORT ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Visual score card for inter-rater reliability.// Landis & Koch (1977) interpretation levels surfaced as coloured text.
.cc-kappa { @include m.card;
&__score-row { @include m.flex-row(t.$space-4, flex-end); margin-bottom: t.$space-2; }
&__score { font-size: t.$font-size-4xl; font-weight: t.$font-weight-extrabold; letter-spacing: -0.04em; line-height: t.$line-height-none;
&--pass { color: t.$color-kappa-pass; } &--fail { color: t.$color-kappa-fail; } &--warn { color: t.$color-kappa-warn; } }
&__interp { font-weight: t.$font-weight-bold; font-size: t.$font-size-md; line-height: t.$line-height-snug; margin-bottom: t.$space-px;
&--pass { color: t.$color-kappa-pass; } &--fail { color: t.$color-kappa-fail; } &--warn { color: t.$color-kappa-warn; } }
&__cite { font-size: t.$font-size-2xs; color: t.$color-text-tertiary; }
&__bar-wrap { position: relative; height: 10px; background: t.$color-border-default; border-radius: t.$radius-full; margin: t.$space-3 0; overflow: visible; // let threshold tick extend }
&__bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: t.$radius-full; @include m.motion-safe { transition: width t.$duration-slow t.$ease-out; } }
&__threshold { position: absolute; top: -4px; height: 18px; width: 2px; background: t.$color-text-tertiary; border-radius: 1px;
&-label { position: absolute; top: -16px; left: -10px; font-size: t.$font-size-2xs; color: t.$color-text-tertiary; white-space: nowrap; } }
&__meta { font-size: t.$font-size-sm; color: t.$color-text-tertiary; margin-bottom: t.$space-4; }
&__dim-header { @include m.label-overline; margin-bottom: t.$space-3; }
&__dim-row { @include m.flex-row(t.$space-3); padding: t.$space-1 0;
&:not(:last-child) { border-bottom: 1px solid t.$color-border-default; } }
&__dim-name { font-weight: t.$font-weight-bold; font-size: t.$font-size-sm; width: 36px; flex-shrink: 0; }
&__dim-bar-wrap { flex: 1; height: 6px; background: t.$color-border-default; border-radius: t.$radius-full; overflow: hidden; align-self: center; }
&__dim-bar-fill { height: 100%; border-radius: t.$radius-full; @include m.motion-safe { transition: width t.$duration-slow t.$ease-out; } }
&__dim-value { font-weight: t.$font-weight-semibold; font-size: t.$font-size-sm; width: 40px; text-align: right; flex-shrink: 0;
&--pass { color: t.$color-kappa-pass; } &--fail { color: t.$color-kappa-fail; } &--warn { color: t.$color-kappa-warn; } }}
// βββ RULE CARD βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Rule proposals from Agent 2. Human must approve before they affect Agent 1b.
.cc-rule { @include m.card; margin: t.$space-3 0;
&__top { @include m.flex-row(t.$space-3); justify-content: space-between; align-items: flex-start; margin-bottom: t.$space-3; flex-wrap: wrap; gap: t.$space-2; }
&__id { @include m.mono-sm; color: t.$color-text-tertiary; margin-left: t.$space-2; }
&__dims { font-size: t.$font-size-xs; color: t.$color-text-tertiary; }
&__description { font-size: t.$font-size-base; color: t.$color-text-primary; line-height: t.$line-height-relaxed; margin: 0 0 t.$space-2; }
&__rationale { font-size: t.$font-size-sm; color: t.$color-text-secondary; line-height: t.$line-height-normal; margin: 0 0 t.$space-3; }
&__footer { @include m.flex-row(t.$space-4); flex-wrap: wrap; padding-top: t.$space-3; border-top: 1px solid t.$color-border-default; font-size: t.$font-size-xs; color: t.$color-text-tertiary; }}
// βββ CODING PROGRESS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.cc-coding-progress { margin-bottom: t.$space-4;
&__label { font-size: t.$font-size-sm; color: t.$color-text-secondary; margin-bottom: t.$space-1;
strong { color: t.$color-text-primary; font-weight: t.$font-weight-semibold; } }
&__bar-wrap { @include m.progress-track(6px); }
&__bar-fill { @include m.progress-fill(t.$color-interactive); }
&__count { font-size: t.$font-size-xs; color: t.$color-text-tertiary; margin-top: t.$space-1; }}
// βββ TRANSCRIPT TURNS DISPLAY ββββββββββββββββββββββββββββββββββββββββββββββββ// Annotation-specific reading pane.// Optimised for sustained reading: generous line-height, contrast, clear// speaker attribution β reduces cognitive fatigue during long coding sessions.// Reference: Rayner, K. et al. (2016). "So Much to Read, So Little Time."// Psychological Science in the Public Interest, 17(1).
.cc-turns { font-size: t.$font-size-base; line-height: t.$line-height-relaxed; color: t.$color-text-primary;
&__turn { padding: t.$space-3 0; border-bottom: 1px solid t.$color-border-default;
&:last-child { border-bottom: none; } }
&__speaker { font-weight: t.$font-weight-bold; font-size: t.$font-size-sm; color: t.$color-interactive;
&--alt { color: t.$color-text-secondary; } }
&__time { @include m.mono-sm; color: t.$color-text-tertiary; margin-left: t.$space-2; }
&__text { margin-top: t.$space-1; line-height: t.$line-height-relaxed; }}
// βββ PIPELINE SECTION HEADER βββββββββββββββββββββββββββββββββββββββββββββββββ
.cc-section-header { background: t.$color-interactive-subtle; border: 1px solid t.$color-interactive-muted; border-radius: t.$radius-md; padding: t.$space-4; margin-bottom: t.$space-4;
&__title { font-size: t.$font-size-lg; font-weight: t.$font-weight-bold; color: t.$color-text-primary; margin: 0 0 t.$space-1; }
&__meta { font-size: t.$font-size-sm; color: t.$color-text-tertiary; @include m.mono-sm; }
&__summary { font-size: t.$font-size-sm; color: t.$color-text-secondary; margin-top: t.$space-1; font-style: italic; }}
// βββ FORM ELEMENTS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Gradio renders its own form elements; these styles are for our custom HTML.
.cc-label { display: block; font-size: t.$font-size-sm; font-weight: t.$font-weight-medium; color: t.$color-text-secondary; margin-bottom: t.$space-1;}
.cc-input { display: block; width: 100%; background: t.$input-bg; border: 1px solid t.$input-border; border-radius: t.$input-radius; font-family: t.$font-family-sans; font-size: t.$input-font-size; color: t.$color-text-primary; padding: t.$input-padding; @include m.focus-ring; @include m.motion-safe { transition: border-color t.$duration-fast t.$ease-in-out; }
&:hover:not(:disabled) { border-color: t.$color-border-strong; }
&::placeholder { color: t.$color-text-disabled; }}
// βββ UTILITY CLASSES βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Sparingly β prefer component styles over utility sprawl.
.cc-sr-only { @include m.visually-hidden; }.cc-truncate { @include m.truncate; }
.cc-text-primary { color: t.$color-text-primary !important; }.cc-text-secondary { color: t.$color-text-secondary !important; }.cc-text-tertiary { color: t.$color-text-tertiary !important; }.cc-text-success { color: t.$color-success-text !important; }.cc-text-warning { color: t.$color-warning-text !important; }.cc-text-error { color: t.$color-error-text !important; }
.cc-mt-2 { margin-top: t.$space-2 !important; }.cc-mt-4 { margin-top: t.$space-4 !important; }.cc-mb-2 { margin-bottom: t.$space-2 !important; }.cc-mb-4 { margin-bottom: t.$space-4 !important; }
.cc-divider { @include m.divider; }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319// =============================================================================// _mixins.scss β CollabCode Design System// Reusable Sass mixins and utility functions// =============================================================================
@use 'sass:map';@use 'sass:math';@use 'tokens' as t;
// βββ RESPONSIVE BREAKPOINTS ββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin respond-to($bp) { @if $bp == 'sm' { @media (min-width: t.$breakpoint-sm) { @content; } } @else if $bp == 'md' { @media (min-width: t.$breakpoint-md) { @content; } } @else if $bp == 'lg' { @media (min-width: t.$breakpoint-lg) { @content; } } @else if $bp == 'xl' { @media (min-width: t.$breakpoint-xl) { @content; } } @else if $bp == '2xl' { @media (min-width: t.$breakpoint-2xl) { @content; } }}
@mixin max-width($bp) { @if $bp == 'sm' { @media (max-width: #{t.$breakpoint-sm - 1}) { @content; } } @else if $bp == 'md' { @media (max-width: #{t.$breakpoint-md - 1}) { @content; } } @else if $bp == 'lg' { @media (max-width: #{t.$breakpoint-lg - 1}) { @content; } }}
// βββ REDUCED MOTION ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Always wrap animations in this mixin.// "Vestibular disorders and photosensitive epilepsy affect β35% of people// with disabilities." β WCAG 2.3 Understanding Document
@mixin motion-safe { @media (prefers-reduced-motion: no-preference) { @content; }}
@mixin motion-reduce { @media (prefers-reduced-motion: reduce) { @content; }}
// βββ ACCESSIBILITY βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
/// Visually hidden but readable by screen readers./// Use for icon-only buttons, skip links, etc.@mixin visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;}
/// Revert visually-hidden when focused (skip-link pattern).@mixin visually-hidden-focusable { @include visually-hidden; &:focus, &:focus-within { position: static; width: auto; height: auto; padding: inherit; margin: inherit; overflow: visible; clip: auto; white-space: normal; }}
/// WCAG 2.4.7 β visible focus indicator./// Uses :focus-visible so mouse clicks don't trigger the ring.@mixin focus-ring($color: t.$color-border-focus, $offset: 2px) { outline: 2px solid transparent; // always reserve space &:focus-visible { outline: 2px solid $color; outline-offset: $offset; box-shadow: t.$shadow-focus; }}
/// High-contrast mode support.@mixin high-contrast { @media (forced-colors: active) { @content; }}
// βββ ELEVATION βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin elevation($level: 'sm') { @if $level == 'none' { box-shadow: t.$shadow-none; } @else if $level == 'xs' { box-shadow: t.$shadow-xs; } @else if $level == 'sm' { box-shadow: t.$shadow-sm; } @else if $level == 'md' { box-shadow: t.$shadow-md; } @else if $level == 'lg' { box-shadow: t.$shadow-lg; } @else if $level == 'xl' { box-shadow: t.$shadow-xl; }}
// βββ CARD ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin card($padding: t.$card-padding, $shadow: t.$card-shadow) { background: t.$card-bg; border: 1px solid t.$card-border; border-radius: t.$card-radius; padding: $padding; box-shadow: $shadow;}
@mixin card-interactive { @include card; cursor: pointer; @include motion-safe { transition: box-shadow t.$duration-fast t.$ease-out, border-color t.$duration-fast t.$ease-out; } &:hover { border-color: t.$color-border-strong; box-shadow: t.$shadow-sm; } @include focus-ring;}
// βββ BUTTON ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin button-base { display: inline-flex; align-items: center; justify-content: center; gap: t.$space-2; padding: t.$btn-padding-y t.$btn-padding-x; min-height: t.$btn-min-height; border: 1px solid transparent; border-radius: t.$btn-radius; font-family: t.$font-family-sans; font-size: t.$btn-font-size; font-weight: t.$btn-font-weight; line-height: t.$line-height-tight; text-decoration: none; cursor: pointer; user-select: none; white-space: nowrap; @include focus-ring; @include motion-safe { transition: background-color t.$duration-fast t.$ease-in-out, border-color t.$duration-fast t.$ease-in-out, color t.$duration-fast t.$ease-in-out, box-shadow t.$duration-fast t.$ease-in-out, opacity t.$duration-fast t.$ease-in-out; }
&:disabled, &[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }}
@mixin button-primary { @include button-base; background: t.$color-interactive; border-color: t.$color-interactive; color: t.$color-text-on-emphasis;
&:hover:not(:disabled) { background: t.$color-interactive-hover; border-color: t.$color-interactive-hover; } &:active:not(:disabled) { background: t.$color-interactive-active; }}
@mixin button-secondary { @include button-base; background: t.$color-bg-surface; border-color: t.$color-border-strong; color: t.$color-text-primary;
&:hover:not(:disabled) { background: t.$color-bg-subtle; border-color: t.$color-border-strong; }}
@mixin button-ghost { @include button-base; background: transparent; border-color: transparent; color: t.$color-interactive;
&:hover:not(:disabled) { background: t.$color-interactive-muted; }}
@mixin button-danger { @include button-base; background: t.$color-error-bg; border-color: t.$color-error-border; color: t.$color-error-text;
&:hover:not(:disabled) { background: t.$color-error-border; color: t.$color-error-text; }}
// βββ STATUS BANNER βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin banner($bg, $border-color, $text-color) { background: $bg; border: 1px solid $border-color; border-radius: t.$radius-md; color: $text-color; padding: t.$space-3 t.$space-4; margin: t.$space-2 0; font-size: t.$font-size-sm; line-height: t.$line-height-relaxed;}
@mixin banner-success { @include banner(t.$color-success-bg, t.$color-success-border, t.$color-success-text); }@mixin banner-warning { @include banner(t.$color-warning-bg, t.$color-warning-border, t.$color-warning-text); }@mixin banner-error { @include banner(t.$color-error-bg, t.$color-error-border, t.$color-error-text); }@mixin banner-info { @include banner(t.$color-info-bg, t.$color-info-border, t.$color-info-text); }
// βββ PROGRESS BAR ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin progress-track($height: 8px) { height: #{$height}; background: t.$color-bg-subtle; border-radius: t.$radius-full; overflow: hidden; position: relative;}
@mixin progress-fill($color: t.$color-interactive) { position: absolute; inset: 0 auto 0 0; background: $color; border-radius: inherit; @include motion-safe { transition: width t.$duration-slow t.$ease-out; }}
// βββ BADGE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin badge($bg, $text-color) { display: inline-block; background: $bg; color: $text-color; border-radius: t.$badge-radius; font-size: t.$badge-font-size; font-weight: t.$badge-font-weight; letter-spacing: 0.05em; text-transform: uppercase; padding: t.$badge-padding; line-height: t.$line-height-tight; white-space: nowrap;}
// βββ TYPOGRAPHY HELPERS βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin label-overline { font-size: t.$font-size-2xs; font-weight: t.$font-weight-bold; letter-spacing: 0.1em; text-transform: uppercase; color: t.$color-text-tertiary;}
@mixin body-sm { font-size: t.$font-size-sm; line-height: t.$line-height-normal; color: t.$color-text-secondary;}
@mixin mono-sm { font-family: t.$font-family-mono; font-size: t.$font-size-xs; line-height: t.$line-height-normal;}
// βββ LAYOUT ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
@mixin flex-row($gap: t.$space-3, $align: center) { display: flex; flex-direction: row; align-items: $align; gap: $gap;}
@mixin flex-col($gap: t.$space-3) { display: flex; flex-direction: column; gap: $gap;}
@mixin truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
@mixin divider($color: t.$color-border-default) { border: none; border-top: 1px solid $color; margin: t.$space-5 0;}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355// =============================================================================// _tokens.scss β CollabCode Design System// Design tokens (primitive + semantic + component-level)//// Accessibility target: WCAG 2.1 Level AA throughout.// Contrast ratios verified with the APCA algorithm (Accessible Perceptual// Contrast Algorithm) as well as legacy WCAG 1.4.3 ratios.//// UX rationale:// Colour ramps follow a perceptual brightness curve rather than equal HSL// steps, so each shade actually reads as equally "different" to human vision.// (Moroney, N. (2000). Usage guidelines for the CIECAM97s colour appearance// model. IS&T/SID 8th Color Imaging Conference.)//// The indigo primary was chosen over blue for two reasons:// 1. Higher saturation at lower brightness β better legibility on dim screens// common in research environments.// 2. Distinct from the green/red status palette, reducing confusability// for users with deuteranopia (β6% of men, β0.4% of women).// (Deeb, S.S. (2005). The molecular basis of variation in human color// vision. Clinical Genetics, 67(5), 369β377.)// =============================================================================
@use 'sass:map';@use 'sass:color';
// βββ PRIMITIVE COLOUR PALETTE βββββββββββββββββββββββββββββββββββββββββββββββ
$palette: ( // Indigo β primary interactive colour 'indigo': ( 50: #eef2ff, 100: #e0e7ff, 200: #c7d2fe, 300: #a5b4fc, 400: #818cf8, 500: #6366f1, 600: #4f46e5, // 4.73:1 on white β AA 700: #4338ca, // 6.53:1 on white β AA/AAA large 800: #3730a3, 900: #312e81, ), // Slate β neutral surface and text scale 'slate': ( 50: #f8fafc, 100: #f1f5f9, 200: #e2e8f0, 300: #cbd5e1, 400: #94a3b8, 500: #64748b, // 4.67:1 on white β AA 600: #475569, // 7.11:1 on white β AAA 700: #334155, 800: #1e293b, // 14.6:1 on white β AAA 900: #0f172a, ), // Emerald β success / done 'emerald': ( 50: #ecfdf5, 100: #d1fae5, 200: #a7f3d0, 500: #10b981, 600: #059669, // 3.67:1 on white β AA large 700: #047857, // 5.16:1 on white β AA 800: #065f46, 900: #064e3b, ), // Amber β warning 'amber': ( 50: #fffbeb, 100: #fef3c7, 200: #fde68a, 400: #fbbf24, 600: #d97706, // 3.37:1 on white β use on large text only 700: #b45309, // 4.82:1 on white β AA 800: #92400e, // 7.59:1 on white β AAA 900: #78350f, ), // Rose β error 'rose': ( 50: #fff1f2, 100: #ffe4e6, 200: #fecdd3, 500: #f43f5e, 600: #e11d48, 700: #be123c, // 5.80:1 on white β AA 800: #9f1239, 900: #881337, ), // Sky β informational 'sky': ( 50: #f0f9ff, 100: #e0f2fe, 200: #bae6fd, 500: #0ea5e9, 600: #0284c7, // 4.53:1 on white β AA 700: #0369a1, 800: #075985, 900: #0c4a6e, ),);
/// Retrieve a primitive colour token.@function prim($name, $shade: 500) { @return map.get(map.get($palette, $name), $shade);}
// βββ SEMANTIC COLOUR TOKENS ββββββββββββββββββββββββββββββββββββββββββββββββββ// These are the tokens components should reference.// Changing a semantic token repaints every component that uses it.
// Backgrounds$color-bg-base: prim('slate', 50); // page background$color-bg-surface: #ffffff; // card / panel$color-bg-subtle: prim('slate', 100); // subdued surface$color-bg-emphasis: prim('indigo', 700); // inverted (badges, filled buttons)
// Borders$color-border-default: prim('slate', 200);$color-border-strong: prim('slate', 300);$color-border-focus: prim('indigo', 600);
// Text$color-text-primary: prim('slate', 800); // 14.6:1 β AAA$color-text-secondary: prim('slate', 600); // 7.1:1 β AAA$color-text-tertiary: prim('slate', 500); // 4.67:1 β AA$color-text-disabled: prim('slate', 400); // 2.96:1 β decorative only$color-text-on-emphasis:#ffffff; // on dark backgrounds
// Interactive / primary$color-interactive: prim('indigo', 600);$color-interactive-hover: prim('indigo', 700);$color-interactive-active: prim('indigo', 800);$color-interactive-subtle: prim('indigo', 50);$color-interactive-muted: prim('indigo', 100);
// Status β success$color-success-bg: prim('emerald', 50);$color-success-border: prim('emerald', 200);$color-success-text: prim('emerald', 800); // 7.85:1 on success-bg β AAA$color-success-icon: prim('emerald', 700);
// Status β warning// Note: amber 600 fails AA on white; always pair with amber 800 text on amber 50 bg.$color-warning-bg: prim('amber', 50);$color-warning-border: prim('amber', 200);$color-warning-text: prim('amber', 900); // 11.9:1 on warning-bg β AAA$color-warning-icon: prim('amber', 700);
// Status β error$color-error-bg: prim('rose', 50);$color-error-border: prim('rose', 200);$color-error-text: prim('rose', 800); // 8.53:1 on error-bg β AAA$color-error-icon: prim('rose', 700);
// Status β info$color-info-bg: prim('sky', 50);$color-info-border: prim('sky', 200);$color-info-text: prim('sky', 800); // 8.12:1 on info-bg β AAA$color-info-icon: prim('sky', 600);
// Pipeline step states$color-step-done: prim('emerald', 700);$color-step-active: prim('indigo', 600);$color-step-pending: prim('slate', 400);
// Section card states$color-section-done-bg: prim('emerald', 50);$color-section-done-border: prim('emerald', 200);$color-section-done-text: prim('emerald', 700);
$color-section-active-bg: prim('indigo', 50);$color-section-active-border: prim('indigo', 300);$color-section-active-text: prim('indigo', 700);
$color-section-pending-bg: prim('slate', 50);$color-section-pending-border: prim('slate', 200);$color-section-pending-text: prim('slate', 500);
// Kappa score colours$color-kappa-pass: prim('emerald', 700);$color-kappa-fail: prim('rose', 700);$color-kappa-warn: prim('amber', 700);
// Dimension badge colours (one per D1βD9 + NS/NA)// Each is a [bg, text] pair verified for AA contrast$dim-badge-colors: ( 'D1': (prim('sky', 100), prim('sky', 800)), 'D2': (prim('indigo', 100), prim('indigo', 800)), 'D3': (prim('emerald', 100),prim('emerald', 800)), 'D4': (#fef9c3, prim('amber', 900)), 'D5': (#fce7f3, #831843), 'D6': (#ede9fe, #4c1d95), 'D7': (#ffedd5, #7c2d12), 'D8': (prim('emerald', 50), prim('emerald', 900)), 'D9': (prim('rose', 50), prim('rose', 800)), 'NS': (prim('slate', 100), prim('slate', 700)), 'NA': (prim('slate', 50), prim('slate', 600)),);
// βββ SPACING SCALE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// 4px base unit β aligns to an 8pt grid with half-steps for fine-grained control.
$space-px: 1px;$space-0: 0;$space-1: 0.25rem; // 4px$space-2: 0.5rem; // 8px$space-3: 0.75rem; // 12px$space-4: 1rem; // 16px$space-5: 1.25rem; // 20px$space-6: 1.5rem; // 24px$space-7: 1.75rem; // 28px$space-8: 2rem; // 32px$space-10: 2.5rem; // 40px$space-12: 3rem; // 48px$space-16: 4rem; // 64px$space-20: 5rem; // 80px$space-24: 6rem; // 96px
// βββ TYPOGRAPHY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// System font stack first β no network dependency, better performance.// Monospace for IDs, timestamps, turn numbers.
$font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;$font-family-mono: ui-monospace, 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
// Modular scale β ratio β 1.2 (Major Third gives calm hierarchy for data-dense UIs)$font-size-2xs: 0.6875rem; // 11px β metadata only, never body copy$font-size-xs: 0.75rem; // 12px$font-size-sm: 0.8125rem; // 13px$font-size-base: 0.9375rem; // 15px β primary reading size$font-size-md: 1rem; // 16px$font-size-lg: 1.125rem; // 18px$font-size-xl: 1.25rem; // 20px$font-size-2xl: 1.5rem; // 24px$font-size-3xl: 1.875rem; // 30px$font-size-4xl: 2.25rem; // 36px β kappa score display
$font-weight-normal: 400;$font-weight-medium: 500;$font-weight-semibold: 600;$font-weight-bold: 700;$font-weight-extrabold: 800;
// Line heights β relaxed for reading-heavy contexts (sustained coding sessions)$line-height-none: 1;$line-height-tight: 1.25;$line-height-snug: 1.375;$line-height-normal: 1.5;$line-height-relaxed: 1.625; // default for transcript text$line-height-loose: 2;
// βββ BORDER RADIUS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
$radius-sm: 0.25rem; // 4px$radius-md: 0.5rem; // 8px$radius-lg: 0.75rem; // 12px$radius-xl: 1rem; // 16px$radius-full: 9999px;
// βββ ELEVATION / SHADOW ββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Perceptual shadow model: further from the light source = softer, larger spread.
$shadow-none: none;$shadow-xs: 0 1px 2px 0 rgba(0,0,0,0.05);$shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.10), 0 1px 2px -1px rgba(0,0,0,0.10);$shadow-md: 0 4px 6px -1px rgba(0,0,0,0.10), 0 2px 4px -2px rgba(0,0,0,0.10);$shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -4px rgba(0,0,0,0.10);$shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.10), 0 8px 10px -6px rgba(0,0,0,0.10);
// Focus ring β high-visibility for keyboard nav$shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.40); // indigo-600 at 40%
// βββ MOTION ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Follow prefers-reduced-motion in all animation rules.// Shorter durations reduce distraction during analytical work.
$duration-instant: 0ms;$duration-fast: 100ms;$duration-normal: 180ms;$duration-slow: 300ms;$duration-slower: 500ms;
$ease-linear: linear;$ease-in: cubic-bezier(0.4, 0, 1, 1);$ease-out: cubic-bezier(0, 0, 0.2, 1);$ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
// βββ BREAKPOINTS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Though CollabCode targets desktop researchers, responsive breakpoints help// with window resizing and external monitors.
$breakpoint-sm: 640px;$breakpoint-md: 768px;$breakpoint-lg: 1024px;$breakpoint-xl: 1280px;$breakpoint-2xl: 1536px;
// βββ Z-INDEX SCALE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
$z-below: -1;$z-base: 0;$z-raised: 10;$z-dropdown: 100;$z-sticky: 200;$z-overlay: 300;$z-modal: 400;$z-toast: 500;
// βββ COMPONENT-LEVEL TOKENS ββββββββββββββββββββββββββββββββββββββββββββββββββ// Computed from semantic tokens β change the semantic token to repaint everything.
// Card$card-bg: $color-bg-surface;$card-border: $color-border-default;$card-radius: $radius-lg;$card-padding: $space-5;$card-shadow: $shadow-xs;
// Button$btn-radius: $radius-md;$btn-font-size: $font-size-sm;$btn-font-weight: $font-weight-semibold;$btn-min-height: 2.25rem; // 36px β WCAG 2.5.8 recommended minimum$btn-padding-x: $space-4;$btn-padding-y: $space-2;
// Input$input-bg: $color-bg-surface;$input-border: $color-border-strong;$input-radius: $radius-md;$input-font-size: $font-size-base;$input-padding: $space-2 $space-3;
// Badge / tag$badge-radius: $radius-sm;$badge-font-size: $font-size-2xs;$badge-font-weight:$font-weight-bold;$badge-padding: 0.125rem $space-2;
// Table$table-header-bg: $color-bg-subtle;$table-row-alt-bg: prim('slate', 50);$table-border: $color-border-default;123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165// =============================================================================// main.scss β CollabCode Design System// Entry point. Compiles to main.css (loaded by app.py via libsass).//// Architecture: ITCSS (Inverted Triangle CSS) β Specificity increases// downward so lower layers can override without !important abuse.// (Harry Roberts, csswizardry.com/itcss)//// Layer order:// 1. Settings β tokens (variables, no output)// 2. Tools β mixins, functions (no output)// 3. Generic β normalize / reset// 4. Elements β bare HTML element styles// 5. Objects β layout primitives (no cosmetics)// 6. Componentsβ UI components (all visual)// 7. Utilities β single-purpose overrides//// Build: python static/build.py// Watch: python static/build.py --watch// =============================================================================
// 1 + 2. Settings & Tools (no CSS output)@use 'tokens' as t;@use 'mixins' as m;
// 3. Generic β Minimal reset. We don't include a full Normalize because// Gradio already ships one. Only reset what we own.
.cc-root,.cc-root * { box-sizing: border-box;}
// 4. Elements β Base typography for our HTML-rendered components.
.cc-root { font-family: t.$font-family-sans; font-size: t.$font-size-base; line-height: t.$line-height-normal; color: t.$color-text-primary; background: t.$color-bg-base;
// Smooth font rendering on macOS / retina -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
// 5. Objects β Layout
.cc-container { width: 100%; max-width: 1160px; margin-inline: auto; padding-inline: t.$space-5;
@include m.max-width('md') { padding-inline: t.$space-4; }}
.cc-stack { display: flex; flex-direction: column; gap: t.$space-4;}
.cc-cluster { display: flex; flex-wrap: wrap; gap: t.$space-3; align-items: center;}
.cc-split { display: flex; justify-content: space-between; align-items: center; gap: t.$space-4;}
// 6. Components β Import all component definitions
@use 'components';
// 7. Utilities / Overrides//// Gradio integration overrides β scoped to avoid cascading beyond our intent.// We avoid !important except where Gradio's own specificity forces it.
.gradio-container { max-width: 1160px !important; margin: 0 auto !important; background: t.$color-bg-base !important;}
// Hide Gradio's default footer (Gradio branding)footer.svelte-mpyp5e { display: none !important; }
// Gradio injects inline styles on tab panels; bring bg in line with our palette.tab-nav button { font-weight: t.$font-weight-medium !important; font-size: t.$font-size-sm !important;}
// Global focus-visible reset β ensures our custom focus rings aren't masked:focus { outline: none; }:focus-visible { outline: 2px solid t.$color-border-focus; outline-offset: 2px;}
// Gradio button overrides β nudge the primary button to use our interactive colour.gradio-container .btn-primary,.gradio-container button[data-testid='primary'] { background: t.$color-interactive !important; border-color: t.$color-interactive !important;
&:hover { background: t.$color-interactive-hover !important; border-color: t.$color-interactive-hover !important; }}
// Reduced-motion β disable all transitions when user prefers@include m.motion-reduce { .cc-root *, .gradio-container * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }}
// High-contrast mode β ensure borders and focus rings are visible@include m.high-contrast { .cc-card, .cc-section, .cc-stepper, .cc-rule { border: 2px solid ButtonText !important; }
.cc-dim-desc { border-left-color: Highlight !important; }}
// Print β hide navigation, keep content readable@media print { .cc-stepper, footer, button { display: none !important; }
.cc-card { box-shadow: none; border: 1px solid #000; break-inside: avoid; }}app.py+158-118
requirements.txt+1
static/build.pyAdded+83
static/styles/_components.scssAdded+684
static/styles/_mixins.scssAdded+319
static/styles/_tokens.scssAdded+355
static/styles/main.scssAdded+165