screw-bugs 0.1.8 → 0.1.10

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.
Files changed (107) hide show
  1. package/README.md +49 -34
  2. package/dist/browser-playwright/capture.js +1 -1
  3. package/dist/browser-playwright/launch.js +27 -10
  4. package/dist/browser-playwright/page.d.ts +48 -26
  5. package/dist/browser-playwright/page.js +86 -89
  6. package/dist/browser-playwright/recorder.d.ts +154 -0
  7. package/dist/browser-playwright/recorder.js +382 -0
  8. package/dist/build-info.json +3 -3
  9. package/dist/cli/app.js +6 -2
  10. package/dist/cli/commands.js +4 -3
  11. package/dist/cli/doctor.d.ts +17 -2
  12. package/dist/cli/doctor.js +62 -4
  13. package/dist/cli/mcp.js +2 -2
  14. package/dist/cli/report-server.d.ts +19 -10
  15. package/dist/cli/report-server.js +43 -18
  16. package/dist/cli/share.js +2 -2
  17. package/dist/cli/sign-in.d.ts +9 -3
  18. package/dist/cli/sign-in.js +12 -9
  19. package/dist/cli/tailnet.d.ts +57 -0
  20. package/dist/cli/tailnet.js +82 -0
  21. package/dist/core/index.d.ts +1 -14
  22. package/dist/core/index.js +3 -14
  23. package/dist/report/index.d.ts +1 -10
  24. package/dist/report/index.js +3 -10
  25. package/dist/schema/index.d.ts +1 -9
  26. package/dist/schema/index.js +3 -9
  27. package/package.json +14 -14
  28. package/dist/core/accounts.d.ts +0 -40
  29. package/dist/core/accounts.js +0 -95
  30. package/dist/core/css.d.ts +0 -95
  31. package/dist/core/css.js +0 -436
  32. package/dist/core/engine.d.ts +0 -75
  33. package/dist/core/engine.js +0 -554
  34. package/dist/core/errors.d.ts +0 -85
  35. package/dist/core/errors.js +0 -36
  36. package/dist/core/evidence.d.ts +0 -14
  37. package/dist/core/evidence.js +0 -131
  38. package/dist/core/labels.d.ts +0 -47
  39. package/dist/core/labels.js +0 -199
  40. package/dist/core/liveness.d.ts +0 -45
  41. package/dist/core/liveness.js +0 -66
  42. package/dist/core/marks.d.ts +0 -63
  43. package/dist/core/marks.js +0 -410
  44. package/dist/core/services.d.ts +0 -574
  45. package/dist/core/services.js +0 -25
  46. package/dist/core/share.d.ts +0 -68
  47. package/dist/core/share.js +0 -318
  48. package/dist/core/steps.d.ts +0 -106
  49. package/dist/core/steps.js +0 -722
  50. package/dist/core/uploads.d.ts +0 -49
  51. package/dist/core/uploads.js +0 -133
  52. package/dist/core/video.d.ts +0 -47
  53. package/dist/core/video.js +0 -233
  54. package/dist/core/viewport.d.ts +0 -28
  55. package/dist/core/viewport.js +0 -50
  56. package/dist/report/assets.d.ts +0 -34
  57. package/dist/report/assets.js +0 -105
  58. package/dist/report/bug.d.ts +0 -11
  59. package/dist/report/bug.js +0 -20
  60. package/dist/report/html.d.ts +0 -47
  61. package/dist/report/html.js +0 -923
  62. package/dist/report/icons.d.ts +0 -51
  63. package/dist/report/icons.js +0 -93
  64. package/dist/report/live.d.ts +0 -7
  65. package/dist/report/live.js +0 -135
  66. package/dist/report/logos.d.ts +0 -4
  67. package/dist/report/logos.js +0 -19
  68. package/dist/report/markup.d.ts +0 -50
  69. package/dist/report/markup.js +0 -156
  70. package/dist/report/menu-bar.d.ts +0 -60
  71. package/dist/report/menu-bar.js +0 -157
  72. package/dist/report/player.d.ts +0 -102
  73. package/dist/report/player.js +0 -315
  74. package/dist/report/pr-summary.d.ts +0 -11
  75. package/dist/report/pr-summary.js +0 -119
  76. package/dist/report/sha256.d.ts +0 -9
  77. package/dist/report/sha256.js +0 -97
  78. package/dist/report/share-page.d.ts +0 -48
  79. package/dist/report/share-page.js +0 -291
  80. package/dist/report/shots.d.ts +0 -59
  81. package/dist/report/shots.js +0 -280
  82. package/dist/report/sign-in.d.ts +0 -41
  83. package/dist/report/sign-in.js +0 -568
  84. package/dist/report/styles.d.ts +0 -3
  85. package/dist/report/styles.js +0 -274
  86. package/dist/report/view.d.ts +0 -296
  87. package/dist/report/view.js +0 -702
  88. package/dist/report/walkthrough.d.ts +0 -93
  89. package/dist/report/walkthrough.js +0 -716
  90. package/dist/schema/accounts.d.ts +0 -137
  91. package/dist/schema/accounts.js +0 -121
  92. package/dist/schema/config.d.ts +0 -7
  93. package/dist/schema/config.js +0 -6
  94. package/dist/schema/doctor.d.ts +0 -46
  95. package/dist/schema/doctor.js +0 -30
  96. package/dist/schema/evidence.d.ts +0 -1115
  97. package/dist/schema/evidence.js +0 -565
  98. package/dist/schema/findings.d.ts +0 -161
  99. package/dist/schema/findings.js +0 -82
  100. package/dist/schema/job.d.ts +0 -1905
  101. package/dist/schema/job.js +0 -577
  102. package/dist/schema/ledger.d.ts +0 -1124
  103. package/dist/schema/ledger.js +0 -285
  104. package/dist/schema/share.d.ts +0 -55
  105. package/dist/schema/share.js +0 -64
  106. package/dist/schema/status.d.ts +0 -7
  107. package/dist/schema/status.js +0 -11
@@ -1,923 +0,0 @@
1
- import { Layer } from 'effect';
2
- import { ReportRenderer, SESSION_NOTE } from '../core/index.js';
3
- import { isWebUrl, judgedLedger, runFiles, } from '../schema/index.js';
4
- import { assetsOf, contentPolicy } from './assets.js';
5
- import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, textParts, webFonts, } from './markup.js';
6
- import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, videoFixPrompt, } from './player.js';
7
- import { CHROME_LOGO } from './logos.js';
8
- import { renderLivePage } from './live.js';
9
- import { topBar } from './menu-bar.js';
10
- import { cspHash } from './sha256.js';
11
- import { cardShot, viewerShot } from './shots.js';
12
- import { styles } from './styles.js';
13
- import { cardShots, caseShots, caseSpans, caseViews, checksNote, countsOf, countWords, browserWords, deviceWords, durationOf, evaluationOf, formatBytes, formatClock, formatTime, formatTimecode, fragmentSeconds, idleStretches, reportHeading, runMs, severityLabel, statusLabel, statuses, stepParts, uploadNotes, urlAt, urlTimeline, verdictOf, waitNote, } from './view.js';
14
- import { renderWalkthrough } from './walkthrough.js';
15
- /*
16
- * The report: one page, one player. At the top, the run in a line and what was asked; then the
17
- * player on one side and, on the other, the evaluation and one card per case. Scrolling the cases
18
- * drives the player: the case at the reading line is the current one, and the player plays it (in
19
- * a loop, unless the reader turns that off). Statuses come from the ledger, except that the agent's
20
- * write-up may mark a case failed (`judgedCase`), which the card labels as the agent's verdict
21
- * beside the code's result; the write-up fills its own slots and is labelled as its own.
22
- */
23
- /**
24
- * The page's one script, allowed by its hash in the Content Security Policy. On top of the shared
25
- * player (see `PLAYER_JS`): the player's column learns where its top is (`--rp-top`) as the page
26
- * scrolls, resizes or its heading changes, so the player, its controls and the case playing now
27
- * fit on screen together wherever they are; the case at the reading line (30% down the view under the sticky top
28
- * bar, or just under the pinned player and its fade on a narrow screen) becomes current as the reader scrolls, and the player jumps to it and loops it
29
- * (a case with no video to play stops the player, which says so in the video's place); a click
30
- * on a case, a scrubber segment or a case link makes that case current (scrolling it to the line,
31
- * with scroll detection held off for 700 ms meanwhile); with "Loop case" off the current case
32
- * follows the playhead. With "Skip inactive" on (as the walkthrough's, and remembered with it), it
33
- * jumps over the stretches where nothing happened (`idleStretches`) while it plays; a stretch that
34
- * runs past the end of the case being looped starts the case again instead. A timecode seeks the player there, playing on only when it was playing.
35
- * The status filters hide cards (a hidden current case hands over to the
36
- * first shown). Screenshots open in a modal viewer that steps through the case's shots (arrow
37
- * keys, Esc, focus back where it was). A screenshot that cannot load says so in its figure, as
38
- * before; errors can come before the script runs, so it also looks for images that already
39
- * failed. Without script: the video has its own controls, timecodes open the video at their time
40
- * and screenshots open the image.
41
- */
42
- export const REPORT_SCRIPT = `(()=>{${PLAYER_JS}
43
- const badImg=i=>{const f=i.closest('figure');if(!f||f.classList.contains('broken'))return;f.classList.add('broken');f.querySelectorAll('.unloaded').forEach(u=>u.removeAttribute('aria-hidden'))};
44
- const scan=()=>d.querySelectorAll('figure img').forEach(i=>{if(i.complete&&i.naturalWidth===0)badImg(i)});
45
- d.addEventListener('error',e=>{const t=e.target;if(t instanceof Element&&t.matches('figure img'))badImg(t)},true);
46
- addEventListener('load',scan);
47
- d.addEventListener('DOMContentLoaded',()=>{
48
- chrome();scan();
49
- const cards=[...d.querySelectorAll('.case[data-i]')],segs=[...d.querySelectorAll('.seg[data-case]')];
50
- const np=d.getElementById('rp-now'),loopB=d.getElementById('rp-loop'),skipB=d.getElementById('rp-skip'),dlg=d.getElementById('viewer');
51
- const idle=[...d.querySelectorAll('.idle[data-a]')].map(e=>({s:e.closest('.track').dataset.s,a:Number(e.dataset.a),b:Number(e.dataset.b)}));
52
- let skip=!!skipB;const sk='screw-bugs-skip';try{skip=skip&&localStorage.getItem(sk)!=='off'}catch(e){}if(skipB)skipB.setAttribute('aria-pressed',String(skip));
53
- const N=cards.length,dash=String.fromCharCode(8211);let cur=null,loop=true,lock=0,lastT=0,P=null,sr=0;
54
- const timed=c=>!!c&&c.dataset.t0!==undefined;
55
- const span=c=>[Number(c.dataset.t0),Number(c.dataset.t1)];
56
- const shown=()=>cards.filter(c=>!c.hidden);
57
- const line=()=>{const b=topEdge();if(matchMedia('(max-width: 900px)').matches){const s=d.querySelector('.rp-left');return s?s.getBoundingClientRect().bottom+24:b+120}return Math.round(b+(innerHeight-b)*0.3)};
58
- const playable=c=>timed(c)&&!!P&&P.has(c.dataset.s);
59
- const chip=c=>{if(!playable(c)||P.down()!==null)return '';const s=span(c);return (loop?'Looping ':'Playing ')+clock(s[0])+dash+clock(s[1])};
60
- const paintNow=()=>{
61
- if(!np||!cur)return;
62
- np.querySelector('.np-st').replaceChildren(cur.querySelector('.case-head .st').cloneNode(true));
63
- np.querySelector('.np-n').textContent=cur.dataset.i+' / '+N;
64
- np.querySelector('.np-title').textContent=cur.querySelector('.case-go').textContent;
65
- np.querySelector('.np-status').textContent=cur.dataset.label+': ';
66
- const ch=np.querySelector('.np-chip'),t=chip(cur);ch.querySelector('span').textContent=t||'No video';ch.classList.toggle('none',!t);
67
- };
68
- const toCard=c=>{lock=Date.now()+700;const y=c.getBoundingClientRect().top+scrollY-line()+2;scrollTo({top:Math.max(0,y),behavior:still()?'auto':'smooth'})};
69
- const setCurrent=(c,seek,scroll)=>{
70
- if(!c)return;
71
- if(c!==cur){if(cur){cur.classList.remove('on');cur.removeAttribute('aria-current')}cur=c;c.classList.add('on');c.setAttribute('aria-current','true');segs.forEach(x=>x.classList.toggle('on',x.dataset.case===c.dataset.id));paintNow()}
72
- if(seek&&P){if(playable(c)){const a=span(c)[0];lastT=a;P.load(c.dataset.s,a,P.playing())}else P.none()}
73
- if(scroll)toCard(c);
74
- };
75
- const caseAt=(s,t)=>{let f=null;for(const c of shown()){if(timed(c)&&c.dataset.s===s){const x=span(c);if(t>=x[0]&&t<x[1])f=c}}return f};
76
- const onScroll=()=>{
77
- if(Date.now()<lock)return;const vis=shown();if(!vis.length)return;
78
- const L=line();let pick=vis[0];for(const c of vis){if(c.getBoundingClientRect().top<=L)pick=c}
79
- const last=vis[vis.length-1];if(innerHeight+scrollY>=r.scrollHeight-2&&last.getBoundingClientRect().bottom<=innerHeight)pick=last;
80
- if(pick!==cur)setCurrent(pick,true,false);
81
- };
82
- const stk=d.querySelector('.rp-sticky'),head=d.querySelector('.rp-head');
83
- const fit=()=>{if(stk)stk.style.setProperty('--rp-top',Math.round(stk.getBoundingClientRect().top)+'px')};
84
- fit();addEventListener('resize',fit);addEventListener('load',fit);
85
- if(head&&window.ResizeObserver)new ResizeObserver(fit).observe(head);
86
- addEventListener('scroll',()=>{if(!sr)sr=requestAnimationFrame(()=>{sr=0;fit();onScroll()})},{passive:true});
87
- if(d.getElementById('rp-video'))P=player('rp',{
88
- broken:paintNow,fine:paintNow,
89
- tick:t=>{
90
- if(!cur||P.down()!==null||P.v.seeking)return;const s=P.cur();
91
- const lp=loop&&timed(cur)&&cur.dataset.s===s,x=lp?span(cur):null;
92
- if(lp&&!P.v.paused&&t>=x[1]-0.03&&lastT<x[1]){lastT=x[0];P.v.currentTime=x[0];return}
93
- if(skip&&!P.v.paused){const gap=idle.find(g=>g.s===s&&t>=g.a&&t<g.b-0.05);if(gap){let to=gap.b;if(lp&&lastT<x[1]&&to>=x[1]-0.03)to=x[0];lastT=to;P.v.currentTime=to;return}}
94
- if(!loop){const c=caseAt(s,t);if(c&&c!==cur)setCurrent(c,false,true)}
95
- lastT=t;
96
- },
97
- seek:t=>{lastT=t;const c=caseAt(P.cur(),t);if(c&&c!==cur)setCurrent(c,false,true)},
98
- ended:()=>{
99
- if(!cur)return false;
100
- if(loop&&timed(cur)&&cur.dataset.s===P.cur()){P.load(P.cur(),span(cur)[0],true);return true}
101
- if(!loop){const later=shown().find(c=>timed(c)&&Number(c.dataset.s)>Number(P.cur())&&P.has(c.dataset.s));if(later){setCurrent(later,false,true);P.load(later.dataset.s,span(later)[0],true);return true}}
102
- return false;
103
- },
104
- });
105
- if(loopB)loopB.addEventListener('click',()=>{loop=!loop;loopB.setAttribute('aria-pressed',String(loop));paintNow()});
106
- if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip));try{localStorage.setItem(sk,skip?'on':'off')}catch(e){}});
107
- const filter=f=>{
108
- d.querySelectorAll('[data-filter]').forEach(x=>x.setAttribute('aria-pressed',String(x.dataset.filter===f)));
109
- cards.forEach(c=>{c.hidden=!(f==='all'||c.dataset.status===f)});
110
- segs.forEach(x=>{const c=cards.find(k=>k.dataset.id===x.dataset.case);x.classList.toggle('off',!!c&&c.hidden)});
111
- if(cur&&cur.hidden)setCurrent(shown()[0],true,false);
112
- };
113
- d.querySelectorAll('[data-filter]').forEach(b=>b.addEventListener('click',()=>filter(b.dataset.filter)));
114
- d.querySelectorAll('.filters').forEach(f=>f.classList.add('live'));
115
- let vCase=null,vIdx=0,opener=null;
116
- const q=s=>dlg.querySelector(s);
117
- const list=c=>{const t=c&&c.querySelector('template.shots');return t?[...t.content.children]:[]};
118
- const showShot=()=>{
119
- const l=list(vCase),f=l[vIdx];if(!f)return;
120
- q('.v-body').replaceChildren(f.cloneNode(true));
121
- q('.v-st').replaceChildren(vCase.querySelector('.case-head .st').cloneNode(true));
122
- q('.v-title').textContent=vCase.querySelector('.case-go').textContent;
123
- q('.v-what').textContent=f.dataset.cap+(l.length>1?' ('+(vIdx+1)+' of '+l.length+')':'');
124
- q('.v-prev').disabled=vIdx===0;q('.v-next').disabled=vIdx>=l.length-1;scan();
125
- };
126
- if(dlg){
127
- q('.v-prev').addEventListener('click',()=>{if(vIdx>0){vIdx--;showShot()}});
128
- q('.v-next').addEventListener('click',()=>{if(vIdx<list(vCase).length-1){vIdx++;showShot()}});
129
- q('.v-close').addEventListener('click',()=>dlg.close());
130
- dlg.addEventListener('click',e=>{if(e.target===dlg)dlg.close()});
131
- dlg.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){e.preventDefault();q('.v-prev').click()}else if(e.key==='ArrowRight'){e.preventDefault();q('.v-next').click()}});
132
- dlg.addEventListener('close',()=>{q('.v-body').replaceChildren();if(opener&&opener.isConnected)opener.focus()});
133
- }
134
- d.addEventListener('click',e=>{
135
- const t=e.target;if(!(t instanceof Element))return;
136
- const tc=t.closest('a.tc[data-t]');
137
- if(tc){if(!P||!P.has(tc.dataset.s))return;e.preventDefault();const s=tc.dataset.s,at=Number(tc.dataset.t),c=caseAt(s,at)||tc.closest('.case')||(dlg&&dlg.open?vCase:null);if(dlg&&dlg.open)dlg.close();if(c)setCurrent(c,false,!tc.closest('.case'));lastT=at;P.load(s,at,P.playing());return}
138
- const go=t.closest('a[href^="#case-"]');
139
- if(go){const c=d.getElementById(go.getAttribute('href').slice(1));if(!c||!c.matches('.case[data-i]'))return;e.preventDefault();if(c.hidden)filter('all');toCard(c);setCurrent(c,true,false);return}
140
- const shot=t.closest('[data-shot]');
141
- if(shot&&dlg&&dlg.showModal){e.preventDefault();opener=shot;vCase=shot.closest('.case');vIdx=Number(shot.dataset.shot)||0;showShot();dlg.showModal();q('.v-close').focus();return}
142
- const c=t.closest('.case[data-i]');
143
- if(!c||t.closest('a,summary,details,input,label')||(t.closest('button')&&!t.closest('.case-go')))return;
144
- toCard(c);setCurrent(c,true,false);
145
- });
146
- const first=cards.find(c=>timed(c)&&(!P||P.has(c.dataset.s)))||cards[0];
147
- if(first){setCurrent(first,false,false);if(timed(first))lastT=span(first)[0]}
148
- });
149
- })();`;
150
- /** Built outside `html` so no formatter ever adds whitespace inside: the hash is of exact text. */
151
- const scriptTag = new Markup(`<script>${REPORT_SCRIPT}</script>`);
152
- /**
153
- * Images and video load from the run folder by relative path (`'self'`, and `file:` for a report
154
- * opened from disk); styles are inline, but for Google Fonts' stylesheet, whose fonts come from
155
- * its font host; the only script is {@link REPORT_SCRIPT}, by its hash. Nothing else loads from
156
- * the network. A report rendered with an asset base URL also allows images and media (only) from
157
- * its origin (`reportCsp`).
158
- */
159
- export const REPORT_CSP = contentPolicy(cspHash(REPORT_SCRIPT));
160
- /** The report's policy when its files load from `assetOrigin` (see `RenderOptions`). */
161
- export const reportCsp = (assetOrigin) => contentPolicy(cspHash(REPORT_SCRIPT), assetOrigin);
162
- const reportStyles = /* css */ `
163
- .rp { max-width: 1440px; margin: 0 auto; padding-bottom: 32px; }
164
- .rp-head { padding: 16px 32px 0; text-align: center; }
165
- .rp-head h1 { margin: 0; font: var(--t-title); letter-spacing: var(--ls-title); color: var(--text); overflow-wrap: anywhere; }
166
- .meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 20px; margin: 26px 0 0; padding: 0; list-style: none; font: var(--t-mono); color: var(--muted); }
167
- .meta li { display: inline-flex; align-items: center; gap: 6px; }
168
- .rp-head .prompt { margin-top: 19px; max-width: 394px; }
169
- .filters { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
170
- .filters button { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 16px 0 12px; border: 0; border-radius: 999px; background: var(--subtle); color: var(--text); font: var(--t-control); cursor: pointer; }
171
- .filters button.all { padding-left: 16px; }
172
- .filters button:hover { background: var(--subtle-hover); }
173
- .filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
174
- .filters button[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--text) 88%, var(--bg)); }
175
- .filters button[aria-pressed="true"] .st { box-shadow: 0 0 0 1.5px var(--bg); }
176
- .filters .st { width: 18px; height: 18px; }
177
- .filters .st svg { width: 12px; height: 12px; }
178
- .filters:not(.live) { display: none; }
179
- .alert { max-width: 760px; margin: 22px auto 0; padding: 12px 16px; border: 1px solid var(--fail); border-radius: 12px; background: var(--bg-2); color: var(--text); overflow-wrap: anywhere; }
180
- .alert strong { color: var(--fail-text); }
181
-
182
- .rp-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 430px); gap: 42px; align-items: start; padding: 78px 32px 0; }
183
- .rp-left { align-self: stretch; }
184
- /* The player, its controls and the case playing now fit on screen together wherever they are: a
185
- column no taller than the view below its top (\`--rp-top\`, set by the page's script as it
186
- scrolls; without script, where it sticks) less \`--fit-gap\`. Everything in it keeps its own
187
- height but the player, which shrinks to what is left; its window then fits that space, at the
188
- recording's shape (\`--win-h\` and \`--win-w\` are what the window adds around the screen).
189
- \`--win-cap\` is the widest the window may be; \`--player-cap\` the tallest the player may be. */
190
- /* Over the case segments, an inactive stretch dims the segment under it. */
191
- .rp-sticky .idle { background: color-mix(in srgb, var(--bg) 55%, transparent); pointer-events: none; }
192
- .rp-sticky { --stuck: calc(var(--bar) + 20px); --fit-gap: 20px; --win-cap: 100cqw; position: sticky; top: var(--stuck); display: flex; flex-direction: column; max-height: calc(100dvh - max(var(--rp-top, 0px), var(--stuck)) - var(--fit-gap)); container-type: inline-size; }
193
- .rp-sticky > * { flex: none; }
194
- .rp-sticky > .player { flex: 0 1 auto; min-height: 0; height: calc((var(--win-cap) - var(--win-w)) / var(--arw, 1.6) + var(--win-h)); max-height: var(--player-cap, none); container-type: size; }
195
- .rp-sticky > .player.broken { height: auto; container-type: normal; }
196
- .rp-sticky .window { width: min(var(--win-cap), calc((100cqh - var(--win-h)) * var(--arw, 1.6) + var(--win-w))); margin: 0 auto; }
197
- .rp-sticky .controls { width: 100%; }
198
- .device-mobile .rp-sticky { --win-cap: min(360px, 100cqw); }
199
- /* The cases column scrolls with the page (the current case follows the window's scroll). Where it
200
- goes under the top bar, and where it runs on past the bottom of the view, it fades out. Each fade
201
- is the column's own first or last \`--fade\` of space, kept empty and sticky: at rest it lies over
202
- nothing, so a fade shows only where content is cut off, in any browser. Clicks go through. */
203
- .rp-right { --fade: 32px; margin-top: calc(-1 * var(--fade)); }
204
- .rp-right::before, .rp-right::after { content: ""; display: block; position: sticky; z-index: 1; height: var(--fade); pointer-events: none; }
205
- .rp-right::before { top: var(--bar); background: linear-gradient(var(--bg), transparent); }
206
- .rp-right::after { bottom: 0; background: linear-gradient(transparent, var(--bg)); }
207
- .nowplaying { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
208
- .np-n { font: var(--t-mono); color: var(--muted); white-space: nowrap; }
209
- .np-title { flex: 1; min-width: 0; font: var(--t-heading-sm); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
210
- .np-chip { background: var(--accent-subtle); color: var(--text); }
211
- .np-chip.none svg { display: none; }
212
- .video-notes { margin: 12px 0 0; padding: 0; list-style: none; font: var(--t-control); color: var(--muted); }
213
- .video-notes li { margin: 4px 0; overflow-wrap: anywhere; }
214
-
215
- .eval { padding: 0 0 26px; }
216
- .eval .verdict { margin: 0; font: var(--t-lead); letter-spacing: var(--ls-lead); color: var(--text); overflow-wrap: anywhere; }
217
- .eval .counts { margin: 8px 0 0; font: var(--t-body-lg); color: var(--muted); }
218
- .eval .counts a { color: inherit; }
219
- .by { margin: 6px 0 0; font: var(--t-mono); color: var(--header); }
220
- .issues { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
221
- .issue { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 2px 10px; }
222
- .issue .st { width: 20px; height: 20px; margin-top: 1px; }
223
- .issue h3 { margin: 0; font: var(--t-heading-sm); color: var(--text); overflow-wrap: anywhere; }
224
- .issue p { grid-column: 2; margin: 2px 0 0; font: var(--t-body); color: var(--muted); overflow-wrap: anywhere; }
225
- .issue .sev { font: var(--t-mono); color: var(--header); }
226
- .issue .on-cases a { color: var(--muted); }
227
- .fix-first { display: flex; gap: 22px; align-items: baseline; margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); font: var(--t-body-tight); color: var(--text); }
228
- .fix-first .k { font: var(--t-small-strong); color: var(--muted); text-transform: uppercase; white-space: nowrap; }
229
- .fix-first span:last-child { overflow-wrap: anywhere; }
230
- .not-tested { margin: 18px 0 0; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 12px; font: var(--t-body); }
231
- .not-tested h3 { margin: 0 0 6px; font: var(--t-heading-sm); }
232
- .not-tested ul { margin: 0; padding-left: 18px; }
233
- .not-tested li { margin: 3px 0; overflow-wrap: anywhere; }
234
- .not-tested .why { color: var(--muted); }
235
-
236
- .cases { display: grid; gap: 12px; }
237
- .case { position: relative; padding: 16px 16px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-2); cursor: pointer; scroll-margin-top: 20px; transition: background-color var(--ease), border-color var(--ease); }
238
- .case:not(.on):hover { border-color: var(--border-strong); }
239
- .case.on { background: var(--accent-subtle); border-color: var(--accent-border); }
240
- .case-head { display: flex; align-items: center; gap: 12px; }
241
- .case-head h3 { flex: 1; min-width: 0; margin: 0; font: var(--t-card-title); color: var(--text); }
242
- .case-go { all: unset; cursor: pointer; overflow-wrap: anywhere; }
243
- .case-go:focus-visible { outline: 2px solid transparent; border-radius: 4px; box-shadow: var(--focus); }
244
- .case-head .st-label { margin-left: 6px; }
245
- .time { flex: none; }
246
- .case.on .time { background: var(--accent); color: var(--on-accent); font: var(--t-mono-strong); }
247
- .eq { display: none; gap: 2px; align-items: flex-end; height: 10px; }
248
- .case.on .eq { display: inline-flex; }
249
- .eq i { width: 2px; height: 100%; background: currentColor; animation: eq 0.9s ease-in-out infinite; }
250
- .eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
251
- @keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
252
- .eq i { transform-origin: bottom; }
253
- .agent-verdict { margin: 8px 0 0 34px; color: var(--st); font: var(--t-control); overflow-wrap: anywhere; }
254
- .agent-verdict .k { font: var(--t-small-strong); margin-right: 6px; }
255
- .agent-verdict .checked { display: block; margin-top: 2px; color: var(--muted); font: var(--t-small); }
256
- .reason { margin: 8px 0 0 34px; color: var(--st); font: var(--t-control); white-space: pre-wrap; overflow-wrap: anywhere; }
257
- .thumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 0 34px; }
258
- .thumb { margin: 0; width: 92px; }
259
- .thumb.large { width: auto; }
260
- /* A thumbnail whose image cannot load grows to say so in words. */
261
- .thumb.broken { width: 100%; }
262
- .thumb.broken .frame { width: 100%; }
263
- .thumb .frame { width: 92px; border-radius: 6px; box-shadow: 0 0 0 1px var(--border); background: var(--bg); }
264
- .thumb .frame:focus-visible { box-shadow: 0 0 0 1px var(--ring), 0 0 0 4px var(--ring-soft); }
265
- .thumbs.large { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
266
- .thumbs.large.one { grid-template-columns: minmax(0, 1fr); }
267
- .thumb.large .frame { width: 100%; }
268
- .thumb.role-actual .frame { box-shadow: 0 0 0 2px var(--fail); }
269
- .thumb.role-actual .frame:focus-visible { box-shadow: 0 0 0 2px var(--fail), 0 0 0 5px var(--ring-soft); }
270
- .thumb figcaption { margin-top: 6px; font: var(--t-small); color: var(--muted); }
271
- .thumb.role-actual figcaption { font: var(--t-small-strong); color: var(--fail-text); }
272
- .thumb.missing { font: var(--t-small); color: var(--muted); }
273
- .more-shots { display: inline-grid; place-items: center; min-width: 36px; height: 30px; padding: 0 10px; border-radius: 999px; background: var(--subtle); color: var(--muted); font: var(--t-small); text-align: center; text-decoration: none; }
274
- .more-shots:hover { background: var(--subtle-hover); color: var(--text); }
275
- .thumbs.large .more-shots { justify-self: start; }
276
- .case-more { margin: 12px 0 0 34px; font: var(--t-body); cursor: auto; }
277
- /* A collapsible: its chevron turns down when open. */
278
- .case-more summary { display: flex; align-items: center; gap: 4px; list-style: none; cursor: pointer; color: var(--muted); font: var(--t-control); width: fit-content; border-radius: 4px; }
279
- .case-more summary::-webkit-details-marker { display: none; }
280
- .case-more summary:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
281
- .case-more .chev { margin-left: -2px; transition: transform .2s ease; }
282
- .case-more[open] .chev { transform: rotate(90deg); }
283
- .case-more[open] summary { margin-bottom: 10px; }
284
- .case-id { margin: 0 0 8px; font: var(--t-small); color: var(--muted); }
285
- .success, .continued { margin: 0 0 10px; overflow-wrap: anywhere; }
286
- .success .k, .continued .k { color: var(--muted); }
287
- .video-problem { margin: 0 0 10px; color: var(--fail-text); }
288
- .steps { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
289
- .step { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 7px 10px; border-top: 1px solid var(--border); }
290
- .step:first-child { border-top: 0; }
291
- .step-n { font: var(--t-mono); color: var(--muted); text-align: right; }
292
- .step-text { overflow-wrap: anywhere; }
293
- .step-text code { padding: 1px 5px; border-radius: 4px; background: var(--subtle); }
294
- .step-text q.value { font-weight: 500; }
295
- .step-files { display: block; margin-top: 4px; font: var(--t-small); color: var(--muted); }
296
- .step-file { display: block; }
297
- .step-state { grid-column: 2 / -1; font: var(--t-small); color: var(--muted); }
298
- .step.st-not-run .step-text, .step.st-not-run .step-n { color: var(--muted); }
299
- .step.st-decided { background: var(--bg-2); box-shadow: inset 3px 0 0 var(--sc); }
300
- .step.st-decided .step-state { color: var(--st); font-weight: 500; }
301
- .tc { display: inline-block; font: var(--t-mono); padding-block: 2px; color: var(--text); background: var(--subtle); border-radius: 999px; padding: 0 8px; text-decoration: none; white-space: nowrap; }
302
- a.tc:hover { background: var(--accent); color: var(--on-accent); }
303
- .tc.off { background: none; color: var(--muted); }
304
- .writeup { margin: 14px 0 0; }
305
- .writeup h4 { margin: 12px 0 4px; font: var(--t-small-strong); }
306
- .writeup ul { margin: 0; padding-left: 18px; }
307
- .writeup li { margin-bottom: 3px; overflow-wrap: anywhere; }
308
- .moments { list-style: none; margin: 0; padding: 0; }
309
- .moments li { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; overflow-wrap: anywhere; }
310
- .observed { margin-top: 10px; padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; }
311
- .observed h4 { margin-top: 0; }
312
-
313
- .after { margin-top: 36px; display: grid; gap: 28px; font: var(--t-body); }
314
- .after h2 { margin: 0 0 10px; font: var(--t-card-title); }
315
- .next { margin: 0; padding-left: 20px; }
316
- .next li { margin: 5px 0; overflow-wrap: anywhere; }
317
- .details dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
318
- .details dt { color: var(--muted); }
319
- .details dd { margin: 0; overflow-wrap: anywhere; }
320
- .state-errored { color: var(--fail-text); font-weight: 500; }
321
- .details .file { font: var(--t-mono); }
322
- .details p { margin: 10px 0 0; color: var(--muted); }
323
- .foot { font: var(--t-small); color: var(--muted); }
324
- .foot p { margin: 4px 0; }
325
-
326
- .viewer { width: min(1100px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
327
- /* A dialog: it and its overlay fade and zoom in, as shadcn/ui's do. */
328
- .viewer[open] { display: flex; flex-direction: column; animation: viewer-in .15s ease-out; }
329
- .viewer::backdrop { background: var(--scrim); }
330
- .viewer[open]::backdrop { animation: scrim-in .15s ease-out; }
331
- @keyframes viewer-in { from { opacity: 0; transform: scale(.95); } }
332
- @keyframes scrim-in { from { opacity: 0; } }
333
- .v-body { flex: 1; min-height: 0; overflow: auto; background: var(--bg-2); }
334
- .v-body .vshot { margin: 0; }
335
- .v-body .frame { background: var(--bg-2); }
336
- .v-body figcaption { padding: 10px 16px; font: var(--t-control); color: var(--muted); }
337
- .v-body .cap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
338
- .v-body .shot-id, .v-body .file { font: var(--t-mono); color: var(--muted); }
339
- .v-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--border); background: var(--bg); }
340
- .v-cap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font: var(--t-body); }
341
- .v-what { color: var(--muted); }
342
- .v-bar button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--subtle); color: var(--text); cursor: pointer; }
343
- .v-bar button:hover { background: var(--subtle-hover); }
344
-
345
- @media (max-width: 900px) {
346
- .rp-head { padding: 20px 16px 0; }
347
- .rp-head h1 { font-size: 24px; line-height: 30px; }
348
- .filters button { height: 44px; }
349
- .rp-main { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 18px 0 0; }
350
- /* The player no wider than on a phone, centered: in a window wider than a phone, a full-width
351
- player would be pinned so tall that little room is left to read the cases under it. Its strip
352
- stays full width, so the cases still scroll out of sight under it. */
353
- .rp-sticky { max-width: 416px; margin: 0 auto; }
354
- /* The player is pinned under the top bar; the cases fade out under it instead. */
355
- .rp-left { position: sticky; top: var(--bar); z-index: 2; background: var(--bg); padding: 8px 12px 10px; }
356
- .rp-left::after { content: ""; position: absolute; top: 100%; left: 0; right: 0; height: var(--fade); background: linear-gradient(var(--bg), transparent); pointer-events: none; }
357
- .rp-main { --fade: 24px; }
358
- .rp-right { margin-top: 0; }
359
- .rp-right::before { position: static; background: none; }
360
- /* Pinned with its padding under the top bar, the player about two fifths of the view high. */
361
- .rp-sticky { position: static; --stuck: calc(var(--bar) + 8px); --fit-gap: 10px; --player-cap: calc(42vh - var(--bar) / 2 + var(--win-h)); }
362
- .device-mobile .rp-sticky { --win-cap: min(180px, 100cqw); --player-cap: calc(30vh - var(--bar) / 2 + var(--win-h)); }
363
- .rp-sticky .window { box-shadow: none; }
364
- .nowplaying { margin-top: 8px; padding: 8px 10px; }
365
- .nowplaying .np-chip { display: none; }
366
- .video-notes { display: none; }
367
- .rp-right { padding: 0 16px; }
368
- .reason, .agent-verdict, .thumbs, .case-more { margin-left: 0; }
369
- .play, .full { width: 44px; height: 44px; }
370
- .speed button { height: 38px; }
371
- }
372
- /* Between a small window and the two columns, the cases as wide as the player, so their lines do
373
- not run across the whole window; narrower windows give them all of their width. */
374
- @media (min-width: 641px) and (max-width: 900px) {
375
- .rp-right { max-width: 440px; margin: 0 auto; }
376
- }
377
- `;
378
- const caseAnchor = (id) => `case-${id}`;
379
- /** A timecode: a link that opens the video at that time, which the page's script turns into a
380
- * seek of the one player. The time is in the text either way. */
381
- const timecode = (sessions, session, ms, label) => {
382
- const src = sessions.get(session);
383
- const text = formatTimecode(ms);
384
- if (src === undefined)
385
- return html `<span class="tc off">${text}</span>`;
386
- const t = fragmentSeconds(ms);
387
- return html `<a
388
- class="tc"
389
- href="${`${src}#t=${t}`}"
390
- data-s="${String(session)}"
391
- data-t="${t}"
392
- aria-label="${`Play the video from ${text}${label ? `: ${label}` : ''}`}"
393
- >${text}</a
394
- >`;
395
- };
396
- const stepStateLabel = {
397
- done: '',
398
- decided: 'Decided the result',
399
- 'not-run': 'Not run',
400
- unknown: '',
401
- };
402
- /** The files an upload step sends: name, size once it ran, and what the job says each is. */
403
- const uploadFiles = (step) => {
404
- const files = uploadNotes(step.step, step.timing?.files);
405
- return files.length === 0
406
- ? ''
407
- : html `<span class="step-files"
408
- >${files.map((file) => html `<span class="step-file"
409
- ><code>${file.name}</code>${file.size !== undefined
410
- ? html ` <span class="note">${formatBytes(file.size)}</span>`
411
- : ''}${file.note !== undefined ? html ` <span class="note">(${file.note})</span>` : ''}${file.about !== undefined ? html `: ${file.about}` : ''}</span
412
- >`)}</span
413
- >`;
414
- };
415
- const stepRow = (view, step, sessions) => {
416
- const wait = waitNote(step.step, step.state === 'done' || step.state === 'decided');
417
- const decided = step.state === 'decided';
418
- return html `<li
419
- class="step st-${step.state}${decided ? ` s-${view.checkStatus}` : ''}"
420
- ${decided ? html ` aria-current="step"` : ''}
421
- >
422
- <span class="step-n">${step.index}</span>
423
- <span class="step-text"
424
- >${textParts(stepParts(step.step))}${step.implicit
425
- ? html ` <span class="note">(added: every case starts at the job URL)</span>`
426
- : ''}${wait !== undefined ? html ` <span class="note">(${wait})</span>` : ''}${uploadFiles(step)}</span
427
- >
428
- <span class="step-time"
429
- >${step.timing ? timecode(sessions, view.entry.session ?? 1, step.timing.startMs) : ''}</span
430
- >
431
- ${stepStateLabel[step.state] ? html `<span class="step-state">${stepStateLabel[step.state]}</span>` : ''}
432
- </li>`;
433
- };
434
- const list = (items) => items && items.length > 0
435
- ? html `<ul>
436
- ${items.map((item) => html `<li>${item}</li>`)}
437
- </ul>`
438
- : html `<p class="note">Nothing noted.</p>`;
439
- /** The agent's did / worked / didn't, key moments and unchecked observations for one case. */
440
- const caseWriteUp = (view, sessions) => {
441
- const written = view.findings;
442
- if (written === undefined)
443
- return '';
444
- const moments = written.keyMoments ?? [];
445
- const observed = written.observed ?? [];
446
- return html `<div class="writeup">
447
- <p class="by">The agent's write-up</p>
448
- <h4>What we did</h4>
449
- ${list(written.did)}
450
- <h4>What worked</h4>
451
- ${list(written.worked)}
452
- <h4>What didn't</h4>
453
- ${list(written.didnt)}
454
- ${moments.length > 0
455
- ? html `<h4>Key moments</h4>
456
- <ol class="moments">
457
- ${moments
458
- .toSorted((a, b) => a.ms - b.ms)
459
- .map((m) => html `<li>
460
- ${timecode(sessions, view.entry.session ?? 1, m.ms, m.label)}<span
461
- >${m.label}</span
462
- >
463
- </li>`)}
464
- </ol>`
465
- : ''}
466
- ${observed.length > 0
467
- ? html `<div class="observed">
468
- <h4>Observed, not checked by a step</h4>
469
- <ul>
470
- ${observed.map((o) => html `<li>${o}</li>`)}
471
- </ul>
472
- </div>`
473
- : ''}
474
- </div>`;
475
- };
476
- /* The meta row's icons and the now-playing chip's, from Lucide (see `icons.ts`). */
477
- const clockIcon = icon('timer', { size: 15 });
478
- const desktopIcon = icon('monitor', { size: 15 });
479
- const phoneIcon = icon('smartphone', { size: 15 });
480
- const loopIcon = icon('refresh-cw', { size: 14, strokeWidth: 2.25 });
481
- /** The meta row's browser: Chrome's logo and words for Chrome or Chromium, the words alone for
482
- * any other; nothing for a run that recorded no browser. */
483
- const browserItem = (bundle) => {
484
- const words = browserWords(bundle.browser);
485
- return words === undefined
486
- ? ''
487
- : html `<li>
488
- ${words.chromeLogo ? new Markup(CHROME_LOGO) : ''}<span class="sr">Browser: </span
489
- >${words.text}
490
- </li>`;
491
- };
492
- /** The time chip of a case: `0:05–0:12`, its playing marker, or nothing without times. */
493
- const timeChip = (span) => span === undefined
494
- ? ''
495
- : html `<span class="chip time"
496
- ><span class="eq" aria-hidden="true"><i></i><i></i><i></i></span
497
- ><span class="sr">Plays </span>${formatClock(span.startMs)}–${formatClock(span.endMs)}</span
498
- >`;
499
- /** One case: what it is, how it ended, its screenshots, and (folded) its steps and write-up. */
500
- const caseCard = (view, position, span, sessions, assets) => {
501
- const { entry } = view;
502
- const shots = caseShots(view);
503
- const { large, small, more } = cardShots(shots);
504
- const shown = [...large, ...small];
505
- const firstHidden = shots.findIndex((s) => !shown.includes(s));
506
- const hiddenFile = firstHidden >= 0 ? safeRelative(shots[firstHidden].shot.path) : undefined;
507
- const moreLink = more > 0 && firstHidden >= 0
508
- ? html `<a
509
- class="more-shots"
510
- href="${hiddenFile === undefined ? '#' : assets.url(hiddenFile)}"
511
- target="_blank"
512
- rel="noopener"
513
- data-shot="${String(firstHidden)}"
514
- aria-label="${`${more} more ${more === 1 ? 'screenshot' : 'screenshots'}`}"
515
- >+${more}</a
516
- >`
517
- : '';
518
- const thumbs = shown.map((s) => cardShot(view, s, shots.indexOf(s), large.includes(s), assets));
519
- const success = view.spec?.success?.trim();
520
- const session = entry.session ?? 1;
521
- const timed = span !== undefined && sessions.has(span.session);
522
- return html `<article
523
- class="case s-${entry.status}"
524
- id="${caseAnchor(entry.id)}"
525
- data-i="${String(position)}"
526
- data-id="${entry.id}"
527
- data-status="${entry.status}"
528
- data-label="${statusLabel[entry.status]}"
529
- ${timed
530
- ? html ` data-s="${String(span.session)}" data-t0="${fragmentSeconds(span.startMs)}"
531
- data-t1="${fragmentSeconds(span.endMs)}"`
532
- : ''}
533
- >
534
- <div class="case-head">
535
- ${statusIcon(entry.status)}
536
- <h3>
537
- <button type="button" class="case-go">${entry.title}</button
538
- ><span class="${entry.status === 'passed' ? 'sr' : 'st-label'}"
539
- ><span class="sr">: </span>${statusLabel[entry.status]}</span
540
- >
541
- </h3>
542
- ${timeChip(span)}
543
- </div>
544
- ${view.agentFailed !== undefined
545
- ? html `<p class="agent-verdict">
546
- <span class="k">Agent's verdict</span>${view.agentFailed}
547
- <span class="checked">${checksNote(view.checkStatus)}</span>
548
- </p>`
549
- : ''}
550
- ${entry.reason ? html `<p class="reason">${entry.reason}</p>` : ''}
551
- ${shown.length > 0
552
- ? html `<div
553
- class="${`thumbs${large.length > 0 ? ' large' : ''}${large.length === 1 ? ' one' : ''}`}"
554
- >
555
- ${thumbs} ${moreLink}
556
- </div>`
557
- : ''}
558
- <details class="case-more">
559
- <summary>${icon('chevron-right', { size: 14, className: 'chev' })}Steps and details</summary>
560
- <p class="case-id">
561
- <code>${entry.id}</code>${view.spec ? '' : html ` · no steps recorded for this case`}
562
- </p>
563
- ${view.video?.problem ? html `<p class="video-problem">Video missing or incomplete: ${view.video.problem}</p>` : ''}
564
- ${entry.continuedFrom === undefined
565
- ? ''
566
- : html `<p class="continued">
567
- <span class="k">Continued</span> from case
568
- <a href="#${caseAnchor(entry.continuedFrom)}"><code>${entry.continuedFrom}</code></a
569
- >, on the page it ended on
570
- </p>`}
571
- ${success ? html `<p class="success"><span class="k">Success looks like</span> ${success}</p>` : ''}
572
- ${view.steps.length > 0
573
- ? html `<ol class="steps">
574
- ${view.steps.map((step) => stepRow(view, step, sessions))}
575
- </ol>`
576
- : ''}
577
- ${caseWriteUp(view, sessions)}
578
- </details>
579
- <template class="shots"
580
- >${shots.map((s) => viewerShot(s, s.shot.shot?.atMs !== undefined ? timecode(sessions, session, s.shot.shot.atMs) : '', assets))}</template
581
- >
582
- </article>`;
583
- };
584
- /** The evaluation: the verdict, the counts, the issues to fix and the one to fix first. */
585
- const evaluationBlock = (bundle, views) => {
586
- const evaluation = evaluationOf(bundle);
587
- const byId = new Map(views.map((v) => [v.entry.id, v]));
588
- const notTested = bundle.findings?.notTested ?? [];
589
- return html `<section class="eval" aria-labelledby="eval-title">
590
- <h2 class="verdict" id="eval-title">${evaluation.verdict}</h2>
591
- <p class="counts">
592
- ${evaluation.counts}${notTested.length > 0 && !evaluation.byAgent
593
- ? html ` <a href="#not-tested">${notTested.length} not tested</a>`
594
- : ''}
595
- </p>
596
- <p class="by">
597
- ${evaluation.byAgent ? "Verdict and issues: the agent's write-up. " : ''}Statuses: decided by
598
- code in a real browser${agentFailedNote(views)}.
599
- </p>
600
- ${evaluation.issues.length > 0
601
- ? html `<ul class="issues">
602
- ${evaluation.issues.map((issue) => html `<li class="issue">
603
- ${statusIcon('failed')}
604
- <h3>${issue.title} <span class="sev">${severityLabel[issue.severity]}</span></h3>
605
- <p>${issue.why}</p>
606
- <p class="on-cases">
607
- ${issue.caseIds.flatMap((id) => {
608
- const view = byId.get(id);
609
- return view === undefined
610
- ? []
611
- : [
612
- html `<a href="${`#${caseAnchor(id)}`}">${view.entry.title}</a>
613
- <span class="sr">(${statusLabel[view.entry.status]})</span> `,
614
- ];
615
- })}
616
- </p>
617
- </li>`)}
618
- </ul>`
619
- : bundle.findings
620
- ? html `<p class="note">The agent listed nothing to fix.</p>`
621
- : ''}
622
- ${evaluation.fixFirst
623
- ? html `<p class="fix-first">
624
- <span class="k">Fix first</span><span>${evaluation.fixFirst.title}</span>
625
- </p>`
626
- : ''}
627
- ${notTested.length > 0
628
- ? html `<div class="not-tested" id="not-tested">
629
- <h3>Not tested</h3>
630
- <ul>
631
- ${notTested.map((item) => html `<li><strong>${item.what}</strong> <span class="why">${item.why}</span></li>`)}
632
- </ul>
633
- </div>`
634
- : ''}
635
- </section>`;
636
- };
637
- /** `; 2 marked failed by the agent's review`, when its findings mark any case failed. */
638
- const agentFailedNote = (views) => {
639
- const n = views.filter((v) => v.agentFailed !== undefined).length;
640
- return n === 0 ? '' : `; ${n} marked failed by the agent's review`;
641
- };
642
- const filterBlock = (bundle) => {
643
- const counts = countsOf(judgedLedger(bundle.ledger, bundle.findings).cases);
644
- const order = [...statuses.filter((s) => s !== 'passed'), 'passed'];
645
- return html `<div class="filters" role="group" aria-label="Show cases">
646
- <button type="button" class="all" data-filter="all" aria-pressed="true">
647
- All ${bundle.ledger.cases.length}
648
- </button>
649
- ${order
650
- .filter((s) => counts[s] > 0)
651
- .map((s) => html `<button type="button" data-filter="${s}" aria-pressed="false">
652
- ${statusIcon(s)}${countWords(s, counts[s])}
653
- </button>`)}
654
- </div>`;
655
- };
656
- /** The player, its controls with one segment per case, and the case playing now. */
657
- const playerBlock = (bundle, views, spans, playable, hosted) => {
658
- const sessions = new Map(playable.map((p) => [p.number, p.src]));
659
- const firstCase = views.find((v) => {
660
- const span = spans.get(v.entry.id);
661
- return span !== undefined && sessions.has(span.session);
662
- });
663
- const firstSpan = firstCase ? spans.get(firstCase.entry.id) : undefined;
664
- const first = playable.find((p) => p.number === firstSpan?.session) ?? playable[0];
665
- const problems = (bundle.ledger.sessions ?? []).filter((s) => s.videoProblem || !s.video);
666
- const idle = idleStretches(bundle);
667
- const notes = problems.length > 0
668
- ? html `<ul class="video-notes">
669
- ${problems.map((s) => html `<li>
670
- Session ${s.number}: video missing or
671
- incomplete${s.videoProblem ? `: ${s.videoProblem}` : ': the video file was not saved.'}
672
- </li>`)}
673
- </ul>`
674
- : '';
675
- if (first === undefined)
676
- return html `<p class="novideo" role="note">
677
- <strong>This run has no video</strong>, so its cases cannot be played. Their results and
678
- screenshots are all here.
679
- </p>
680
- ${notes}`;
681
- const urls = urlTimeline(bundle, views);
682
- const startMs = firstSpan?.startMs ?? 0;
683
- const firstEntry = firstCase?.entry ?? views[0]?.entry;
684
- return html `${playerWindow({
685
- prefix: 'rp',
686
- sessions: playable,
687
- first,
688
- startMs,
689
- urls,
690
- initialUrl: urlAt(urls, first.number, startMs),
691
- none: html `<strong>This case has no video</strong>, so it cannot be played. Its result and
692
- screenshots are in its card.`,
693
- ...(hosted ? {} : { fixPrompt: videoFixPrompt(bundle.jobId) }),
694
- })}
695
- ${controlsBlock({
696
- prefix: 'rp',
697
- bundle,
698
- sessions: playable,
699
- progress: false,
700
- label: 'Seek in the recording; each segment is a case',
701
- marks: (session, length) => views
702
- .flatMap((view) => {
703
- const span = spans.get(view.entry.id);
704
- if (span === undefined || span.session !== session)
705
- return [];
706
- return [
707
- html `<span
708
- class="seg s-${view.entry.status}"
709
- data-case="${view.entry.id}"
710
- title="${`${view.entry.title} (${statusLabel[view.entry.status]})`}"
711
- style="${`left:${share(span.startMs, length)};width:calc(${share(span.endMs - span.startMs, length)} - 2px)`}"
712
- ></span>`,
713
- ];
714
- })
715
- .concat(idle
716
- .filter((g) => g.session === session)
717
- .map((g) => html `<span
718
- class="idle"
719
- data-a="${fragmentSeconds(g.fromMs)}"
720
- data-b="${fragmentSeconds(g.toMs)}"
721
- style="${`left:${share(g.fromMs, length)};width:${share(g.toMs - g.fromMs, length)}`}"
722
- ></span>`)),
723
- toggles: html `${toggleButton('rp-loop', html `Loop<span class="wide"> case</span>`, true)}${idle.length > 0
724
- ? toggleButton('rp-skip', html `Skip<span class="wide"> inactive</span>`, true)
725
- : ''}`,
726
- })}
727
- <div class="nowplaying" id="rp-now" aria-live="polite">
728
- <span class="np-st">${firstEntry ? statusIcon(firstEntry.status) : ''}</span>
729
- <span class="np-n"
730
- >${firstEntry ? `${views.findIndex((v) => v.entry === firstEntry) + 1} / ${views.length}` : ''}</span
731
- >
732
- <span class="sr np-status">${firstEntry ? `${statusLabel[firstEntry.status]}: ` : ''}</span>
733
- <span class="np-title">${firstEntry?.title ?? ''}</span>
734
- <span class="chip np-chip"
735
- >${loopIcon}<span
736
- >${firstSpan ? `Looping ${formatClock(firstSpan.startMs)}–${formatClock(firstSpan.endMs)}` : ''}</span
737
- ></span
738
- >
739
- </div>
740
- ${notes}`;
741
- };
742
- const videoSummary = (bundle, assets) => {
743
- const sessions = bundle.ledger.sessions ?? [];
744
- if (sessions.length === 0)
745
- return html `<span class="note">none recorded</span>`;
746
- return sessions.map((session) => {
747
- const href = safeRelative(session.video);
748
- const length = session.videoDurationMs !== undefined ? ` (${formatTimecode(session.videoDurationMs)})` : '';
749
- return html `<span class="video-line"
750
- >${href ? html `<a class="file" href="${assets.url(href)}">${href}</a>${length}` : html `<span class="note">no video</span>`}${session.videoProblem || !href
751
- ? html ` Video missing or incomplete:
752
- ${session.videoProblem ?? 'the video file was not saved.'}`
753
- : ''}
754
- </span>`;
755
- });
756
- };
757
- const detail = (term, value) => html `<dt>${term}</dt>
758
- <dd>${value}</dd>`;
759
- /**
760
- * The version that ran the job, and the one that built this report when that is another (a run
761
- * re-rendered later by a newer version, say).
762
- */
763
- const versionDetail = (bundle) => {
764
- const ran = bundle.ledger.version;
765
- const built = bundle.generator?.version;
766
- const run = ran ?? html `<span class="note">unknown</span>`;
767
- return built === undefined || built === ran
768
- ? run
769
- : html `${run} <span class="note">· report built with ${built}</span>`;
770
- };
771
- /**
772
- * The run's details, all from the run: what it checks, where, when, and its raw files. The raw
773
- * files are left out when `hosted` (an asset base URL): a host stores the screenshots and videos,
774
- * never the run's JSON files, so links to them would only fail.
775
- */
776
- const runDetails = (bundle, assets, hosted) => {
777
- const { spec, ledger, summary } = bundle;
778
- const duration = durationOf(bundle.startedAt, bundle.finishedAt);
779
- const findings = assets.url(runFiles.findings);
780
- const rawData = detail('Raw data', html `<a class="file" href="${assets.url(bundle.files.ledger)}">${bundle.files.ledger}</a> ·
781
- <a class="file" href="${assets.url(runFiles.job)}">${runFiles.job}</a> ·
782
- <a class="file" href="${assets.url(runFiles.evidence)}">${runFiles.evidence}</a>${bundle.findings ? html ` · <a class="file" href="${findings}">${runFiles.findings}</a>` : ''}`);
783
- return html `<section class="details" aria-labelledby="details-title">
784
- <h2 id="details-title">Run details</h2>
785
- <dl>
786
- ${detail('Checks', html `${summary.text}${summary.derived ? html ` <span class="note">(summarized from case titles)</span>` : ''}`)}
787
- ${detail('Target', isWebUrl(spec.url) ? html `<a href="${spec.url}" rel="noopener noreferrer">${spec.url}</a>` : spec.url)}
788
- ${detail('Job', html `<code>${bundle.jobId}</code> ·
789
- <span class="state state-${ledger.state}">${ledger.state.replaceAll('_', ' ')}</span>`)}
790
- ${detail('Device', bundle.device.label)}
791
- ${detail('Started', html `<time datetime="${bundle.startedAt}">${formatTime(bundle.startedAt)}</time>`)}
792
- ${detail('Finished', bundle.finishedAt
793
- ? html `<time datetime="${bundle.finishedAt}">${formatTime(bundle.finishedAt)}</time>`
794
- : html `<span class="note">not yet</span>`)}
795
- ${detail('Duration', duration ?? html `<span class="note">n/a</span>`)}
796
- ${detail('Video', videoSummary(bundle, assets))}
797
- ${detail('screw-bugs', versionDetail(bundle))} ${hosted ? '' : rawData}
798
- </dl>
799
- ${ledger.sessions && ledger.sessions.length > 0 ? html `<p>${SESSION_NOTE}</p>` : ''}
800
- </section>`;
801
- };
802
- const viewerDialog = html `<dialog class="viewer" id="viewer" aria-labelledby="viewer-cap">
803
- <div class="v-body"></div>
804
- <div class="v-bar">
805
- <p class="v-cap" id="viewer-cap">
806
- <span class="v-st"></span><span class="v-title"></span><span aria-hidden="true">·</span
807
- ><span class="v-what"></span>
808
- </p>
809
- <button type="button" class="v-prev" aria-label="Previous screenshot">
810
- ${icon('chevron-left', { size: 18 })}
811
- </button>
812
- <button type="button" class="v-next" aria-label="Next screenshot">
813
- ${icon('chevron-right', { size: 18 })}
814
- </button>
815
- <button type="button" class="v-close" aria-label="Close">${icon('x', { size: 18 })}</button>
816
- </div>
817
- </dialog>`;
818
- /**
819
- * A self-contained HTML report: inline CSS, one inline script, and from the network only Geist
820
- * and Geist Mono from Google Fonts (system fonts offline). Screenshots and the video are linked by
821
- * paths relative to the run folder, so the page works from disk and after the folder is zipped or
822
- * moved; or, with `options.assetBaseUrl`, under that URL (see `RenderOptions`), and then without
823
- * the details' raw data row (a host keeps no JSON files). With no options the page is exactly the
824
- * local one. Code lays out every part and decides every status; the
825
- * agent's write-up, when it submitted one, fills fixed slots and is labelled as its own. Every
826
- * piece of text from the job, the page or the agent is escaped.
827
- */
828
- export const renderHtmlReport = (bundle, options) => {
829
- const { spec, ledger, findings } = bundle;
830
- const assets = assetsOf(options);
831
- const views = caseViews(bundle);
832
- const spans = caseSpans(bundle);
833
- const playable = playableSessions(bundle, assets);
834
- const sessions = new Map(playable.map((p) => [p.number, p.src]));
835
- const nextTests = findings?.nextTests ?? [];
836
- // A page, not a file to load: relative even with an asset base URL (see `assets.ts`).
837
- const walkthrough = safeRelative(bundle.files.walkthrough);
838
- const length = runMs(bundle);
839
- const ended = ledger.state === 'finished' || ledger.state === 'errored';
840
- const page = html `<!doctype html>
841
- <html lang="en">
842
- <head>
843
- <meta charset="utf-8" />
844
- <meta name="viewport" content="width=device-width, initial-scale=1" />
845
- <meta name="color-scheme" content="light dark" />
846
- ${generatorMeta(bundle)}
847
- <meta http-equiv="Content-Security-Policy" content="${reportCsp(assets.origin)}" />
848
- ${favicon} ${webFonts}
849
- <title>
850
- ${`${findings?.headline ?? verdictOf(bundle)} · screw-bugs report ${bundle.jobId}`}
851
- </title>
852
- <style>
853
- ${new Markup(styles + reportStyles)}
854
- </style>
855
- </head>
856
- <body>
857
- ${scriptTag}
858
- <div class="${`rp device-${bundle.device.kind}`}" style="${shapeStyle(bundle)}">
859
- ${topBar(bundle.startedAt, bundle.jobId, walkthrough ? { href: walkthrough, name: 'Walkthrough', icon: 'play' } : undefined)}
860
- <header class="rp-head">
861
- <h1>${reportHeading(bundle)}</h1>
862
- <ul class="meta" aria-label="Run">
863
- <li>${ledger.cases.length} ${ledger.cases.length === 1 ? 'case' : 'cases'}</li>
864
- ${length !== undefined ? html `<li>${clockIcon}<span class="sr">Took </span>${formatClock(length)}</li>` : ''}
865
- <li>
866
- ${bundle.device.kind === 'mobile' ? phoneIcon : desktopIcon}${deviceWords(bundle.device)}
867
- </li>
868
- ${browserItem(bundle)}
869
- </ul>
870
- ${promptBlock(spec.instructions)} ${filterBlock(bundle)}
871
- </header>
872
- ${ledger.error
873
- ? html `<div class="alert" role="note">
874
- <strong>The run stopped early.</strong> ${ledger.error}
875
- </div>`
876
- : ended
877
- ? ''
878
- : html `<div class="alert" role="note">
879
- <strong>In progress.</strong> This report shows the run so far.
880
- </div>`}
881
- <main class="rp-main">
882
- <div class="rp-left">
883
- <div class="rp-sticky">
884
- ${playerBlock(bundle, views, spans, playable, options?.assetBaseUrl !== undefined)}
885
- </div>
886
- </div>
887
- <div class="rp-right">
888
- ${evaluationBlock(bundle, views)}
889
- <section class="cases" aria-label="Cases">
890
- ${views.map((view, i) => caseCard(view, i + 1, spans.get(view.entry.id), sessions, assets))}
891
- </section>
892
- <div class="after">
893
- ${nextTests.length > 0
894
- ? html `<section id="next" aria-labelledby="next-title">
895
- <h2 id="next-title">What to test next</h2>
896
- <p class="by">The agent's write-up</p>
897
- <ol class="next">
898
- ${nextTests.map((t) => html `<li>${t}</li>`)}
899
- </ol>
900
- </section>`
901
- : ''}
902
- ${runDetails(bundle, assets, options?.assetBaseUrl !== undefined)}
903
- <footer class="foot">
904
- <p>
905
- Statuses decided by code in a real browser; write-up by the agent.
906
- ${findings ? '' : 'The agent has not submitted a write-up for this run.'}
907
- </p>
908
- </footer>
909
- </div>
910
- </div>
911
- </main>
912
- ${viewerDialog}
913
- </div>
914
- </body>
915
- </html> `;
916
- return page.value;
917
- };
918
- /** The report module's renderer, for the engine to write a run's report. */
919
- export const ReportRendererHtml = Layer.succeed(ReportRenderer, {
920
- html: (bundle) => renderHtmlReport(bundle),
921
- walkthrough: (bundle) => renderWalkthrough(bundle),
922
- live: (page) => renderLivePage(page),
923
- });