Athmabhiram1 commited on
Commit
d51d64a
·
1 Parent(s): 506681c

fix: improve graph tooltip formatting and report panel readability

Browse files
code-review-env/server/static/css/app.css CHANGED
@@ -82,6 +82,22 @@ header h1 { margin: 0; font-size: 1.2rem; }
82
  background: white;
83
  cursor: pointer;
84
  transition: all 0.15s ease;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  .result-item:hover { border-color: var(--accent); transform: translateY(-1px); }
 
82
  background: white;
83
  cursor: pointer;
84
  transition: all 0.15s ease;
85
+ text-align: left;
86
+ display: grid;
87
+ gap: 4px;
88
+ }
89
+
90
+ .result-item strong {
91
+ display: block;
92
+ line-height: 1.25;
93
+ overflow-wrap: anywhere;
94
+ word-break: break-word;
95
+ }
96
+
97
+ .result-item .muted {
98
+ overflow-wrap: anywhere;
99
+ word-break: break-word;
100
+ line-height: 1.25;
101
  }
102
 
103
  .result-item:hover { border-color: var(--accent); transform: translateY(-1px); }
code-review-env/server/static/js/app.js CHANGED
@@ -26,6 +26,26 @@ const runAnalysisOutputEl = document.getElementById('runAnalysisOutput');
26
  let currentNodes = [];
27
  let selectedModuleId = '';
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  function applyGraphTooltipStyles() {
30
  const frameDoc = graphFrame?.contentDocument;
31
  if (!frameDoc) {
@@ -46,10 +66,15 @@ function applyGraphTooltipStyles() {
46
  overflow-wrap: anywhere !important;
47
  word-break: break-word !important;
48
  line-height: 1.35 !important;
 
49
  }
50
  `;
51
 
52
  frameDoc.head?.appendChild(style);
 
 
 
 
53
  }
54
 
55
  graphFrame?.addEventListener('load', applyGraphTooltipStyles);
@@ -110,14 +135,24 @@ function renderSchema(columns) {
110
  });
111
  }
112
 
113
- function renderDiagnostics(connectivity, metrics) {
114
- const isolationClass = connectivity.isolation_ratio > 0.35 ? 'danger' : '';
 
 
 
 
 
 
 
 
 
 
115
  diagEl.innerHTML = `
116
- <div class="kv"><span>Nodes</span><strong>${connectivity.node_count}</strong></div>
117
- <div class="kv"><span>Edges</span><strong>${connectivity.edge_count}</strong></div>
118
- <div class="kv"><span>Connected Components</span><strong>${connectivity.connected_components}</strong></div>
119
- <div class="kv"><span>Largest Component</span><strong>${connectivity.largest_component_size}</strong></div>
120
- <div class="kv"><span>Isolated Nodes</span><strong class="${isolationClass}">${connectivity.isolated_nodes} (${fmtPct(connectivity.isolation_ratio)})</strong></div>
121
  <div class="kv"><span>Precision / Recall / F1</span><strong>${Number(metrics.precision || 0).toFixed(3)} / ${Number(metrics.recall || 0).toFixed(3)} / ${Number(metrics.f1 || 0).toFixed(3)}</strong></div>
122
  <div class="kv"><span>Security Coverage</span><strong>${Number(metrics.security_coverage || 0).toFixed(3)}</strong></div>
123
  <div class="kv"><span>Stage Coverage</span><strong>${Number(metrics.stage_coverage || 0).toFixed(3)}</strong></div>
@@ -223,7 +258,7 @@ async function selectResult(result, itemEl) {
223
  }
224
 
225
  const detail = await res.json();
226
- renderDiagnostics(detail.connectivity, detail.report.metrics || {});
227
  renderSchema(detail.db_columns || {});
228
  renderNodes(detail.report || {});
229
  moduleDetailEl.classList.add('muted');
 
26
  let currentNodes = [];
27
  let selectedModuleId = '';
28
 
29
+ function normalizeTooltipText(raw) {
30
+ const text = String(raw || '');
31
+ return text
32
+ .replace(/<br\s*\/?\s*>/gi, '\n')
33
+ .replace(/<\/?b>/gi, '')
34
+ .replace(/<[^>]+>/g, '')
35
+ .replace(/[ \t]+\n/g, '\n')
36
+ .trim();
37
+ }
38
+
39
+ function normalizeGraphTooltips(frameDoc) {
40
+ const tooltips = frameDoc.querySelectorAll('.vis-tooltip, .vis-network-tooltip');
41
+ tooltips.forEach((tooltip) => {
42
+ const normalized = normalizeTooltipText(tooltip.textContent);
43
+ if (normalized && normalized !== tooltip.textContent) {
44
+ tooltip.textContent = normalized;
45
+ }
46
+ });
47
+ }
48
+
49
  function applyGraphTooltipStyles() {
50
  const frameDoc = graphFrame?.contentDocument;
51
  if (!frameDoc) {
 
66
  overflow-wrap: anywhere !important;
67
  word-break: break-word !important;
68
  line-height: 1.35 !important;
69
+ text-align: left !important;
70
  }
71
  `;
72
 
73
  frameDoc.head?.appendChild(style);
74
+
75
+ const observer = new MutationObserver(() => normalizeGraphTooltips(frameDoc));
76
+ observer.observe(frameDoc.body, { subtree: true, childList: true, characterData: true });
77
+ normalizeGraphTooltips(frameDoc);
78
  }
79
 
80
  graphFrame?.addEventListener('load', applyGraphTooltipStyles);
 
135
  });
136
  }
137
 
138
+ function renderDiagnostics(connectivity, metrics, report) {
139
+ const reportNodeCount = Array.isArray(report?.nodes) ? report.nodes.length : 0;
140
+ const reportEdgeCount = Array.isArray(report?.edges) ? report.edges.length : 0;
141
+
142
+ const nodeCount = Number(connectivity?.node_count || 0) || reportNodeCount;
143
+ const edgeCount = Number(connectivity?.edge_count || 0) || reportEdgeCount;
144
+ const connectedComponents = Number(connectivity?.connected_components || 0);
145
+ const largestComponentSize = Number(connectivity?.largest_component_size || 0);
146
+ const isolatedNodes = Number(connectivity?.isolated_nodes || 0);
147
+ const isolationRatio = Number(connectivity?.isolation_ratio || 0);
148
+
149
+ const isolationClass = isolationRatio > 0.35 ? 'danger' : '';
150
  diagEl.innerHTML = `
151
+ <div class="kv"><span>Nodes</span><strong>${nodeCount}</strong></div>
152
+ <div class="kv"><span>Edges</span><strong>${edgeCount}</strong></div>
153
+ <div class="kv"><span>Connected Components</span><strong>${connectedComponents}</strong></div>
154
+ <div class="kv"><span>Largest Component</span><strong>${largestComponentSize}</strong></div>
155
+ <div class="kv"><span>Isolated Nodes</span><strong class="${isolationClass}">${isolatedNodes} (${fmtPct(isolationRatio)})</strong></div>
156
  <div class="kv"><span>Precision / Recall / F1</span><strong>${Number(metrics.precision || 0).toFixed(3)} / ${Number(metrics.recall || 0).toFixed(3)} / ${Number(metrics.f1 || 0).toFixed(3)}</strong></div>
157
  <div class="kv"><span>Security Coverage</span><strong>${Number(metrics.security_coverage || 0).toFixed(3)}</strong></div>
158
  <div class="kv"><span>Stage Coverage</span><strong>${Number(metrics.stage_coverage || 0).toFixed(3)}</strong></div>
 
258
  }
259
 
260
  const detail = await res.json();
261
+ renderDiagnostics(detail.connectivity, detail.report.metrics || {}, detail.report || {});
262
  renderSchema(detail.db_columns || {});
263
  renderNodes(detail.report || {});
264
  moduleDetailEl.classList.add('muted');