diff --git a/services/api-server/src/api_server/html5.py b/services/api-server/src/api_server/html5.py
index 88f2497..a4848cd 100644
--- a/services/api-server/src/api_server/html5.py
+++ b/services/api-server/src/api_server/html5.py
@@ -227,8 +227,9 @@ def render_html5_editor(
{''.join(f'- {escape(kind)}{count}
' for kind, count in counts.most_common(10))}
Результаты
- {render_html5_symbols(snapshot, q)}
+ {render_html5_symbols(snapshot, q, project_id)}
+ {render_html5_symbol_detail(project_id, None)}
{render_html5_project_report(project_id, None)}
{render_html5_review(project_id, None)}
@@ -560,11 +561,46 @@ def html5_symbol_results(snapshot: SirSnapshot, q: str) -> list[object]:
][:30]
-def render_html5_symbols(snapshot: SirSnapshot, q: str) -> str:
+def render_html5_symbols(snapshot: SirSnapshot, q: str, project_id: str | None = None) -> str:
results = html5_symbol_results(snapshot, q)
if not results:
return 'Нет результатов
'
- return "".join(_symbol_result(node) for node in results)
+ return "".join(_symbol_result(node, project_id) for node in results)
+
+
+def render_html5_symbol_detail(project_id: str, references: object | None) -> str:
+ if references is None:
+ return f"""
+
+
Символ
+
Выберите результат поиска для server-side definition/references по проекту {escape(project_id)}.
+
+ """
+ symbol = getattr(references, "symbol", None)
+ node = getattr(symbol, "node", None)
+ source = getattr(symbol, "source", None)
+ name = getattr(node, "qualified_name", None) or getattr(node, "name", "symbol")
+ kind = getattr(node, "kind", "")
+ source_path = getattr(source, "source_path", None) or ""
+ line = getattr(source, "line_start", None)
+ location = f"{source_path}:{line}" if source_path and line else source_path or "source unavailable"
+ refs = getattr(references, "references", []) or []
+ ref_items = "".join(_symbol_reference_item(ref) for ref in refs[:10]) or 'References не найдены
'
+ lineage_id = str(getattr(node, "lineage_id", ""))
+ return f"""
+
+
Символ · {escape(str(kind))}
+
+ {escape(str(name))}
+ {escape(str(location))}
+
+
{ref_items}
+
+ """
def render_html5_source(node: object | None) -> str:
@@ -773,21 +809,49 @@ def _tree_item(project_id: str, node: object) -> str:
)
-def _symbol_result(node: object) -> str:
+def _symbol_result(node: object, project_id: str | None = None) -> str:
name = getattr(node, "qualified_name", None) or getattr(node, "name", "")
kind = getattr(node, "kind", "")
kind_value = str(kind.value if hasattr(kind, "value") else kind)
+ lineage_id = str(getattr(node, "lineage_id", ""))
source_path = getattr(node, "source_path", None) or getattr(getattr(node, "source_ref", None), "source_path", None) or ""
line = getattr(node, "line_start", None) or getattr(getattr(node, "source_ref", None), "line_start", None)
location = f"{source_path}:{line}" if source_path and line else source_path or "source unavailable"
+ htmx_attrs = (
+ f'hx-get="/html5/projects/{quote(project_id)}/symbols/{quote(lineage_id, safe="")}/detail" '
+ 'hx-target="[data-html5-symbol-detail]" hx-swap="outerHTML"'
+ if project_id and lineage_id
+ else ""
+ )
return f"""
-
+
{escape(str(name))}
{escape(kind_value)}
{escape(str(location))}
"""
+def _symbol_reference_item(reference: object) -> str:
+ kind = str(getattr(reference, "kind", ""))
+ direction = str(getattr(reference, "direction", ""))
+ source = getattr(reference, "source", None)
+ target = getattr(reference, "target", None)
+ location = getattr(reference, "location", None)
+ source_name = getattr(source, "qualified_name", None) or getattr(source, "name", "")
+ target_name = getattr(target, "qualified_name", None) or getattr(target, "name", "")
+ source_path = getattr(location, "source_path", None) or ""
+ line = getattr(location, "line_start", None)
+ place = f"{source_path}:{line}" if source_path and line else source_path
+ label = f"{source_name} -> {target_name}".strip(" ->")
+ return f"""
+
+ {escape(label or kind)}
+ {escape(direction)} · {escape(kind)}
+ {escape(place or "source unavailable")}
+
+ """
+
+
def _node_source_text(node: object | None) -> str:
if node is None:
return "// Модуль не найден в snapshot.\n// HTML5 IDE показывает серверный fallback без клиентского JS."
@@ -808,7 +872,7 @@ def _css() -> str:
.workspace{min-height:100vh;padding-bottom:34px}.topbar{position:sticky;top:0;z-index:2;height:54px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.94);padding:0 14px}.brand{font-weight:900;text-decoration:none;color:var(--brand)}.project-nav{display:flex;gap:6px;overflow:auto;flex:1}.project-link{white-space:nowrap;text-decoration:none;border:1px solid var(--line);padding:6px 10px;background:#fff}.project-link.active{background:var(--brand);border-color:var(--brand);color:#fff}
.layout{display:grid;grid-template-columns:280px minmax(0,1fr)320px;height:calc(100vh - 88px)}.panel{overflow:auto}.panel-title{padding:12px;border-bottom:1px solid var(--line);font-size:12px;font-weight:900;text-transform:uppercase;color:var(--muted)}.tree-item{display:block;padding:10px 12px;border-bottom:1px solid var(--line);text-decoration:none}.tree-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tree-item small{color:var(--muted)}
.editor{min-width:0;overflow:hidden;border-top:0;border-bottom:0}.editor-head{height:72px;border-bottom:1px solid var(--line);padding:0 14px}.editor-head h1{margin:0;font-size:18px}.search{display:flex;gap:6px}.search input{height:32px;width:260px;border:1px solid var(--line);padding:0 10px}.code{height:calc(100% - 72px);margin:0;overflow:auto;padding:16px;background:#fbfaf7;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap}
-.metrics{display:grid;grid-template-columns:1fr 1fr;margin:0}.metrics div{padding:12px;border-bottom:1px solid var(--line)}.metrics dt{color:var(--muted);font-size:12px}.metrics dd{margin:2px 0 0;font-size:22px;font-weight:800}.compact{list-style:none;margin:0;padding:0}.compact li{display:flex;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line)}.symbol{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.symbol span,.symbol small{color:var(--muted)}.report-grid{display:grid;grid-template-columns:1fr 1fr;margin:0}.report-grid div{padding:10px 12px;border-bottom:1px solid var(--line)}.report-grid dt{color:var(--muted);font-size:12px}.report-grid dd{margin:2px 0 0;font-size:20px;font-weight:900}.review-item{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.review-item span,.review-item small{color:var(--muted)}.status{position:fixed;bottom:0;left:0;right:0;display:flex;gap:18px;overflow:auto;height:34px;align-items:center;border-top:1px solid var(--line);background:#fff;padding:0 12px;color:var(--muted);font-size:12px}.empty-state{max-width:720px;margin:80px auto;background:#fff;border:1px solid var(--line);padding:28px}
+.metrics{display:grid;grid-template-columns:1fr 1fr;margin:0}.metrics div{padding:12px;border-bottom:1px solid var(--line)}.metrics dt{color:var(--muted);font-size:12px}.metrics dd{margin:2px 0 0;font-size:22px;font-weight:800}.compact{list-style:none;margin:0;padding:0}.compact li{display:flex;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line)}.symbol{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line);cursor:pointer}.symbol:hover{background:#f8fbff}.symbol span,.symbol small{color:var(--muted)}.symbol-focus,.symbol-reference{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.symbol-focus small,.symbol-reference span,.symbol-reference small{color:var(--muted)}.report-grid{display:grid;grid-template-columns:1fr 1fr;margin:0}.report-grid div{padding:10px 12px;border-bottom:1px solid var(--line)}.report-grid dt{color:var(--muted);font-size:12px}.report-grid dd{margin:2px 0 0;font-size:20px;font-weight:900}.review-item{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.review-item span,.review-item small{color:var(--muted)}.status{position:fixed;bottom:0;left:0;right:0;display:flex;gap:18px;overflow:auto;height:34px;align-items:center;border-top:1px solid var(--line);background:#fff;padding:0 12px;color:var(--muted);font-size:12px}.empty-state{max-width:720px;margin:80px auto;background:#fff;border:1px solid var(--line);padding:28px}
.setup-layout{display:grid;grid-template-columns:340px minmax(0,1fr);gap:16px;max-width:1180px;margin:18px auto;padding:0 16px}.setup-workspace{background:#f3f6fb}.setup-card{padding:16px;border-bottom:1px solid var(--line)}.setup-card h1{margin:0;font-size:24px}.setup-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.setup-main{min-height:620px}.settings-form{display:grid;grid-template-columns:2fr 1fr 1fr auto;gap:8px;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.settings-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.settings-form input{height:32px;border:1px solid var(--line);padding:0 8px}.saved{float:right;color:var(--ok);font-weight:900}.setup-actions-panel{display:flex;gap:8px;flex-wrap:wrap;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fbfcfe}.inline-form{display:flex;gap:8px;align-items:end}.inline-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.inline-form select{height:32px;min-width:240px;border:1px solid var(--line);background:#fff;padding:0 8px}.setup-summary{display:grid;gap:0}.compact-lead{margin:0;padding:0 16px 16px}.setup-metrics,.ops-summary{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border-top:1px solid var(--line)}.ops-summary{grid-template-columns:repeat(5,1fr);margin:12px 0}.setup-metrics div,.ops-summary div{padding:16px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);background:#fff}.setup-metrics div:last-child,.ops-summary div:last-child{border-right:0}.setup-metrics dt,.ops-summary dt{font-size:12px;color:var(--muted)}.setup-metrics dd,.ops-summary dd{margin:4px 0 0;font-size:28px;font-weight:900}.status-pill{border:1px solid var(--line);padding:6px 10px;background:#eef6f1;color:var(--ok);font-weight:800}.flush{border-top:1px solid var(--line)}.padded{padding:12px 16px;margin:0}.setup-detail,.history-item,.source-card,.check-item{display:grid;gap:3px;padding:12px 16px;border-bottom:1px solid var(--line)}.setup-detail span,.setup-detail small,.history-item span,.history-item small,.source-card span,.source-card small,.check-item span,.check-item small,.check-head span,.check-head small{color:var(--muted)}.source-list,.history-list,.check-list{display:grid}.check-head{display:flex;gap:10px;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.job-log{margin:0;padding:0;list-style:none}.job-log li{padding:8px 16px;border-bottom:1px solid var(--line);color:var(--muted);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}
@media(max-width:980px){.layout{grid-template-columns:1fr;height:auto}.tree,.inspector{max-height:320px}.editor{min-height:520px}.hero{display:block}.shell{padding:16px}}
@media(max-width:980px){.setup-layout{grid-template-columns:1fr}.setup-metrics{grid-template-columns:1fr 1fr}.settings-form{grid-template-columns:1fr}}
diff --git a/services/api-server/src/api_server/main.py b/services/api-server/src/api_server/main.py
index 8d2c681..0845f4a 100644
--- a/services/api-server/src/api_server/main.py
+++ b/services/api-server/src/api_server/main.py
@@ -42,6 +42,7 @@ from api_server.html5 import (
render_html5_project_rows,
render_html5_project_report,
render_html5_review,
+ render_html5_symbol_detail,
render_html5_import_check,
render_html5_import_job,
render_html5_operation_rows,
@@ -1687,7 +1688,16 @@ async def html5_project_events(project_id: str, once: bool = False) -> Streaming
async def html5_project_symbols(project_id: str, q: str = "") -> Response:
snapshot = _project_snapshot_or_404(project_id)
return Response(
- render_html5_symbols(snapshot, q),
+ render_html5_symbols(snapshot, q, project_id),
+ media_type="text/html; charset=utf-8",
+ )
+
+
+@app.get("/html5/projects/{project_id}/symbols/{lineage_id}/detail")
+async def html5_project_symbol_detail(project_id: str, lineage_id: str) -> Response:
+ references = await project_symbol_references(project_id, lineage_id, direction="both")
+ return Response(
+ render_html5_symbol_detail(project_id, references),
media_type="text/html; charset=utf-8",
)
diff --git a/services/api-server/tests/test_api.py b/services/api-server/tests/test_api.py
index 6bb1943..4c28c60 100644
--- a/services/api-server/tests/test_api.py
+++ b/services/api-server/tests/test_api.py
@@ -107,12 +107,14 @@ def test_html5_server_rendered_project_editor(tmp_path: Path):
assert 'data-html5-page="editor"' in editor.text
assert "data-html5-editor" in editor.text
assert "data-html5-symbol-results" in editor.text
+ assert "data-html5-symbol-detail" in editor.text
assert "data-html5-project-report" in editor.text
assert f'hx-get="/html5/projects/{project_id}/report"' in editor.text
assert "data-html5-review" in editor.text
assert f'hx-get="/html5/projects/{project_id}/review"' in editor.text
assert 'hx-get="/html5/projects/' in editor.text
assert 'hx-target="[data-html5-symbol-results]"' in editor.text
+ assert 'hx-target="[data-html5-symbol-detail]"' in editor.text
assert 'hx-target="[data-html5-source]"' in editor.text
assert 'hx-swap="outerHTML"' in editor.text
assert "hx-ext=\"sse\"" in editor.text
@@ -133,11 +135,14 @@ def test_html5_server_rendered_project_editor(tmp_path: Path):
assert symbols.status_code == 200
assert "text/html" in symbols.headers["content-type"]
assert 'data-html5-symbol' in symbols.text
+ assert 'data-html5-lineage-id' in symbols.text
+ assert 'hx-target="[data-html5-symbol-detail]"' in symbols.text
assert "Проверить" in symbols.text
assert "