user.email commited on
Commit ·
24c3f9c
1
Parent(s): ea30645
fix-ref-labels
Browse files- server/ui.py +15 -7
server/ui.py
CHANGED
|
@@ -203,14 +203,19 @@ body, .gradio-container, .gradio-container .main, .contain,
|
|
| 203 |
.gradio-container { width: 100% !important; max-width: 100% !important; min-width: 100% !important; margin: 0 !important; padding: 0 !important; min-height: 100vh !important; }
|
| 204 |
.gr-group, .gr-box, .gr-form, .gr-panel, .gr-block, .block,
|
| 205 |
.gradio-container .block, .gradio-container .form { background: transparent !important; border-radius: 0 !important; box-shadow: none !important;}
|
| 206 |
-
input, textarea, select, .gr-input, .gr-text-input,
|
| 207 |
[data-testid="textbox"], [data-testid="dropdown"] { background: var(--bg-input) !important; color: var(--text-primary) !important; border: 1px solid var(--border) !important; font-family: var(--mono) !important; border-radius: 0 !important; }
|
| 208 |
label, .gr-label, .label-wrap { color: var(--text-secondary) !important; font-family: var(--mono) !important; text-transform: uppercase; font-size: 11px !important;}
|
| 209 |
.tabs, .tab-nav, .tabitem { background: transparent !important; }
|
| 210 |
.tab-nav { border-bottom: 1px solid var(--border) !important; }
|
| 211 |
.tab-nav button { color: var(--text-tertiary) !important; font-weight: 400 !important; border: none !important; font-family: var(--mono) !important; text-transform: uppercase; border-radius: 0 !important;}
|
| 212 |
.tab-nav button.selected { color: var(--text-primary) !important; border-bottom: 2px solid var(--text-primary) !important; background: transparent !important;}
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
footer { display: none !important; }
|
| 215 |
|
| 216 |
.shell { min-height: 100vh; font-family: var(--mono); }
|
|
@@ -616,20 +621,22 @@ def _choose_file(obs: Any, selected_file: Optional[str]) -> Optional[str]:
|
|
| 616 |
return available[0]
|
| 617 |
|
| 618 |
|
| 619 |
-
def _highlight_lines(obs: Any, selected_file: Optional[str]) -> List[int]:
|
| 620 |
if not obs or not selected_file:
|
| 621 |
return []
|
| 622 |
lines: set[int] = set()
|
| 623 |
-
if env.state:
|
| 624 |
for cve_id, path in env.state.ground_truth_files.items():
|
| 625 |
if path == selected_file:
|
| 626 |
lines.update(env.state.ground_truth_lines.get(cve_id, []))
|
|
|
|
| 627 |
if env.state.action_history:
|
| 628 |
last = env.state.action_history[-1]
|
| 629 |
if last.get("file_path") == selected_file and last.get("line_number"):
|
| 630 |
lines.add(int(last["line_number"]))
|
| 631 |
-
|
| 632 |
-
|
|
|
|
| 633 |
return sorted(line for line in lines if line > 0)
|
| 634 |
|
| 635 |
|
|
@@ -915,7 +922,8 @@ def _compose_outputs(selected_file: Optional[str], show_ground_truth: bool):
|
|
| 915 |
_record_rollout_if_needed(obs)
|
| 916 |
chosen_file = _choose_file(obs, selected_file)
|
| 917 |
code_choices = [code_file.path for code_file in obs.code_files] if obs else []
|
| 918 |
-
code_html = _render_code(obs.code_files if obs else [], chosen_file, _highlight_lines(obs, chosen_file))
|
|
|
|
| 919 |
return (
|
| 920 |
_status_label(obs),
|
| 921 |
_episode_header_html(obs),
|
|
|
|
| 203 |
.gradio-container { width: 100% !important; max-width: 100% !important; min-width: 100% !important; margin: 0 !important; padding: 0 !important; min-height: 100vh !important; }
|
| 204 |
.gr-group, .gr-box, .gr-form, .gr-panel, .gr-block, .block,
|
| 205 |
.gradio-container .block, .gradio-container .form { background: transparent !important; border-radius: 0 !important; box-shadow: none !important;}
|
| 206 |
+
input:not([type="checkbox"]), textarea, select, .gr-input, .gr-text-input,
|
| 207 |
[data-testid="textbox"], [data-testid="dropdown"] { background: var(--bg-input) !important; color: var(--text-primary) !important; border: 1px solid var(--border) !important; font-family: var(--mono) !important; border-radius: 0 !important; }
|
| 208 |
label, .gr-label, .label-wrap { color: var(--text-secondary) !important; font-family: var(--mono) !important; text-transform: uppercase; font-size: 11px !important;}
|
| 209 |
.tabs, .tab-nav, .tabitem { background: transparent !important; }
|
| 210 |
.tab-nav { border-bottom: 1px solid var(--border) !important; }
|
| 211 |
.tab-nav button { color: var(--text-tertiary) !important; font-weight: 400 !important; border: none !important; font-family: var(--mono) !important; text-transform: uppercase; border-radius: 0 !important;}
|
| 212 |
.tab-nav button.selected { color: var(--text-primary) !important; border-bottom: 2px solid var(--text-primary) !important; background: transparent !important;}
|
| 213 |
+
input[type="checkbox"], .gr-checkbox {
|
| 214 |
+
accent-color: var(--amber) !important;
|
| 215 |
+
border: 1px solid var(--border) !important;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
|
| 219 |
footer { display: none !important; }
|
| 220 |
|
| 221 |
.shell { min-height: 100vh; font-family: var(--mono); }
|
|
|
|
| 621 |
return available[0]
|
| 622 |
|
| 623 |
|
| 624 |
+
def _highlight_lines(obs: Any, selected_file: Optional[str], show_ground_truth: bool = True) -> List[int]:
|
| 625 |
if not obs or not selected_file:
|
| 626 |
return []
|
| 627 |
lines: set[int] = set()
|
| 628 |
+
if env.state and show_ground_truth:
|
| 629 |
for cve_id, path in env.state.ground_truth_files.items():
|
| 630 |
if path == selected_file:
|
| 631 |
lines.update(env.state.ground_truth_lines.get(cve_id, []))
|
| 632 |
+
|
| 633 |
if env.state.action_history:
|
| 634 |
last = env.state.action_history[-1]
|
| 635 |
if last.get("file_path") == selected_file and last.get("line_number"):
|
| 636 |
lines.add(int(last["line_number"]))
|
| 637 |
+
for item in _candidate_signals([code_file for code_file in obs.code_files if code_file.path == selected_file]):
|
| 638 |
+
lines.update(item["lines"])
|
| 639 |
+
|
| 640 |
return sorted(line for line in lines if line > 0)
|
| 641 |
|
| 642 |
|
|
|
|
| 922 |
_record_rollout_if_needed(obs)
|
| 923 |
chosen_file = _choose_file(obs, selected_file)
|
| 924 |
code_choices = [code_file.path for code_file in obs.code_files] if obs else []
|
| 925 |
+
code_html = _render_code(obs.code_files if obs else [], chosen_file, _highlight_lines(obs, chosen_file, show_ground_truth))
|
| 926 |
+
|
| 927 |
return (
|
| 928 |
_status_label(obs),
|
| 929 |
_episode_header_html(obs),
|