@william_jin/autobrowse 0.8.46 → 0.8.48

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.
@@ -152,6 +152,37 @@ button:focus-visible,.row:focus-visible{outline:2px solid var(--ring);outline-of
152
152
  .row .tab.more[aria-expanded=false] .ti .ic{transform:rotate(-90deg)}
153
153
  .row.needs .rb{background:var(--needsbtn);color:inherit}
154
154
  /* Raycast's bottom bar: the Enter action of the row in focus, and the keys; the list runs under it */
155
+ /* status lines (the host, WA-1530): pause or play icon, name, reason; no capsule */
156
+ #linesw{display:grid;grid-template-rows:1fr;transition:grid-template-rows .2s cubic-bezier(.4,0,.2,1),opacity .15s cubic-bezier(.16,1,.3,1)}
157
+ #linesw.shut{grid-template-rows:0fr;opacity:0}
158
+ #linesw>div{min-height:0;overflow:hidden}
159
+ #lines{padding:6px 6px 0}
160
+ .hl{display:flex;align-items:flex-start;gap:7px;padding:3px 9px;font-size:12px;color:var(--mut);-webkit-user-select:text;user-select:text;transition:opacity .2s}
161
+ .hl .hi{position:relative;flex:none;width:13px;height:13px;margin-top:1px}
162
+ .hl :is(.hp,.hr){position:absolute;inset:0;width:13px;height:13px;transition:opacity .2s cubic-bezier(.16,1,.3,1),transform .2s cubic-bezier(.16,1,.3,1)}
163
+ .hl .hp{color:var(--held)}
164
+ .hl .hr{color:var(--brand)}
165
+ .hl.run .hp,.hl:not(.run) .hr{opacity:0;transform:scale(.7)}
166
+ .hl.old{opacity:.7}
167
+ .hl.old :is(.hp,.hr){color:var(--mut)}
168
+ .hl .w{min-width:0;overflow-wrap:anywhere}
169
+ .hl b{color:var(--fg);font-weight:500}
170
+ .hl .y:not(:empty)::before{content:" · "}
171
+ .railrows #lines{padding:4px 6px 0}
172
+ .railrows .hl{justify-content:center;width:40px;padding:6px 0}
173
+ .railrows .hl .w{display:none}
174
+ /* the topic filter (WA-1530): Mail's "Filtered by" line over the list; opens and shuts in place */
175
+ #tfw{display:grid;grid-template-rows:1fr;transition:grid-template-rows .2s cubic-bezier(.4,0,.2,1),opacity .15s cubic-bezier(.16,1,.3,1)}
176
+ #tfw.shut{grid-template-rows:0fr;opacity:0}
177
+ #tfw>div{min-height:0;overflow:hidden}
178
+ #tf{display:flex;align-items:center;gap:7px;margin:6px 6px 2px;padding:4px 4px 4px 9px;border-radius:8px;background:var(--btn);font-size:12px;color:var(--mut)}
179
+ #tf .ic{flex:none;width:13px;height:13px}
180
+ #tf .w{min-width:0;overflow-wrap:anywhere}
181
+ #tf b{color:var(--fg);font-weight:500}
182
+ #tfh:not(:empty)::before{content:" · "}
183
+ #tf button{flex:none;margin-left:auto;height:22px;padding:0 8px;border-radius:6px;color:var(--fg);font-weight:500;transition:background-color .15s}
184
+ #tf button:hover{background:var(--btnh)}
185
+ .railrows #tfw{display:none}
155
186
  #bar{position:absolute;z-index:2;left:0;right:0;bottom:0;height:36px;display:flex;align-items:center;gap:6px;padding:0 10px 0 14px;font-size:12px;color:var(--mut);transition:opacity .15s cubic-bezier(.16,1,.3,1)}
156
187
  /* rows fade out above the bar, never a hard cut */
157
188
  #list{mask-image:linear-gradient(to top,transparent 36px,#000 54px)}
@@ -288,6 +319,18 @@ kbd{display:inline-flex;align-items:center;justify-content:center;min-width:18px
288
319
  .qr.go:focus-visible{outline:2px solid var(--ring);outline-offset:-2px}
289
320
  .qr .qt{font-size:12px;font-weight:500;overflow-wrap:anywhere;text-wrap:pretty}
290
321
  .qr .qs{color:var(--mut);font-size:12px;overflow-wrap:anywhere}
322
+ .qr .qd{color:var(--mut);font-size:12px;white-space:pre-line;overflow-wrap:anywhere;margin-top:2px}
323
+ /* a count that opens: its caret hangs in the marker column, its items take the full width under it */
324
+ .qc .qgt{min-width:0}
325
+ .qg{display:flex;align-items:center;gap:6px;width:calc(100% + 18px);margin-left:-18px;padding:0;color:inherit;text-align:left;transition:color .15s}
326
+ .qg:hover{color:var(--fg)}
327
+ .qc .qg .qcar{flex:none;width:12px;height:12px;transform:rotate(-90deg);transition:transform .2s cubic-bezier(.4,0,.2,1)}
328
+ .qc .qg[aria-expanded=true] .qcar{transform:none}
329
+ .qg:focus-visible{outline:2px solid var(--ring);outline-offset:2px;border-radius:4px}
330
+ .qc .qgw{grid-column:1/-1;margin:0 0 2px;text-align:left;font-weight:400;display:grid;grid-template-rows:1fr;transition:grid-template-rows .22s cubic-bezier(.4,0,.2,1),opacity .18s}
331
+ .qc .qgw.shut{grid-template-rows:0fr;opacity:0;margin:0}
332
+ .qc .qgw>.qgi{min-height:0;overflow:hidden}
333
+ .qc .qgw .qi{margin:0}
291
334
  .qr .qx{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
292
335
  .qr .qx:empty{display:none}
293
336
  .qr .qh{display:inline-block;padding:2px 7px;border-radius:9px;background:var(--heldt);color:var(--held);font-size:11px;font-weight:500;overflow-wrap:anywhere}
@@ -337,6 +380,18 @@ kbd{display:inline-flex;align-items:center;justify-content:center;min-width:18px
337
380
  #qsheet .fl:focus-visible{outline:2px solid var(--ring);outline-offset:-1px}
338
381
  #qsheet .b{padding:0 10px 10px}
339
382
  #qsheet .qi{margin:0}
383
+ /* a feed with counts: one chip per kind (Mail's filter chips), the items in sections under sticky heads */
384
+ #qsheet .qchips{display:flex;flex-wrap:wrap;gap:6px;min-inline-size:0;margin:0;border:0;padding:8px 18px 0}
385
+ #qsheet .qchips[hidden]{display:none}
386
+ #qsheet .qch{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px;border-radius:13px;background:var(--btn);font-size:12px;font-weight:500;transition:background-color .15s,color .15s}
387
+ #qsheet .qch:hover{background:var(--btnh)}
388
+ #qsheet .qch[aria-pressed=true]{background:color-mix(in srgb,var(--brand) 16%,transparent);color:var(--brand)}
389
+ #qsheet .qch b{font-weight:500;color:var(--mut);font-variant-numeric:tabular-nums;transition:color .15s}
390
+ #qsheet .qch[aria-pressed=true] b{color:inherit}
391
+ #qsheet .qch:focus-visible{outline:2px solid var(--ring);outline-offset:1px}
392
+ #qsheet .qsh{position:sticky;top:0;z-index:1;display:flex;justify-content:space-between;gap:12px;margin:0;padding:10px 8px 4px;background:var(--paper);color:var(--mut);font-size:11px;font-weight:600;-webkit-user-select:none;user-select:none}
393
+ #qsheet .qshn{font-variant-numeric:tabular-nums}
394
+ #qsheet .qsec:first-child .qsh{padding-top:4px}
340
395
  #qsheet .qi,#qsheet .qsum{-webkit-user-select:text;user-select:text;cursor:auto}
341
396
  #qsheet .qr{margin:0;padding:7px 8px;content-visibility:auto;contain-intrinsic-size:auto 56px}
342
397
  #qsheet .qr .qt{font-size:13px}
@@ -344,7 +399,7 @@ kbd{display:inline-flex;align-items:center;justify-content:center;min-width:18px
344
399
  #qsheet .qr[data-n]::before{top:7px;font-size:13px}
345
400
  /* the sheet is wide: the hold sits right of the job, so rows keep one height and holds scan down one edge */
346
401
  #qsheet .qr{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px}
347
- #qsheet .qr :is(.qt,.qs){grid-column:1}
402
+ #qsheet .qr :is(.qt,.qs,.qd){grid-column:1}
348
403
  #qsheet .qr .qx{grid-column:2;grid-row:1/span 2;align-self:center;justify-content:flex-end;max-width:240px;margin-top:0}
349
404
  #qsheet .none{padding:24px 8px;color:var(--mut);text-align:center}
350
405
  @media (prefers-reduced-motion:reduce){.sheet>.sht{transform:none}}
@@ -365,7 +420,7 @@ kbd{display:inline-flex;align-items:center;justify-content:center;min-width:18px
365
420
  <button type="button" class="nb" id="keysbtn" title="Keys" aria-label="Keys" aria-expanded="false"><svg class="ic" viewBox="0 0 16 16" aria-hidden="true"><rect x="1.5" y="4" width="13" height="8.5" rx="1.8"/><path d="M4.5 7h.01M7 7h.01M9.5 7h.01M12 7h.01M5 10h6"/></svg></button>
366
421
  </div>
367
422
  <div id="main">
368
- <nav id="side" aria-label="Sessions"><div id="sideclip"><div id="sidein"><ul id="list"></ul>
423
+ <nav id="side" aria-label="Sessions"><div id="sideclip"><div id="sidein"><div id="linesw" class="shut" inert><div><div id="lines"></div></div></div><div id="tfw" class="shut" inert><div><div id="tf" role="status"><svg class="ic" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 4h11M4.5 8h7M6.5 12h3"/></svg><span class="w">Filtered by <b id="tfn"></b><span id="tfh"></span></span><button type="button" id="tfx">Show all</button></div></div></div><ul id="list"></ul>
369
424
  <div id="bar" class="off"><span id="barl"></span><span class="sp"></span><button type="button" id="barkeys" title="Keys (⌘/)">Keys <span class="ks"><kbd>⌘</kbd><kbd>/</kbd></span></button><button type="button" id="more" title="Sidebar actions" aria-label="Sidebar actions" aria-haspopup="menu" aria-expanded="false" aria-controls="menu" popovertarget="menu"><svg class="ic" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h.01M8 8h.01M12.5 8h.01" stroke-width="2.4"/></svg></button></div></div></div>
370
425
  <!-- biome-ignore lint/a11y/useSemanticElements: a focusable splitter (WAI-ARIA window splitter); <hr> is a static rule -->
371
426
  <div id="grip" role="separator" tabindex="0" aria-orientation="vertical" aria-label="Sidebar width" aria-valuemin="0" aria-valuemax="420" aria-valuenow="248" title="Drag to resize; double-click to reset"></div>
@@ -376,7 +431,7 @@ kbd{display:inline-flex;align-items:center;justify-content:center;min-width:18px
376
431
  </div>
377
432
  <div id="menu" popover role="menu" aria-label="Sidebar actions"></div>
378
433
  <div id="keys" class="sheet"><div class="sht" role="dialog" aria-modal="true" aria-label="Keyboard shortcuts" tabindex="-1"><div class="hd"><svg class="hdm" aria-hidden="true" viewBox="0 0 100 100"><use href="#mark"/></svg>Keyboard shortcuts<button type="button" class="cl" id="keysx" title="Close (Esc)" aria-label="Close (Esc)"><kbd>esc</kbd></button></div><div class="b"></div></div></div>
379
- <div id="qsheet" class="sheet"><div class="sht" role="dialog" aria-modal="true" aria-labelledby="qsheetn" tabindex="-1"><div class="hd"><span id="qsheetn" dir="auto"></span><span class="sub"></span><button type="button" class="cl" id="qsheetx" title="Close (Esc)" aria-label="Close (Esc)"><kbd>esc</kbd></button></div><div class="qsum"></div><input type="search" class="fl" id="qfilter" placeholder="Filter by company, role or reason" aria-label="Filter the queue" autocomplete="off" spellcheck="false"><div class="b"><ol class="qi"></ol><div class="none" hidden></div></div></div></div>
434
+ <div id="qsheet" class="sheet"><div class="sht" role="dialog" aria-modal="true" aria-labelledby="qsheetn" tabindex="-1"><div class="hd"><span id="qsheetn" dir="auto"></span><span class="sub"></span><button type="button" class="cl" id="qsheetx" title="Close (Esc)" aria-label="Close (Esc)"><kbd>esc</kbd></button></div><div class="qsum"></div><fieldset class="qchips" aria-label="Show one kind" hidden></fieldset><input type="search" class="fl" id="qfilter" placeholder="Filter by company, role or reason" aria-label="Filter the queue" autocomplete="off" spellcheck="false"><div class="b"><div class="qsecs"></div><div class="none" hidden></div></div></div></div>
380
435
  <script>
381
436
  'use strict';
382
437
  const $ = (id) => document.getElementById(id);
@@ -486,11 +541,46 @@ const keep = () => Math.max(CAP.grid, CAP.focus);
486
541
  const OFF_HOLD_MS = 1500;
487
542
  const idOf = (key) => key.split('#')[0];
488
543
 
544
+ // --- topics (WA-1530): a run's or feed's broad topic; topics not shown leave the list, Grid and Focus ---
545
+ /** queue item id → its feed's topic: a run on a queue item (`JOB_REF`) takes it when it names none */
546
+ const refTopic = new Map();
547
+ const topicKey = (t) => (typeof t === 'string' ? t.trim().toLocaleLowerCase().slice(0, 40) : '');
548
+ const topicOf = (r) => topicKey(r.topic) || (typeof r.job?.ref === 'string' ? refTopic.get(r.job.ref) ?? '' : '');
549
+ const feedTopic = (f) => topicKey(f?.topic);
550
+ const topicName = (t) => (t ? t[0].toLocaleUpperCase() + t.slice(1) : 'Other');
551
+ /** the topics shown; null: all, a new topic too. A set holds: a topic that comes later stays out */
552
+ let showTopics = null;
553
+ try { const v = JSON.parse(store.get('hub.topics', 'null')); if (Array.isArray(v)) showTopics = new Set(v.map(String)); } catch {}
554
+ const seenTopic = (t) => !showTopics || showTopics.has(t);
555
+ const seen = (id) => { const r = rows.get(id); return !!r && seenTopic(topicOf(r)); };
556
+ /** live runs the filter hides */
557
+ const hiddenRuns = () => [...rows.keys()].filter((id) => !rows.get(id).ended && !seen(id)).length;
558
+ /** every topic on the hub, plus the shown ones; Other last */
559
+ function topics() {
560
+ const s = new Set([...rows.values()].map(topicOf));
561
+ for (const f of feeds.values()) { const t = feedTopic(f); if (t) s.add(t); }
562
+ for (const t of showTopics ?? []) s.add(t);
563
+ return [...s].sort((a, b) => (a === '' ? 1 : 0) - (b === '' ? 1 : 0) || a.localeCompare(b));
564
+ }
565
+ function setTopics(next) {
566
+ showTopics = next;
567
+ store.set('hub.topics', next ? JSON.stringify([...next]) : 'null');
568
+ const was = places();
569
+ fill(); render(); settle(was);
570
+ }
571
+ /** ⌥: only this topic (Finder's ⌥-click); else it turns on or off */
572
+ function toggleTopic(t, only) {
573
+ if (only) return setTopics(new Set([t]));
574
+ const s = new Set(showTopics ?? topics());
575
+ if (s.has(t)) s.delete(t); else s.add(t);
576
+ setTopics(topics().every((x) => s.has(x)) ? null : s);
577
+ }
578
+
489
579
  function sorted() {
490
- return order.filter((id) => rows.has(id)).sort((a, b) => (rows.get(b).needs ? 1 : 0) - (rows.get(a).needs ? 1 : 0));
580
+ return order.filter(seen).sort((a, b) => (rows.get(b).needs ? 1 : 0) - (rows.get(a).needs ? 1 : 0));
491
581
  }
492
582
  /** a session that can have a pane now */
493
- const placeable = (id) => { const r = rows.get(id); return !!r && !!r.url && !r.torn && !r.ended && !r.moved; };
583
+ const placeable = (id) => { const r = rows.get(id); return !!r && !!r.url && !r.torn && !r.ended && !r.moved && seen(id); };
494
584
 
495
585
  // --- the app's words ----------------------------------------------------------------
496
586
  window.hub = {
@@ -1077,11 +1167,12 @@ function render() {
1077
1167
  });
1078
1168
  tellViewers();
1079
1169
  $('empty').classList.toggle('on', cells.length === 0);
1080
- txt($('empty').querySelector('.h'), rows.size ? 'Pick a session' : 'No sessions');
1081
- const es = $('empty').querySelector('.s'), want = rows.size ? 'pick' : 'none';
1170
+ const nSeen = order.filter(seen).length, nHid = nSeen ? 0 : hiddenRuns();
1171
+ txt($('empty').querySelector('.h'), nSeen ? 'Pick a session' : 'No sessions');
1172
+ const es = $('empty').querySelector('.s'), want = nSeen ? 'pick' : nHid ? `hid${nHid}` : 'none';
1082
1173
  if (es.dataset.k !== want) {
1083
1174
  es.dataset.k = want;
1084
- es.innerHTML = rows.size ? 'Open a run from the list, or drag a row here.' : 'Start one with <code>autobrowse explore &lt;site&gt;</code>';
1175
+ es.innerHTML = nSeen ? 'Open a run from the list, or drag a row here.' : nHid ? `${nHid} ${nHid === 1 ? 'run is' : 'runs are'} hidden by the topic filter.` : 'Start one with <code>autobrowse explore &lt;site&gt;</code>';
1085
1176
  }
1086
1177
  }
1087
1178
 
@@ -1122,7 +1213,7 @@ function stateSec(r) {
1122
1213
  return r.lazy && !r.url && !r.moved ? 'lazy' : 'run';
1123
1214
  }
1124
1215
  /** Group by (Linear's Display, PT-17): state sections, a task or an account; keys t:… a:… */
1125
- const GROUPS = [['state', 'State'], ['task', 'Task'], ['account', 'Account']];
1216
+ const GROUPS = [['state', 'State'], ['task', 'Task'], ['account', 'Account'], ['topic', 'Topic']];
1126
1217
  let groupBy = store.get('hub.group', 'state');
1127
1218
  if (!GROUPS.some(([k]) => k === groupBy)) groupBy = 'state';
1128
1219
  /** the job, else the flow's label or name, else the kind */
@@ -1136,6 +1227,7 @@ const accountOf = (r) => typeof r.profile !== 'string' || !r.profile ? 'No profi
1136
1227
  function secOf(r) {
1137
1228
  if (groupBy === 'task') return `t:${taskOf(r)}`;
1138
1229
  if (groupBy === 'account') return `a:${accountOf(r)}`;
1230
+ if (groupBy === 'topic') return `p:${topicName(topicOf(r))}`;
1139
1231
  return stateSec(r);
1140
1232
  }
1141
1233
  /** groups in list order, each with its rows; in Task and Account, needs-you rows first and ended rows last */
@@ -1143,7 +1235,7 @@ function groupList() {
1143
1235
  const m = new Map(groupBy === 'state' ? SECS.map(([k, l]) => [k, { k, label: l, ids: [] }]) : []);
1144
1236
  for (const id of order) {
1145
1237
  const r = rows.get(id);
1146
- if (!r) continue;
1238
+ if (!r || !seen(id)) continue;
1147
1239
  const k = secOf(r);
1148
1240
  if (!m.has(k)) m.set(k, { k, label: k.slice(2), ids: [] });
1149
1241
  m.get(k).ids.push(id);
@@ -1388,7 +1480,19 @@ function renderRows(was = places()) {
1388
1480
  settle(was);
1389
1481
  $('bar').classList.toggle('off', !rows.size);
1390
1482
  bar();
1391
- }
1483
+ fillFilter();
1484
+ }
1485
+ /** the "Filtered by" line: the topics shown and how many runs it hides */
1486
+ function fillFilter() {
1487
+ const w = $('tfw'), on = !!showTopics;
1488
+ w.classList.toggle('shut', !on);
1489
+ if (w.inert === on) w.inert = !on;
1490
+ if (!on) return;
1491
+ txt($('tfn'), [...showTopics].map(topicName).sort().join(', ') || 'no topic');
1492
+ const h = hiddenRuns();
1493
+ txt($('tfh'), h ? `${h} ${h === 1 ? 'run' : 'runs'} hidden` : '');
1494
+ }
1495
+ $('tfx').addEventListener('click', () => setTopics(null));
1392
1496
  /** rows a person can see, top to bottom: ⌘⌥1–9 and ↑ ↓ walk these */
1393
1497
  const shown = () => live().filter((el) => el.classList.contains('row'));
1394
1498
  /** the bar: the focused row's ↩ action, else the jump keys */
@@ -1453,10 +1557,11 @@ function takeFeeds(m, whole) {
1453
1557
  for (const [k, v] of Object.entries(m && typeof m === 'object' ? m : {})) {
1454
1558
  if (v && typeof v === 'object') feeds.set(k, v); else feeds.delete(k);
1455
1559
  }
1456
- byRef.clear();
1457
- for (const f of feeds.values()) for (const it of Array.isArray(f.items) ? f.items : []) if (it && typeof it.id === 'string') byRef.set(it.id, it);
1458
- // rows too: a run's title comes from its item
1459
- renderRows();
1560
+ const vis = () => [...rows.keys()].filter(seen).join('\n'), before = vis();
1561
+ byRef.clear(); refTopic.clear();
1562
+ for (const f of feeds.values()) for (const it of Array.isArray(f.items) ? f.items : []) if (it && typeof it.id === 'string') { byRef.set(it.id, it); refTopic.set(it.id, feedTopic(f)); }
1563
+ // rows too: a run's title and topic come from its item; panes move only when a run's topic turned it in or out
1564
+ if (vis() !== before) { fill(); render(); } else renderRows();
1460
1565
  fillQSheet();
1461
1566
  }
1462
1567
  const atOf = (f) => { const t = Date.parse(f.updatedAt); return Number.isFinite(t) ? t : NaN; };
@@ -1487,6 +1592,7 @@ function itemHtml(it, running) {
1487
1592
  const cap = h ? `<span class="qh">${esc(h.why || 'Held')}${cd}</span>` : st ? `<span class="cap${['running', 'submitting'].includes(st) ? ' run' : ''}">${esc(word(st))}</span>` : '';
1488
1593
  return `<div class="qt" dir="auto">${esc(it.title || it.id || 'Job')}</div>`
1489
1594
  + (it.sub ? `<div class="qs" dir="auto">${esc(it.sub)}</div>` : '')
1595
+ + (typeof it.detail === 'string' && it.detail.trim() ? `<div class="qd" dir="auto">${esc(it.detail.trim())}</div>` : '')
1490
1596
  + (cap ? `<div class="qx">${cap}</div>` : '');
1491
1597
  }
1492
1598
  const untilWord = (ms) => until(ms);
@@ -1513,7 +1619,8 @@ function keyed(ol, list, still = new Set()) {
1513
1619
  if (it.ref) el.dataset.ref = it.ref;
1514
1620
  }
1515
1621
  if (el.dataset.h !== it.html) { el.dataset.h = it.html; el.innerHTML = it.html; }
1516
- if (el.dataset.n !== String(it.n)) el.dataset.n = String(it.n);
1622
+ if (it.n == null) delete el.dataset.n;
1623
+ else if (el.dataset.n !== String(it.n)) el.dataset.n = String(it.n);
1517
1624
  el.classList.toggle('go', !!it.url);
1518
1625
  if (it.url) { el.dataset.url = it.url; attr(el, 'title', `Open the posting: ${it.url}`); el.tabIndex = 0; }
1519
1626
  else { delete el.dataset.url; el.removeAttribute('title'); el.removeAttribute('tabindex'); }
@@ -1547,10 +1654,58 @@ function feedEl(k) {
1547
1654
  return el;
1548
1655
  }
1549
1656
  const show1 = (el, on) => { if (el.hidden === on) el.hidden = !on; };
1550
- /** the counts as words-and-number pairs */
1551
- function countsHtml(f) {
1552
- return [...counts(f.status), ...counts(f.runs)].map(([w, n]) => `<dt>${esc(labelOf(f, w))}</dt><dd>${nf.format(n)}</dd>`).join('');
1553
- }
1657
+ /** an item filed under a count (`group` = its status key, WA-1530): it lists under that count, never in the queue */
1658
+ const groupOf = (it) => (it && typeof it === 'object' && typeof it.group === 'string' && it.group ? it.group : '');
1659
+ /** the queue: items under no count; null when every item sits under one */
1660
+ function queueOf(all) {
1661
+ if (!all) return null;
1662
+ const q = all.filter((it) => !groupOf(it));
1663
+ return q.length || !all.some(groupOf) ? q : null;
1664
+ }
1665
+ /** a feed's items under each count, `group` → items */
1666
+ function byGroup(f) {
1667
+ const by = new Map();
1668
+ for (const it of Array.isArray(f?.items) ? f.items : []) { const g = groupOf(it); if (g) { if (!by.has(g)) by.set(g, []); by.get(g).push(it); } }
1669
+ return by;
1670
+ }
1671
+ /** the counts in the feed's key order, then any group with no count: [[key, n]] */
1672
+ function countList(f, by) {
1673
+ const list = [...counts(f.status), ...counts(f.runs)];
1674
+ for (const [g, its] of by) if (!list.some(([w]) => w === g)) list.push([g, its.length]);
1675
+ return list;
1676
+ }
1677
+ /** a status line (WA-1530): no topic, no items; it shows at the sidebar top, not under Queues */
1678
+ const lineFeed = (f) => !!f && typeof f.error !== 'string' && !feedTopic(f) && !Array.isArray(f.items);
1679
+ /** counts a person opened, `feed\ngroup` → true (kept) */
1680
+ let qopen = {};
1681
+ try { qopen = JSON.parse(store.get('hub.qopen', '{}')) || {}; } catch {}
1682
+ /** the counts as words-and-number pairs; a count with items opens (Finder's outline) to list them */
1683
+ function countsHtml(f, k) {
1684
+ const by = byGroup(f);
1685
+ return countList(f, by).map(([w, n]) => {
1686
+ const its = by.get(w);
1687
+ if (!its) return `<dt>${esc(labelOf(f, w))}</dt><dd>${nf.format(n)}</dd>`;
1688
+ const id = `qg-${k}-${w}`.replace(/[^\w-]/g, '_');
1689
+ const li = its.map((it) => { const u = linkOf(it); return `<li class="qr${u ? ' go' : ''}"${u ? ` data-url="${esc(u)}" tabindex="0" title="Open: ${esc(u)}"` : ''}>${itemHtml(it, false)}</li>`; }).join('');
1690
+ return `<dt class="qgt"><button type="button" class="qg" data-g="${esc(w)}" aria-expanded="false" aria-controls="${id}">${icon('caret').replace('class="ic', 'class="ic qcar')}<span>${esc(labelOf(f, w))}</span></button></dt><dd class="qgn">${nf.format(n)}</dd>`
1691
+ + `<dd class="qgw shut" id="${id}" inert><div class="qgi"><ol class="qi">${li}</ol></div></dd>`;
1692
+ }).join('');
1693
+ }
1694
+ function openGroup(b, on) {
1695
+ attr(b, 'aria-expanded', String(on));
1696
+ const w = document.getElementById(b.getAttribute('aria-controls'));
1697
+ if (!w) return;
1698
+ w.classList.toggle('shut', !on);
1699
+ if (w.inert === on) w.inert = !on;
1700
+ }
1701
+ list.addEventListener('click', (e) => {
1702
+ const b = e.target.closest('.qg'), k = b?.closest('.qf')?.dataset.f;
1703
+ if (!b || !k) return;
1704
+ const key = `${k}\n${b.dataset.g}`, on = !qopen[key];
1705
+ if (on) qopen[key] = true; else delete qopen[key];
1706
+ store.set('hub.qopen', JSON.stringify(qopen));
1707
+ openGroup(b, on);
1708
+ });
1554
1709
  function fillFeed(el, k, f, now, refs) {
1555
1710
  const $q = (c) => el.querySelector(c);
1556
1711
  const bad = typeof f.error === 'string' ? `Unreadable feed file (${f.error})` : f.v !== FEED_V ? `feed v${f.v ?? '?'}: update autobrowse` : '';
@@ -1559,7 +1714,7 @@ function fillFeed(el, k, f, now, refs) {
1559
1714
  el.classList.toggle('old', old);
1560
1715
  const st = f.status && typeof f.status === 'object' ? f.status : {};
1561
1716
  const state = !bad && typeof st.state === 'string' ? st.state : '';
1562
- const items = !bad && Array.isArray(f.items) ? f.items : null;
1717
+ const items = bad ? null : queueOf(Array.isArray(f.items) ? f.items : null);
1563
1718
  // the state in a capsule: blue runs, amber waits, grey when old; a queue shows its size
1564
1719
  const cap = $q('.qhd .cap');
1565
1720
  cls(cap, `cap${old ? '' : state === 'running' ? ' run' : state ? ' held' : ''}`);
@@ -1574,27 +1729,32 @@ function fillFeed(el, k, f, now, refs) {
1574
1729
  txt($q('.qy'), why);
1575
1730
  $q('.qy').classList.toggle('mut', !!why && !given);
1576
1731
  show1($q('.qy'), !!why);
1577
- const ch = bad ? '' : countsHtml(f);
1732
+ const ch = bad ? '' : countsHtml(f, k);
1578
1733
  if ($q('.qc').dataset.h !== ch) { $q('.qc').dataset.h = ch; $q('.qc').innerHTML = ch; }
1734
+ for (const b of $q('.qc').querySelectorAll('.qg')) openGroup(b, !!qopen[`${k}\n${b.dataset.g}`]);
1579
1735
  show1($q('.qc'), !!ch);
1580
1736
  // next: jobs that can start (no hold), not running yet
1581
1737
  const next = (items ?? []).filter((it) => { const o = itemOf(it); return !(o.hold && typeof o.hold === 'object') && !refs.has(String(o.id ?? '')); }).slice(0, NEXT);
1582
1738
  txt($q('.qsub'), !items ? '' : !items.length ? 'The queue is empty' : next.length ? `Next ${next.length}` : 'No job can start now');
1583
1739
  show1($q('.qsub'), !!items);
1584
1740
  $q('.qsub').classList.toggle('none', !!items && !next.length);
1585
- const ol = $q('.qi');
1741
+ const ol = $q('.qbd>.qi');
1586
1742
  keyed(ol, itemRows(next, new Set()), refs);
1587
1743
  show1(ol, next.length > 0);
1588
- show1($q('.qfoot'), !!items?.length);
1744
+ const grouped = !bad && f.items?.some?.(groupOf);
1745
+ txt($q('.qm'), grouped ? 'View all' : 'View full queue');
1746
+ show1($q('.qfoot'), !!items?.length || !!grouped);
1589
1747
  const open = !qfold[k], hd = $q('.qhd'), bw = $q('.qbw');
1590
1748
  attr(hd, 'aria-expanded', String(open));
1591
1749
  bw.classList.toggle('shut', !open);
1592
1750
  bw.inert = !open;
1593
1751
  }
1594
1752
  /** the Queues section: last in the list, under the sessions; none with no feed */
1753
+ const inQueues = (f) => !lineFeed(f) && (!feedTopic(f) || seenTopic(feedTopic(f)));
1595
1754
  function renderQueues(now = Date.now()) {
1755
+ renderLines(now);
1596
1756
  let q = list.querySelector(':scope>.q');
1597
- if (!feeds.size) { q?.remove(); return; }
1757
+ if (![...feeds.values()].some(inQueues)) { q?.remove(); return; }
1598
1758
  if (!q) {
1599
1759
  q = document.createElement('li');
1600
1760
  q.className = 'q'; q.dataset.k = 'q';
@@ -1609,8 +1769,8 @@ function renderQueues(now = Date.now()) {
1609
1769
  const qb = q.querySelector('.qb');
1610
1770
  show1(qb, open);
1611
1771
  if (!open) return;
1612
- // status lines first (the host), then queues; by name inside each
1613
- const ks = [...feeds.keys()].sort((a, b) => (Array.isArray(feeds.get(a).items) ? 1 : 0) - (Array.isArray(feeds.get(b).items) ? 1 : 0) || a.localeCompare(b));
1772
+ // status feeds with a topic first, then queues; by name inside each
1773
+ const ks = [...feeds.keys()].filter((k) => inQueues(feeds.get(k))).sort((a, b) => (Array.isArray(feeds.get(a).items) ? 1 : 0) - (Array.isArray(feeds.get(b).items) ? 1 : 0) || a.localeCompare(b));
1614
1774
  const have = new Map([...qb.children].map((el) => [el.dataset.f, el]));
1615
1775
  const refs = runRefs();
1616
1776
  ks.forEach((k, i) => {
@@ -1621,6 +1781,33 @@ function renderQueues(now = Date.now()) {
1621
1781
  });
1622
1782
  for (const el of have.values()) el.remove();
1623
1783
  }
1784
+ /** status lines at the sidebar top (the host): a pause or play icon, the name, its reason */
1785
+ function renderLines(now = Date.now()) {
1786
+ const box = $('lines'), ks = [...feeds.keys()].filter((k) => lineFeed(feeds.get(k))).sort();
1787
+ const have = new Map([...box.children].map((el) => [el.dataset.f, el]));
1788
+ ks.forEach((k, i) => {
1789
+ let el = have.get(k);
1790
+ have.delete(k);
1791
+ if (!el) {
1792
+ el = document.createElement('div'); el.className = 'hl'; el.dataset.f = k; el.setAttribute('role', 'status');
1793
+ el.innerHTML = `<span class="hi">${icon('pause').replace('class="ic', 'class="ic hp')}${icon('play').replace('class="ic', 'class="ic hr')}</span><span class="w"><b dir="auto"></b><span class="y" dir="auto"></span></span>`;
1794
+ }
1795
+ const f = feeds.get(k), st = f.status && typeof f.status === 'object' ? f.status : {};
1796
+ const state = typeof st.state === 'string' ? st.state : '', old = staleOf(f, now), at = atOf(f);
1797
+ const why = old ? (Number.isFinite(at) ? `Stale since ${clock(at)}` : 'Stale: no update time') : typeof st.why === 'string' ? st.why.trim() : '';
1798
+ el.classList.toggle('run', state === 'running');
1799
+ el.classList.toggle('old', old);
1800
+ txt(el.querySelector('b'), nameOf(f, k));
1801
+ txt(el.querySelector('.y'), why);
1802
+ const runs = counts(f.runs).map(([w, n]) => `${labelOf(f, w)} ${nf.format(n)}`).join(', ');
1803
+ attr(el, 'title', [`${nameOf(f, k)}: ${state ? word(state) : 'no state'}`, why, runs && `Running: ${runs}`].filter(Boolean).join('\n'));
1804
+ if (box.children[i] !== el) box.insertBefore(el, box.children[i] ?? null);
1805
+ });
1806
+ for (const el of have.values()) el.remove();
1807
+ const w = $('linesw'), on = box.children.length > 0;
1808
+ w.classList.toggle('shut', !on);
1809
+ if (w.inert === on) w.inert = !on;
1810
+ }
1624
1811
  // a job with a link opens its posting in the browser; a drag that selected words does not
1625
1812
  function openJob(e) {
1626
1813
  const el = e.target.closest('.qr.go');
@@ -1633,33 +1820,80 @@ for (const el of [list, $('qsheet')]) { el.addEventListener('click', openJob); e
1633
1820
  // --- the full queue: a window sheet (WA-1520) ---------------------------------------
1634
1821
  /** the feed the sheet shows; null = shut */
1635
1822
  let qsheetOf = null;
1823
+ /** the chip picked: a count's key; '' = every kind */
1824
+ let qgroup = '';
1636
1825
  const qfilterEl = $('qfilter');
1826
+ const hasItems = (f) => Array.isArray(f?.items) && f.items.length > 0;
1637
1827
  function qsheet(k) {
1638
1828
  const was = qsheetOf;
1639
- qsheetOf = k && feeds.has(k) ? k : null;
1640
- if (qsheetOf && qsheetOf !== was) qfilterEl.value = '';
1829
+ qsheetOf = k && hasItems(feeds.get(k)) ? k : null;
1830
+ if (qsheetOf && qsheetOf !== was) { qfilterEl.value = ''; qgroup = ''; }
1641
1831
  fillQSheet();
1642
1832
  showSheet('qsheet', !!qsheetOf, () => list.querySelector(`.qf[data-f="${CSS.escape(was ?? '')}"] .qm`)?.focus({ preventScroll: true }));
1643
1833
  if (qsheetOf) qfilterEl.focus({ preventScroll: true });
1644
1834
  }
1835
+ /** one section per kind: a sticky head (words, count) over its list */
1836
+ function qsecEl(g) {
1837
+ const el = document.createElement('section');
1838
+ el.className = 'qsec'; el.dataset.g = g;
1839
+ el.innerHTML = '<h3 class="qsh"><span dir="auto"></span><span class="qshn"></span></h3><ol class="qi"></ol>';
1840
+ return el;
1841
+ }
1645
1842
  function fillQSheet() {
1646
1843
  if (!qsheetOf) return;
1647
1844
  const f = feeds.get(qsheetOf);
1648
- if (!f || !Array.isArray(f.items)) { qsheet(null); return; }
1649
- const sh = $('qsheet'), items = f.items, refs = runRefs();
1845
+ if (!hasItems(f)) { qsheet(null); return; }
1846
+ const sh = $('qsheet'), refs = runRefs(), by = byGroup(f), queue = queueOf(f.items) ?? [];
1847
+ const grouped = by.size > 0;
1848
+ if (qgroup && !by.has(qgroup) && !(qgroup === '\n' && queue.length)) qgroup = '';
1650
1849
  txt($('qsheetn'), nameOf(f, qsheetOf));
1651
- const at = atOf(f), old = staleOf(f);
1652
- txt(sh.querySelector('.hd .sub'), `${nf.format(items.length)} ${items.length === 1 ? 'job' : 'jobs'}, ${old ? 'stale since' : 'updated'} ${Number.isFinite(at) ? clock(at) : 'never'}`);
1653
- const sum = counts(f.status).map(([w, n]) => `<span>${esc(labelOf(f, w))} <b>${nf.format(n)}</b></span>`).join('');
1654
- if (sh.querySelector('.qsum').dataset.h !== sum) { sh.querySelector('.qsum').dataset.h = sum; sh.querySelector('.qsum').innerHTML = sum; }
1850
+ const at = atOf(f), old = staleOf(f), n = f.items.length;
1851
+ txt(sh.querySelector('.hd .sub'), `${nf.format(n)} ${grouped ? (n === 1 ? 'item' : 'items') : (n === 1 ? 'job' : 'jobs')}, ${old ? 'stale since' : 'updated'} ${Number.isFinite(at) ? clock(at) : 'never'}`);
1852
+ // totals with no items behind them; the rest are chips
1853
+ const sum = countList(f, by).filter(([w]) => !by.has(w)).map(([w, c]) => `<span>${esc(labelOf(f, w))} <b>${nf.format(c)}</b></span>`).join('');
1854
+ const qs = sh.querySelector('.qsum');
1855
+ if (qs.dataset.h !== sum) { qs.dataset.h = sum; qs.innerHTML = sum; }
1856
+ show1(qs, !!sum);
1857
+ // sections: the queue (key "\n", never a group key) first, then each count in key order
1858
+ const secs = [...(queue.length ? [['\n', grouped ? 'Queue' : '', queue]] : []), ...countList(f, by).filter(([w]) => by.has(w)).map(([w]) => [w, labelOf(f, w), by.get(w)])];
1859
+ const chips = sh.querySelector('.qchips');
1860
+ const ch = grouped ? [['', 'All', n], ...secs.map(([g, l, its]) => [g, l, its.length])] : [];
1861
+ const chh = ch.map(([g, l, c]) => `<button type="button" class="qch" data-g="${esc(g)}" aria-pressed="false">${esc(l)} <b>${nf.format(c)}</b></button>`).join('');
1862
+ if (chips.dataset.h !== chh) { chips.dataset.h = chh; chips.innerHTML = chh; }
1863
+ for (const b of chips.children) attr(b, 'aria-pressed', String(b.dataset.g === qgroup));
1864
+ show1(chips, grouped);
1865
+ attr(qfilterEl, 'placeholder', grouped ? 'Search every item' : 'Filter by company, role or reason');
1866
+ attr(qfilterEl, 'aria-label', grouped ? 'Search every item' : 'Filter the queue');
1655
1867
  const q = qfilterEl.value.trim().toLocaleLowerCase();
1656
- const hit = (it) => { const o = itemOf(it); return !q || [o.title, o.sub, o.hold?.why, o.state].some((x) => typeof x === 'string' && x.toLocaleLowerCase().includes(q)); };
1657
- const shown = itemRows(items, refs).filter((_, i) => hit(items[i]));
1658
- keyed(sh.querySelector('.qi'), shown);
1868
+ const hit = (it, l) => { const o = itemOf(it); return !q || [o.title, o.sub, o.detail, o.hold?.why, o.state, l].some((x) => typeof x === 'string' && x.toLocaleLowerCase().includes(q)); };
1869
+ const box = sh.querySelector('.qsecs'), have = new Map([...box.children].map((el) => [el.dataset.g, el]));
1870
+ let shown = 0;
1871
+ secs.forEach(([g, l, its], i) => {
1872
+ const el = have.get(g) ?? qsecEl(g);
1873
+ have.delete(g);
1874
+ const rows = itemRows(its, refs).filter((_, j) => hit(its[j], l)).map((r) => (g === '\n' ? r : { ...r, n: null }));
1875
+ const on = (!qgroup || qgroup === g) && rows.length > 0;
1876
+ if (on) shown += rows.length;
1877
+ txt(el.querySelector('.qsh span'), l);
1878
+ txt(el.querySelector('.qshn'), q ? `${nf.format(rows.length)} of ${nf.format(its.length)}` : nf.format(its.length));
1879
+ show1(el.querySelector('.qsh'), !!l);
1880
+ keyed(el.querySelector('.qi'), on ? rows : []);
1881
+ show1(el, on);
1882
+ if (box.children[i] !== el) box.insertBefore(el, box.children[i] ?? null);
1883
+ });
1884
+ for (const el of have.values()) el.remove();
1659
1885
  const none = sh.querySelector('.none');
1660
- txt(none, !items.length ? 'The queue is empty' : `No job matches “${qfilterEl.value.trim()}”`);
1661
- show1(none, !shown.length);
1662
- }
1886
+ const chip = qgroup ? secs.find(([g]) => g === qgroup)?.[1] : '';
1887
+ txt(none, !q ? 'The queue is empty' : `No ${grouped ? 'item' : 'job'}${chip ? ` in ${chip}` : ''} matches “${qfilterEl.value.trim()}”`);
1888
+ show1(none, !shown);
1889
+ }
1890
+ $('qsheet').querySelector('.qchips').addEventListener('click', (e) => {
1891
+ const b = e.target.closest('.qch');
1892
+ if (!b) return;
1893
+ qgroup = qgroup === b.dataset.g ? '' : b.dataset.g;
1894
+ fillQSheet();
1895
+ $('qsheet').querySelector('.b').scrollTop = 0;
1896
+ });
1663
1897
  $('qsheetx').addEventListener('click', () => qsheet(null));
1664
1898
  qfilterEl.addEventListener('input', fillQSheet);
1665
1899
  // countdowns each second; stale on its own once-a-minute clock (no file change needed)
@@ -1691,7 +1925,7 @@ function act(id, a, d = {}) {
1691
1925
  */
1692
1926
  function show(id, more = false) {
1693
1927
  const r = rows.get(id);
1694
- if (!r || r.ended) return;
1928
+ if (!r || r.ended || !seen(id)) return;
1695
1929
  if (r.torn) return app({ t: 'tear', id });
1696
1930
  if (r.lazy && !r.url) { if (more) adding.add(id); else adding.delete(id); return act(id, 'watch'); }
1697
1931
  if (!placeable(id)) return;
@@ -2004,7 +2238,10 @@ function menuItems() {
2004
2238
  const m = shownMode(), secs = groupList().filter((g) => g.k !== 'needs');
2005
2239
  const allFolded = secs.length > 0 && secs.every((g) => folded(g.k, g.ids.length)), anyFolded = secs.some((g) => folded(g.k, g.ids.length));
2006
2240
  const narrow = narrowQ.matches;
2241
+ const ts = topics();
2007
2242
  const out = [
2243
+ // a topic filter is worth a menu only once there are two topics, or one is hidden
2244
+ ...(ts.length > 1 || showTopics ? [{ h: 'Show topics' }, ...ts.map((t) => ({ a: `topic:${t}`, l: topicName(t), check: seenTopic(t), tip: `⌥-click: only ${topicName(t)}` })), { a: 'topics', l: 'Show all', off: !showTopics }, null] : []),
2008
2245
  { a: 'collapse', l: 'Collapse all', off: !secs.length || allFolded },
2009
2246
  { a: 'expand', l: 'Expand all', off: !anyFolded },
2010
2247
  { a: 'compact', l: 'Compact rows', check: compact },
@@ -2023,7 +2260,7 @@ function menuItems() {
2023
2260
  }
2024
2261
  function fillMenu() {
2025
2262
  menu.innerHTML = menuItems().map((x) => !x ? '<hr>' : x.h ? `<div class="mh" role="presentation">${esc(x.h)}</div>`
2026
- : `<button type="button" role="${'radio' in x ? 'menuitemradio' : 'check' in x ? 'menuitemcheckbox' : 'menuitem'}" data-a="${x.a}"${'check' in x || 'radio' in x ? ` aria-checked="${x.check ?? x.radio}"` : ''}${x.off ? ' disabled' : ''}>${'check' in x || 'radio' in x ? CHECK : '<span class="ck"></span>'}${esc(x.l)}${x.k ? kbds(['⌘', '\\']) : ''}</button>`).join('');
2263
+ : `<button type="button" role="${'radio' in x ? 'menuitemradio' : 'check' in x ? 'menuitemcheckbox' : 'menuitem'}" data-a="${esc(x.a)}"${x.tip ? ` title="${esc(x.tip)}"` : ''}${'check' in x || 'radio' in x ? ` aria-checked="${x.check ?? x.radio}"` : ''}${x.off ? ' disabled' : ''}>${'check' in x || 'radio' in x ? CHECK : '<span class="ck"></span>'}${esc(x.l)}${x.k ? kbds(['⌘', '\\']) : ''}</button>`).join('');
2027
2264
  }
2028
2265
  // placed before the first paint: anchored by its bottom edge, so no measure is needed
2029
2266
  menu.addEventListener('beforetoggle', (e) => {
@@ -2052,7 +2289,9 @@ menu.addEventListener('click', (e) => {
2052
2289
  const a = e.target.closest('button')?.dataset.a;
2053
2290
  if (!a) return;
2054
2291
  menu.hidePopover();
2055
- if (a === 'collapse' || a === 'expand') foldAll(a === 'collapse');
2292
+ if (a.startsWith('topic:')) toggleTopic(a.slice(6), e.altKey);
2293
+ else if (a === 'topics') setTopics(null);
2294
+ else if (a === 'collapse' || a === 'expand') foldAll(a === 'collapse');
2056
2295
  else if (a === 'compact') setCompact(!compact);
2057
2296
  else if (a.startsWith('pace:')) {
2058
2297
  const k = Number(a.slice(5));
@@ -57,6 +57,8 @@ export interface Look {
57
57
  agree: number;
58
58
  of: number;
59
59
  }
60
+ /** Why a solve failed, for code to branch on: `none` nothing found, `no-eyes` a picture with no model that sees, `off` 0 attempts. */
61
+ export type CaptchaFail = "none" | "no-eyes" | "unsolved" | "off";
60
62
  export type CaptchaOutcome = ({
61
63
  solved: true;
62
64
  kind: CaptchaKind;
@@ -67,9 +69,12 @@ export type CaptchaOutcome = ({
67
69
  kind: CaptchaKind | null;
68
70
  vendor: CaptchaVendor | null;
69
71
  reason: string;
72
+ code?: CaptchaFail;
70
73
  }) & {
71
74
  looks?: Look[];
72
75
  };
76
+ /** The fail code; an outcome made without one (a fake, an old row) reads by its kind. */
77
+ export declare const failCode: (o: CaptchaOutcome) => CaptchaFail | null;
73
78
  export interface SolveOptions {
74
79
  hands: Hands;
75
80
  /** Absent: checkboxes only. A list is a panel, the lead first. */
@@ -1,3 +1,5 @@
1
+ /** The fail code; an outcome made without one (a fake, an old row) reads by its kind. */
2
+ export const failCode = (o) => o.solved ? null : (o.code ?? (o.kind ? "unsolved" : "none"));
1
3
  const T = { timeout: 10_000 };
2
4
  /** Where each vendor keeps its parts. */
3
5
  const RECAPTCHA = {
@@ -145,7 +147,13 @@ async function solveRounds(page, o, looks) {
145
147
  let now = await findCaptcha(page);
146
148
  if (!now) {
147
149
  if (!last)
148
- return { solved: false, kind: null, vendor: null, reason: "no captcha on the page" };
150
+ return {
151
+ solved: false,
152
+ kind: null,
153
+ vendor: null,
154
+ reason: "no captcha on the page",
155
+ code: "none",
156
+ };
149
157
  // hCaptcha hides its frame between puzzles: gone counts only if it stays gone.
150
158
  await page.waitForTimeout(o.goneMs ?? 3_000);
151
159
  now = await findCaptcha(page);
@@ -158,6 +166,7 @@ async function solveRounds(page, o, looks) {
158
166
  solved: false,
159
167
  ...now,
160
168
  reason: `a ${now.kind} captcha needs eyes (a model that sees)`,
169
+ code: "no-eyes",
161
170
  };
162
171
  const panel = panelOf(eyes, o.lookMs ?? 20_000, (look) => looks.push({ kind: now.kind, round, ...look }));
163
172
  let done;
@@ -176,10 +185,15 @@ async function solveRounds(page, o, looks) {
176
185
  catch (err) {
177
186
  // A model that cannot see, a part that moved: the person's, with the reason.
178
187
  const why = err instanceof Error ? (err.message.split("\n")[0] ?? "") : String(err);
179
- return { solved: false, ...now, reason: why.slice(0, 160) };
188
+ return { solved: false, ...now, reason: why.slice(0, 160), code: "unsolved" };
180
189
  }
181
190
  if (done === "gave-up")
182
- return { solved: false, ...now, reason: `the eyes could not read the ${now.kind}` };
191
+ return {
192
+ solved: false,
193
+ ...now,
194
+ reason: `the eyes could not read the ${now.kind}`,
195
+ code: "unsolved",
196
+ };
183
197
  if (done === "ticked")
184
198
  return { solved: true, ...now, rounds: round };
185
199
  await page.waitForTimeout(1_000);
@@ -189,6 +203,7 @@ async function solveRounds(page, o, looks) {
189
203
  kind: last?.kind ?? null,
190
204
  vendor: last?.vendor ?? null,
191
205
  reason: `still there after ${rounds} rounds`,
206
+ code: "unsolved",
192
207
  };
193
208
  }
194
209
  function panelOf(eyes, lookMs, record) {