Spaces:
Sleeping
Sleeping
File size: 6,612 Bytes
574cb9d 554ae62 574cb9d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | # Medical Coding Auditor β UI Analysis & Improvement Plan
## Why Our UI Looked the Same (Root Cause Analysis)
### Problem 1: Wrong CSS injection point
| | Reference (sre-incident-env / Gradio 4.x) | Our implementation (Gradio 6.11) |
|---|---|---|
| CSS injection | `gr.Blocks(css=CUSTOM_CSS)` | `mount_gradio_app(..., css=CSS)` |
In **Gradio 6.x** the `css=` parameter moved from `gr.Blocks()` to `mount_gradio_app()`.
Passing `css=` to `gr.Blocks()` emits a deprecation warning and is silently ignored
(the blocks's `.css` attribute stays `None`). Verified against Gradio 6.11.0.
The correct Gradio 6.x pattern is:
```python
# gradio_landing.py
CSS = "..." # plain string, no <style> tags
def create_gradio_app():
with gr.Blocks(title="...") as demo: # NO css= here in Gradio 6.x
...
return demo
# app.py
gradio_app = create_gradio_app()
app = gr.mount_gradio_app(app, gradio_app, path="/", css=CSS) # css= goes HERE
```
### Problem 2: Missing Gradio container overrides
Our CSS only defined custom classes (`.hero`, `.card`, etc.) but never overrode Gradio's
default container styling. The reference CSS starts with:
```css
html, body, .gradio-container {
background: #0a0a0a !important;
color: #ededed !important;
font-family: "Inter", -apple-system, ...;
-webkit-font-smoothing: antialiased;
}
.gradio-container .block {
background: transparent !important;
border: none !important;
box-shadow: none !important;
padding: 0 !important;
}
```
Without these, Gradio's own theme renders as the "frame" around the custom HTML,
so the custom classes only style their immediate content while the Gradio chrome
(background, panels, dropdowns) looks unmodified.
### Problem 3: Mount path was wrong initially
We originally mounted at `/ui` instead of `/`. The reference always mounts at `/`
so the Gradio UI is the first thing visitors see. Fixed.
---
## Reference Architecture (sre-incident-env)
```python
# server/app.py β how the reference does it
CUSTOM_CSS = "..." # ~200 lines, plain CSS string, NO <style> tags
def create_landing_app():
with gr.Blocks(css=CUSTOM_CSS) as demo: # <-- CSS goes HERE
...
return demo
app = gr.mount_gradio_app(app, _landing_app, path="/") # NO css= here
```
### Reference CSS scope
The reference CSS (~200 lines) has three layers:
1. **Gradio container overrides** β forces dark background, font, removes default panels:
```css
html, body, .gradio-container { background: #0a0a0a !important; ... }
.gradio-container .block { background: transparent !important; border: none !important; }
.gradio-container .form, .gradio-container .panel { background: transparent !important; }
```
2. **Component-level overrides** β dropdowns, textboxes, buttons:
```css
.gradio-container select, .gradio-container input, .gradio-container textarea {
background: #0a0a0a !important; border: 1px solid #262626 !important; color: #ededed !important;
}
.gradio-container button { background: #141414 !important; border: 1px solid #262626 !important; }
.gradio-container button.primary { background: #00d084 !important; color: #0a0a0a !important; }
```
3. **Custom class definitions** β `.hero`, `.card`, `.scenario`, `.lb`, `.pg-*`:
These only work AFTER the container overrides establish the dark background.
---
## What Our Fixed Implementation Does
### CSS approach (fixed)
```python
# gradio_landing.py
CSS = """
html, body, .gradio-container {
background: #0a0a0a !important;
color: #ededed !important;
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
-webkit-font-smoothing: antialiased;
}
.gradio-container .block, .gradio-container .panel, .gradio-container .form {
background: transparent !important;
border: none !important;
box-shadow: none !important;
padding: 0 !important;
}
/* ... then our custom classes ... */
.hero { background: #141414; border: 1px solid #262626; border-radius: 12px; ... }
"""
def create_gradio_app() -> gr.Blocks:
with gr.Blocks(css=CSS, title="...") as demo: # CSS passed here
...
```
### app.py (fixed)
```python
from .gradio_landing import create_gradio_app # no CSS import needed
gradio_app = create_gradio_app()
app = gr.mount_gradio_app(app, gradio_app, path="/") # no css= param
```
### Tab structure (5 tabs matching reference quality)
1. **Overview** β Hero stats + 6 uniqueness cards + 5 scenario cards
2. **Rewards** β Full reward table with all 18 signals
3. **Leaderboard** β Color-coded score table with tier badges
4. **Playground** β Interactive episode runner with live HTML status
5. **Try It** β Code examples for inference.py and session API
### Design palette (medical blue, adapted from reference emerald)
```
bg: #0a0a0a (near-black)
surface: #141414 (cards)
surface-2: #1a1a1a (nested elements)
border: #262626 (subtle dividers)
text: #ededed (primary)
muted: #9ca3af (secondary)
accent: #3b82f6 (medical blue β vs emerald in sre-incident-env)
success: #22c55e
warning: #f59e0b
danger: #ef4444
```
---
## Remaining Differences vs Reference
| Feature | Reference | Ours | Gap |
|---|---|---|---|
| Mermaid state-graph SVGs | β (pre-generated per scenario) | β (no state machine) | N/A β our env doesn't have a state graph |
| Traces tab | β (stored episode JSON replays) | β | Could add if episode traces are stored |
| 6 tabs | β | 5 tabs | Missing "Traces" (requires stored traces) |
| Leaderboard from log files | β (parses output logs) | Static data | Fine for hackathon β logs not generated yet |
| Component-level CSS overrides | β (dropdowns, buttons styled) | Partial | Added in fixed version |
| `pg-row` layout class | β (explicit flex row CSS) | β | Added in fixed version |
| Font: Inter + JetBrains Mono | β | β (via CSS font-family) | Same |
| HF Spaces app_port | β | β | Same |
| Mount at `/` | β | β (fixed) | Same |
---
## What is NOT Needed
- **Mermaid diagrams**: Our environment uses a tool-based audit workflow, not a state
machine. Adding fake state graph SVGs would be misleading and add no value.
- **Traces tab**: The reference pre-generates agent traces offline and ships them in
the Docker image. We don't have stored traces yet β the Playground tab covers
interactive exploration.
- **JSONL scenario database**: The reference stores 8 scenarios in `incidents_v3.jsonl`.
Our ground truth is in `data/ground_truth_cases.json` β already structured correctly.
|