heartcode 0.1.33 → 0.1.36

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.
package/src/settings.html CHANGED
@@ -256,9 +256,9 @@
256
256
  .mrow.flash { animation: flash 1.6s ease-out; }
257
257
  @keyframes flash { from { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); } to { background: none; box-shadow: none; } }
258
258
  .mrow .id { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
259
- .rows > .mrow, .rows > .mwrap { height: 56px; } /* one height: a long list only draws what's in view */
259
+ .rows > .mrow, .rows > .mwrap { height: 40px; } /* one height: a long list only draws what's in view */
260
260
  .mwrap .mrow { height: 100%; }
261
- .mrow .can { display: block; margin-top: 2px; color: var(--muted); font-family: system-ui, sans-serif; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
261
+ .mrow .can { display: inline; margin-left: 12px; color: var(--muted); font-family: var(--sans); font-size: 11.5px; } /* on the name's line: one line a model */
262
262
  .mrow .add { color: var(--accent); font-size: 12.5px; font-weight: 600; white-space: nowrap; opacity: .55; transition: opacity .12s; }
263
263
  .mwrap:hover .mrow .add, .mrow:focus-visible .add { opacity: 1; }
264
264
  .mrow.taken .id { color: var(--muted); }
@@ -370,10 +370,10 @@
370
370
  .mt-top .chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); border-radius: 8px; padding: 1px 3px 1px 9px; margin: 2px 4px 2px 0; color: var(--text); font-size: 12.5px; }
371
371
  .mt-top .chip button { border: 0; background: none; padding: 0 4px; font-size: 12px; color: var(--muted); }
372
372
  .mt-scroll { overflow-x: auto; }
373
- .mt { min-width: 1116px; }
373
+ .mt { min-width: 1080px; }
374
374
  .mt-h input[type=checkbox], .mtable input[type=checkbox] { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); cursor: pointer; }
375
375
  .mtable li.picked { background: var(--brand-soft); }
376
- .mt-rules { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 28px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
376
+ .mt-rules { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
377
377
  .mt-rules .rule { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
378
378
  .mt-rules select { width: auto; height: 32px; padding: 4px 30px 4px 10px; }
379
379
  .mt-rules input { width: 64px; height: 32px; }
@@ -392,8 +392,10 @@
392
392
  .pill .again:hover:not(:disabled) { color: var(--text); }
393
393
  .pill.on { border-color: var(--accent); background: var(--accent-soft); }
394
394
  .pill.on .again { border-left-color: color-mix(in srgb, var(--accent) 40%, transparent); }
395
- .mt-h, .mtable li { display: grid; grid-template-columns: 16px 20px 44px minmax(150px, 3fr) minmax(70px, 1.1fr) 66px 66px 42px 60px 50px 54px 60px minmax(166px, 1.5fr) minmax(120px, 1.3fr) 28px; align-items: center; column-gap: 6px; padding: 8px 16px; }
396
- .mtable .src, .mt-h > :nth-child(13) { padding-left: 12px; } /* room after the right-aligned prices */
395
+ .mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 44px minmax(240px, 1fr) 110px 62px 52px 70px 58px 116px 84px 132px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
396
+ .mt-h button.mid, .mtable .mid { text-align: center; }
397
+ .mt-h > :nth-child(11), .mtable .try { padding-left: 12px; } /* Works?: a little room after the right-aligned price */
398
+ .mtable li .acts { justify-content: flex-start; }
397
399
  .mt-h { border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--faint); padding-top: 10px; padding-bottom: 10px; background: var(--panel2); }
398
400
  .mt-h button { display: inline; border: 0; background: none !important; padding: 0; font: inherit; color: inherit; text-align: left; white-space: nowrap; transform: none !important; }
399
401
  .mt-h button.num { text-align: right; }
@@ -473,6 +475,69 @@
473
475
  .setting .t span { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.45; text-wrap: pretty; }
474
476
  .setting select, .setting input { flex: none; width: 240px; }
475
477
  .settings-col .card.wide { grid-column: 1 / -1; }
478
+ /* a sort being applied: its header spins, the table dims */
479
+ #mt.sorting { opacity: .55; transition: opacity .1s; pointer-events: none; }
480
+ button.sorting::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 6px; vertical-align: -1px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
481
+ .sort-live { color: var(--warn); }
482
+ /* Your models: the header's buttons, the list's settings, the toolbar (sticky), the table */
483
+ .mt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
484
+ /* Your models: the settings (three cells across), the toolbar (sticky), the table */
485
+ .mt-sets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
486
+ .mt-set { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
487
+ .mt-set:first-child { border-left: 0; }
488
+ .mt-setl { font-size: 12px; font-weight: 600; color: var(--muted); }
489
+ .mt-setc { display: flex; align-items: center; gap: 8px; }
490
+ .mt-setc select { flex: 1; width: 100%; min-width: 0; height: 34px; }
491
+ .mt-setc input[type=number] { width: 96px; height: 34px; }
492
+ .mt-setc input.tries { width: 64px; }
493
+ .mt-setc .unit { color: var(--muted); font-size: 13px; }
494
+ .mt-sets + .mt-tools { border-radius: 0; }
495
+ .mt-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 0 18px 12px; }
496
+ .mt-status { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 30px; font-size: 13px; color: var(--muted); }
497
+ .mt-do { display: flex; align-items: center; gap: 8px; flex: none; }
498
+ .mt-hpick .mt-pickbar { grid-column: 3 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
499
+ .mt-hpick { background: var(--brand-soft); }
500
+ .mt-h.mt-hpick .mt-pickbar button { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--panel) !important; color: var(--text); font-size: 12.5px; font-weight: 500; }
501
+ .mt-h.mt-hpick .mt-pickbar button:hover { background: var(--hover) !important; }
502
+ .mt-h.mt-hpick .mt-pickbar button.danger { color: var(--err); }
503
+ .mt-h.mt-hpick .mt-pickbar button.ghost { border-color: transparent; background: transparent !important; color: var(--muted); }
504
+ .mt-h.mt-hpick .mt-pickbar b { margin-right: 4px; }
505
+ .mt-tools { position: sticky; top: 0; z-index: 6; background: var(--panel); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
506
+ .mt-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 18px 10px; }
507
+ .f-search { position: relative; flex: 1 1 0; min-width: 170px; display: block; } /* the room the others leave: one line */
508
+ .f-search .f-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-52%); color: var(--faint); font-size: 16px; pointer-events: none; }
509
+ .mt-filters .f-text { width: 100%; height: 34px; padding-left: 32px; }
510
+ .mt-filters select { height: 34px; width: auto; padding-top: 0; padding-bottom: 0; line-height: 32px; }
511
+ .mt-filters select.on { border-color: var(--accent); background-color: color-mix(in srgb, var(--accent-soft) 50%, var(--input)); }
512
+ .f-togs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
513
+ .mt-status .count b { color: var(--text); }
514
+ .mt-status .chip { display: inline-flex; align-items: center; gap: 2px; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); border-radius: 999px; padding: 2px 4px 2px 10px; color: var(--text); font-size: 12.5px; }
515
+ .mt-status .chip.sort { border-color: var(--line-strong); background: var(--panel2); }
516
+ .mt-status .chip button { border: 0; background: none; padding: 0 5px; font-size: 11px; color: var(--muted); border-radius: 999px; }
517
+ .mt-status .chip button:hover { color: var(--text); background: var(--hover); }
518
+ .mt-tools .mt-outcomes { border-bottom: 0; border-top: 1px solid var(--line); padding: 9px 18px; }
519
+ .mt-hwrap { overflow: hidden; border-top: 1px solid var(--line); }
520
+ .mt-hwrap .mt-h { border-bottom: 0; }
521
+ .mt-outcomes .label { margin-right: 4px; }
522
+ .pill.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
523
+ .mt-tools .job-slot:not(:empty) { border-top: 1px solid var(--line); }
524
+ .mtable .m { display: flex; align-items: center; gap: 6px; min-width: 0; }
525
+ .mtable .m .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
526
+ .mtable .tag { flex: none; font: 600 10.5px var(--sans); padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); background: none; line-height: 1.5; }
527
+ .mtable .tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
528
+ .mtable button.tag:hover { background: var(--hover); }
529
+ .mtable .price { white-space: nowrap; font-size: 12.5px; }
530
+ .mtable .acts { display: flex; justify-content: flex-end; gap: 4px; }
531
+ .mtable li .acts button { padding-left: 8px; padding-right: 8px; background: transparent; border-color: transparent; color: var(--muted); }
532
+ .mtable li .acts button:hover:not(:disabled) { background: var(--hover); border-color: var(--line-strong); color: var(--text); }
533
+ .mtable li .acts button.danger:hover:not(:disabled) { color: var(--err); }
534
+ .f-tog { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px; cursor: pointer; user-select: none; }
535
+ .f-tog:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--panel)); }
536
+ .f-tog input { margin: 0; accent-color: var(--brand); }
537
+ .mt-filters .f-count { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
538
+ .mt-filters.on .f-count { color: var(--text); font-weight: 600; }
539
+ .test-wait { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
540
+ .test-wait input { width: 64px; height: 28px; padding: 2px 8px; font-size: 12.5px; text-align: right; }
476
541
  .ws-url { display: flex; gap: 8px; margin-top: 10px; }
477
542
  .ws-url input { flex: 1; min-width: 0; }
478
543
  .ws-addr { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
@@ -549,6 +614,12 @@
549
614
  nav a.on::before { display: none; } /* a strip of tabs: the highlighted one is enough */
550
615
  nav a .count, .using, .nav-group { display: none; }
551
616
  .theme-btn { top: 10px; right: 12px; }
617
+ .mt-tools { position: static; } /* a phone: too tall to stay in sight, it scrolls with the page */
618
+ .mt-sets { grid-template-columns: minmax(0, 1fr); }
619
+ .mt-set { border-left: 0; border-top: 1px solid var(--line); }
620
+ .mt-set:first-child { border-top: 0; }
621
+ .mt-do { width: 100%; }
622
+ .mt-do button { flex: 1; }
552
623
  main { padding: 20px 16px 60px; }
553
624
  .steps { grid-template-columns: 1fr; }
554
625
  .choices, .choices.three { grid-template-columns: 1fr; }
@@ -609,6 +680,62 @@
609
680
  .opt.tg-off { opacity: .5; }
610
681
  .imp-row .imp-label { font-weight: 500; font-family: var(--mono); font-size: 12.5px; flex: none; }
611
682
  .imp-row .imp-desc { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
683
+
684
+ /* ===== The look: icons, a color for each part, room used (no empty bands) ===== */
685
+ :root {
686
+ --c-blue: #2563eb; --c-violet: #7c3aed; --c-amber: #b45309; --c-teal: #0f766e; --c-pink: #db2777; --c-slate: #475569; --c-gray: #6b7280; --c-green: #15803d; --c-red: #dc2626;
687
+ }
688
+ @media (prefers-color-scheme: dark) { :root:not([data-theme=light]) {
689
+ --c-blue: #60a5fa; --c-violet: #a78bfa; --c-amber: #fbbf24; --c-teal: #2dd4bf; --c-pink: #f472b6; --c-slate: #94a3b8; --c-gray: #9ca3af; --c-green: #4ade80; --c-red: #f87171;
690
+ } }
691
+ :root[data-theme=dark] { --c-blue: #60a5fa; --c-violet: #a78bfa; --c-amber: #fbbf24; --c-teal: #2dd4bf; --c-pink: #f472b6; --c-slate: #94a3b8; --c-gray: #9ca3af; --c-green: #4ade80; --c-red: #f87171; }
692
+ .icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
693
+ .icon svg { width: 100%; height: 100%; display: block; }
694
+ /* a tile: an icon on its color, soft */
695
+ .tile { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 7px; color: var(--tc, var(--c-slate)); background: color-mix(in srgb, var(--tc, var(--c-slate)) 14%, transparent); }
696
+ .tile .icon { width: 15px; height: 15px; }
697
+ .tile.lg { width: 38px; height: 38px; border-radius: 10px; }
698
+ .tile.lg .icon { width: 20px; height: 20px; }
699
+ [data-tone=blue] { --tc: var(--c-blue); } [data-tone=violet] { --tc: var(--c-violet); } [data-tone=amber] { --tc: var(--c-amber); } [data-tone=teal] { --tc: var(--c-teal); }
700
+ [data-tone=pink] { --tc: var(--c-pink); } [data-tone=slate] { --tc: var(--c-slate); } [data-tone=gray] { --tc: var(--c-gray); } [data-tone=green] { --tc: var(--c-green); } [data-tone=red] { --tc: var(--c-red); }
701
+ /* the sidebar: each part with its tile */
702
+ nav a { padding: 6px 10px; }
703
+ nav a .tile { width: 24px; height: 24px; }
704
+ nav a:not(.on) .tile { filter: saturate(.75); }
705
+ nav a.on .tile { background: var(--tc); color: var(--panel); }
706
+ /* the page: less room around it; its title with its tile */
707
+ main { padding-top: 22px; }
708
+ .head { margin-bottom: 16px; align-items: center; }
709
+ .head h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
710
+ .page > .head:first-child { padding-right: 54px; } /* the theme button sits up there */
711
+ .mcp-row { align-items: flex-start; }
712
+ .mcp-row > .tile { margin-top: 2px; }
713
+ .subtabs { margin-bottom: 14px; }
714
+ .card:not(.mt-card):not(.reqs-card):not(.work > .card) { padding: 16px 18px 18px; } /* the ones that set their own (edge to edge) keep it */
715
+ .card > h2:first-child, .card > .card-h, h2[data-ic] { display: flex; align-items: center; gap: 9px; }
716
+ /* buttons: their icon, colored by what they do */
717
+ button .icon { width: 15px; height: 15px; margin-left: -2px; }
718
+ button.small .icon { width: 14px; height: 14px; }
719
+ button .icon.k-save, button .icon.k-add { color: var(--c-green); }
720
+ button.primary .icon { color: inherit; }
721
+ button .icon.k-test { color: var(--c-blue); }
722
+ button .icon.k-del { color: var(--c-red); }
723
+ button .icon.k-refresh { color: var(--c-amber); }
724
+ button .icon.k-edit { color: var(--c-violet); }
725
+ button .icon.k-info { color: var(--c-slate); }
726
+ button:disabled .icon { opacity: .55; }
727
+ /* General: the cards packed in two columns, no gaps under the short ones */
728
+ .settings-col { display: block; columns: 2; column-gap: 16px; }
729
+ .settings-col > .card { break-inside: avoid; display: block; width: 100%; margin: 0 0 16px; }
730
+ .settings-col > .card.wide { column-span: all; }
731
+ @media (max-width: 1280px) { .settings-col { columns: 1; } }
732
+ /* Your models: a row's actions as icon buttons */
733
+ .mtable li .acts .ib { width: 30px; height: 28px; padding: 0; justify-content: center; }
734
+ .mtable li .acts .ib .icon { margin: 0; width: 15px; height: 15px; }
735
+ .mtable li .acts .ib.k-test { color: var(--c-blue); }
736
+ .mtable li .acts .ib.k-info { color: var(--c-slate); }
737
+ .mtable li .acts .ib.k-edit { color: var(--c-violet); }
738
+ .mtable li .acts .ib.k-del { color: var(--c-red); }
612
739
  </style>
613
740
  </head>
614
741
  <body>
@@ -659,7 +786,7 @@
659
786
 
660
787
  <!-- Your models: all at once, sortable -->
661
788
  <section class="page" id="page-models">
662
- <div class="head"><div><h1>Your models</h1><p class="lead">Every model HeartCode can use, and what each can do. Drag a row to reorder, or sort by columns (click more to break ties) and save the order you see.</p></div></div>
789
+ <div class="head"><div><h1>Your models</h1><p class="lead">HeartCode uses #1, and the next one when it fails. Filter, sort or drag, then Save list.</p></div><div class="mt-actions" id="mt-actions"></div></div>
663
790
  <div class="card mt-card" id="mt"></div>
664
791
  </section>
665
792
 
@@ -712,7 +839,7 @@
712
839
  <label for="l-days"><b>Keep logs for</b></label>
713
840
  <input type="number" id="l-days" min="1" max="3650" step="1" value="30">
714
841
  <span>days</span>
715
- <span class="muted">Older ones (both kinds) are deleted when HeartCode starts, and right away when you change this. 30 days unless you change it.</span>
842
+ <span class="muted">Older ones (both kinds) are deleted when HeartCode starts, and right away when you change this. 3 days unless you change it.</span>
716
843
  </div>
717
844
  </div>
718
845
  <div class="card reqs-card">
@@ -761,7 +888,7 @@
761
888
  </div>
762
889
  <div class="card">
763
890
  <h2>Voice input</h2>
764
- <p class="sub">Press Space in an empty input box (or type /voice), talk, and Enter. Your words land in the box.</p>
891
+ <p class="sub">Press Space in an empty input box (or type /voice) and talk: your words show in the box as you speak, and Enter sends them. Esc cancels.</p>
765
892
  <div class="setting">
766
893
  <label class="t" for="v-src"><b>Transcribe with</b><span id="v-src-about"></span></label>
767
894
  <select id="v-src"></select>
@@ -975,6 +1102,115 @@ const h = (tag, props = {}, ...kids) => {
975
1102
  el.append(...kids.flat(Infinity).filter((x) => x != null && x !== false))
976
1103
  return el
977
1104
  }
1105
+ // Icons: simple line drawings (24×24, drawn with the text's color), no files or fonts to load.
1106
+ const ICON = {
1107
+ list: 'M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01',
1108
+ sliders: 'M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6',
1109
+ bell: 'M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0',
1110
+ sparkles: 'M12 3l1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2zM19 3v4M17 5h4',
1111
+ plug: 'M9 2v6M15 2v6M6 8h12v4a6 6 0 0 1-12 0zM12 18v4',
1112
+ message: 'M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2zM8 9h8M8 13h5',
1113
+ wrench: 'M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18v3h3l6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-.6-.6-2.4z',
1114
+ save: 'M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2zM17 21v-8H7v8M7 3v5h8',
1115
+ play: 'M7 4l13 8-13 8z',
1116
+ refresh: 'M21 12a9 9 0 1 1-2.6-6.4L21 8M21 3v5h-5',
1117
+ plus: 'M12 5v14M5 12h14',
1118
+ trash: 'M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6',
1119
+ pencil: 'M17 3l4 4L7 21H3v-4z',
1120
+ search: 'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM21 21l-4.3-4.3',
1121
+ x: 'M18 6L6 18M6 6l12 12',
1122
+ check: 'M20 6L9 17l-5-5',
1123
+ bars: 'M4 20V10M10 20V4M16 20v-7M22 20H2',
1124
+ download: 'M12 3v12M7 10l5 5 5-5M5 21h14',
1125
+ eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z',
1126
+ send: 'M22 2L11 13M22 2l-7 20-4-9-9-4z',
1127
+ shield: 'M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z',
1128
+ palette: 'M12 3a9 9 0 1 0 0 18c1 0 1.5-.8 1.5-1.5 0-1.5 1-2 2.5-2H18a3 3 0 0 0 3-3c0-5-4-8.5-9-8.5zM7.5 11h.01M10 7h.01M15 7h.01',
1129
+ toggle: 'M7 7h10a5 5 0 0 1 0 10H7A5 5 0 0 1 7 7zM7 9.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5z',
1130
+ cpu: 'M7 7h10v10H7zM10 10h4v4h-4zM9 2v3M15 2v3M9 19v3M15 19v3M2 9h3M2 15h3M19 9h3M19 15h3',
1131
+ mic: 'M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3zM19 11a7 7 0 0 1-14 0M12 18v4',
1132
+ globe: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zM2 12h20M12 2c3 3 4 6.5 4 10s-1 7-4 10c-3-3-4-6.5-4-10s1-7 4-10z',
1133
+ server: 'M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01',
1134
+ file: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M8 13h8M8 17h5',
1135
+ activity: 'M22 12h-4l-3 9L9 3l-3 9H2',
1136
+ link: 'M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1-1',
1137
+ layout: 'M3 3h18v18H3zM3 15h18M8 18h.01',
1138
+ stop: 'M6 6h12v12H6z',
1139
+ swap: 'M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7',
1140
+ filter: 'M3 4h18l-7 8v6l-4 2v-8z',
1141
+ key: 'M15 7a4 4 0 1 1-3.9 4.9L3 20v1h3l1-1v-2h2v-2h2l1.1-1.1A4 4 0 0 1 15 7zM16 8h.01',
1142
+ clock: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zM12 6v6l4 2',
1143
+ tool: 'M4 20l6-6M14 4l6 6-8 8-6-6zM15 9l-6 6',
1144
+ folder: 'M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z',
1145
+ terminal: 'M4 17l6-5-6-5M12 19h8',
1146
+ upload: 'M12 21V9M7 14l5-5 5 5M5 3h14',
1147
+ arrow: 'M5 12h14M13 6l6 6-6 6',
1148
+ }
1149
+ const ic = (name, cls = '') => {
1150
+ const el = document.createElement('span')
1151
+ el.className = `icon ${cls}`.trim()
1152
+ el.setAttribute('aria-hidden', 'true')
1153
+ el.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="${ICON[name] ?? ICON.check}"/></svg>`
1154
+ return el
1155
+ }
1156
+ const tile = (name, tone, big = false) => {
1157
+ const t = h('span', { className: `tile${big ? ' lg' : ''}` }, ic(name))
1158
+ t.dataset.tone = tone
1159
+ return t
1160
+ }
1161
+ // each part of the page: its icon and its color (the sidebar, the page's title)
1162
+ const PART = { models: ['list', 'blue'], providers: ['server', 'blue'], general: ['sliders', 'slate'], statusbar: ['layout', 'slate'], notify: ['bell', 'amber'], skills: ['sparkles', 'violet'], mcp: ['plug', 'teal'], prompts: ['message', 'pink'], logging: ['wrench', 'gray'], files: ['folder', 'gray'] }
1163
+ // a button's icon, by what it says: [words it starts with, icon, kind (its color)]
1164
+ const BUTTON_ICONS = [
1165
+ [/^save|^keep only/i, 'save', 'k-save'], [/^\+|^add|^new /i, 'plus', 'k-add'], [/^install/i, 'download', 'k-save'], [/^import/i, 'download', 'k-info'],
1166
+ [/^test|^send a test/i, 'play', 'k-test'], [/^request|^show the raw/i, 'eye', 'k-info'], [/^edit|^set up/i, 'pencil', 'k-edit'],
1167
+ [/^remove|^delete|^disconnect/i, 'trash', 'k-del'], [/^stop/i, 'stop', 'k-del'], [/^refresh|^retry|^get from models|^look it up|^reset/i, 'refresh', 'k-refresh'],
1168
+ [/^provider ranking/i, 'bars', 'k-info'], [/^clear|^select none/i, 'x', 'k-info'], [/^invert/i, 'swap', 'k-info'], [/^connect|^sign in/i, 'link', 'k-test'],
1169
+ [/^your models/i, 'list', 'k-info'], [/^collapse|^expand/i, 'list', 'k-info'], [/^turn off/i, 'x', 'k-del'],
1170
+ ]
1171
+ // card titles: their icon and color
1172
+ const TITLE_ICONS = [
1173
+ [/^permissions/i, 'shield', 'green'], [/^terminal colors/i, 'palette', 'pink'], [/^behavior/i, 'toggle', 'blue'], [/^model$/i, 'cpu', 'violet'], [/^voice/i, 'mic', 'amber'],
1174
+ [/^external tools/i, 'tool', 'slate'], [/^web search/i, 'globe', 'teal'], [/^telegram/i, 'send', 'blue'], [/^when to send/i, 'bell', 'amber'], [/^servers/i, 'server', 'teal'],
1175
+ [/^install from/i, 'download', 'violet'], [/^the run's log/i, 'file', 'gray'], [/^requests logged/i, 'activity', 'blue'], [/^requests$/i, 'activity', 'blue'], [/^lines/i, 'layout', 'slate'],
1176
+ [/^items/i, 'list', 'slate'], [/^show the status bar/i, 'layout', 'slate'],
1177
+ ]
1178
+ // Icons put where they belong, as things are drawn (one pass: a button or title that has one is left alone)
1179
+ function decorate(root = document.body) {
1180
+ for (const b of root.querySelectorAll('button:not([data-ic])')) {
1181
+ if (b.closest('.acts, .mt-h:not(.mt-hpick), .chip, .pill, .seg, .subtabs, .theme-btn, .f-tog, .sw, nav, [data-no-ic]') || b.querySelector('.icon')) continue
1182
+ const text = b.textContent.trim()
1183
+ const hit = BUTTON_ICONS.find(([re]) => re.test(text))
1184
+ if (!hit || text.length < 3) continue
1185
+ b.dataset.ic = '1'
1186
+ if (/^\+\s*/.test(text)) b.textContent = text.replace(/^\+\s*/, '')
1187
+ b.prepend(ic(hit[1], hit[2]))
1188
+ }
1189
+ for (const t of root.querySelectorAll('.card h2:first-child:not([data-ic]), .card h2:first-of-type:not([data-ic])')) {
1190
+ const hit = TITLE_ICONS.find(([re]) => re.test(t.textContent.trim()))
1191
+ if (!hit) continue
1192
+ t.dataset.ic = '1'
1193
+ t.prepend(tile(hit[1], hit[2]))
1194
+ }
1195
+ }
1196
+ let decorating = false
1197
+ new MutationObserver(() => {
1198
+ if (decorating) return
1199
+ decorating = true
1200
+ queueMicrotask(() => ((decorating = false), decorate()))
1201
+ }).observe(document.documentElement, { childList: true, subtree: true, characterData: true })
1202
+ // the sidebar's parts and the pages' titles: their tiles
1203
+ addEventListener('DOMContentLoaded', () => {
1204
+ for (const a of document.querySelectorAll('nav a[data-page]')) {
1205
+ const [name, tone] = PART[a.dataset.page] ?? ['list', 'slate']
1206
+ a.querySelector('.ic')?.replaceWith(tile(name, tone))
1207
+ }
1208
+ for (const sec of document.querySelectorAll('section.page')) {
1209
+ const [name, tone] = PART[sec.id.replace(/^page-/, '')] ?? ['list', 'slate']
1210
+ sec.querySelector('.head h1')?.prepend(tile(name, tone, true))
1211
+ }
1212
+ decorate()
1213
+ })
978
1214
  // an element's content, without the null/false parts (left out on purpose)
979
1215
  const put = (el, ...kids) => el.replaceChildren(...kids.flat(Infinity).filter((x) => x != null && x !== false))
980
1216
  let S = null
@@ -998,6 +1234,7 @@ function job(id, state) {
998
1234
  }
999
1235
  // a panel's place for them: made empty, filled now and kept up to date by job()
1000
1236
  const jobSlot = (where) => fillSlot(h('div', { className: 'job-slot', 'data-where': where }))
1237
+ let tableJobs = null // the Your models table's (made once, put back in each time the table is drawn)
1001
1238
  function fillSlot(slot) {
1002
1239
  const mine = [...JOBS.values()].filter((j) => j.where.includes(slot.dataset.where))
1003
1240
  for (const el of [...slot.children]) if (!mine.some((j) => j.id === el.dataset.job)) el.remove()
@@ -1017,7 +1254,13 @@ function fillSlot(slot) {
1017
1254
  stop.hidden = !j.stop
1018
1255
  stop.textContent = j.stopping ? 'Stopping…' : 'Stop'
1019
1256
  stop.disabled = Boolean(j.stopping)
1020
- stop.onclick = () => (j.stop(), job(j.id, { stopping: true }))
1257
+ // at the press, not the release: a stop that's wanted now (and the keyboard's Enter/Space still click)
1258
+ const halt = (e) => {
1259
+ e.preventDefault()
1260
+ if (!JOBS.get(j.id)?.stopping) j.stop(), job(j.id, { stopping: true })
1261
+ }
1262
+ stop.onpointerdown = halt
1263
+ stop.onclick = halt
1021
1264
  el.querySelector('.bar').classList.toggle('unknown', !known)
1022
1265
  el.querySelector('.bar i').style.width = known ? `${Math.round((100 * (j.done ?? 0)) / j.total)}%` : ''
1023
1266
  }
@@ -1363,7 +1606,8 @@ $('dev-all').onclick = async () => {
1363
1606
  $('m-search').oninput = (e) => ((modelQuery = e.target.value), (searchOpen = true), S && drawProviders(S), applyFolds())
1364
1607
  // A model's tooltip: its full name and what's known about it (from the provider, HeartCode's price
1365
1608
  // list and its own test), and what a click does. Shown on hover and on keyboard focus.
1366
- const kTok = (n) => (n >= 1e6 ? `${Math.round(n / 1e5) / 10}M` : n >= 1000 ? `${Math.round(n / 1000)}k` : String(n))
1609
+ // a token count, short: 1M, 1.05M (two decimals, not rounded up to 1.1M), 131k
1610
+ const kTok = (n) => (n >= 1e6 ? `${Number((n / 1e6).toFixed(2))}M` : n >= 1000 ? `${Math.round(n / 1000)}k` : String(n))
1367
1611
  const usd = (x) => (x === 0 ? 'free' : `$${x < 0.01 ? x.toFixed(4) : x < 1 ? x.toFixed(3).replace(/0$/, '') : x.toFixed(2)}`)
1368
1612
  // where what a model can do comes from (the Your models table)
1369
1613
  const FROM = { 'models.dev': 'from models.dev', you: 'set by you', tested: 'tested' }
@@ -1389,7 +1633,7 @@ const MEANS = {
1389
1633
  503: '503: the model or provider is unavailable now',
1390
1634
  504: '504: the provider timed out',
1391
1635
  empty: 'it answered, but with no text at all',
1392
- 'no answer': 'no answer within 90 seconds',
1636
+ 'no answer': 'no answer within the test timeout (next to Test all)',
1393
1637
  failed: 'it failed without a status code (a lost connection, an unreadable reply…)',
1394
1638
  }
1395
1639
  // What a test came to, in a word: works, its status code (402, 429…), empty, no answer or failed;
@@ -1403,16 +1647,37 @@ function triedCell(t) {
1403
1647
  : r.going ? ['going', 'testing…', 'sending it a short message']
1404
1648
  : r.ok ? ['ok', `✓ ${(r.ms / 1000).toFixed(1)}s`, `works: it answered "${r.reply}"${secs}`]
1405
1649
  : ['bad', `✗ ${outcome(r)}`, `doesn't work: ${r.error}${secs}`] // the reason on hover
1406
- return h('div', { className: 'try ' + cls },
1407
- h('span', { className: 'msg', textContent: text, title: about }),
1408
- h('button', { className: 'small', textContent: 'Test', disabled: Boolean(r?.going), title: 'send it a short message to see that it really answers', 'aria-label': `test ${t.model}`, onclick: () => tryModel(t) }))
1650
+ return h('div', { className: 'try ' + cls }, h('span', { className: 'msg', textContent: text, title: about }))
1409
1651
  }
1410
1652
  function showTried(t) {
1411
- document.querySelector(`#mt li[data-key="${CSS.escape(keyOf(t))}"] .try`)?.replaceWith(triedCell(t))
1653
+ const li = document.querySelector(`#mt li[data-key="${CSS.escape(keyOf(t))}"]`)
1654
+ li?.querySelector('.try')?.replaceWith(triedCell(t))
1655
+ const btn = li?.querySelector('.row-test')
1656
+ if (btn) (btn.disabled = Boolean(TRIES[keyOf(t)]?.going)), btn.replaceChildren(ic(btn.disabled ? 'clock' : 'play'))
1412
1657
  if (!TRIES[keyOf(t)]?.going) mineSoon() // a result: the counts by result (and a sort by it) change
1413
1658
  }
1414
1659
  let mineFrame = 0
1415
- const mineSoon = () => (mineFrame ||= requestAnimationFrame(() => ((mineFrame = 0), S && drawMine(S))))
1660
+ // While tests run, results come many a second: the table is drawn again at most every 400 ms (drawn
1661
+ // every frame, its buttons were replaced between a click's press and release, and the click was lost)
1662
+ // And never while the mouse button is down: a click's press and release then land on the same button.
1663
+ let mineLast = 0
1664
+ let pressed = false
1665
+ let drawAfterPress = false
1666
+ addEventListener('pointerdown', () => (pressed = true), true)
1667
+ for (const ev of ['pointerup', 'pointercancel']) addEventListener(ev, () => {
1668
+ pressed = false
1669
+ if (drawAfterPress) (drawAfterPress = false), setTimeout(mineSoon, 0) // after the click it finishes
1670
+ }, true)
1671
+ const mineSoon = () => {
1672
+ if (mineFrame) return
1673
+ const later = testingAll ? Math.max(0, mineLast + 400 - Date.now()) : 0
1674
+ mineFrame = setTimeout(() => requestAnimationFrame(() => {
1675
+ mineFrame = 0
1676
+ if (pressed) return (drawAfterPress = true) // drawn once it's let go
1677
+ mineLast = Date.now()
1678
+ S && drawMine(S)
1679
+ }), later)
1680
+ }
1416
1681
  // Tests run on the settings server (closing this page doesn't stop them; their results are kept
1417
1682
  // there for next time): this page asks for them and shows what the server says as it goes.
1418
1683
  async function tryModel(t) {
@@ -1800,7 +2065,7 @@ async function clearAdded(p) {
1800
2065
  if (inList.length && !(await saveOrder(S.order.filter((t) => !inList.includes(t))))) return
1801
2066
  act('/api/provider/added', { name: p.name, all: true }, `${p.name}: the models you added are forgotten`)
1802
2067
  }
1803
- const CAT_ROW = 56 // a model's row on the left: its name, and what it can do under it
2068
+ const CAT_ROW = 40 // a model's row: its name, and what it can do beside it
1804
2069
  // The models ticked (provider → Set of ids): kept while you search, so ones ticked for one search
1805
2070
  // and the next are added (or taken off) together. SHOWN: each provider's models shown now (the
1806
2071
  // search's matches).
@@ -1924,18 +2189,25 @@ function buildCatalog(s) {
1924
2189
  // --- Your models page: the list as a table; sorted by several columns at once (each a tie-break
1925
2190
  // for the ones before it), the sort kept in this browser ---
1926
2191
  const can = (t) => ({ tools: t.tested ? t.tested.mode === 'tools' : t.known?.tools !== false, thinking: Boolean(t.tested ? t.tested.thinking : t.known?.thinking), images: Boolean(t.tested ? t.tested.vision : t.known?.images) })
1927
- // how: text (A to Z first), cheap (lowest first), else most first
2192
+ // Every column sorts by the value it shows: up (↑) smallest first, down (↓) largest first. first: the
2193
+ // direction of the first click (the useful one). get: the value; null when there's none (no price, no
2194
+ // context, no time because it failed or wasn't tested): last, either way; missing: their order then.
2195
+ // words: what each direction means, for the "Sorted by" line.
1928
2196
  const COLS = {
1929
- model: { label: 'Model', how: 'text', get: (t) => t.model },
1930
- provider: { label: 'Provider', how: 'rank', get: (t) => RANKED.get(t.provider) }, // by your ranking of the providers
1931
- context: { label: 'Context', get: (t) => t.tested?.context ?? t.known?.context ?? 0 },
1932
- abilities: { label: 'Abilities', get: (t) => Object.values(can(t)).filter(Boolean).length },
1933
- tools: { label: 'Tools', get: (t) => can(t).tools },
1934
- thinking: { label: 'Thinking', get: (t) => can(t).thinking },
1935
- images: { label: 'Images', get: (t) => can(t).images },
1936
- input: { label: 'In $/M', how: 'cheap', get: (t) => t.price?.input ?? null },
1937
- output: { label: 'Out $/M', how: 'cheap', get: (t) => t.price?.output ?? null },
1938
- works: { label: 'Works?', get: (t) => { const r = TRIES[keyOf(t)]; return !r || r.going ? 1 : r.ok ? 2 : 0 } }, // tested and working first; not tested; not working
2197
+ model: { label: 'Model', first: 'up', get: (t) => t.model, words: ['A→Z', 'Z→A'] },
2198
+ // a provider's priority: your ranking's first is the highest
2199
+ provider: { label: 'Provider', first: 'down', get: (t) => -(RANKED.get(t.provider) ?? 1e6), words: ['your ranking, reversed', 'your ranking'] },
2200
+ context: { label: 'Context', first: 'down', get: (t) => t.tested?.context ?? t.known?.context ?? null, words: ['smallest first', 'biggest first'] },
2201
+ abilities: { label: 'Abilities', first: 'down', get: (t) => Object.values(can(t)).filter(Boolean).length, words: ['fewest first', 'most first'] },
2202
+ tools: { label: 'Tools', first: 'down', get: (t) => can(t).tools, words: ['without first', 'with first'] },
2203
+ thinking: { label: 'Thinking', first: 'down', get: (t) => can(t).thinking, words: ['without first', 'with first'] },
2204
+ images: { label: 'Images', first: 'down', get: (t) => can(t).images, words: ['without first', 'with first'] },
2205
+ input: { label: 'In $/M', first: 'up', get: (t) => t.price?.input ?? null, words: ['cheapest first', 'priciest first'] },
2206
+ output: { label: 'Out $/M', first: 'up', get: (t) => t.price?.output ?? null, words: ['cheapest first', 'priciest first'] },
2207
+ // in and out together, per million tokens
2208
+ price: { label: 'Price $/M', first: 'up', get: (t) => (t.price?.input == null && t.price?.output == null ? null : (t.price.input ?? 0) + (t.price.output ?? 0)), words: ['cheapest first', 'priciest first'] },
2209
+ // its test's time (seconds, as shown); failed or not tested: no time, at the end (not tested before failed)
2210
+ works: { label: 'Works?', first: 'up', get: (t) => { const r = TRIES[keyOf(t)]; return r?.ok && !r.going ? r.ms ?? 0 : null }, missing: (t) => { const r = TRIES[keyOf(t)]; return !r || r.going ? 0 : 1 }, words: ['fastest first', 'slowest first'] },
1939
2211
  }
1940
2212
  let SORT = []
1941
2213
  // your ranking of the providers, best first (kept: savePref); a provider not ranked yet comes after, A to Z
@@ -1966,20 +2238,28 @@ $('pr-save').onclick = () => {
1966
2238
  RANK = [...list, ...RANK.filter((n) => !list.includes(n))] // providers not in your list now keep their place for later
1967
2239
  savePref('rank', RANK)
1968
2240
  $('pr').close()
1969
- setSort(SORT.some((x) => x.key === 'provider') ? SORT : [{ key: 'provider', dir: 'up' }, ...SORT]) // sorted by it now
2241
+ setSort(SORT.some((x) => x.key === 'provider') ? SORT : [{ key: 'provider', dir: 'down' }, ...SORT]) // sorted by it now
1970
2242
  }
1971
- const firstDir = (key) => (COLS[key].how ? 'up' : 'down') // up: A to Z, low to high
2243
+ const firstDir = (key) => COLS[key].first // up: A to Z, low to high
1972
2244
  function setSort(next) {
1973
2245
  SORT = next
1974
- savePref('sort', SORT)
2246
+ savePref('sorts', SORT)
1975
2247
  drawMine(S)
1976
2248
  }
1977
- // a column's header: first click adds it (after those already sorted by), the second flips it, the third drops it
1978
- function clickSort(key) {
2249
+ // A column's header: the first click adds it (after the ones already sorted by, to break their ties),
2250
+ // the second flips it, the third drops it. Until the new order is drawn, the header spins and the table
2251
+ // dims (the next frame: the click shows at once).
2252
+ function clickSort(key, btn) {
1979
2253
  const at = SORT.find((x) => x.key === key)
1980
- if (!at) return setSort([...SORT, { key, dir: firstDir(key) }])
1981
- if (at.dir === firstDir(key)) return setSort(SORT.map((x) => (x === at ? { key, dir: at.dir === 'up' ? 'down' : 'up' } : x)))
1982
- setSort(SORT.filter((x) => x !== at))
2254
+ const next = !at ? [...SORT, { key, dir: firstDir(key) }]
2255
+ : at.dir === firstDir(key) ? SORT.map((x) => (x === at ? { key, dir: at.dir === 'up' ? 'down' : 'up' } : x))
2256
+ : SORT.filter((x) => x !== at)
2257
+ btn?.classList.add('sorting')
2258
+ $('mt')?.classList.add('sorting')
2259
+ requestAnimationFrame(() => setTimeout(() => {
2260
+ setSort(next)
2261
+ $('mt')?.classList.remove('sorting')
2262
+ }, 0))
1983
2263
  }
1984
2264
  let RANKED = new Map() // provider → its place in the ranking, for one sort
1985
2265
  function sorted(order) {
@@ -1987,63 +2267,213 @@ function sorted(order) {
1987
2267
  const cmp = (a, b, { key, dir }) => {
1988
2268
  let x = COLS[key].get(a)
1989
2269
  let y = COLS[key].get(b)
2270
+ if (x == null && y == null) return (COLS[key].missing?.(a) ?? 0) - (COLS[key].missing?.(b) ?? 0)
1990
2271
  if (x === y) return 0
1991
- if (x == null) return 1 // unknown (no price): last, either way
2272
+ if (x == null) return 1 // none (no price, no time): last, either way
1992
2273
  if (y == null) return -1
1993
2274
  const r = typeof x === 'string' ? byName(x, y) : Number(x) - Number(y)
1994
2275
  return dir === 'up' ? r : -r
1995
2276
  }
1996
2277
  return order.map((t, i) => ({ t, i })).sort((a, b) => SORT.reduce((r, s) => r || cmp(a.t, b.t, s), 0) || a.i - b.i).map((x) => x.t)
1997
2278
  }
1998
- const dirText = (key, dir) => (key === 'provider' ? (dir === 'up' ? 'your ranking' : 'your ranking, reversed') : key === 'works' ? (dir === 'down' ? 'working first' : 'not working first') : COLS[key].how === 'text' ? (dir === 'up' ? 'A→Z' : 'Z→A') : COLS[key].how === 'cheap' ? (dir === 'up' ? 'cheapest first' : 'priciest first') : dir === 'down' ? 'most first' : 'least first')
2279
+ const dirText = (key, dir) => COLS[key].words[dir === 'up' ? 0 : 1] + (key === 'works' ? ' (then not tested, then not working)' : '')
2280
+ // Filters on the Your models page: which models are shown (and tested by "Test N shown", counted,
2281
+ // sorted, selected by "select all", saved first by Save list). Combined: a model shows when it passes
2282
+ // all of them. Kept with the page's choices.
2283
+ const NO_FILTER = { text: '', provider: '', works: '', context: 0, tools: false, thinking: false, images: false, free: false }
2284
+ let FILTER = { ...NO_FILTER }
2285
+ let filtersLoaded = false
2286
+ const filtering = () => Object.keys(NO_FILTER).some((k) => FILTER[k] !== NO_FILTER[k])
2287
+ function passes(t, skip) {
2288
+ const f = FILTER
2289
+ if (f.text) {
2290
+ const hay = `${t.model} ${t.provider}`.toLowerCase()
2291
+ if (!f.text.toLowerCase().split(/\s+/).filter(Boolean).every((w) => hay.includes(w))) return false
2292
+ }
2293
+ if (f.provider && t.provider !== f.provider) return false
2294
+ if (f.works && skip !== 'works') {
2295
+ const r = TRIES[keyOf(t)]
2296
+ const tested = r && !r.going
2297
+ if (f.works === 'works' ? !(tested && r.ok) : f.works === 'fails' ? !(tested && !r.ok) : f.works === 'untested' ? tested : outcome(r) !== f.works) return false
2298
+ }
2299
+ if (f.context && !((COLS.context.get(t) ?? 0) >= f.context)) return false
2300
+ const c = can(t)
2301
+ if ((f.tools && !c.tools) || (f.thinking && !c.thinking) || (f.images && !c.images)) return false
2302
+ if (f.free && !(t.price?.input === 0 && t.price?.output === 0)) return false
2303
+ return true
2304
+ }
2305
+ const setFilter = (change) => {
2306
+ FILTER = { ...FILTER, ...change }
2307
+ if ('text' in change && filterBar) filterBar.querySelector('.f-text').value = FILTER.text
2308
+ savePref('filters', FILTER)
2309
+ drawMine(S)
2310
+ }
2311
+ const RESULT_NAME = (w) => (w === 'works' ? '✓ works' : w === 'fails' ? "✗ doesn't work" : w === 'untested' ? 'not tested' : `✗ ${w}`)
2312
+ const CONTEXTS = [[0, 'Any context'], [32_000, '32k+'], [128_000, '128k+'], [200_000, '200k+'], [1_000_000, '1M+']]
2313
+ // the active filters, as chips to take off one by one
2314
+ const filterChips = () => [
2315
+ FILTER.text && [`“${FILTER.text}”`, { text: '' }],
2316
+ FILTER.provider && [`Provider: ${FILTER.provider}`, { provider: '' }],
2317
+ FILTER.works && [`Result: ${RESULT_NAME(FILTER.works)}`, { works: '' }],
2318
+ FILTER.context && [`Context ${CONTEXTS.find(([v]) => v === FILTER.context)?.[1] ?? FILTER.context}`, { context: 0 }],
2319
+ FILTER.tools && ['Tools', { tools: false }],
2320
+ FILTER.thinking && ['Thinking', { thinking: false }],
2321
+ FILTER.images && ['Images', { images: false }],
2322
+ FILTER.free && ['Free', { free: false }],
2323
+ ].filter(Boolean)
2324
+ const clearView = () => {
2325
+ SORT = []
2326
+ savePref('sorts', SORT)
2327
+ setFilter({ ...NO_FILTER })
2328
+ }
2329
+ // The filter controls: made once (typing in the search isn't interrupted by the table being drawn
2330
+ // again), brought up to date each time
2331
+ let filterBar = null
2332
+ function filterBarOf(order, counts = {}) {
2333
+ if (!filterBar) {
2334
+ let typing = 0
2335
+ const toggle = (key, label, about) => h('label', { className: 'f-tog', title: about }, h('input', { type: 'checkbox', 'data-f': key, onchange: (e) => setFilter({ [key]: e.target.checked }) }), label)
2336
+ filterBar = h('div', { className: 'mt-filters' },
2337
+ h('label', { className: 'f-search' },
2338
+ h('span', { className: 'f-icon', 'aria-hidden': 'true', textContent: '⌕' }),
2339
+ h('input', { type: 'search', className: 'f-text', placeholder: 'Search models', 'aria-label': 'Search models and providers', oninput: (e) => (clearTimeout(typing), (typing = setTimeout(() => ((FILTER = { ...FILTER, text: e.target.value.trim() }), savePref('filters', FILTER), drawMine(S)), 150))) })),
2340
+ h('select', { className: 'f-provider', 'aria-label': 'Filter by provider', onchange: (e) => setFilter({ provider: e.target.value }) }),
2341
+ h('select', { className: 'f-works', 'aria-label': 'Filter by test result', onchange: (e) => setFilter({ works: e.target.value }) }),
2342
+ h('select', { className: 'f-context', 'aria-label': 'Filter by context window', onchange: (e) => setFilter({ context: Number(e.target.value) }) },
2343
+ CONTEXTS.map(([v, l]) => h('option', { value: v, textContent: v ? `Context ${l}` : l }))),
2344
+ h('span', { className: 'f-togs' },
2345
+ toggle('tools', 'Tools', 'only models that call tools'),
2346
+ toggle('thinking', 'Thinking', 'only models that think'),
2347
+ toggle('images', 'Images', 'only models that see images'),
2348
+ toggle('free', 'Free', 'only models that cost nothing, in and out')))
2349
+ }
2350
+ const bar = filterBar
2351
+ const focused = (el) => document.activeElement === el
2352
+ const providers = [...new Set(order.map((t) => t.provider))].sort(byName)
2353
+ const results = [...new Set(order.map((t) => outcome(TRIES[keyOf(t)])).filter((o) => o && o !== 'works'))].sort(byName)
2354
+ const fill = (sel, opts, value) => {
2355
+ const sig = JSON.stringify(opts)
2356
+ if (sel.dataset.sig !== sig && !focused(sel)) (sel.dataset.sig = sig), put(sel, opts.map(([v, l]) => h('option', { value: v, textContent: l })))
2357
+ if (!focused(sel)) sel.value = String(value)
2358
+ }
2359
+ fill(bar.querySelector('.f-provider'), [['', 'All providers'], ...providers.map((p) => [p, p])], FILTER.provider)
2360
+ const c = (k) => (counts[k] ? ` (${counts[k].toLocaleString()})` : ' (0)')
2361
+ fill(bar.querySelector('.f-works'), [['', 'Any result'], ['works', `✓ Works${c('works')}`], ['fails', `✗ Doesn't work${c('fails')}`], ['untested', `Not tested${c('untested')}`], ...results.map((o) => [o, ` ✗ ${o}${c(o)}`])], FILTER.works)
2362
+ if (!focused(bar.querySelector('.f-context'))) bar.querySelector('.f-context').value = String(FILTER.context)
2363
+ const text = bar.querySelector('.f-text')
2364
+ if (!focused(text) && text.value.trim() !== FILTER.text) text.value = FILTER.text
2365
+ for (const box of bar.querySelectorAll('input[data-f]')) box.checked = Boolean(FILTER[box.dataset.f])
2366
+ for (const sel of bar.querySelectorAll('select')) sel.classList.toggle('on', Boolean(FILTER[{ 'f-provider': 'provider', 'f-works': 'works', 'f-context': 'context' }[sel.className.split(' ')[0]]]))
2367
+ return bar
2368
+ }
2369
+
1999
2370
  // The models ticked on the Your models page ("provider/model"), to remove several at once; the last
2000
2371
  // one ticked, so a Shift+click ticks the ones between
2001
2372
  const PICKED = new Set()
2002
2373
  let lastPicked = null
2374
+
2003
2375
  function drawMine(s) {
2004
2376
  const order = shownOrder() // a provider switched off: its models aren't shown (nor tested, sorted, ranked)
2005
2377
  $('n-mine').textContent = order.length || ''
2006
- const view = sorted(order)
2378
+ const shown = filtering() ? order.filter((t) => passes(t)) : order
2379
+ const view = sorted(shown)
2380
+ const filtered = shown.length !== order.length
2007
2381
  for (const k of PICKED) if (placeOf(...k.split(/\/(.*)/s)) === undefined) PICKED.delete(k) // gone from the list
2008
- const removePicked = () => {
2009
- const rest = order.filter((t) => !PICKED.has(keyOf(t)))
2010
- const n = order.length - rest.length
2011
- if (!confirm(`Take ${n} model${n === 1 ? '' : 's'} off your list?${!rest.length ? ' None is left then: HeartCode has no model to use until you choose one.' : rest[0] !== order[0] ? ` HeartCode then uses ${rest[0].provider} · ${rest[0].model}.` : ''} (They stay under their providers.)`)) return
2012
- PICKED.clear()
2013
- saveOrder(withOff(rest), `${n} removed${rest.length ? '' : ': no model chosen now'}`)
2014
- }
2015
- const all = view.length > 0 && view.every((t) => PICKED.has(keyOf(t)))
2016
- // the tests' results, by outcome: a click selects those models (again: unselects them)
2017
- const outcomes = Map.groupBy(order.filter((t) => outcome(TRIES[keyOf(t)])), (t) => outcome(TRIES[keyOf(t)]))
2018
- const byOutcome = [...outcomes].sort(([a, x], [b, y]) => (b === 'works') - (a === 'works') || y.length - x.length).map(([what, models]) => {
2019
- const on = models.every((t) => PICKED.has(keyOf(t)))
2020
- const n = models.length
2021
- return h('span', { className: 'pill' + (what === 'works' ? ' ok' : ' bad') + (on ? ' on' : '') },
2022
- h('button', { type: 'button', className: 'pick', title: `${MEANS[what] ?? `the provider answered ${what}`}\n${on ? 'Unselect' : 'Select'} the ${n} model${n === 1 ? '' : 's'}`, onclick: () => (models.forEach((t) => (on ? PICKED.delete(keyOf(t)) : PICKED.add(keyOf(t)))), drawMine(S)) },
2023
- h('span', { className: 'what', textContent: what === 'works' ? '✓ works' : `✗ ${what}` }), h('span', { className: 'n', textContent: n.toLocaleString() })),
2024
- what === 'works' ? null : h('button', { type: 'button', className: 'again', textContent: '↻', title: `Test these ${n} again`, 'aria-label': `test the ${what} ones again`, disabled: testingAll, onclick: () => tryAll(models) }))
2025
- })
2382
+ const n = (x) => x.toLocaleString()
2026
2383
 
2384
+ // --- what you do to the list ---
2027
2385
  // the order you see, saved as yours; the sort then goes (your own order from here on: drag on)
2028
2386
  const keep = (list, moved) => {
2029
2387
  SORT = []
2030
- savePref('sort', SORT)
2031
- return saveOrder(withOff(list), list[0] !== order[0] ? `${moved ? '' : 'order saved: '}HeartCode now uses ${list[0].provider} · ${list[0].model}` : 'order saved')
2388
+ savePref('sorts', SORT)
2389
+ return saveOrder(withOff(list), list[0] !== order[0] ? `${moved ? '' : 'list saved: '}HeartCode now uses ${list[0].provider} · ${list[0].model}` : 'list saved')
2032
2390
  }
2033
- // a row dragged (in the order shown, sorted or not)
2391
+ // a row dragged (in the order shown, sorted or not). Filtered: it moves among the ones shown; the
2392
+ // hidden ones keep their places (the shown ones fill their own places in the new order)
2034
2393
  const move = (i, j) => {
2035
2394
  if (i === j) return
2036
2395
  const list = [...view]
2037
2396
  const [t] = list.splice(i, 1)
2038
2397
  list.splice(j, 0, t)
2039
- return keep(list, true)
2398
+ if (!filtered) return keep(list, true)
2399
+ const mine = new Set(list)
2400
+ const slots = order.map((x, k) => (mine.has(x) ? k : -1)).filter((k) => k >= 0)
2401
+ const all = [...order]
2402
+ slots.forEach((k, m) => (all[k] = list[m]))
2403
+ return keep(all, true)
2404
+ }
2405
+ // Save list: what's shown, in the order shown; filtered, the others after them as they were
2406
+ const saveList = () => keep(filtered ? [...view, ...order.filter((t) => !view.includes(t))] : view)
2407
+ const keepOnly = () => {
2408
+ if (!confirm(`Keep only these ${n(view.length)} as your list, in this order? The other ${n(order.length - view.length)} come off it (they stay under their providers: you can add them back).`)) return
2409
+ return keep(view)
2410
+ }
2411
+ const removePicked = () => {
2412
+ const rest = order.filter((t) => !PICKED.has(keyOf(t)))
2413
+ const k = order.length - rest.length
2414
+ if (!confirm(`Take ${k} model${k === 1 ? '' : 's'} off your list?${!rest.length ? ' None is left then: HeartCode has no model to use until you choose one.' : rest[0] !== order[0] ? ` HeartCode then uses ${rest[0].provider} · ${rest[0].model}.` : ''} (They stay under their providers.)`)) return
2415
+ PICKED.clear()
2416
+ saveOrder(withOff(rest), `${k} removed${rest.length ? '' : ': no model chosen now'}`)
2040
2417
  }
2041
- const head = (key, num) => {
2418
+ const pickedList = order.filter((t) => PICKED.has(keyOf(t)))
2419
+
2420
+ // --- the page's header, right: what's known about the models ---
2421
+ put($('mt-actions'),
2422
+ h('button', { className: 'small', textContent: 'Provider ranking', disabled: !order.some((t) => t.provider !== order[0]?.provider), title: 'drag your providers into order; the Provider column sorts by it', onclick: openRanking }),
2423
+ h('button', { className: 'small', textContent: 'Refresh from models.dev', disabled: !order.length, title: 'ask models.dev again what each model can do: context, tools, thinking, images, price', onclick: () => lookUp() }))
2424
+
2425
+ // --- the list's settings: three cells across, a label over each control ---
2426
+ const ro = s.rotation
2427
+ const cell = (label, about, ...control) => h('label', { className: 'mt-set', title: about }, h('span', { className: 'mt-setl', textContent: label }), h('span', { className: 'mt-setc' }, ...control))
2428
+ const settings = h('div', { className: 'mt-sets' },
2429
+ cell('When a model fails', ro.on === 'retries' ? 'a rate limit or outage: that model is tried again that many times first; any other error moves on at once' : "any error moves on at once, to another provider's model first",
2430
+ h('select', { onchange: (e) => saveOrder(S.order, 'saved', { on: e.target.value }) },
2431
+ [['failure', 'the next one answers'], ['retries', 'try it again first']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.on === v }))),
2432
+ ro.on === 'retries' ? h('input', { type: 'number', className: 'tries', 'aria-label': 'tries', title: 'tries of the same model first (rate limits, outages)', min: 1, max: 20, value: ro.retries, onchange: (e) => saveOrder(S.order, 'saved', { retries: Number(e.target.value) }) }) : null),
2433
+ cell('A new message starts with', 'the model a new message goes to first',
2434
+ h('select', { onchange: (e) => saveOrder(S.order, 'saved', { next: e.target.value }) },
2435
+ [['first', '#1'], ['stay', 'the last that answered']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v })))),
2436
+ cell('A test waits for an answer', 'every model test: Test, Test all, Request',
2437
+ h('input', { type: 'number', min: 1, max: 600, step: 1, value: S.settings.testTimeout ?? 10, 'aria-label': 'Test timeout in seconds', onchange: (e) => {
2438
+ const v = Math.round(Number(e.target.value))
2439
+ if (!(v >= 1 && v <= 600)) return (e.target.value = S.settings.testTimeout ?? 10), toast('a whole number of seconds, 1 to 600', true)
2440
+ act('/api/setting', { name: 'testTimeout', value: v }, `tests wait ${v} second${v === 1 ? '' : 's'} for an answer`)
2441
+ } }), h('span', { className: 'unit', textContent: 'seconds' })))
2442
+
2443
+ // --- under the filters: what's shown (left) · what you do with it (right) ---
2444
+ const chip = (label, off, cls = '') => h('span', { className: 'chip ' + cls }, label, h('button', { type: 'button', textContent: '✕', 'aria-label': `remove ${label}`, onclick: off }))
2445
+ const line = h('div', { className: 'mt-line' },
2446
+ h('div', { className: 'mt-status' },
2447
+ h('span', { className: 'count' }, filtered ? [h('b', { textContent: n(shown.length) }), ` of ${n(order.length)} shown`] : [h('b', { textContent: n(order.length) }), ` model${order.length === 1 ? '' : 's'}, in your order`]),
2448
+ ...filterChips().map(([label, off]) => chip(label, () => setFilter(off))),
2449
+ ...SORT.map(({ key, dir }, k) => chip(`${SORT.length > 1 ? `${k + 1}. ` : 'Sorted: '}${COLS[key].label} ${COLS[key].words[dir === 'up' ? 0 : 1]}`, () => setSort(SORT.filter((x) => x.key !== key)), 'sort')),
2450
+ testingAll && SORT.some((x) => x.key === 'works') ? h('span', { className: 'sort-live', textContent: 'tests running: the order moves as results come in' }) : null,
2451
+ filtering() || SORT.length ? h('button', { className: 'small ghost', textContent: 'Clear all', title: 'every filter and the sort off: your whole list, in your order', onclick: clearView }) : null),
2452
+ h('div', { className: 'mt-do' },
2453
+ h('button', { className: 'small', textContent: filtered ? `Test ${n(shown.length)} shown` : 'Test all', disabled: testingAll || !shown.length, title: `send ${filtered ? 'the models shown' : 'each model'} a short message to see which really answer`, onclick: () => tryAll(filtered ? shown : order) }),
2454
+ filtered ? h('button', { className: 'small', textContent: `Keep only these ${n(view.length)}`, disabled: !view.length, title: 'your list becomes the models shown, in this order; the others come off it (they stay under their providers)', onclick: keepOnly }) : null,
2455
+ h('button', { className: 'small primary', textContent: 'Save list', disabled: !view.length || order.length < 2, title: filtered ? `save these ${n(view.length)} first, in the order shown; the other ${n(order.length - view.length)} after them, as they are` : 'save the list in the order shown (#1 first)', onclick: saveList })))
2456
+
2457
+ // --- the table ---
2458
+ const all = view.length > 0 && view.every((t) => PICKED.has(keyOf(t)))
2459
+ const head = (key, align) => {
2042
2460
  const at = SORT.findIndex((x) => x.key === key)
2043
- return h('button', { type: 'button', className: (at >= 0 ? 'on ' : '') + (num ? 'num' : ''), title: `sort by ${COLS[key].label.toLowerCase()}`, onclick: () => clickSort(key) },
2044
- COLS[key].label, at >= 0 ? ` ${SORT[at].dir === 'up' ? '↑' : '↓'}${SORT.length > 1 ? at + 1 : ''}` : '')
2461
+ return h('button', { type: 'button', className: (at >= 0 ? 'on ' : '') + (align || ''), title: `sort by ${COLS[key].label.toLowerCase()} (after the ones already sorted by) · click again: reversed · again: off`, onclick: (e) => clickSort(key, e.currentTarget) },
2462
+ COLS[key].label, at >= 0 ? h('span', { className: 'dir', textContent: ` ${SORT[at].dir === 'up' ? '↑' : '↓'}${SORT.length > 1 ? at + 1 : ''}` }) : '')
2045
2463
  }
2046
- const table = order.length ? h('ol', { className: 'mtable' + (order.length < 2 ? '' : ' drag') }) : null
2464
+ const selectAll = h('input', { type: 'checkbox', checked: all, indeterminate: PICKED.size > 0 && !all, title: all ? 'select none' : 'select all shown', 'aria-label': 'select all shown', onchange: () => (all ? PICKED.clear() : view.forEach((t) => PICKED.add(keyOf(t))), (lastPicked = null), drawMine(S)) })
2465
+ // the columns' names; with models selected, what to do with them instead (the checkbox stays)
2466
+ const header = PICKED.size
2467
+ ? h('div', { className: 'mt-h mt-hpick' }, h('span'), selectAll,
2468
+ h('div', { className: 'mt-pickbar' },
2469
+ h('b', { textContent: `${n(PICKED.size)} selected` }),
2470
+ h('button', { className: 'small', textContent: 'Test', disabled: testingAll, onclick: () => tryAll(pickedList) }),
2471
+ h('button', { className: 'small danger', textContent: 'Remove', onclick: removePicked }),
2472
+ h('button', { className: 'small ghost', textContent: 'Invert', title: "select the ones shown that aren't selected, unselect the ones that are", onclick: () => (view.forEach((t) => (PICKED.has(keyOf(t)) ? PICKED.delete(keyOf(t)) : PICKED.add(keyOf(t)))), (lastPicked = null), drawMine(S)) }),
2473
+ h('button', { className: 'small ghost', textContent: 'Select none', onclick: () => (PICKED.clear(), drawMine(S)) })))
2474
+ : h('div', { className: 'mt mt-h' }, h('span'), selectAll,
2475
+ h('span', { textContent: '#', title: 'its place in your list' }), head('model'), head('provider'), head('context', 'num'), head('tools', 'mid'), head('thinking', 'mid'), head('images', 'mid'), head('price', 'num'), head('works'), h('span', { className: 'num', textContent: '' }))
2476
+ const table = view.length ? h('ol', { className: 'mtable' + (view.length < 2 ? '' : ' drag') }) : null
2047
2477
  // ticked or not; with Shift, every row from the last one ticked to this one
2048
2478
  const pick = (i, e) => {
2049
2479
  const on = !PICKED.has(keyOf(view[i]))
@@ -2055,46 +2485,41 @@ function drawMine(s) {
2055
2485
  }
2056
2486
  const tableV = table && virtual(table, { count: view.length, height: TABLE_ROW, row: (i) => tableRow(view[i], order.indexOf(view[i]), (e) => pick(i, e)), scroller: window })
2057
2487
  if (tableV) tableV.items = view.length
2488
+ // typing in a filter: the box is put back in the redrawn page, still with the focus and the caret
2489
+ const typing = filterBar?.contains(document.activeElement) ? document.activeElement : null
2490
+ const caret = typing?.selectionStart ?? null
2491
+ const empty = (text, ...more) => h('div', { className: 'mt-empty' }, text, ...more)
2492
+ // the counts of each test result, for the Result filter (with the other filters as they are)
2493
+ const counted = order.filter((t) => passes(t, 'works'))
2494
+ const results = { works: 0, fails: 0, untested: 0 }
2495
+ for (const t of counted) {
2496
+ const o = outcome(TRIES[keyOf(t)])
2497
+ if (!o) results.untested++
2498
+ else if (o === 'works') results.works++
2499
+ else (results.fails++, (results[o] = (results[o] ?? 0) + 1))
2500
+ }
2058
2501
  put($('mt'),
2059
- h('div', { className: 'mt-top' },
2060
- h('div', { className: 'sorts' }, SORT.length
2061
- ? ['Sorted by ', SORT.map(({ key, dir }, k) => h('span', { className: 'chip' }, `${k + 1}. ${COLS[key].label}: ${dirText(key, dir)}`, h('button', { type: 'button', textContent: '✕', 'aria-label': `stop sorting by ${COLS[key].label}`, onclick: () => setSort(SORT.filter((x) => x.key !== key)) })))]
2062
- : order.length > 1 ? 'Your order: #1 first, the next when one fails.' : ''),
2063
- PICKED.size ? h('button', { className: 'small danger', textContent: `Remove ${PICKED.size} selected`, onclick: removePicked }) : null,
2064
- PICKED.size ? h('button', { className: 'small', textContent: `Test ${PICKED.size} selected`, disabled: testingAll, onclick: () => tryAll(order.filter((t) => PICKED.has(keyOf(t)))) }) : null,
2065
- PICKED.size ? h('button', { className: 'small', textContent: 'Clear selection', onclick: () => (PICKED.clear(), drawMine(S)) }) : null,
2066
- PICKED.size ? h('button', { className: 'small', textContent: 'Invert selection', title: 'tick the ones not ticked, untick the ones ticked', onclick: () => (view.forEach((t) => (PICKED.has(keyOf(t)) ? PICKED.delete(keyOf(t)) : PICKED.add(keyOf(t)))), (lastPicked = null), drawMine(S)) }) : null,
2067
- order.some((t) => t.provider !== order[0].provider) ? h('button', { className: 'small', textContent: 'Provider ranking', title: 'drag your providers into order; the Provider column sorts by it', onclick: openRanking }) : null,
2068
- SORT.length ? h('button', { className: 'small', textContent: 'Clear sort', onclick: () => setSort([]) }) : null,
2069
- order.length > 1 ? h('button', { className: 'small primary', textContent: 'Save order', title: 'save the order shown as your model order (#1 first)', onclick: () => keep(view) }) : null,
2070
- order.length ? h('button', { className: 'small', textContent: 'Refresh from models.dev', title: 'ask models.dev again what each model can do: context, tools, thinking, images, price', onclick: () => lookUp() }) : null,
2071
- order.length ? h('button', { className: 'small', textContent: 'Test all', disabled: testingAll, title: 'send each a short message to see which really answer: every provider at once, a few from each (one at a time per 100 models)', onclick: () => tryAll(order) }) : null),
2072
- // when the one in use fails, and what a new message starts with
2073
- order.length > 1 ? h('div', { className: 'mt-rules' },
2074
- h('span', { className: 'rule' },
2075
- h('label', { for: 'r-on', textContent: 'When a model fails, go on to the next' }),
2076
- h('select', { id: 'r-on', onchange: (e) => saveOrder(S.order, 'saved', { on: e.target.value }) },
2077
- [['failure', 'at its first failure'], ['retries', 'after some tries of the same model']].map(([v, t]) => h('option', { value: v, textContent: t, selected: s.rotation.on === v }))),
2078
- s.rotation.on === 'retries' ? h('input', { type: 'number', 'aria-label': 'tries', title: 'tries of the same model first (rate limits, outages)', min: 1, max: 20, value: s.rotation.retries, onchange: (e) => saveOrder(S.order, 'saved', { retries: Number(e.target.value) }) }) : null),
2079
- h('span', { className: 'rule' },
2080
- h('label', { for: 'r-next', textContent: 'A new message starts with' }),
2081
- h('select', { id: 'r-next', onchange: (e) => saveOrder(S.order, 'saved', { next: e.target.value }) },
2082
- [['first', '#1 again'], ['stay', 'the model that answered last']].map(([v, t]) => h('option', { value: v, textContent: t, selected: s.rotation.next === v })))),
2083
- h('span', { className: 'hint', textContent: s.rotation.on === 'retries' ? 'A rate limit or outage: that model is tried again that many times first; any other error moves on at once.' : "Any error moves on at once, to another provider's model first." })) : null,
2502
+ order.length > 1 ? settings : null,
2503
+ order.length
2504
+ ? h('div', { className: 'mt-tools' },
2505
+ filterBarOf(order, results),
2506
+ line,
2507
+ (tableJobs ??= jobSlot('table')), // the same one every time: its Stop button isn't replaced under the mouse
2508
+ view.length ? h('div', { className: 'mt-hwrap' }, header) : null)
2509
+ : null,
2084
2510
  order.length
2085
- ? h('div', { className: 'mt-scroll' }, h('div', { className: 'mt' },
2086
- jobSlot('table'),
2087
- byOutcome.length ? h('div', { className: 'mt-outcomes' }, h('span', { textContent: 'Test results', title: 'click one to select those models; ↻ tests them again' }), byOutcome) : null,
2088
- h('div', { className: 'mt-h' }, h('span'),
2089
- h('input', { type: 'checkbox', checked: all, indeterminate: PICKED.size > 0 && !all, title: all ? 'select none' : 'select all', 'aria-label': 'select all', onchange: () => (all ? PICKED.clear() : view.forEach((t) => PICKED.add(keyOf(t))), (lastPicked = null), drawMine(S)) }),
2090
- h('span', { textContent: '#' }), head('model'), head('provider'), head('context', true), head('abilities', true), head('tools'), head('thinking'), head('images'), head('input', true), head('output', true), h('span', { textContent: 'From' }), head('works'), h('span')),
2091
- table))
2092
- : h('div', { className: 'mt-empty' }, 'No models in your list yet. ', h('a', { href: '#providers', textContent: 'Choose some under Providers & models' }), '.'))
2511
+ ? h('div', { className: 'mt-scroll', onscroll: (e) => { const hw = e.target.closest('.card')?.querySelector('.mt-hwrap'); if (hw) hw.scrollLeft = e.target.scrollLeft } }, h('div', { className: 'mt' },
2512
+ table ?? empty('No model matches these filters. ', h('button', { type: 'button', className: 'small', textContent: 'Clear all', onclick: clearView }))))
2513
+ : empty('No models in your list yet. ', h('a', { href: '#providers', textContent: 'Choose some under Providers' }), '.'))
2514
+ if (typing && document.activeElement !== typing) {
2515
+ typing.focus({ preventScroll: true })
2516
+ if (caret !== null && typing.setSelectionRange) typing.setSelectionRange(caret, caret)
2517
+ }
2093
2518
  tableV?.draw()
2094
2519
  sortable(tableV, move)
2095
2520
  }
2096
2521
  // the table's cells: yes or no; where what it can do comes from
2097
- const yes = (v) => h('span', { className: v ? 'yes' : 'no', textContent: v ? '✓' : '–' })
2522
+ const yes = (v) => h('span', { className: (v ? 'yes' : 'no') + ' mid', textContent: v ? '✓' : '–' })
2098
2523
  const src = (t) => {
2099
2524
  const x = t.tested
2100
2525
  if (!x) return h('div', { className: 'src', textContent: 'looking it up…' })
@@ -2102,24 +2527,33 @@ const src = (t) => {
2102
2527
  return h('div', { className: 'src' }, Object.keys(x.set ?? {}).length ? 'set by you' : x.source === 'models.dev' ? 'models.dev' : FROM[x.source], h('button', { className: 'small', textContent: 'Edit', onclick: () => openSetup(t) }))
2103
2528
  }
2104
2529
  // a row of the table: one model of your list, in the order shown (at: its place in your order)
2530
+ const money = (x) => (x == null ? '–' : x === 0 ? '$0' : usd(x))
2531
+ const priceOf = (t) => (t.price?.input == null && t.price?.output == null ? '–' : t.price.input === 0 && t.price.output === 0 ? 'free' : `${money(t.price.input)} / ${money(t.price.output)}`)
2105
2532
  function tableRow(t, at, pick) {
2106
2533
  const c = can(t)
2107
2534
  const ctx = COLS.context.get(t)
2108
2535
  const picked = PICKED.has(keyOf(t))
2536
+ const x = t.tested
2537
+ // where what it can do comes from, when that's worth a look: not known to models.dev (a guess), or set by you
2538
+ const tag = !x ? h('span', { className: 'tag', textContent: '…', title: 'looking it up in models.dev' })
2539
+ : x.source === 'assumed' ? h('button', { type: 'button', className: 'tag warn', textContent: 'unknown', title: "models.dev doesn't know it: what it can do is a guess. Click to set it up", onclick: () => openSetup(t) })
2540
+ : Object.keys(x.set ?? {}).length ? h('button', { type: 'button', className: 'tag', textContent: 'edited', title: 'what it can do: set by you (click to change)', onclick: () => openSetup(t) }) : null
2541
+ const going = Boolean(TRIES[keyOf(t)]?.going)
2109
2542
  return h('li', { className: 'in' + (picked ? ' picked' : '') + (isOff(t.provider) ? ' off' : ''), 'data-key': `${t.provider}/${t.model}`, title: isOff(t.provider) ? `${t.provider} is switched off: HeartCode skips this model until it's on` : '' },
2110
2543
  h('span', { className: 'grip', textContent: '⋮⋮', 'aria-hidden': 'true' }),
2111
2544
  h('input', { type: 'checkbox', checked: picked, 'aria-label': `select ${t.model}`, title: 'select (Shift: and every row up to the last one selected)', onclick: (e) => (e.preventDefault(), pick(e)) }),
2112
- h('span', { className: 'n', textContent: `#${at + 1}`, title: SORT.length ? 'its place in your order now' : '' }),
2113
- h('span', { className: 'm', textContent: t.model, title: t.model }),
2545
+ h('span', { className: 'n', textContent: `#${at + 1}`, title: SORT.length || filtering() ? 'its place in your list' : '' }),
2546
+ h('span', { className: 'm' }, h('span', { className: 'name', textContent: t.model, title: t.model }), tag),
2114
2547
  h('span', { className: 'p', textContent: isOff(t.provider) ? `${t.provider} · off` : t.provider, title: t.provider }),
2115
- h('span', { className: 'num', textContent: ctx ? `${t.tested?.sure === false ? '~' : ''}${kTok(ctx)}` : '–' }),
2116
- h('span', { className: 'num', textContent: `${Object.values(c).filter(Boolean).length} of 3` }),
2548
+ h('span', { className: 'num', textContent: ctx ? `${t.tested?.sure === false ? '~' : ''}${kTok(ctx)}` : '–', title: ctx ? `${ctx.toLocaleString()} tokens${t.tested?.sure === false ? ' (assumed: the server and models.dev don\'t say)' : ''}` : '' }),
2117
2549
  yes(c.tools), yes(c.thinking), yes(c.images),
2118
- h('span', { className: 'num', textContent: t.price?.input != null ? usd(t.price.input) : '–' }),
2119
- h('span', { className: 'num', textContent: t.price?.output != null ? usd(t.price.output) : '–' }),
2120
- src(t),
2550
+ h('span', { className: 'num price', textContent: priceOf(t), title: t.price ? `in ${money(t.price.input)} · out ${money(t.price.output)} per million tokens` : 'price not known' }),
2121
2551
  triedCell(t),
2122
- h('button', { className: 'danger', textContent: '✕', title: 'take it off the list', 'aria-label': `remove ${t.model}`, onclick: () => removeMine(t.provider, t.model) }))
2552
+ h('span', { className: 'acts' },
2553
+ h('button', { type: 'button', className: 'small ghost ib k-test row-test', disabled: going, title: going ? 'testing…' : 'Test: send it a short message to see that it really answers', 'aria-label': `test ${t.model}`, onclick: () => tryModel(t) }, ic(going ? 'clock' : 'play')),
2554
+ h('button', { type: 'button', className: 'small ghost ib k-info', title: 'Request: send it "Hello" and see exactly what was sent and what came back', 'aria-label': `raw request to ${t.model}`, onclick: () => hello(t.provider, t.model) }, ic('eye')),
2555
+ h('button', { type: 'button', className: 'small ghost ib k-edit', title: 'Edit what it can do: context, tool calls, thinking, images (or look it up in models.dev again)', 'aria-label': `edit ${t.model}`, onclick: () => openSetup(t) }, ic('pencil')),
2556
+ h('button', { type: 'button', className: 'small ghost ib k-del', title: 'Remove it from your list (it stays under its provider)', 'aria-label': `remove ${t.model}`, onclick: () => removeMine(t.provider, t.model) }, ic('trash'))))
2123
2557
  }
2124
2558
 
2125
2559
  // your list changed: the rows and counts it touches, in place
@@ -2299,6 +2733,7 @@ function drawNotify(s) {
2299
2733
  h('button', { className: 'ghost', type: 'button', textContent: 'Disconnect', onclick: () => confirm('Stop sending notifications to Telegram and forget the bot token?') && act('/api/telegram/remove', {}, 'Telegram disconnected') })))
2300
2734
  }
2301
2735
  put($('tg-events'), Object.entries(t.names ?? {}).map(([k, label]) => h('label', { className: 'opt' + (t.connected ? '' : ' tg-off') },
2736
+ tile(...({ done: ['check', 'green'], failed: ['x', 'red'], waiting: ['clock', 'amber'] }[k] ?? ['bell', 'amber'])),
2302
2737
  h('div', { className: 't' }, h('b', { textContent: label }), h('span', { textContent: TG_EVENT_INFO[k] ?? '' })),
2303
2738
  sw({ checked: t.events?.[k] !== false, disabled: !t.connected, 'aria-label': label, onchange: (e) => act('/api/telegram/set', { event: k, value: e.target.checked }, `${label}: ${e.target.checked ? 'on' : 'off'}`) }))))
2304
2739
  }
@@ -2481,7 +2916,8 @@ $('c-cancel').onclick = () => $('c-form').close()
2481
2916
  function drawMcp(s) {
2482
2917
  const authTag = (a) => (a === 'in' ? h('span', { className: 'tag ok', textContent: 'signed in' }) : h('span', { className: 'tag need', textContent: 'sign-in needed' }))
2483
2918
  put($('c-list'), h('h2', { textContent: 'Servers' }), h('p', { className: 'sub', textContent: 'Built in, and yours. Remote ones (a URL) may need signing in; local ones don\'t. Switch one off to keep it without using it.' }),
2484
- s.mcp.length ? s.mcp.map((m) => h('div', { className: 'opt' },
2919
+ s.mcp.length ? s.mcp.map((m) => h('div', { className: 'opt mcp-row' },
2920
+ tile(m.remote ? 'globe' : m.name.includes('chrome') || m.name.includes('browser') ? 'globe' : m.name.includes('computer') ? 'cpu' : 'plug', m.on ? 'teal' : 'gray'),
2485
2921
  h('div', { className: 't' }, h('b', {}, m.name, ' ', h('span', { className: 'tag', textContent: m.from }), m.remote ? authTag(m.auth) : null), m.description ? h('span', { textContent: m.description }) : null, h('div', { className: 'mono muted', style: 'word-break:break-all;margin-top:3px', textContent: m.what })),
2486
2922
  m.remote ? h('button', { className: 'small', textContent: m.auth === 'in' ? 'Sign in again' : 'Sign in', onclick: () => act('/api/mcp/login', { name: m.name }, `signed in to ${m.name}`) }) : null,
2487
2923
  m.from === 'yours' ? h('button', { className: 'small danger', textContent: 'Remove', onclick: () => confirm(`Remove the MCP server ${m.name}?`) && act('/api/mcp/remove', { name: m.name }, `removed ${m.name}`) }) : null,
@@ -2754,8 +3190,12 @@ function render(s) {
2754
3190
  $('free-only').checked = freeOnly
2755
3191
  FOLDED.clear()
2756
3192
  for (const n of Array.isArray(p.folded) ? p.folded : []) FOLDED.add(n)
2757
- SORT = Array.isArray(p.sort) ? p.sort.filter((x) => COLS[x?.key]) : []
3193
+ const flip = (x) => (['provider', 'works'].includes(x.key) ? { ...x, dir: x.dir === 'up' ? 'down' : 'up' } : x) // an older page's sort: these two ran the other way
3194
+ // the sort and filters: taken in once; after that the page's own are the latest (a state from the
3195
+ // server can be older than a change made here a moment ago)
3196
+ if (!filtersLoaded) SORT = Array.isArray(p.sorts) ? p.sorts.filter((x) => COLS[x?.key]) : Array.isArray(p.sort) ? p.sort.filter((x) => COLS[x?.key]).map(flip) : []
2758
3197
  RANK = Array.isArray(p.rank) ? p.rank.filter((x) => typeof x === 'string') : []
3198
+ if (!filtersLoaded) (filtersLoaded = true), (FILTER = { ...NO_FILTER, ...(p.filters && typeof p.filters === 'object' ? p.filters : {}) }) // after that the page's own are the latest
2759
3199
  }
2760
3200
  S = s
2761
3201
  for (const [key, r] of Object.entries(TRIES)) if (!r.going && placeOf(...key.split(/\/(.*)/s)) === undefined) delete TRIES[key] // off your list: its result too