- components/diff_view.render_unified_diff: pinta +/-/@@ del unified diff. - pages/1_🏛️_Registro.py: selector de agente, detalle (estado, owner, propósito, guardrails, system_prompt, output_schema, llm), tabla de versiones y comparador. - pyproject: per-file-ignore N999 en pages/* — Streamlit exige nombres "<n>_<emoji>_<Label>.py" para la navegación multipágina. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
"""Componente para renderizar diffs unificados con coloreado básico."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import streamlit as st
|
|
|
|
|
|
def render_unified_diff(diff_text: str) -> None:
|
|
if not diff_text.strip():
|
|
st.info("Sin diferencias entre las versiones seleccionadas.")
|
|
return
|
|
lines: list[str] = []
|
|
for line in diff_text.splitlines():
|
|
if line.startswith("+") and not line.startswith("+++"):
|
|
lines.append(f'<span style="color:#22c55e">{line}</span>')
|
|
elif line.startswith("-") and not line.startswith("---"):
|
|
lines.append(f'<span style="color:#ef4444">{line}</span>')
|
|
elif line.startswith("@@"):
|
|
lines.append(f'<span style="color:#3b82f6;font-weight:bold">{line}</span>')
|
|
else:
|
|
lines.append(line)
|
|
html = (
|
|
"<pre style='background:#0f172a;color:#e2e8f0;padding:12px;border-radius:6px;"
|
|
"font-size:12px;overflow:auto'>" + "\n".join(lines) + "</pre>"
|
|
)
|
|
st.markdown(html, unsafe_allow_html=True)
|