viberadar 0.3.229 → 0.3.230

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8476,6 +8476,46 @@ function formatLoadMetricMs(value) {
8476
8476
  return value == null || !Number.isFinite(Number(value)) ? '-' : `${Math.round(Number(value))} ms`;
8477
8477
  }
8478
8478
 
8479
+ function numberOrNull(value) {
8480
+ const n = Number(value);
8481
+ return Number.isFinite(n) ? n : null;
8482
+ }
8483
+
8484
+ function formatLoadPromptNumber(value, digits = 0, suffix = '') {
8485
+ const n = numberOrNull(value);
8486
+ if (n == null) return '-';
8487
+ return `${digits > 0 ? n.toFixed(digits) : Math.round(n)}${suffix}`;
8488
+ }
8489
+
8490
+ function getLoadPromptLogs() {
8491
+ if (Array.isArray(loadState?.logs) && loadState.logs.length > 0) return loadState.logs;
8492
+ if (Array.isArray(loadLogLines) && loadLogLines.length > 0) return loadLogLines;
8493
+ return [];
8494
+ }
8495
+
8496
+ function getLoadPromptAggregate(summary) {
8497
+ const endpoints = Array.isArray(summary?.endpoints) ? summary.endpoints : [];
8498
+ const totalFromEndpoints = endpoints.reduce((sum, endpoint) => sum + Number(endpoint.requests || 0), 0);
8499
+ const weightedAvg = totalFromEndpoints > 0
8500
+ ? endpoints.reduce((sum, endpoint) => sum + Number(endpoint.avgDuration || 0) * Number(endpoint.requests || 0), 0) / totalFromEndpoints
8501
+ : null;
8502
+ const maxEndpoint = (field) => {
8503
+ const values = endpoints.map(endpoint => numberOrNull(endpoint[field])).filter(v => v != null);
8504
+ return values.length ? Math.max(...values) : null;
8505
+ };
8506
+ return {
8507
+ totalRequests: numberOrNull(summary?.totalRequests) ?? numberOrNull(loadState?.totalRequests) ?? totalFromEndpoints || null,
8508
+ rps: numberOrNull(summary?.rps),
8509
+ avgDuration: numberOrNull(summary?.avgDuration) ?? weightedAvg,
8510
+ p90Duration: numberOrNull(summary?.p90Duration) ?? maxEndpoint('p90Duration'),
8511
+ p95Duration: numberOrNull(summary?.p95Duration) ?? maxEndpoint('p95Duration'),
8512
+ p99Duration: numberOrNull(summary?.p99Duration) ?? maxEndpoint('p99Duration'),
8513
+ errorPct: numberOrNull(summary?.errorPct) ?? (totalFromEndpoints > 0
8514
+ ? endpoints.reduce((sum, endpoint) => sum + Number(endpoint.failures || 0), 0) / totalFromEndpoints * 100
8515
+ : null),
8516
+ };
8517
+ }
8518
+
8479
8519
  function loadEndpointLatencyColor(endpoint, summary) {
8480
8520
  const p95 = Number(endpoint?.p95Duration || 0);
8481
8521
  const threshold = Number(summary?.p95ThresholdMs || 0);
@@ -9206,8 +9246,9 @@ async function stopLoadTest() {
9206
9246
  function buildLoadAnalysisPrompt() {
9207
9247
  if (!loadState || !loadState.summary) return '';
9208
9248
  const summary = loadState.summary;
9209
- const logs = loadState.logs || [];
9210
- const totalRequests = Number(summary.totalRequests || loadState.totalRequests || 0);
9249
+ const logs = getLoadPromptLogs();
9250
+ const aggregate = getLoadPromptAggregate(summary);
9251
+ const totalRequests = Number(aggregate.totalRequests || 0);
9211
9252
  if (totalRequests <= 0 && logs.length === 0) {
9212
9253
  return '';
9213
9254
  }
@@ -9225,13 +9266,13 @@ Script: ${loadState.config?.scriptName || '-'}
9225
9266
  VUs: ${loadState.config?.vus || '-'}
9226
9267
  Duration: ${loadState.config?.duration || '-'}
9227
9268
 
9228
- RPS: ${(summary.rps||0).toFixed(2)}
9229
- avg latency: ${Math.round(summary.avgDuration||0)}ms
9230
- p90 latency: ${Math.round(summary.p90Duration||0)}ms
9231
- p95 latency: ${Math.round(summary.p95Duration||0)}ms
9232
- p99 latency: ${Math.round(summary.p99Duration||0)}ms
9233
- Total requests: ${totalRequests}
9234
- Error rate: ${(summary.errorPct||0).toFixed(2)}%
9269
+ RPS: ${formatLoadPromptNumber(aggregate.rps, 2)}
9270
+ avg latency: ${formatLoadPromptNumber(aggregate.avgDuration, 0, 'ms')}
9271
+ p90 latency: ${formatLoadPromptNumber(aggregate.p90Duration, 0, 'ms')}
9272
+ p95 latency: ${formatLoadPromptNumber(aggregate.p95Duration, 0, 'ms')}
9273
+ p99 latency: ${formatLoadPromptNumber(aggregate.p99Duration, 0, 'ms')}
9274
+ Total requests: ${aggregate.totalRequests ?? '-'}
9275
+ Error rate: ${formatLoadPromptNumber(aggregate.errorPct, 2, '%')}
9235
9276
  Checks failed: ${summary.checksFailed ?? '-'}
9236
9277
  Exit code: ${summary.exitCode ?? '-'}
9237
9278
 
@@ -9823,11 +9864,16 @@ function connectSSE() {
9823
9864
  if (contextMode === 'load') { renderSidebar(); renderContent(); }
9824
9865
  });
9825
9866
 
9826
- es.addEventListener('load-log', (e) => {
9827
- const { line } = JSON.parse(e.data);
9828
- loadLogLines.push(line);
9829
- if (loadLogLines.length > 500) loadLogLines.shift();
9830
- if (contextMode === 'load') {
9867
+ es.addEventListener('load-log', (e) => {
9868
+ const { line } = JSON.parse(e.data);
9869
+ loadLogLines.push(line);
9870
+ if (loadLogLines.length > 500) loadLogLines.shift();
9871
+ if (loadState) {
9872
+ if (!Array.isArray(loadState.logs)) loadState.logs = [];
9873
+ loadState.logs.push(line);
9874
+ if (loadState.logs.length > 500) loadState.logs.shift();
9875
+ }
9876
+ if (contextMode === 'load') {
9831
9877
  const logEl = document.getElementById('loadLogContent');
9832
9878
  if (logEl) {
9833
9879
  const div = document.createElement('div');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viberadar",
3
- "version": "0.3.229",
3
+ "version": "0.3.230",
4
4
  "description": "Live module map with test coverage for vibecoding projects",
5
5
  "main": "./dist/cli.js",
6
6
  "bin": {