fixed restart target

This commit is contained in:
2026-05-02 16:19:19 +02:00
parent 0505e8352c
commit 14fce4f4d6
3 changed files with 63 additions and 12 deletions

View File

@@ -17,7 +17,12 @@ router = APIRouter(include_in_schema=False)
APP_NAME = "Repository Scoping"
def page(title: str, body: str) -> HTMLResponse:
def page(title: str, body: str, selected_repository: str | None = None) -> HTMLResponse:
repository_context = (
f'<span class="header-context">{escape(selected_repository)}</span>'
if selected_repository
else ""
)
return HTMLResponse(
f"""
<!doctype html>
@@ -166,6 +171,9 @@ def page(title: str, body: str) -> HTMLResponse:
font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}}
.actions {{ display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }}
.header-brand {{ display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }}
.header-context {{ color: #b6c8d6; font-weight: 650; }}
.header-context::before {{ content: "/"; color: #6b7d8f; margin-right: 10px; }}
[data-pending] {{ display: none; color: var(--muted); }}
form.is-submitting [data-pending] {{ display: inline; }}
form.is-submitting button[type="submit"] {{ opacity: .7; cursor: wait; }}
@@ -182,7 +190,10 @@ def page(title: str, body: str) -> HTMLResponse:
</head>
<body>
<header>
<a href="/ui"><strong>{APP_NAME}</strong></a>
<div class="header-brand">
<a href="/ui"><strong>{APP_NAME}</strong></a>
{repository_context}
</div>
<nav class="actions">
<a href="/ui/search">Search</a>
<a href="/ui/discovery">Discovery</a>
@@ -279,6 +290,7 @@ def repository_index(service: RegistryService = Depends(get_service)) -> HTMLRes
@router.get("/ui/scope")
def scope_document() -> HTMLResponse:
repository_name = Path.cwd().name
scope_path = Path("SCOPE.md")
if scope_path.exists():
content = scope_path.read_text(encoding="utf-8")
@@ -288,7 +300,7 @@ def scope_document() -> HTMLResponse:
body = f"""
<h1>SCOPE.md</h1>
<section class="panel stack">
<p class="muted">Canonical scope summary for this repository.</p>
<p class="muted">Canonical scope summary for the {escape(repository_name)} repository.</p>
{rendered}
</section>
"""
@@ -828,7 +840,7 @@ def repository_detail(
</form>
</section>
"""
return page(repository.name, body)
return page(repository.name, body, selected_repository=repository.name)
@router.get("/ui/repos/{repository_id}/export")
@@ -1280,7 +1292,11 @@ def analysis_run_detail(
{render_expectation_gaps(expectation_gaps)}
</section>
"""
return page(f"{repository.name} Run {analysis_run_id}", body)
return page(
f"{repository.name} Run {analysis_run_id}",
body,
selected_repository=repository.name,
)
@router.post("/ui/repos/{repository_id}/analysis-runs/{analysis_run_id}/expectation-gaps")
@@ -1446,7 +1462,7 @@ def repository_element_listing(
</table>
</section>
"""
return page(title, body)
return page(title, body, selected_repository=repository.name)
@router.get("/ui/repos/{repository_id}/analysis-runs/{base_analysis_run_id}/diff/{target_analysis_run_id}")
@@ -1499,7 +1515,11 @@ def analysis_run_diff_detail(
</section>
</div>
"""
return page(f"{diff.repository.name} Change Review", body)
return page(
f"{diff.repository.name} Change Review",
body,
selected_repository=diff.repository.name,
)
@router.post("/ui/repos/{repository_id}/analysis-runs/{analysis_run_id}/candidate-graph/approve")
@@ -2654,11 +2674,17 @@ def render_element_row(
repository_id: int,
analysis_run_id: int | None,
) -> str:
name = str(row["name"])
rendered_name = (
f'<a href="/ui/repos/{repository_id}">{escape(name)}</a>'
if row.get("item_kind") == "scope"
else escape(name)
)
return f"""
<tr>
<td>{render_entry_badge(row)}</td>
<td><span class="pill">{escape(str(row["primary_class"]))}</span>{render_attribute_pills(row)}</td>
<td>{escape(str(row["name"]))}{render_drilldown_links(row, repository_id, analysis_run_id)}</td>
<td>{rendered_name}{render_drilldown_links(row, repository_id, analysis_run_id)}</td>
<td>{escape(str(row["parent"]))}</td>
<td>{render_element_source_detail(row)}</td>
<td>{render_element_actions(row, repository_id, analysis_run_id)}</td>
@@ -3587,7 +3613,7 @@ def render_ability_map(ability_map: dict, repository_id: int) -> str:
<div class="tree">
<ul>
<li id="scope-{scope['id']}">
<strong>{escape(scope['name'])}</strong>
<strong><a href="/ui/repos/{repository_id}">{escape(scope['name'])}</a></strong>
<span class="pill">scope</span>
<span class="pill">{scope['confidence']:.2f} {escape(scope['confidence_label'])}</span>
<p class="muted">{escape(scope_description)}</p>