Forge
csharp3407750f
1namespace AgentForge.Plugin.View.Components.Artifact;
2
3public static class ForgeViewIssueTitle
4{
5 public static string Render(int number, string title) =>
6 ForgeHtml.H1(
7 ForgeHtml.Text($"#{number} "),
8 ForgeHtml.Text(title));
9}
10
11public static class ForgeViewArtifactMeta
12{
13 public static string Render(string forgeBracket, string viewHref, string apiHref, string? forgeMagicUri = null)
14 {
15 var magicSpan = string.IsNullOrWhiteSpace(forgeMagicUri)
16 ? ""
17 : ForgeHtml.SpanData("meta", forgeMagicUri);
18
19 return ForgeHtml.P("meta",
20 ForgeHtml.Code(forgeBracket),
21 ForgeHtml.Text(" · "),
22 ForgeHtml.A(viewHref, "view"),
23 ForgeHtml.Text(" · "),
24 ForgeHtml.A(apiHref, "API"),
25 string.IsNullOrWhiteSpace(forgeMagicUri) ? "" : ForgeHtml.Fragment(ForgeHtml.Text(" · "), magicSpan));
26 }
27}
28
29public static class ForgeViewMrRefreshScript
30{
31 public static string Render(string repoName, int number, string? sourceTip)
32 {
33 if (string.IsNullOrWhiteSpace(sourceTip))
34 return "";
35
36 var eventsUrl = $"/view/repos/{ForgeRepoNames.ToUrlPath(repoName)}/merge-requests/{number}/events";
37 var pollUrl = $"/view/repos/{ForgeRepoNames.ToUrlPath(repoName)}/merge-requests/{number}/head.json";
38 return ForgeHtml.Script(
39 $"(function(){{const url={ForgeViewPresenter.JsonEncode(eventsUrl)};let head={ForgeViewPresenter.JsonEncode(sourceTip)};try{{const es=new EventSource(url);es.addEventListener('head',e=>{{try{{const j=JSON.parse(e.data);if(j.sourceTip&&j.sourceTip!==head){{head=j.sourceTip;location.reload();}}}}catch{{}}}});}}catch{{const poll={ForgeViewPresenter.JsonEncode(pollUrl)};setInterval(async()=>{{try{{const r=await fetch(poll,{{cache:'no-store'}});if(!r.ok)return;const j=await r.json();if(j.sourceTip&&j.sourceTip!==head)location.reload();}}catch{{}}}},15000);}}}})();");
40 }
41}
42
43public static class ForgeViewAnchorLink
44{
45 public static string Render(string href, string label, string? lensUrl = null) =>
46 ForgeHtml.ARawWithForgeUri(href, "anchor-link", null, null, lensUrl, ForgeHtml.Code(label));
47}
48
49public static class ForgeViewScrollToLineScript
50{
51 public static string Render(int line) =>
52 ForgeHtml.Script($"document.getElementById('L{line}')?.scrollIntoView({{block:'center'}});");
53}
54
View only · write via MCP/CIDE