viberadar 0.3.229 → 0.3.231

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,49 @@ 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
+ const totalRequests = numberOrNull(summary?.totalRequests)
8507
+ ?? numberOrNull(loadState?.totalRequests)
8508
+ ?? (totalFromEndpoints || null);
8509
+ return {
8510
+ totalRequests,
8511
+ rps: numberOrNull(summary?.rps),
8512
+ avgDuration: numberOrNull(summary?.avgDuration) ?? weightedAvg,
8513
+ p90Duration: numberOrNull(summary?.p90Duration) ?? maxEndpoint('p90Duration'),
8514
+ p95Duration: numberOrNull(summary?.p95Duration) ?? maxEndpoint('p95Duration'),
8515
+ p99Duration: numberOrNull(summary?.p99Duration) ?? maxEndpoint('p99Duration'),
8516
+ errorPct: numberOrNull(summary?.errorPct) ?? (totalFromEndpoints > 0
8517
+ ? endpoints.reduce((sum, endpoint) => sum + Number(endpoint.failures || 0), 0) / totalFromEndpoints * 100
8518
+ : null),
8519
+ };
8520
+ }
8521
+
8479
8522
  function loadEndpointLatencyColor(endpoint, summary) {
8480
8523
  const p95 = Number(endpoint?.p95Duration || 0);
8481
8524
  const threshold = Number(summary?.p95ThresholdMs || 0);
@@ -9206,8 +9249,9 @@ async function stopLoadTest() {
9206
9249
  function buildLoadAnalysisPrompt() {
9207
9250
  if (!loadState || !loadState.summary) return '';
9208
9251
  const summary = loadState.summary;
9209
- const logs = loadState.logs || [];
9210
- const totalRequests = Number(summary.totalRequests || loadState.totalRequests || 0);
9252
+ const logs = getLoadPromptLogs();
9253
+ const aggregate = getLoadPromptAggregate(summary);
9254
+ const totalRequests = Number(aggregate.totalRequests || 0);
9211
9255
  if (totalRequests <= 0 && logs.length === 0) {
9212
9256
  return '';
9213
9257
  }
@@ -9225,13 +9269,13 @@ Script: ${loadState.config?.scriptName || '-'}
9225
9269
  VUs: ${loadState.config?.vus || '-'}
9226
9270
  Duration: ${loadState.config?.duration || '-'}
9227
9271
 
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)}%
9272
+ RPS: ${formatLoadPromptNumber(aggregate.rps, 2)}
9273
+ avg latency: ${formatLoadPromptNumber(aggregate.avgDuration, 0, 'ms')}
9274
+ p90 latency: ${formatLoadPromptNumber(aggregate.p90Duration, 0, 'ms')}
9275
+ p95 latency: ${formatLoadPromptNumber(aggregate.p95Duration, 0, 'ms')}
9276
+ p99 latency: ${formatLoadPromptNumber(aggregate.p99Duration, 0, 'ms')}
9277
+ Total requests: ${aggregate.totalRequests ?? '-'}
9278
+ Error rate: ${formatLoadPromptNumber(aggregate.errorPct, 2, '%')}
9235
9279
  Checks failed: ${summary.checksFailed ?? '-'}
9236
9280
  Exit code: ${summary.exitCode ?? '-'}
9237
9281
 
@@ -9823,11 +9867,16 @@ function connectSSE() {
9823
9867
  if (contextMode === 'load') { renderSidebar(); renderContent(); }
9824
9868
  });
9825
9869
 
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') {
9870
+ es.addEventListener('load-log', (e) => {
9871
+ const { line } = JSON.parse(e.data);
9872
+ loadLogLines.push(line);
9873
+ if (loadLogLines.length > 500) loadLogLines.shift();
9874
+ if (loadState) {
9875
+ if (!Array.isArray(loadState.logs)) loadState.logs = [];
9876
+ loadState.logs.push(line);
9877
+ if (loadState.logs.length > 500) loadState.logs.shift();
9878
+ }
9879
+ if (contextMode === 'load') {
9831
9880
  const logEl = document.getElementById('loadLogContent');
9832
9881
  if (logEl) {
9833
9882
  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.231",
4
4
  "description": "Live module map with test coverage for vibecoding projects",
5
5
  "main": "./dist/cli.js",
6
6
  "bin": {