@vehicle-sil/gui-client 0.5.0 → 0.6.0

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.
@@ -12,6 +12,8 @@
12
12
  (function (global) {
13
13
  'use strict';
14
14
 
15
+ const hasLine = (line) => line !== null && line !== undefined && line !== '';
16
+
15
17
  const en = {
16
18
  // --- reading a file
17
19
  'file.named': ({ name }) => `"${name}"`,
@@ -131,6 +133,7 @@
131
133
  'page.noName': '(a scenario without a name)',
132
134
  'fact.file': 'timeline file',
133
135
  'fact.scenario': 'scenario',
136
+ 'fact.case': 'case',
134
137
  'fact.configuration': 'configuration',
135
138
  'fact.variant': 'variant',
136
139
  'fact.timeStep': 'controller time step',
@@ -149,7 +152,9 @@
149
152
 
150
153
  // --- the summary above the chart
151
154
  'failure.heading': ({ step, at }) => `Step ${step} failed at ${at}`,
152
- 'failure.where': ({ line, file }) => `line ${line} of ${file}`,
155
+ 'failure.where': ({ line, file }) =>
156
+ hasLine(line) ? (file ? `line ${line} of ${file}` : `line ${line}`) : file || '',
157
+ 'failure.calledFrom': 'Called from:',
153
158
  'passed.heading': ({ count }) => `Passed: ${count} step${count === 1 ? '' : 's'}`,
154
159
  'passed.skipped': ({ count }) => `${count} skipped (see the table of steps).`,
155
160
  'notDecided.heading': ({ status }) => `Scenario ${status}`,
@@ -175,6 +180,13 @@
175
180
  'conditions.sampleOf': ({ at }) => ` (sample of ${at})`,
176
181
  'conditions.noSample': 'no sample came in the interval',
177
182
  'conditions.noValue': 'it had no value yet',
183
+ 'conditions.while': '; while ',
184
+ 'conditions.comparedSep': ', ',
185
+ 'conditions.comparedValue': ({ value }) => ` was ${value}`,
186
+ 'conditions.comparedNoSample': ' had no sample in the interval',
187
+ 'conditions.comparedNoValue': ' had no value yet',
188
+ 'conditions.rounded': ({ max }) =>
189
+ `Integer values beyond ±${max} are rounded by the browser; see the failure message above for exact 64-bit values.`,
178
190
  'participants.label': 'Participants',
179
191
 
180
192
  // --- the tables below the chart
@@ -215,7 +227,13 @@
215
227
  'chart.cursor': ({ at }) => `Cursor ${at}`,
216
228
  'chart.steps': 'Steps',
217
229
  'step.title': ({ index, kind, line, status }) =>
218
- `Step ${index} (${kind}, line ${line}): ${status}`,
230
+ hasLine(line)
231
+ ? `Step ${index} (${kind}, line ${line}): ${status}`
232
+ : `Step ${index} (${kind}): ${status}`,
233
+ 'step.titleInFile': ({ index, kind, file, line, status }) =>
234
+ hasLine(line)
235
+ ? `Step ${index} (${kind}, ${file} line ${line}): ${status}`
236
+ : `Step ${index} (${kind}, ${file}): ${status}`,
219
237
  'step.times': ({ start, decided, end }) => `start ${start}, decided ${decided}, end ${end}`,
220
238
  'step.details': 'Step details',
221
239
  'step.matchOnce': ({ from, to }) =>
@@ -242,7 +260,10 @@
242
260
  'fit.toValues': 'Scale to the values',
243
261
  'fit.declared': 'declared range',
244
262
  'fit.values': 'fit values',
245
- 'line.title': ({ text, where, line }) => `${text} (${where}, line ${line})`,
263
+ 'line.title': ({ text, where, line }) =>
264
+ hasLine(line) ? `${text} (${where}, line ${line})` : `${text} (${where})`,
265
+ 'line.titleInFile': ({ text, where, file, line }) =>
266
+ hasLine(line) ? `${text} (${where}, ${file} line ${line})` : `${text} (${where}, ${file})`,
246
267
  'line.step': ({ step }) => `step ${step}`,
247
268
  'state.notApplied': 'Sent, and the ECU did not apply it',
248
269
  'state.notKnown': 'Sent; not known whether the ECU applied it',
@@ -262,8 +283,13 @@
262
283
  'band.title': ({ step, mode, compare, range, limit, result }) =>
263
284
  `Step ${step} (${mode}): ${compare}, ${range}${limit}: ${result}`,
264
285
  'band.expect': ({ compare }) => `expect ${compare}`,
286
+ 'band.sliceRange': ({ compare, from, to }) => `${compare} (${from} to ${to})`,
265
287
  'mark.noValueAt': ({ at }) => `No value at ${at}`,
266
288
  'mark.was': ({ value, at }) => `It was ${value} (sample of ${at}): the condition did not hold`,
289
+ 'mark.comparedNoValueAt': ({ at, variable }) =>
290
+ `Compared variable had no value at ${at} for ${variable}`,
291
+ 'mark.comparedWas': ({ value, at, variable }) =>
292
+ `Compared value was ${value} (sample of ${at}) for ${variable}`,
267
293
  'mark.noValue': 'no value',
268
294
  'mark.applied': 'applied',
269
295
  'mark.notSent': 'not sent',
@@ -438,6 +464,7 @@
438
464
  'page.noName': '(名前のないシナリオ)',
439
465
  'fact.file': '時間の軸のファイル',
440
466
  'fact.scenario': 'シナリオ',
467
+ 'fact.case': 'ケース',
441
468
  'fact.configuration': '構成ファイル',
442
469
  'fact.variant': 'variant',
443
470
  'fact.timeStep': 'コントローラーの時間の刻み',
@@ -456,7 +483,9 @@
456
483
 
457
484
  // --- 図の上の要約
458
485
  'failure.heading': ({ step, at }) => `手順 ${step} が ${at} で失敗しました`,
459
- 'failure.where': ({ line, file }) => `${file} の ${line} 行`,
486
+ 'failure.where': ({ line, file }) =>
487
+ hasLine(line) ? (file ? `${file} の ${line} 行` : `${line} 行`) : file || '',
488
+ 'failure.calledFrom': '呼び出し元:',
460
489
  'passed.heading': ({ count }) => `通りました: ${count} 個の手順`,
461
490
  'passed.skipped': ({ count }) => `${count} 個を飛ばしました(手順の表を見てください)。`,
462
491
  'notDecided.heading': ({ status }) => `シナリオ: ${status}`,
@@ -481,6 +510,13 @@
481
510
  'conditions.sampleOf': ({ at }) => `(${at} のサンプル)`,
482
511
  'conditions.noSample': '区間の中にサンプルが来なかった',
483
512
  'conditions.noValue': 'まだ値がなかった',
513
+ 'conditions.while': '。比較対象の ',
514
+ 'conditions.comparedSep': '、',
515
+ 'conditions.comparedValue': ({ value }) => ` は ${value}`,
516
+ 'conditions.comparedNoSample': ' は区間の中にサンプルが来なかった',
517
+ 'conditions.comparedNoValue': ' はまだ値がなかった',
518
+ 'conditions.rounded': ({ max }) =>
519
+ `±${max} を超える整数はブラウザーで丸められます。正確な 64 ビット整数は上の失敗メッセージを確認してください。`,
484
520
  'participants.label': 'participant',
485
521
 
486
522
  // --- 図の下の表
@@ -522,7 +558,13 @@
522
558
  'chart.cursor': ({ at }) => `カーソル ${at}`,
523
559
  'chart.steps': '手順',
524
560
  'step.title': ({ index, kind, line, status }) =>
525
- `手順 ${index}(${kind}、${line} 行): ${status}`,
561
+ hasLine(line)
562
+ ? `手順 ${index}(${kind}、${line} 行): ${status}`
563
+ : `手順 ${index}(${kind}): ${status}`,
564
+ 'step.titleInFile': ({ index, kind, file, line, status }) =>
565
+ hasLine(line)
566
+ ? `手順 ${index}(${kind}、${file} ${line} 行): ${status}`
567
+ : `手順 ${index}(${kind}、${file}): ${status}`,
526
568
  'step.times': ({ start, decided, end }) =>
527
569
  `始まり ${start}、決まった ${decided}、終わり ${end}`,
528
570
  'step.details': '手順の詳細',
@@ -549,7 +591,10 @@
549
591
  'fit.toValues': '値に合わせる',
550
592
  'fit.declared': '宣言の範囲',
551
593
  'fit.values': '値に合わせた',
552
- 'line.title': ({ text, where, line }) => `${text}(${where}、${line} 行)`,
594
+ 'line.title': ({ text, where, line }) =>
595
+ hasLine(line) ? `${text}(${where}、${line} 行)` : `${text}(${where})`,
596
+ 'line.titleInFile': ({ text, where, file, line }) =>
597
+ hasLine(line) ? `${text}(${where}、${file} ${line} 行)` : `${text}(${where}、${file})`,
553
598
  'line.step': ({ step }) => `手順 ${step}`,
554
599
  'state.notApplied': '送ったが、ECU に入らなかった',
555
600
  'state.notKnown': '送ったが、ECU に入ったか不明',
@@ -568,8 +613,13 @@
568
613
  'band.title': ({ step, mode, compare, range, limit, result }) =>
569
614
  `手順 ${step}(${mode}): ${compare}、${range}${limit}: ${result}`,
570
615
  'band.expect': ({ compare }) => `expect ${compare}`,
616
+ 'band.sliceRange': ({ compare, from, to }) => `${compare}(${from} から ${to})`,
571
617
  'mark.noValueAt': ({ at }) => `${at} に値がない`,
572
618
  'mark.was': ({ value, at }) => `値は ${value}(${at} のサンプル): 条件は成り立たなかった`,
619
+ 'mark.comparedNoValueAt': ({ at, variable }) =>
620
+ `比較対象の変数は ${at} に値がなかった: ${variable} の条件`,
621
+ 'mark.comparedWas': ({ value, at, variable }) =>
622
+ `比較対象の値は ${value}(${at} のサンプル): ${variable} の条件`,
573
623
  'mark.noValue': '値なし',
574
624
  'mark.applied': '入った',
575
625
  'mark.notSent': '送っていない',
@@ -1326,13 +1376,22 @@ svg text {
1326
1376
  stroke: var(--_neutral);
1327
1377
  stroke-width: 1.5;
1328
1378
  }
1379
+ .band .expect-box.dynamic {
1380
+ fill: var(--_neutral-fill);
1381
+ }
1329
1382
  .band.ok .expect-box {
1330
1383
  stroke: var(--_ok);
1331
1384
  }
1385
+ .band.ok .expect-box.dynamic {
1386
+ fill: var(--_ok-fill);
1387
+ }
1332
1388
  .band.bad .expect-box {
1333
1389
  stroke: var(--_bad);
1334
1390
  stroke-width: 2;
1335
1391
  }
1392
+ .band.bad .expect-box.dynamic {
1393
+ fill: var(--_bad-fill);
1394
+ }
1336
1395
  .expect-label {
1337
1396
  font-size: 10px;
1338
1397
  }
@@ -1341,6 +1400,11 @@ svg text {
1341
1400
  stroke: var(--_panel);
1342
1401
  stroke-width: 1.5;
1343
1402
  }
1403
+ .mark.compared path {
1404
+ fill: var(--_panel);
1405
+ stroke: var(--_bad);
1406
+ stroke-width: 2;
1407
+ }
1344
1408
  .mark text {
1345
1409
  font-weight: 700;
1346
1410
  pointer-events: none;
@@ -1587,15 +1651,18 @@ tr.selected td {
1587
1651
  return fmtNum(v, exact);
1588
1652
  }
1589
1653
 
1590
- /** One condition's comparisons, the way the scenario writes them ("le 200", "near 200 ± 0.5"). */
1654
+ const nonEmptyString = (v) => (typeof v === 'string' && v !== '' ? v : null);
1655
+ const compareTarget = (c) => (isObject(c) ? nonEmptyString(c.variable) : null);
1656
+
1657
+ /** One condition's comparisons, the way the scenario writes them ("le 200", "near 200 ± 0.5", "near Engine.speed ± 10"). */
1591
1658
  function compareText(compare, info) {
1592
1659
  if (!Array.isArray(compare)) return '';
1593
1660
  return compare
1594
1661
  .map((c) => {
1595
1662
  if (!isObject(c)) return '?';
1596
- const tol =
1597
- c.op === 'near' && c.tolerance !== undefined ? ` ± ${fmtNum(c.tolerance, true)}` : '';
1598
- return `${c.op} ${fmtValue(c.value, info, true)}${tol}`;
1663
+ const tol = c.op === 'near' && isNum(c.tolerance) ? ` ± ${fmtNum(c.tolerance, true)}` : '';
1664
+ const rhs = compareTarget(c) ?? fmtValue(c.value, info, true);
1665
+ return `${c.op} ${rhs}${tol}`;
1599
1666
  })
1600
1667
  .join(t('compare.and'));
1601
1668
  }
@@ -1708,13 +1775,294 @@ tr.selected td {
1708
1775
  return { from: d.dropped_from_ms, before: d.dropped_before_ms, dropped: d.dropped };
1709
1776
  }
1710
1777
 
1778
+ /**
1779
+ * Zero-order-hold segments of a right-hand variable's sampled series within [from, to].
1780
+ * Uses rhsVar.sampled exclusively (never written), skips unobserved intervals and gaps.sampled,
1781
+ * and in "during" mode uses only samples with sample_ms >= from.
1782
+ */
1783
+ function rhsSampleSegments(rhsVar, from, to, mode) {
1784
+ if (!rhsVar || !rhsVar.sampled || !rhsVar.sampled.t.length) return [];
1785
+ const s = rhsVar.sampled;
1786
+ const gap =
1787
+ rhsVar.gaps && rhsVar.gaps.sampled && rhsVar.gaps.sampled.before > rhsVar.gaps.sampled.from
1788
+ ? rhsVar.gaps.sampled
1789
+ : null;
1790
+ const n = s.t.length;
1791
+ const instant = to === from;
1792
+ const segs = [];
1793
+ for (let i = 0; i < n; i++) {
1794
+ const tStart = s.t[i];
1795
+ const tNext = i + 1 < n ? s.t[i + 1] : null;
1796
+ const val = s.v[i];
1797
+ if (val === null || val === undefined) continue;
1798
+ if (mode === 'during' && tStart < from) continue;
1799
+ if (gap && tStart >= gap.from && tStart < gap.before) continue;
1800
+ let rawEnd = tNext !== null ? tNext : Math.max(to, s.lastMs ?? tStart, tStart);
1801
+ if (gap && tStart < gap.from && rawEnd > gap.from) rawEnd = gap.from;
1802
+ if (instant) {
1803
+ if (gap && from >= gap.from && from < gap.before) continue;
1804
+ const active = tStart <= from && (tNext === null ? from <= rawEnd : from < rawEnd);
1805
+ if (active) segs.push({ from, to, value: val, atEnd: true });
1806
+ } else {
1807
+ const coversTo =
1808
+ !(gap && to >= gap.from && to < gap.before) &&
1809
+ tStart <= to &&
1810
+ (tNext === null ? to <= rawEnd : to < rawEnd);
1811
+ const a = Math.max(tStart, from);
1812
+ const b = Math.min(rawEnd, to);
1813
+ if (b > a) segs.push({ from: a, to: b, value: val, atEnd: coversTo });
1814
+ else if (tStart === to && coversTo) segs.push({ from: to, to, value: val, atEnd: true });
1815
+ }
1816
+ }
1817
+ return segs;
1818
+ }
1819
+
1820
+ /** Intersection of resolved numeric comparisons on a slice, or null when empty. */
1821
+ function intersectNumeric(resolved, info) {
1822
+ let lo = -Infinity;
1823
+ let loOpen = false;
1824
+ let hi = Infinity;
1825
+ let hiOpen = false;
1826
+ let hasBound = false;
1827
+ const excluded = [];
1828
+ for (const r of resolved) {
1829
+ if (!isNum(r.value)) return null;
1830
+ if (r.op === 'ge') {
1831
+ hasBound = true;
1832
+ if (r.value > lo) {
1833
+ lo = r.value;
1834
+ loOpen = false;
1835
+ }
1836
+ } else if (r.op === 'gt') {
1837
+ hasBound = true;
1838
+ if (r.value > lo || (r.value === lo && !loOpen)) {
1839
+ lo = r.value;
1840
+ loOpen = true;
1841
+ }
1842
+ } else if (r.op === 'le') {
1843
+ hasBound = true;
1844
+ if (r.value < hi) {
1845
+ hi = r.value;
1846
+ hiOpen = false;
1847
+ }
1848
+ } else if (r.op === 'lt') {
1849
+ hasBound = true;
1850
+ if (r.value < hi || (r.value === hi && !hiOpen)) {
1851
+ hi = r.value;
1852
+ hiOpen = true;
1853
+ }
1854
+ } else if (r.op === 'eq') {
1855
+ hasBound = true;
1856
+ if (r.value > lo) {
1857
+ lo = r.value;
1858
+ loOpen = false;
1859
+ }
1860
+ if (r.value < hi) {
1861
+ hi = r.value;
1862
+ hiOpen = false;
1863
+ }
1864
+ } else if (r.op === 'near') {
1865
+ if (!isNum(r.tolerance) || r.tolerance < 0) return null;
1866
+ hasBound = true;
1867
+ const nLo = r.value - r.tolerance;
1868
+ const nHi = r.value + r.tolerance;
1869
+ if (nLo > lo) {
1870
+ lo = nLo;
1871
+ loOpen = false;
1872
+ }
1873
+ if (nHi < hi) {
1874
+ hi = nHi;
1875
+ hiOpen = false;
1876
+ }
1877
+ } else if (r.op === 'ne') {
1878
+ if (!excluded.includes(r.value)) excluded.push(r.value);
1879
+ }
1880
+ }
1881
+ if (lo > hi) return null;
1882
+ if (lo === hi && (loOpen || hiOpen || excluded.includes(lo))) return null;
1883
+ if (info && info.type === 'integer' && (lo !== -Infinity || hi !== Infinity)) {
1884
+ const intLo = lo === -Infinity ? -Infinity : loOpen ? Math.floor(lo) + 1 : Math.ceil(lo);
1885
+ const intHi = hi === Infinity ? Infinity : hiOpen ? Math.ceil(hi) - 1 : Math.floor(hi);
1886
+ if (intLo > intHi) return null;
1887
+ if (intLo === intHi && excluded.includes(intLo)) return null;
1888
+ if (
1889
+ Number.isSafeInteger(intLo) &&
1890
+ Number.isSafeInteger(intHi) &&
1891
+ intHi - intLo < excluded.length
1892
+ ) {
1893
+ let allExcluded = true;
1894
+ for (let k = intLo; k <= intHi; k++) {
1895
+ if (!excluded.includes(k)) {
1896
+ allExcluded = false;
1897
+ break;
1898
+ }
1899
+ }
1900
+ if (allExcluded) return null;
1901
+ }
1902
+ }
1903
+ return { discrete: false, lo, loOpen, hi, hiOpen, hasBound, excluded, resolved };
1904
+ }
1905
+
1906
+ /** Intersection of resolved discrete (bool/enum) comparisons on a slice, or null when empty. */
1907
+ function intersectDiscrete(resolved, info) {
1908
+ let required;
1909
+ const forbidden = [];
1910
+ for (const r of resolved) {
1911
+ if (r.value === null || r.value === undefined) return null;
1912
+ if (r.op === 'eq') {
1913
+ if (required !== undefined && required !== r.value) return null;
1914
+ required = r.value;
1915
+ } else if (r.op === 'ne') {
1916
+ if (!forbidden.includes(r.value)) forbidden.push(r.value);
1917
+ }
1918
+ }
1919
+ if (required !== undefined && forbidden.includes(required)) return null;
1920
+ if (required === undefined) {
1921
+ if (info && info.type === 'bool' && forbidden.includes(false) && forbidden.includes(true))
1922
+ return null;
1923
+ if (
1924
+ info &&
1925
+ info.type === 'enum' &&
1926
+ Array.isArray(info.items) &&
1927
+ info.items.length > 0 &&
1928
+ info.items.every((item) => item && forbidden.includes(item.value))
1929
+ )
1930
+ return null;
1931
+ }
1932
+ return {
1933
+ discrete: true,
1934
+ value: required !== undefined ? required : null,
1935
+ excluded: forbidden,
1936
+ resolved,
1937
+ };
1938
+ }
1939
+
1940
+ function sameSlice(a, b) {
1941
+ if (a.discrete !== b.discrete || a.to !== b.from) return false;
1942
+ if (a.discrete) {
1943
+ if (a.value !== b.value || a.excluded.length !== b.excluded.length) return false;
1944
+ return a.excluded.every((x, i) => x === b.excluded[i]);
1945
+ }
1946
+ if (
1947
+ a.lo !== b.lo ||
1948
+ a.loOpen !== b.loOpen ||
1949
+ a.hi !== b.hi ||
1950
+ a.hiOpen !== b.hiOpen ||
1951
+ a.hasBound !== b.hasBound ||
1952
+ a.excluded.length !== b.excluded.length ||
1953
+ a.resolved.length !== b.resolved.length
1954
+ )
1955
+ return false;
1956
+ return (
1957
+ a.excluded.every((x, i) => x === b.excluded[i]) &&
1958
+ a.resolved.every(
1959
+ (r, i) =>
1960
+ r.op === b.resolved[i].op &&
1961
+ r.value === b.resolved[i].value &&
1962
+ r.tolerance === b.resolved[i].tolerance,
1963
+ )
1964
+ );
1965
+ }
1966
+
1967
+ /**
1968
+ * Resolves a band's comparisons into non-empty ZOH slices over [from, to], intersecting all comparisons
1969
+ * in the condition at every elementary sub-interval.
1970
+ */
1971
+ function resolveBandSlices(compare, from, to, mode, info, byName) {
1972
+ if (!compare.length) return [];
1973
+ const discrete = info && (info.type === 'bool' || info.type === 'enum');
1974
+ const sources = compare.map((c) => {
1975
+ const target = compareTarget(c);
1976
+ if (!target) return { c, segs: null };
1977
+ return {
1978
+ c,
1979
+ segs: rhsSampleSegments(byName ? byName.get(target) : null, from, to, mode),
1980
+ };
1981
+ });
1982
+ if (sources.some((src) => src.segs && src.segs.length === 0)) return [];
1983
+
1984
+ const intervals = [];
1985
+ if (to === from) {
1986
+ intervals.push([from, to]);
1987
+ } else {
1988
+ const pts = new Set([from, to]);
1989
+ for (const src of sources) {
1990
+ if (!src.segs) continue;
1991
+ for (const seg of src.segs) {
1992
+ pts.add(seg.from);
1993
+ pts.add(seg.to);
1994
+ }
1995
+ }
1996
+ const ts = [...pts].sort((a, b) => a - b);
1997
+ for (let i = 0; i + 1 < ts.length; i++) {
1998
+ if (ts[i + 1] > ts[i]) intervals.push([ts[i], ts[i + 1]]);
1999
+ }
2000
+ const hasTerminalPoint = sources.some(
2001
+ (src) => src.segs && src.segs.some((sg) => sg.from === to && sg.to === to),
2002
+ );
2003
+ if (hasTerminalPoint) intervals.push([to, to]);
2004
+ }
2005
+
2006
+ const slices = [];
2007
+ for (const [a, b] of intervals) {
2008
+ const resolved = [];
2009
+ let missing = false;
2010
+ for (const src of sources) {
2011
+ let val;
2012
+ if (!src.segs) {
2013
+ val = src.c.value;
2014
+ } else {
2015
+ const seg =
2016
+ b > a
2017
+ ? src.segs.find((sg) => sg.from <= a && sg.to >= b)
2018
+ : src.segs.find((sg) => sg.atEnd && sg.from <= a && sg.to >= b);
2019
+ if (!seg) {
2020
+ missing = true;
2021
+ break;
2022
+ }
2023
+ val = seg.value;
2024
+ }
2025
+ resolved.push({
2026
+ op: src.c.op,
2027
+ value: val,
2028
+ tolerance: src.c.op === 'near' && isNum(src.c.tolerance) ? src.c.tolerance : null,
2029
+ });
2030
+ }
2031
+ if (missing) continue;
2032
+ const body = discrete ? intersectDiscrete(resolved, info) : intersectNumeric(resolved, info);
2033
+ if (!body) continue;
2034
+ const slice = { from: a, to: b, ...body };
2035
+ const prev = slices[slices.length - 1];
2036
+ if (prev && sameSlice(prev, slice)) prev.to = slice.to;
2037
+ else slices.push(slice);
2038
+ }
2039
+ return slices;
2040
+ }
2041
+
2042
+ /** Numeric y-position for a "once" band's timeout extension line, resolving dynamic compare[0] when value is null. */
2043
+ function resolveLimitValue(compare, slices) {
2044
+ const last = slices.length ? slices[slices.length - 1] : null;
2045
+ if (last && !last.discrete) {
2046
+ if (last.resolved.length && isNum(last.resolved[0].value)) return last.resolved[0].value;
2047
+ const num = last.resolved.find((r) => isNum(r.value));
2048
+ if (num) return num.value;
2049
+ if (isNum(last.lo) && isNum(last.hi)) return (last.lo + last.hi) / 2;
2050
+ if (isNum(last.lo)) return last.lo;
2051
+ if (isNum(last.hi)) return last.hi;
2052
+ }
2053
+ for (const c of compare) {
2054
+ if (isNum(c.value)) return c.value;
2055
+ }
2056
+ return null;
2057
+ }
2058
+
1711
2059
  /**
1712
2060
  * The bands that conditions put on a variable's lane. A band covers the samples the condition looks at:
1713
2061
  * at: the instant from_ms; always and during: from_ms to to_ms, but not past the failure of the step or the
1714
2062
  * end of the record (`recordedTo`), since no sample was looked at after them; once: from_ms to the time it held
1715
2063
  * (passed) or to the limit, with a thin line on to the limit. `until` is the end the scenario gave.
1716
2064
  */
1717
- function watchBands(step, variable, recordedTo) {
2065
+ function watchBands(step, variable, recordedTo, byName) {
1718
2066
  const w = step.watch;
1719
2067
  if (!isObject(w) || !Array.isArray(w.conditions) || !isNum(w.from_ms))
1720
2068
  return { bands: [], notes: [] };
@@ -1724,6 +2072,7 @@ tr.selected td {
1724
2072
  isObject(step.failed) && Array.isArray(step.failed.conditions)
1725
2073
  ? step.failed.conditions.map((c) => c && c.condition)
1726
2074
  : [];
2075
+ const targetVar = byName ? byName.get(variable) : null;
1727
2076
  w.conditions.forEach((c, index) => {
1728
2077
  if (!isObject(c) || c.variable !== variable) return;
1729
2078
  if (!knows(KNOWN.mode, w.mode)) {
@@ -1750,15 +2099,28 @@ tr.selected td {
1750
2099
  to = Math.min(to, step.failed.at_ms);
1751
2100
  if (isNum(recordedTo)) to = Math.min(to, recordedTo);
1752
2101
  }
2102
+ const bandTo = Math.max(to, from);
2103
+ const dynamic = compare.some((x) => compareTarget(x) !== null);
2104
+ const slices = resolveBandSlices(
2105
+ compare,
2106
+ from,
2107
+ bandTo,
2108
+ w.mode,
2109
+ targetVar && targetVar.info,
2110
+ byName,
2111
+ );
1753
2112
  bands.push({
1754
2113
  step: step.index,
1755
2114
  condition: index,
1756
2115
  mode: w.mode,
1757
2116
  from,
1758
- to: Math.max(to, from),
2117
+ to: bandTo,
1759
2118
  until: Math.max(until, from),
1760
2119
  limit,
2120
+ limitValue: resolveLimitValue(compare, slices),
1761
2121
  compare,
2122
+ dynamic,
2123
+ slices,
1762
2124
  status: knows(KNOWN.stepStatus, step.status) ? step.status : 'unknown',
1763
2125
  failed: failedConditions.includes(index),
1764
2126
  });
@@ -1766,6 +2128,58 @@ tr.selected td {
1766
2128
  return { bands, notes };
1767
2129
  }
1768
2130
 
2131
+ function stepFile(step, scenarioFile) {
2132
+ return (isObject(step) && nonEmptyString(step.file)) || nonEmptyString(scenarioFile) || null;
2133
+ }
2134
+
2135
+ function lineFile(line, scenarioFile) {
2136
+ return (isObject(line) && nonEmptyString(line.file)) || nonEmptyString(scenarioFile) || null;
2137
+ }
2138
+
2139
+ function stepTitle(step, scenarioFile) {
2140
+ const file = stepFile(step, scenarioFile);
2141
+ const args = {
2142
+ index: step.index,
2143
+ kind: step.kind,
2144
+ line: isNum(step.line) ? step.line : null,
2145
+ status: statusWord(step.status),
2146
+ };
2147
+ if (file && file !== scenarioFile) return t('step.titleInFile', { ...args, file });
2148
+ return t('step.title', args);
2149
+ }
2150
+
2151
+ function lineTitle(line, scenarioFile) {
2152
+ const file = lineFile(line, scenarioFile);
2153
+ const where =
2154
+ line.step === null || line.step === undefined
2155
+ ? t('line.inputs')
2156
+ : t('line.step', { step: line.step });
2157
+ const args = {
2158
+ text: line.text ?? line.kind,
2159
+ where,
2160
+ line: isNum(line.line) ? line.line : null,
2161
+ };
2162
+ if (file && file !== scenarioFile) return t('line.titleInFile', { ...args, file });
2163
+ return t('line.title', args);
2164
+ }
2165
+
2166
+ function callStackFrames(callStack, scenarioFile) {
2167
+ if (!Array.isArray(callStack)) return [];
2168
+ const fallback = nonEmptyString(scenarioFile) || '';
2169
+ return callStack.filter(isObject).map((fr) => {
2170
+ const file = nonEmptyString(fr.file) || fallback;
2171
+ const line = isNum(fr.line) ? fr.line : null;
2172
+ const where = file || line !== null ? t('failure.where', { line, file }) : '';
2173
+ const name = nonEmptyString(fr.name);
2174
+ const params = isObject(fr.params)
2175
+ ? Object.entries(fr.params)
2176
+ .map(([k, v]) => `${k} = ${fmtValue(v)}`)
2177
+ .join(', ')
2178
+ : '';
2179
+ return [where, name, params].filter(Boolean).join(' · ');
2180
+ });
2181
+ }
2182
+
1769
2183
  /** The failure to lead the eye to: the failed step and what failed, in numbers and names. */
1770
2184
  function failureOf(tl, byName) {
1771
2185
  const step = tl.steps.find((s) => s.status === 'failed');
@@ -1780,7 +2194,20 @@ tr.selected td {
1780
2194
  : null;
1781
2195
  const variable = isObject(wc) ? wc.variable : null;
1782
2196
  const info = byName.get(variable);
1783
- return {
2197
+ const compared = (Array.isArray(c.compared) ? c.compared : [])
2198
+ .filter(isObject)
2199
+ .map((rhs) => {
2200
+ const rhsName = nonEmptyString(rhs.variable);
2201
+ const rhsInfo = rhsName ? byName.get(rhsName) : null;
2202
+ const rhsVal = rhs.value === undefined ? null : rhs.value;
2203
+ return {
2204
+ variable: rhsName,
2205
+ value: rhsVal,
2206
+ valueText: rhsVal === null ? null : fmtValue(rhsVal, rhsInfo && rhsInfo.info, true),
2207
+ sampleMs: isNum(rhs.sample_ms) ? rhs.sample_ms : null,
2208
+ };
2209
+ });
2210
+ const entry = {
1784
2211
  variable,
1785
2212
  compare: isObject(wc) ? compareText(wc.compare, info && info.info) : null,
1786
2213
  value: c.value,
@@ -1791,6 +2218,8 @@ tr.selected td {
1791
2218
  sampleMs: isNum(c.sample_ms) ? c.sample_ms : null,
1792
2219
  mode: isObject(step.watch) ? step.watch.mode : null,
1793
2220
  };
2221
+ if (compared.length) entry.compared = compared;
2222
+ return entry;
1794
2223
  });
1795
2224
  const writes = (f && Array.isArray(f.writes) ? f.writes : []).map((w, i) => {
1796
2225
  if (!isObject(w)) return null;
@@ -1822,6 +2251,9 @@ tr.selected td {
1822
2251
  const at = f && isNum(f.at_ms) ? f.at_ms : isNum(step.at_ms) ? step.at_ms : null;
1823
2252
  return {
1824
2253
  step,
2254
+ file: stepFile(step, tl.scenario.file),
2255
+ name: nonEmptyString(step.name),
2256
+ callStack: Array.isArray(step.call_stack) ? step.call_stack.filter(isObject) : [],
1825
2257
  at,
1826
2258
  code: (f && f.code) || step.code || null,
1827
2259
  message: typeof step.message === 'string' ? step.message : null,
@@ -1932,7 +2364,7 @@ tr.selected td {
1932
2364
  for (const name of names) {
1933
2365
  if (typeof name !== 'string') continue;
1934
2366
  const v = varOf(name);
1935
- const { bands, notes } = watchBands(step, name, recordedTo);
2367
+ const { bands, notes } = watchBands(step, name, recordedTo, byName);
1936
2368
  v.bands.push(...bands);
1937
2369
  v.notes.push(...notes);
1938
2370
  }
@@ -1941,15 +2373,41 @@ tr.selected td {
1941
2373
  const failure = failureOf(tl, byName);
1942
2374
  if (failure) {
1943
2375
  for (const c of failure.conditions) {
1944
- if (typeof c.variable !== 'string') continue;
1945
- const v = varOf(c.variable);
1946
- v.failing = true;
1947
- v.marks.push({
1948
- kind: 'condition',
1949
- at: c.sampleMs ?? failure.at,
1950
- value: c.value,
1951
- text: c.valueText,
1952
- });
2376
+ if (typeof c.variable === 'string') {
2377
+ const v = varOf(c.variable);
2378
+ v.failing = true;
2379
+ v.marks.push({
2380
+ kind: 'condition',
2381
+ at: c.sampleMs ?? failure.at,
2382
+ value: c.value,
2383
+ text: c.valueText,
2384
+ });
2385
+ }
2386
+ if (Array.isArray(c.compared)) {
2387
+ for (const rhs of c.compared) {
2388
+ if (typeof rhs.variable !== 'string' || rhs.variable === '') continue;
2389
+ const rv = varOf(rhs.variable);
2390
+ rv.failing = true;
2391
+ const at = rhs.sampleMs ?? failure.at;
2392
+ const against = c.variable ?? '?';
2393
+ const dup = rv.marks.some(
2394
+ (mk) =>
2395
+ mk.kind === 'compared' &&
2396
+ mk.at === at &&
2397
+ mk.value === rhs.value &&
2398
+ mk.against === against,
2399
+ );
2400
+ if (!dup) {
2401
+ rv.marks.push({
2402
+ kind: 'compared',
2403
+ at,
2404
+ value: rhs.value,
2405
+ text: rhs.valueText,
2406
+ against,
2407
+ });
2408
+ }
2409
+ }
2410
+ }
1953
2411
  }
1954
2412
  for (const w of failure.writes) {
1955
2413
  if (typeof w.variable !== 'string') continue;
@@ -1997,7 +2455,8 @@ tr.selected td {
1997
2455
  : [];
1998
2456
  return {
1999
2457
  tl,
2000
- name: typeof sc.name === 'string' && sc.name !== '' ? sc.name : null,
2458
+ name: nonEmptyString(sc.name),
2459
+ caseName: nonEmptyString(sc.case),
2001
2460
  status: sc.status,
2002
2461
  recordedTo,
2003
2462
  overAt: isNum(sc.over_at_ms) ? sc.over_at_ms : null,
@@ -2303,9 +2762,20 @@ tr.selected td {
2303
2762
  if (s.base) s.base.forEach(take);
2304
2763
  }
2305
2764
  for (const b of v.bands) {
2765
+ if (Array.isArray(b.slices) && b.slices.length) {
2766
+ for (const sl of b.slices) {
2767
+ if (sl.discrete) continue;
2768
+ take(sl.lo);
2769
+ take(sl.hi);
2770
+ if (Array.isArray(sl.excluded)) sl.excluded.forEach(take);
2771
+ if (Array.isArray(sl.resolved)) {
2772
+ for (const r of sl.resolved) take(r.value);
2773
+ }
2774
+ }
2775
+ }
2306
2776
  for (const c of b.compare) {
2307
2777
  take(c.value);
2308
- if (c.op === 'near' && isNum(c.tolerance)) {
2778
+ if (c.op === 'near' && isNum(c.value) && isNum(c.tolerance)) {
2309
2779
  take(c.value - c.tolerance);
2310
2780
  take(c.value + c.tolerance);
2311
2781
  }
@@ -2390,6 +2860,11 @@ tr.selected td {
2390
2860
  fmtValue,
2391
2861
  fmtMs,
2392
2862
  compareText,
2863
+ stepFile,
2864
+ lineFile,
2865
+ stepTitle,
2866
+ lineTitle,
2867
+ callStackFrames,
2393
2868
  };
2394
2869
 
2395
2870
  global.VehicleSilTimeline = api;
@@ -2583,6 +3058,7 @@ tr.selected td {
2583
3058
  const facts = [
2584
3059
  ['fact.file', state.file],
2585
3060
  ['fact.scenario', tl.scenario.file],
3061
+ ['fact.case', nonEmptyString(tl.scenario.case)],
2586
3062
  ['fact.configuration', tl.file],
2587
3063
  ['fact.variant', tl.variant],
2588
3064
  ['fact.timeStep', m.timeStep !== null ? fmtMs(m.timeStep) : null],
@@ -2617,23 +3093,32 @@ tr.selected td {
2617
3093
  const f = m.failure;
2618
3094
  if (f) {
2619
3095
  const step = f.step;
2620
- const where = [
2621
- step.kind,
2622
- t('failure.where', { line: step.line, file: m.tl.scenario.file }),
2623
- f.code,
2624
- ]
2625
- .filter(Boolean)
2626
- .join(' · ');
3096
+ const stepName = nonEmptyString(step.name);
3097
+ const failFile = stepFile(step, m.tl.scenario.file) || '';
3098
+ const failLine = isNum(step.line) ? step.line : null;
3099
+ const failWhere =
3100
+ failFile || failLine !== null
3101
+ ? t('failure.where', { line: failLine, file: failFile })
3102
+ : null;
3103
+ const where = [step.kind, stepName, failWhere, f.code].filter(Boolean).join(' · ');
3104
+ const frames = callStackFrames(step.call_stack, m.tl.scenario.file);
2627
3105
  parts.push(
2628
3106
  h(
2629
3107
  'div',
2630
3108
  { class: 'banner bad', 'data-testid': 'failure' },
2631
3109
  h('h3', { text: t('failure.heading', { step: step.index, at: fmtMs(f.at) }) }),
2632
3110
  h('p', { class: 'muted small', text: `${where} · ${step.text}` }),
3111
+ frames.length
3112
+ ? h(
3113
+ 'p',
3114
+ { class: 'muted small', 'data-testid': 'failure-call-stack' },
3115
+ `${t('failure.calledFrom')} ${frames.join(' → ')}`,
3116
+ )
3117
+ : null,
2633
3118
  f.message
2634
3119
  ? h('p', { class: 'message', 'data-testid': 'failure-message', text: f.message })
2635
3120
  : null,
2636
- f.conditions.length ? renderConditions(f) : null,
3121
+ f.conditions.length ? renderConditions(f, m) : null,
2637
3122
  f.writes.length ? renderWrites(f) : null,
2638
3123
  ),
2639
3124
  );
@@ -2702,26 +3187,85 @@ tr.selected td {
2702
3187
  box.replaceChildren(...parts);
2703
3188
  }
2704
3189
 
2705
- function renderConditions(f) {
3190
+ function isRoundedInteger(val, info) {
3191
+ return Boolean(
3192
+ info &&
3193
+ info.type === 'integer' &&
3194
+ isNum(val) &&
3195
+ Number.isInteger(val) &&
3196
+ !Number.isSafeInteger(val),
3197
+ );
3198
+ }
3199
+
3200
+ function renderConditions(f, m) {
3201
+ let anyRounded = false;
3202
+ const rawFailed =
3203
+ isObject(f.step?.failed) && Array.isArray(f.step.failed.conditions)
3204
+ ? f.step.failed.conditions.filter(isObject)
3205
+ : [];
3206
+ const watchConds =
3207
+ isObject(f.step?.watch) && Array.isArray(f.step.watch.conditions)
3208
+ ? f.step.watch.conditions
3209
+ : [];
3210
+ const items = f.conditions.map((c, idx) => {
3211
+ const what = `${c.variable ?? '?'} ${c.compare ?? ''}`.trim();
3212
+ const lhsInfo = m && c.variable ? m.byName.get(c.variable)?.info : null;
3213
+ if (isRoundedInteger(c.value, lhsInfo)) anyRounded = true;
3214
+ const fc = rawFailed[idx];
3215
+ const wc = isObject(fc) ? watchConds[fc.condition] : null;
3216
+ if (isObject(wc) && Array.isArray(wc.compare)) {
3217
+ for (const comp of wc.compare) {
3218
+ if (
3219
+ isObject(comp) &&
3220
+ (isRoundedInteger(comp.value, lhsInfo) || isRoundedInteger(comp.tolerance, lhsInfo))
3221
+ ) {
3222
+ anyRounded = true;
3223
+ }
3224
+ }
3225
+ }
3226
+ let got;
3227
+ if (c.valueText !== null)
3228
+ got =
3229
+ t('conditions.was', { value: c.valueText }) +
3230
+ (c.sampleMs !== null ? t('conditions.sampleOf', { at: fmtMs(c.sampleMs) }) : '');
3231
+ else if (c.mode === 'during') got = t('conditions.noSample');
3232
+ else got = t('conditions.noValue');
3233
+ const parts = [h('code', { text: what }), `: ${got}`];
3234
+ if (Array.isArray(c.compared) && c.compared.length) {
3235
+ parts.push(t('conditions.while'));
3236
+ c.compared.forEach((rhs, i) => {
3237
+ if (i > 0) parts.push(t('conditions.comparedSep'));
3238
+ const rhsInfo = m && rhs.variable ? m.byName.get(rhs.variable)?.info : null;
3239
+ if (isRoundedInteger(rhs.value, rhsInfo)) anyRounded = true;
3240
+ parts.push(h('code', { text: rhs.variable ?? '?' }));
3241
+ if (rhs.valueText !== null) {
3242
+ parts.push(
3243
+ t('conditions.comparedValue', { value: rhs.valueText }) +
3244
+ (rhs.sampleMs !== null
3245
+ ? t('conditions.sampleOf', { at: fmtMs(rhs.sampleMs) })
3246
+ : ''),
3247
+ );
3248
+ } else if (c.mode === 'during') {
3249
+ parts.push(t('conditions.comparedNoSample'));
3250
+ } else {
3251
+ parts.push(t('conditions.comparedNoValue'));
3252
+ }
3253
+ });
3254
+ }
3255
+ return h('li', {}, ...parts);
3256
+ });
2706
3257
  return h(
2707
3258
  'div',
2708
3259
  {},
2709
3260
  h('h4', { text: t('conditions.heading') }),
2710
- h(
2711
- 'ul',
2712
- { 'data-testid': 'failed-conditions' },
2713
- ...f.conditions.map((c) => {
2714
- const what = `${c.variable ?? '?'} ${c.compare ?? ''}`.trim();
2715
- let got;
2716
- if (c.valueText !== null)
2717
- got =
2718
- t('conditions.was', { value: c.valueText }) +
2719
- (c.sampleMs !== null ? t('conditions.sampleOf', { at: fmtMs(c.sampleMs) }) : '');
2720
- else if (c.mode === 'during') got = t('conditions.noSample');
2721
- else got = t('conditions.noValue');
2722
- return h('li', {}, h('code', { text: what }), `: ${got}`);
2723
- }),
2724
- ),
3261
+ h('ul', { 'data-testid': 'failed-conditions' }, ...items),
3262
+ anyRounded
3263
+ ? h('p', {
3264
+ class: 'note small',
3265
+ 'data-testid': 'conditions-rounded-note',
3266
+ text: t('conditions.rounded', { max: Number.MAX_SAFE_INTEGER }),
3267
+ })
3268
+ : null,
2725
3269
  );
2726
3270
  }
2727
3271
 
@@ -2821,6 +3365,16 @@ tr.selected td {
2821
3365
  ? t('step.expectSkipped', { why: st.expect_skipped })
2822
3366
  : '');
2823
3367
  const canShow = isNum(st.start_ms);
3368
+ const stFile = nonEmptyString(st.file);
3369
+ const stLine = isNum(st.line) ? String(st.line) : '';
3370
+ const lineCell =
3371
+ stFile && stFile !== m.tl.scenario.file
3372
+ ? stLine
3373
+ ? `${stFile}:${stLine}`
3374
+ : stFile
3375
+ : stLine;
3376
+ const stName = nonEmptyString(st.name);
3377
+ const stFrames = callStackFrames(st.call_stack, m.tl.scenario.file);
2824
3378
  return h(
2825
3379
  'tr',
2826
3380
  {
@@ -2843,7 +3397,7 @@ tr.selected td {
2843
3397
  })
2844
3398
  : `#${st.index}`,
2845
3399
  ),
2846
- h('td', { text: String(st.line ?? '') }),
3400
+ h('td', { text: lineCell }),
2847
3401
  h('td', { text: String(st.kind) }),
2848
3402
  h(
2849
3403
  'td',
@@ -2857,7 +3411,18 @@ tr.selected td {
2857
3411
  h('td', { class: 'num', text: fmtMs(st.start_ms) }),
2858
3412
  h('td', { class: 'num', text: fmtMs(st.at_ms) }),
2859
3413
  h('td', { class: 'num', text: fmtMs(st.end_ms) }),
2860
- h('td', { text: String(st.text ?? '') }),
3414
+ h(
3415
+ 'td',
3416
+ {},
3417
+ stName ? h('strong', { text: `${stName} · ` }) : null,
3418
+ String(st.text ?? ''),
3419
+ stFrames.length
3420
+ ? h('div', {
3421
+ class: 'muted small',
3422
+ text: `${t('failure.calledFrom')} ${stFrames.join(' → ')}`,
3423
+ })
3424
+ : null,
3425
+ ),
2861
3426
  h('td', { text: result }),
2862
3427
  );
2863
3428
  });
@@ -2882,16 +3447,20 @@ tr.selected td {
2882
3447
  h('td', { text: String(l.text ?? '') }),
2883
3448
  ),
2884
3449
  );
2885
- const findingRows = m.findings.map((x) =>
2886
- h(
3450
+ const findingRows = m.findings.map((x) => {
3451
+ const fFile = nonEmptyString(x.file);
3452
+ const fLine = x.line === null || x.line === undefined ? '' : String(x.line);
3453
+ const fWhere =
3454
+ fFile && fFile !== m.tl.scenario.file ? (fLine ? `${fFile}:${fLine}` : fFile) : fLine;
3455
+ return h(
2887
3456
  'tr',
2888
3457
  {},
2889
3458
  h('td', { text: String(x.severity ?? '') }),
2890
3459
  h('td', {}, h('code', { text: String(x.code) })),
2891
- h('td', { text: x.line === null || x.line === undefined ? '' : String(x.line) }),
3460
+ h('td', { text: fWhere }),
2892
3461
  h('td', { text: String(x.message ?? t('finding.codeOnly')) }),
2893
- ),
2894
- );
3462
+ );
3463
+ });
2895
3464
  const table = (caption, heads, rows, testid) =>
2896
3465
  h(
2897
3466
  'details',
@@ -3148,7 +3717,8 @@ tr.selected td {
3148
3717
  ? st.watch.to_ms
3149
3718
  : null;
3150
3719
  if ((limit ?? end) < scale.t0 || start > scale.t1) continue;
3151
- const label = `#${st.index} ${st.kind}`;
3720
+ const stName = nonEmptyString(st.name);
3721
+ const label = stName ? `#${st.index} ${stName}` : `#${st.index} ${st.kind}`;
3152
3722
  const labelWidth = label.length * 6.6 + 12;
3153
3723
  const xs = Math.max(0, scale.x(start));
3154
3724
  const xe = Math.min(scale.width, scale.x(limit ?? end));
@@ -3224,20 +3794,19 @@ tr.selected td {
3224
3794
  g,
3225
3795
  );
3226
3796
  }
3797
+ const stName = nonEmptyString(it.st.name);
3798
+ const stFrames = callStackFrames(it.st.call_stack, m.tl.scenario.file);
3227
3799
  const lines = [
3228
- t('step.title', {
3229
- index: it.st.index,
3230
- kind: it.st.kind,
3231
- line: it.st.line,
3232
- status: statusWord(it.st.status),
3233
- }),
3800
+ stepTitle(it.st, m.tl.scenario.file),
3801
+ stName,
3234
3802
  String(it.st.text ?? ''),
3803
+ ...stFrames.map((fr) => `${t('failure.calledFrom')} ${fr}`),
3235
3804
  t('step.times', {
3236
3805
  start: fmtMs(it.st.start_ms),
3237
3806
  decided: fmtMs(it.st.at_ms),
3238
3807
  end: fmtMs(it.st.end_ms),
3239
3808
  }),
3240
- ];
3809
+ ].filter((x) => x !== null && x !== '');
3241
3810
  if (it.st.message) lines.push(it.st.message);
3242
3811
  if (typeof it.st.expect_skipped === 'string')
3243
3812
  lines.push(t('step.expectSkipped', { why: it.st.expect_skipped }));
@@ -3437,14 +4006,7 @@ tr.selected td {
3437
4006
  if (!isNum(l.from_ms)) continue;
3438
4007
  const known = knows(KNOWN.lineKind, l.kind);
3439
4008
  const x0 = scale.x(l.from_ms);
3440
- const text = t('line.title', {
3441
- text: l.text ?? l.kind,
3442
- where:
3443
- l.step === null || l.step === undefined
3444
- ? t('line.inputs')
3445
- : t('line.step', { step: l.step }),
3446
- line: l.line,
3447
- });
4009
+ const text = lineTitle(l, m.tl.scenario.file);
3448
4010
  const g = tooltip(
3449
4011
  s('g', { class: `line-mark line-${known ? l.kind : 'unknown'}` }, svg),
3450
4012
  text,
@@ -3636,36 +4198,83 @@ tr.selected td {
3636
4198
  function drawBandsNumber(svg, v, scale, y, area, lo, hi) {
3637
4199
  const clampY = (val) => y(Math.min(hi, Math.max(lo, val)));
3638
4200
  for (const b of v.bands) {
3639
- if (b.to < scale.t0 || b.from > scale.t1) continue;
4201
+ const bandEnd = b.limit !== null ? Math.max(b.to, b.limit) : b.to;
4202
+ if (bandEnd < scale.t0 || b.from > scale.t1) continue;
3640
4203
  const x0 = scale.x(b.from);
3641
4204
  const x1 = Math.max(scale.x(b.to), x0 + 3);
3642
4205
  const g = tooltip(s('g', { class: `band ${bandClass(b)}` }, svg), bandTitle(b, v.info));
3643
- for (const c of b.compare) {
3644
- if (!isNum(c.value)) continue;
3645
- let top;
3646
- let bottom;
3647
- if (c.op === 'ge' || c.op === 'gt') [top, bottom] = [area.y0, clampY(c.value)];
3648
- else if (c.op === 'le' || c.op === 'lt') [top, bottom] = [clampY(c.value), area.y1];
3649
- else if (c.op === 'near' && isNum(c.tolerance))
3650
- [top, bottom] = [clampY(c.value + c.tolerance), clampY(c.value - c.tolerance)];
3651
- else if (c.op === 'eq') [top, bottom] = [clampY(c.value) - 2, clampY(c.value) + 2];
3652
- if (top !== undefined)
4206
+ const slices = Array.isArray(b.slices) ? b.slices : [];
4207
+ for (const sl of slices) {
4208
+ if (sl.discrete || sl.to < scale.t0 || sl.from > scale.t1) continue;
4209
+ const sx0 = scale.x(sl.from);
4210
+ const minW = sl.to === sl.from || slices.length === 1 ? 3 : 0.5;
4211
+ const sx1 = Math.max(scale.x(sl.to), sx0 + minW);
4212
+ const target = b.dynamic
4213
+ ? tooltip(
4214
+ s('g', { class: 'band-slice' }, g),
4215
+ t('band.sliceRange', {
4216
+ compare: compareText(sl.resolved, v.info),
4217
+ from: fmtMs(sl.from),
4218
+ to: fmtMs(sl.to),
4219
+ }),
4220
+ )
4221
+ : g;
4222
+ if (sl.hasBound) {
4223
+ let top;
4224
+ let bottom;
4225
+ if (sl.lo === sl.hi) {
4226
+ const cy = clampY(sl.lo);
4227
+ [top, bottom] = [cy - 2, cy + 2];
4228
+ } else {
4229
+ top = sl.hi === Infinity ? area.y0 : clampY(sl.hi);
4230
+ bottom = sl.lo === -Infinity ? area.y1 : clampY(sl.lo);
4231
+ }
3653
4232
  s(
3654
4233
  'rect',
3655
- { class: 'allowed', x: x0, y: top, width: x1 - x0, height: Math.max(2, bottom - top) },
3656
- g,
4234
+ {
4235
+ class: 'allowed',
4236
+ x: sx0,
4237
+ y: top,
4238
+ width: sx1 - sx0,
4239
+ height: Math.max(2, bottom - top),
4240
+ },
4241
+ target,
3657
4242
  );
3658
- const ty = clampY(c.value);
3659
- s(
3660
- 'line',
3661
- { class: `threshold${c.op === 'ne' ? ' ne' : ''}`, x1: x0, x2: x1, y1: ty, y2: ty },
3662
- g,
3663
- );
4243
+ }
4244
+ const drawn = new Set();
4245
+ const drawLine = (val, ne) => {
4246
+ const key = `${ne ? 'ne' : 'th'}:${val}`;
4247
+ if (drawn.has(key)) return;
4248
+ drawn.add(key);
4249
+ const ty = clampY(val);
4250
+ s(
4251
+ 'line',
4252
+ { class: `threshold${ne ? ' ne' : ''}`, x1: sx0, x2: sx1, y1: ty, y2: ty },
4253
+ target,
4254
+ );
4255
+ };
4256
+ for (const r of sl.resolved) {
4257
+ if (!isNum(r.value)) continue;
4258
+ if (r.op === 'ne') drawLine(r.value, true);
4259
+ else if (r.op === 'eq') drawLine(r.value, false);
4260
+ else if (r.op === 'near') {
4261
+ if (r.value >= sl.lo && r.value <= sl.hi) drawLine(r.value, false);
4262
+ } else if (r.op === 'ge' || r.op === 'gt') {
4263
+ if (r.value === sl.lo) drawLine(sl.lo, false);
4264
+ } else if (r.op === 'le' || r.op === 'lt') {
4265
+ if (r.value === sl.hi) drawLine(sl.hi, false);
4266
+ }
4267
+ }
3664
4268
  }
3665
4269
  if (b.limit !== null && b.limit > b.to) {
3666
4270
  const xl = scale.x(b.limit);
3667
- const ty = isNum(b.compare[0] && b.compare[0].value) ? clampY(b.compare[0].value) : area.y0;
3668
- s('line', { class: 'threshold limit', x1: x1, x2: xl, y1: ty, y2: ty }, g);
4271
+ const limitVal = isNum(b.limitValue)
4272
+ ? b.limitValue
4273
+ : isNum(b.compare[0] && b.compare[0].value)
4274
+ ? b.compare[0].value
4275
+ : null;
4276
+ const ty = limitVal !== null ? clampY(limitVal) : (area.y0 + area.y1) / 2;
4277
+ s('line', { class: 'threshold limit', x1, x2: xl, y1: ty, y2: ty }, g);
3669
4278
  }
3670
4279
  }
3671
4280
  }
@@ -3673,23 +4282,59 @@ tr.selected td {
3673
4282
  function drawBandsState(svg, v, scale, area, info) {
3674
4283
  for (const b of v.bands) {
3675
4284
  if (b.to < scale.t0 || b.from > scale.t1) continue;
3676
- const x0 = scale.x(b.from);
3677
- const x1 = Math.max(scale.x(b.to), x0 + 3);
3678
4285
  const g = tooltip(s('g', { class: `band ${bandClass(b)}` }, svg), bandTitle(b, info));
3679
- s(
3680
- 'rect',
3681
- {
3682
- class: 'expect-box',
3683
- x: x0,
3684
- y: area.y0 - 2,
3685
- width: x1 - x0,
3686
- height: area.y1 - area.y0 + 4,
3687
- },
3688
- g,
3689
- );
3690
- const text = t('band.expect', { compare: compareText(b.compare, info) });
3691
- if (x1 - x0 > text.length * 6 + 4)
3692
- s('text', { class: 'expect-label', x: x0 + 3, y: area.y1 - 1, text }, g);
4286
+ const slices = Array.isArray(b.slices) ? b.slices : [];
4287
+ if (!b.dynamic) {
4288
+ if (!slices.length) continue;
4289
+ const x0 = scale.x(b.from);
4290
+ const x1 = Math.max(scale.x(b.to), x0 + 3);
4291
+ s(
4292
+ 'rect',
4293
+ {
4294
+ class: 'expect-box',
4295
+ x: x0,
4296
+ y: area.y0 - 2,
4297
+ width: x1 - x0,
4298
+ height: area.y1 - area.y0 + 4,
4299
+ },
4300
+ g,
4301
+ );
4302
+ const text = t('band.expect', { compare: compareText(b.compare, info) });
4303
+ if (x1 - x0 > text.length * 6 + 4)
4304
+ s('text', { class: 'expect-label', x: x0 + 3, y: area.y1 - 1, text }, g);
4305
+ continue;
4306
+ }
4307
+ for (const sl of slices) {
4308
+ if (sl.to < scale.t0 || sl.from > scale.t1) continue;
4309
+ const sx0 = scale.x(sl.from);
4310
+ const minW = sl.to === sl.from || slices.length === 1 ? 3 : 1;
4311
+ const sx1 = Math.max(scale.x(sl.to), sx0 + minW);
4312
+ const resolvedText = compareText(sl.resolved, info);
4313
+ const sg = tooltip(
4314
+ s('g', { class: 'band-slice' }, g),
4315
+ t('band.sliceRange', {
4316
+ compare: resolvedText,
4317
+ from: fmtMs(sl.from),
4318
+ to: fmtMs(sl.to),
4319
+ }),
4320
+ );
4321
+ s(
4322
+ 'rect',
4323
+ {
4324
+ class: 'expect-box dynamic',
4325
+ x: sx0,
4326
+ y: area.y0 - 2,
4327
+ width: sx1 - sx0,
4328
+ height: area.y1 - area.y0 + 4,
4329
+ },
4330
+ sg,
4331
+ );
4332
+ const label = t('band.expect', { compare: resolvedText });
4333
+ if (sx1 - sx0 > label.length * 6 + 4)
4334
+ s('text', { class: 'expect-label', x: sx0 + 3, y: area.y1 - 1, text: label }, sg);
4335
+ else if (sx1 - sx0 > resolvedText.length * 6 + 4)
4336
+ s('text', { class: 'expect-label', x: sx0 + 3, y: area.y1 - 1, text: resolvedText }, sg);
4337
+ }
3693
4338
  }
3694
4339
  }
3695
4340
 
@@ -3718,6 +4363,30 @@ tr.selected td {
3718
4363
  },
3719
4364
  g,
3720
4365
  );
4366
+ } else if (mk.kind === 'compared') {
4367
+ const g = tooltip(
4368
+ s('g', { class: 'mark bad compared' }, svg),
4369
+ mk.text === null
4370
+ ? t('mark.comparedNoValueAt', { at: fmtMs(mk.at), variable: mk.against ?? '?' })
4371
+ : t('mark.comparedWas', {
4372
+ value: mk.text,
4373
+ at: fmtMs(mk.at),
4374
+ variable: mk.against ?? '?',
4375
+ }),
4376
+ );
4377
+ s('path', { d: `M${x} ${cy - 6} l6 6 l-6 6 l-6 -6 z` }, g);
4378
+ const label = mk.text === null ? t('mark.noValue') : mk.text;
4379
+ const left = x + label.length * 6.5 + 10 > scale.width;
4380
+ s(
4381
+ 'text',
4382
+ {
4383
+ x: left ? x - 9 : x + 9,
4384
+ y: Math.max(area.y0 + 10, cy - 4),
4385
+ 'text-anchor': left ? 'end' : 'start',
4386
+ text: label,
4387
+ },
4388
+ g,
4389
+ );
3721
4390
  } else {
3722
4391
  const cls = mk.applied === true ? 'ok' : mk.applied === false ? 'bad' : 'warn';
3723
4392
  const word =
@@ -3847,12 +4516,9 @@ tr.selected td {
3847
4516
  panel.hidden = !step;
3848
4517
  if (!step || panel.dataset.step === String(step.index)) return;
3849
4518
  panel.dataset.step = String(step.index);
3850
- const title = t('step.title', {
3851
- index: step.index,
3852
- kind: step.kind,
3853
- line: step.line,
3854
- status: statusWord(step.status),
3855
- });
4519
+ const title = stepTitle(step, m.tl.scenario.file);
4520
+ const stepName = nonEmptyString(step.name);
4521
+ const frames = callStackFrames(step.call_stack, m.tl.scenario.file);
3856
4522
  const timings = t('step.times', {
3857
4523
  start: fmtMs(step.start_ms),
3858
4524
  decided: fmtMs(step.at_ms),
@@ -3870,33 +4536,45 @@ tr.selected td {
3870
4536
  };
3871
4537
  const mode = Object.hasOwn(modes, watch?.mode) ? modes[watch.mode] : null;
3872
4538
  panel.replaceChildren(
3873
- h(
3874
- 'div',
3875
- { class: 'detail-heading' },
3876
- h('strong', { text: title }),
3877
- h('span', { class: 'muted', text: timings }),
3878
- ),
3879
- conditions.length
3880
- ? h(
3881
- 'div',
3882
- {},
3883
- mode
3884
- ? h('div', { text: t(mode, { from: fmtMs(watch.from_ms), to: fmtMs(watch.to_ms) }) })
3885
- : null,
3886
- h(
3887
- 'ul',
4539
+ ...[
4540
+ h(
4541
+ 'div',
4542
+ { class: 'detail-heading' },
4543
+ h('strong', { text: title }),
4544
+ stepName ? h('span', { text: stepName }) : null,
4545
+ h('span', { class: 'muted', text: timings }),
4546
+ ),
4547
+ frames.length
4548
+ ? h(
4549
+ 'div',
4550
+ { class: 'muted small', 'data-testid': 'step-call-stack' },
4551
+ `${t('failure.calledFrom')} ${frames.join(' → ')}`,
4552
+ )
4553
+ : null,
4554
+ conditions.length
4555
+ ? h(
4556
+ 'div',
3888
4557
  {},
3889
- conditions.map((c) =>
3890
- h(
3891
- 'li',
3892
- {},
3893
- h('code', { text: c.variable }),
3894
- ` ${compareText(c.compare, m.byName.get(c.variable)?.info)}`,
4558
+ mode
4559
+ ? h('div', {
4560
+ text: t(mode, { from: fmtMs(watch.from_ms), to: fmtMs(watch.to_ms) }),
4561
+ })
4562
+ : null,
4563
+ h(
4564
+ 'ul',
4565
+ {},
4566
+ conditions.map((c) =>
4567
+ h(
4568
+ 'li',
4569
+ {},
4570
+ h('code', { text: c.variable }),
4571
+ ` ${compareText(c.compare, m.byName.get(c.variable)?.info)}`,
4572
+ ),
3895
4573
  ),
3896
4574
  ),
3897
- ),
3898
- )
3899
- : h('div', { text: step.text ?? '' }),
4575
+ )
4576
+ : h('div', { text: step.text ?? '' }),
4577
+ ].filter(Boolean),
3900
4578
  );
3901
4579
  panel.scrollTop = 0;
3902
4580
  }