heartcode 0.1.40 → 0.1.42

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
@@ -407,7 +407,7 @@
407
407
  .pill .again:hover:not(:disabled) { color: var(--text); }
408
408
  .pill.on { border-color: var(--accent); background: var(--accent-soft); }
409
409
  .pill.on .again { border-left-color: color-mix(in srgb, var(--accent) 40%, transparent); }
410
- .mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 44px minmax(240px, 1fr) 110px 62px 52px 70px 58px 58px 58px 58px 116px 84px 132px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
410
+ .mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 44px minmax(240px, 1fr) 110px 62px 52px 70px 58px 88px 88px 88px 116px 84px 132px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
411
411
  .mt-h button.mid, .mtable .mid { text-align: center; }
412
412
  .mt-h > :nth-child(14), .mtable .try { padding-left: 12px; } /* Works?: a little room after the right-aligned price */
413
413
  .mtable li .acts { justify-content: flex-start; }
@@ -429,6 +429,8 @@
429
429
  .mtable .n { font-weight: 650; color: var(--faint); }
430
430
  .mtable li:first-child .n { color: var(--accent); }
431
431
  .mtable .rk { color: var(--muted); }
432
+ .mtable .rk b { color: var(--text); font-weight: 600; margin-right: 5px; }
433
+ .mtable .rk.top b { color: inherit; }
432
434
  .mtable .rk.top { color: var(--ok); font-weight: 600; }
433
435
  .mtable .m { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
434
436
  .mtable .p { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -498,20 +500,23 @@
498
500
  .sort-live { color: var(--warn); }
499
501
  /* Your models: the header's buttons, the list's settings, the toolbar (sticky), the table */
500
502
  .mt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
501
- /* Your models: the settings (three cells across), the toolbar (sticky), the table */
502
- .mt-sets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
503
- .mt-set { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
504
- .mt-set:first-child { border-left: 0; }
505
- .mt-setl { font-size: 12px; font-weight: 600; color: var(--muted); }
503
+ .mt-sets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
504
+ .mt-set { display: flex; align-items: center; gap: 8px; min-width: 0; }
505
+ .mt-setl { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
506
506
  .mt-setc { display: flex; align-items: center; gap: 8px; }
507
- .mt-setc select { flex: 1; width: 100%; min-width: 0; height: 34px; }
508
- .mt-setc input[type=number] { width: 96px; height: 34px; }
507
+ .mt-setc select { width: auto; min-width: 0; height: 34px; padding-top: 0; padding-bottom: 0; line-height: 32px; }
508
+ .mt-setc input[type=number] { width: 64px; height: 34px; }
509
509
  .mt-setc input.tries { width: 64px; }
510
510
  .mt-setc .unit { color: var(--muted); font-size: 13px; }
511
511
  .mt-sets + .mt-tools { border-radius: 0; }
512
- .mt-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 0 18px 12px; }
513
- .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); }
514
- .mt-do { display: flex; align-items: center; gap: 8px; flex: none; }
512
+ .mt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 18px; }
513
+ .mt-row .mt-filters, .mt-row .f-togs { display: contents; } /* filters, toggles and buttons flow as one line, wrapping only when it's full */
514
+ .mt-row .f-search { flex: 1 1 220px; }
515
+ .mt-line { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; font-size: 13px; color: var(--muted); }
516
+ .mt-line .count { white-space: nowrap; }
517
+ .mt-sets[inert], .mt-row[inert], .mt-hwrap[inert], .mt-actions[inert] { opacity: .5; transition: opacity .15s; }
518
+ .mt-row[inert] .sort-live { opacity: 1; }
519
+ .mt-line .count b { color: var(--text); }
515
520
  .mt-hpick .mt-pickbar { grid-column: 3 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
516
521
  .mt-hpick { background: var(--brand-soft); }
517
522
  .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; }
@@ -527,11 +532,6 @@
527
532
  .mt-filters select { height: 34px; width: auto; padding-top: 0; padding-bottom: 0; line-height: 32px; }
528
533
  .mt-filters select.on { border-color: var(--accent); background-color: color-mix(in srgb, var(--accent-soft) 50%, var(--input)); }
529
534
  .f-togs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
530
- .mt-status .count b { color: var(--text); }
531
- .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; }
532
- .mt-status .chip.sort { border-color: var(--line-strong); background: var(--panel2); }
533
- .mt-status .chip button { border: 0; background: none; padding: 0 5px; font-size: 11px; color: var(--muted); border-radius: 999px; }
534
- .mt-status .chip button:hover { color: var(--text); background: var(--hover); }
535
535
  .mt-tools .mt-outcomes { border-bottom: 0; border-top: 1px solid var(--line); padding: 9px 18px; }
536
536
  .mt-hwrap { overflow: hidden; border-top: 1px solid var(--line); }
537
537
  .mt-hwrap .mt-h { border-bottom: 0; }
@@ -615,10 +615,6 @@
615
615
  @keyframes job-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
616
616
 
617
617
  @media (max-width: 1180px) {
618
- .mt-sets { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* the cells: two by two */
619
- .mt-set:nth-child(2n+1) { border-left: 0; }
620
- .mt-set:last-child:nth-child(odd) { grid-column: span 2; } /* an odd one out: the whole row, no hole beside it */
621
- .mt-set:nth-child(n+3) { border-top: 1px solid var(--line); }
622
618
  .split { grid-template-columns: 1fr; }
623
619
  .work { grid-template-columns: 1fr; height: auto !important; }
624
620
  .work .mine { order: -1; }
@@ -636,11 +632,8 @@
636
632
  nav a .count, .using, .nav-group { display: none; }
637
633
  .theme-btn { top: 10px; right: 12px; }
638
634
  .mt-tools { position: static; } /* a phone: too tall to stay in sight, it scrolls with the page */
639
- .mt-sets { grid-template-columns: minmax(0, 1fr); }
640
- .mt-set { border-left: 0; border-top: 1px solid var(--line); }
641
- .mt-set:first-child { border-top: 0; }
642
- .mt-do { width: 100%; }
643
- .mt-do button { flex: 1; }
635
+ .mt-line { width: 100%; }
636
+ .mt-line button.primary { margin-left: auto; }
644
637
  main { padding: 20px 16px 60px; }
645
638
  .steps { grid-template-columns: 1fr; }
646
639
  .choices, .choices.three { grid-template-columns: 1fr; }
@@ -808,7 +801,7 @@
808
801
 
809
802
  <!-- Your models: all at once, sortable -->
810
803
  <section class="page" id="page-models">
811
- <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>
804
+ <div class="head"><div><h1>Your models</h1><p class="lead" id="mt-lead"></p></div><div class="mt-actions" id="mt-actions"></div></div>
812
805
  <div class="card mt-card" id="mt"></div>
813
806
  </section>
814
807
 
@@ -1070,7 +1063,7 @@
1070
1063
  </dialog>
1071
1064
  <dialog id="pr" aria-labelledby="pr-title">
1072
1065
  <form>
1073
- <h2 id="pr-title">Provider ranking</h2>
1066
+ <h2 id="pr-title">Order providers</h2>
1074
1067
  <p class="sub">Drag the providers into order, best first. Your models are then sorted by it.</p>
1075
1068
  <ol id="pr-list"></ol>
1076
1069
  <div class="actions"><button id="pr-cancel" type="button">Cancel</button><button class="primary" id="pr-save" type="button">Save</button></div>
@@ -1306,7 +1299,7 @@ const DOING = {
1306
1299
  '/api/telegram/connect': 'Checking the token with Telegram',
1307
1300
  '/api/telegram/test': 'Sending a test message',
1308
1301
  '/api/search/test': 'Trying a search on your SearXNG',
1309
- '/api/rankings': 'Getting the public model rankings',
1302
+ '/api/rankings': null, // with models.dev, in its strip
1310
1303
  '/api/models-dev': null, // its own strip
1311
1304
  }
1312
1305
  let acting = 0
@@ -1698,6 +1691,9 @@ async function tryModel(t) {
1698
1691
  return r
1699
1692
  }
1700
1693
  let testingAll = false // a run is going (on the server)
1694
+ let lookingUp = false // Update model info is going
1695
+ // while either goes, the list holds still: no filtering, sorting, dragging, selecting or changing rows
1696
+ const locked = () => testingAll || lookingUp
1701
1697
  // a run of tests: all your models, or the ones given
1702
1698
  async function tryAll(only) {
1703
1699
  if (testingAll) return toast('a test is running: wait for it, or stop it', true)
@@ -1717,7 +1713,9 @@ function gotResult(key, result) {
1717
1713
  // the run, as the server says it is: its progress strip, and the models waiting marked as testing
1718
1714
  function showRun(run) {
1719
1715
  for (const key of run?.pending ?? []) if (!TRIES[key]?.going) TRIES[key] = { going: true, before: TRIES[key] } // its last result, kept if it isn't reached
1716
+ const was = testingAll
1720
1717
  testingAll = Boolean(run && !run.over)
1718
+ if (was !== testingAll) mineSoon() // the list locked or unlocked
1721
1719
  if (!testingAll) {
1722
1720
  for (const [key, r] of Object.entries(TRIES)) if (r.going) r.before ? (TRIES[key] = r.before) : delete TRIES[key] // stopped before it: as it was
1723
1721
  job('test-all')
@@ -1733,13 +1731,15 @@ function showRun(run) {
1733
1731
  mineSoon()
1734
1732
  }
1735
1733
 
1736
- // models.dev looked up again: one model (its Retry), or all of yours (Refresh from models.dev)
1734
+ // models.dev looked up again: one model (its Retry), or all of yours with their scores (Update model info)
1737
1735
  const retry = (t) => h('button', { className: 'small', textContent: 'Retry', title: 'look it up in models.dev again', onclick: (e) => (e.stopPropagation(), lookUp(t)) })
1738
1736
  async function lookUp(t) {
1739
- job('models.dev', { where: ['catalog', 'table'], what: t ? `Looking up ${t.model} in models.dev` : 'Asking models.dev about your models', detail: 'context, tool calls, thinking, images' })
1740
- const r = await act('/api/models-dev', t ? { provider: t.provider, model: t.model } : {})
1737
+ job('models.dev', { where: ['catalog', 'table'], what: t ? `Looking up ${t.model} in models.dev` : 'Updating your models: models.dev and LMArena', detail: t ? 'context, tool calls, thinking, images' : 'context, tool calls, thinking, images, price; scores' })
1738
+ if (!t) (lookingUp = true), mineSoon()
1739
+ const [r, scored] = await Promise.all([act('/api/models-dev', t ? { provider: t.provider, model: t.model } : {}), t ? null : act('/api/rankings', {})])
1740
+ if (!t) (lookingUp = false), mineSoon()
1741
1741
  job('models.dev')
1742
- if (r) toast(t ? (r.found ? `${t.model}: found in models.dev` : `${t.model}: still not in models.dev`) : `models.dev: ${r.found} of ${r.of} found`)
1742
+ if (r) toast(t ? (r.found ? `${t.model}: found in models.dev` : `${t.model}: still not in models.dev`) : `models.dev: ${r.found} of ${r.of} found${scored ? ' · scores updated' : ''}`)
1743
1743
  return r
1744
1744
  }
1745
1745
 
@@ -1835,7 +1835,7 @@ function drawProviders(s) {
1835
1835
  const shown = shownOrder()
1836
1836
  $('p-mine').hidden = !shown.length
1837
1837
  $('p-mine').textContent = `Your models (${shown.length}) →`
1838
- $('p-mine').title = shown.length ? `HeartCode uses ${shown[0].provider} · ${shown[0].model}. Open the Your models page: the order, tests, and what happens when one fails` : ''
1838
+ $('p-mine').title = shown.length ? `${S.settings.modelChoice === 'fit' ? 'HeartCode picks the best of them for each task' : `HeartCode uses ${shown[0].provider} · ${shown[0].model}`}. Open the Your models page: the order, tests, and what happens when one fails` : ''
1839
1839
  fillHeight()
1840
1840
 
1841
1841
  // every provider's models, A to Z; one click adds it (the first one becomes #1). Built
@@ -1863,7 +1863,7 @@ function sortable(v, onMove) {
1863
1863
  const scrolled = () => (scroller === window ? scrollY : scroller.scrollTop)
1864
1864
  box.addEventListener('pointerdown', (e) => {
1865
1865
  const li = e.target.closest('li.in')
1866
- if (!li || e.button !== 0 || e.target.closest('button, a, input, select, textarea')) return
1866
+ if (!li || e.button !== 0 || e.target.closest('button, a, input, select, textarea') || !box.classList.contains('drag')) return
1867
1867
  if (e.pointerType !== 'mouse' && !e.target.closest('.grip')) return // a finger scrolls the list, except on the grip
1868
1868
  const n = v.items
1869
1869
  const from = Number(li.dataset.i)
@@ -2290,7 +2290,7 @@ function sorted(order) {
2290
2290
  }
2291
2291
  const dirText = (key, dir) => COLS[key].words[dir === 'up' ? 0 : 1] + (key === 'works' ? ' (then not tested, then not working)' : '')
2292
2292
  // Filters on the Your models page: which models are shown (and tested by "Test N shown", counted,
2293
- // sorted, selected by "select all", saved first by Save list). Combined: a model shows when it passes
2293
+ // sorted, selected by "select all", saved first by Save order). Combined: a model shows when it passes
2294
2294
  // all of them. Kept with the page's choices.
2295
2295
  const NO_FILTER = { text: '', provider: '', works: '', context: 0, tools: false, thinking: false, images: false, free: false }
2296
2296
  let FILTER = { ...NO_FILTER }
@@ -2320,19 +2320,7 @@ const setFilter = (change) => {
2320
2320
  savePref('filters', FILTER)
2321
2321
  drawMine(S)
2322
2322
  }
2323
- const RESULT_NAME = (w) => (w === 'works' ? '✓ works' : w === 'fails' ? "✗ doesn't work" : w === 'untested' ? 'not tested' : `✗ ${w}`)
2324
2323
  const CONTEXTS = [[0, 'Any context'], [32_000, '32k+'], [128_000, '128k+'], [200_000, '200k+'], [1_000_000, '1M+']]
2325
- // the active filters, as chips to take off one by one
2326
- const filterChips = () => [
2327
- FILTER.text && [`“${FILTER.text}”`, { text: '' }],
2328
- FILTER.provider && [`Provider: ${FILTER.provider}`, { provider: '' }],
2329
- FILTER.works && [`Result: ${RESULT_NAME(FILTER.works)}`, { works: '' }],
2330
- FILTER.context && [`Context ${CONTEXTS.find(([v]) => v === FILTER.context)?.[1] ?? FILTER.context}`, { context: 0 }],
2331
- FILTER.tools && ['Tools', { tools: false }],
2332
- FILTER.thinking && ['Thinking', { thinking: false }],
2333
- FILTER.images && ['Images', { images: false }],
2334
- FILTER.free && ['Free', { free: false }],
2335
- ].filter(Boolean)
2336
2324
  const clearView = () => {
2337
2325
  SORT = []
2338
2326
  savePref('sorts', SORT)
@@ -2414,7 +2402,7 @@ function drawMine(s) {
2414
2402
  slots.forEach((k, m) => (all[k] = list[m]))
2415
2403
  return keep(all, true)
2416
2404
  }
2417
- // Save list: the models HeartCode uses become the ones shown, in the order shown. Filtered: only
2405
+ // Save order: the models HeartCode uses become the ones shown, in the order shown. Filtered: only
2418
2406
  // those (asked first; the others stay under Providers, to add back any time)
2419
2407
  const saveList = () => {
2420
2408
  if (filtered && !confirm(`HeartCode will use only these ${n(view.length)}, in this order.\n\nThe other ${n(order.length - view.length)} stay under Providers: add any back whenever you like.`)) return
@@ -2429,52 +2417,53 @@ function drawMine(s) {
2429
2417
  }
2430
2418
  const pickedList = order.filter((t) => PICKED.has(keyOf(t)))
2431
2419
 
2432
- // --- the page's header, right: what's known about the models ---
2420
+ // --- the page's header: how a model is picked (left), what's known about the models (right) ---
2421
+ $('mt-lead').textContent = S.settings.modelChoice === 'fit'
2422
+ ? 'Each message goes to the models that score best for it. Your order breaks ties, and decides among models with no score. Filter, sort or drag, then Save order.'
2423
+ : 'HeartCode uses #1, and the next one when it fails. Filter, sort or drag, then Save order.'
2424
+ const busy = locked()
2425
+ $('mt-actions').inert = busy
2433
2426
  put($('mt-actions'),
2434
- 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 }),
2435
- 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() }))
2427
+ ((why) => h('span', { title: why ?? '' }, h('button', { className: 'small', textContent: 'Order providers', disabled: Boolean(why), title: why ? '' : 'drag your providers into order; the Provider column sorts by it', onclick: openRanking })))( // disabled: why, on a span (a disabled button shows no tooltip in every browser)
2428
+ S.settings.modelChoice === 'fit' ? 'Not used while Pick is "the best for each task": each message gets the models ranked best for it, whatever their provider. Pick "in your order" to use it'
2429
+ : !order.some((t) => t.provider !== order[0]?.provider) ? 'All your models are from one provider: nothing to order' : null),
2430
+ h('button', { className: 'small', textContent: 'Update model info', disabled: !order.length, title: `what each model can do (context, tools, thinking, images, price) from models.dev, and its scores in LMArena's public rankings (coding, web apps, vision${S.rankings ? `; scores from ${new Date(S.rankings.fetched).toLocaleDateString()}` : ''}). Best fit also gets the scores again once a week`, onclick: () => lookUp() }))
2436
2431
 
2437
- // --- the list's settings: five cells across, a label over each control ---
2432
+ // --- the list's settings: one line, a short label beside each control ---
2438
2433
  const ro = s.rotation
2439
2434
  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))
2440
2435
  const fit = S.settings.modelChoice === 'fit'
2441
- const settings = h('div', { className: 'mt-sets' },
2442
- cell('HeartCode picks the model by', fit ? 'for each new message, your models ranked by public rankings (LMArena, fetched once a week) on the skills it needs: web pages, code, images…; models not ranked come after, in your order' : 'your order: #1 works, the next takes over when it fails',
2436
+ const settings = h('div', { className: 'mt-sets', inert: busy },
2437
+ cell('Pick', fit ? 'for each new message, your models ranked by public rankings (LMArena, fetched once a week) on the skills it needs: web pages, code, images…; models not ranked come after, in your order' : 'your order: #1 works, the next takes over when it fails',
2443
2438
  h('select', { onchange: (e) => act('/api/setting', { name: 'modelChoice', value: e.target.value }, e.target.value === 'fit' ? 'models picked for each task by public rankings' : 'models used in your order') },
2444
- [['order', 'your order'], ['fit', 'best fit per task']].map(([v, t]) => h('option', { value: v, textContent: t, selected: S.settings.modelChoice === v })))),
2445
- 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",
2439
+ [['order', 'in your order'], ['fit', 'the best for each task']].map(([v, t]) => h('option', { value: v, textContent: t, selected: S.settings.modelChoice === v })))),
2440
+ cell('If one 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",
2446
2441
  h('select', { onchange: (e) => saveOrder(S.order, 'saved', { on: e.target.value }) },
2447
- [['failure', 'the next one answers'], ['retries', 'try it again first']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.on === v }))),
2442
+ [['failure', 'go to the next'], ['retries', 'retry it first']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.on === v }))),
2448
2443
  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),
2449
- cell('A reply must start within', "a model that hasn't started answering (text, thinking or a tool call) in this many seconds counts as failed: the next one answers",
2444
+ cell('Give up after', "a model that hasn't started answering (text, thinking or a tool call) in this many seconds counts as failed: the next one answers",
2450
2445
  h('input', { type: 'number', className: 'tries', 'aria-label': 'seconds a reply must start within', title: "a model that hasn't started answering (text, thinking or a tool call) in this many seconds counts as failed: the next one answers", min: 5, max: 600, value: S.settings.replyStart ?? 60, onchange: (e) => {
2451
2446
  const v = Math.round(Number(e.target.value))
2452
2447
  if (!(v >= 5 && v <= 600)) return (e.target.value = S.settings.replyStart ?? 60), toast('a whole number of seconds, 5 to 600', true)
2453
2448
  act('/api/setting', { name: 'replyStart', value: v }, `a model that hasn't started answering in ${v}s counts as failed`)
2454
- } }), h('span', { className: 'unit', textContent: 'seconds' })),
2455
- cell('A new message starts with', fit ? 'best fit picks it for each message' : 'the model a new message goes to first',
2449
+ } }), h('span', { className: 'unit', textContent: 'seconds of silence' })),
2450
+ cell('New message to', fit ? 'best fit picks it for each message' : 'the model a new message goes to first',
2456
2451
  h('select', { disabled: fit, onchange: (e) => saveOrder(S.order, 'saved', { next: e.target.value }) },
2457
- [['first', '#1'], ['stay', 'the last that answered']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v })))),
2458
- cell('A test waits for an answer', 'every model test: Test, Test all, Request',
2452
+ [['first', '#1'], ['stay', 'the last that worked']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v })))),
2453
+ cell('Tests wait', 'every model test: Test, Test all, Request',
2459
2454
  h('input', { type: 'number', min: 1, max: 600, step: 1, value: S.settings.testTimeout ?? 10, 'aria-label': 'Test timeout in seconds', onchange: (e) => {
2460
2455
  const v = Math.round(Number(e.target.value))
2461
2456
  if (!(v >= 1 && v <= 600)) return (e.target.value = S.settings.testTimeout ?? 10), toast('a whole number of seconds, 1 to 600', true)
2462
2457
  act('/api/setting', { name: 'testTimeout', value: v }, `tests wait ${v} second${v === 1 ? '' : 's'} for an answer`)
2463
2458
  } }), h('span', { className: 'unit', textContent: 'seconds' })))
2464
2459
 
2465
- // --- under the filters: what's shown (left) · what you do with it (right) ---
2466
- const chip = (label, off, cls = '') => h('span', { className: 'chip ' + cls }, label, h('button', { type: 'button', textContent: '✕', 'aria-label': `remove ${label}`, onclick: off }))
2460
+ // --- beside the filters: what's shown · what you do with it (the sorts show in the column heads) ---
2467
2461
  const line = h('div', { className: 'mt-line' },
2468
- h('div', { className: 'mt-status' },
2469
- 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'}${fit ? ', the order breaks ties' : ', in your order'}`]),
2470
- ...filterChips().map(([label, off]) => chip(label, () => setFilter(off))),
2471
- ...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')),
2472
- testingAll && SORT.some((x) => x.key === 'works') ? h('span', { className: 'sort-live', textContent: 'tests running: the order moves as results come in' }) : null,
2473
- 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),
2474
- h('div', { className: 'mt-do' },
2475
- h('button', { className: 'small', textContent: S.rankings ? 'Refresh rankings' : 'Get rankings', title: `${S.rankings ? `rankings from ${new Date(S.rankings.fetched).toLocaleDateString()}; ` : ''}each model's place in LMArena's public rankings (coding, web apps, vision): best fit picks by them, and gets them again once a week`, onclick: () => act('/api/rankings', {}, 'rankings updated') }),
2476
- 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) }),
2477
- h('button', { className: 'small primary', textContent: filtered ? `Use these ${n(view.length)}` : 'Save list', disabled: !view.length || order.length < 2, title: filtered ? `HeartCode uses only these ${n(view.length)}, in the order shown (the others stay under Providers)` : 'save the list in the order shown (#1 first)', onclick: saveList })))
2462
+ h('span', { className: 'count', title: SORT.length ? `sorted by ${SORT.map(({ key, dir }) => `${COLS[key].label} ${COLS[key].words[dir === 'up' ? 0 : 1]}`).join(', then ')}; ties keep your order` : '' }, filtered ? [h('b', { textContent: n(shown.length) }), ` of ${n(order.length)}`] : [h('b', { textContent: n(order.length) }), ` model${order.length === 1 ? '' : 's'}`]),
2463
+ busy ? h('span', { className: 'sort-live', textContent: `${testingAll ? 'testing' : 'updating'}: filters and changes wait until it's done (or Stop)` }) : null,
2464
+ filtering() || SORT.length ? h('button', { className: 'small ghost', textContent: 'Clear', title: 'every filter and the sort off: your whole list, in your order', onclick: clearView }) : null,
2465
+ h('button', { className: 'small', textContent: filtered ? `Test ${n(shown.length)}` : '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) }),
2466
+ h('button', { className: 'small primary', textContent: filtered ? `Use only these ${n(view.length)}` : 'Save order', disabled: !view.length || order.length < 2, title: filtered ? `HeartCode uses only these ${n(view.length)}, in the order shown (the others stay under Providers)` : S.settings.modelChoice === 'fit' ? 'keep the order shown: it breaks ties between equally scored models' : 'HeartCode uses them in the order shown (#1 first)', onclick: saveList }))
2478
2467
 
2479
2468
  // --- the table ---
2480
2469
  const all = view.length > 0 && view.every((t) => PICKED.has(keyOf(t)))
@@ -2495,7 +2484,7 @@ function drawMine(s) {
2495
2484
  h('button', { className: 'small ghost', textContent: 'Select none', onclick: () => (PICKED.clear(), drawMine(S)) })))
2496
2485
  : h('div', { className: 'mt mt-h' }, h('span'), selectAll,
2497
2486
  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('coding', 'num'), head('web', 'num'), head('vision', 'num'), head('price', 'num'), head('works'), h('span', { className: 'num', textContent: '' }))
2498
- const table = view.length ? h('ol', { className: 'mtable' + (view.length < 2 ? '' : ' drag') }) : null
2487
+ const table = view.length ? h('ol', { className: 'mtable' + (view.length < 2 || busy ? '' : ' drag') }) : null
2499
2488
  // ticked or not; with Shift, every row from the last one ticked to this one
2500
2489
  const pick = (i, e) => {
2501
2490
  const on = !PICKED.has(keyOf(view[i]))
@@ -2524,10 +2513,9 @@ function drawMine(s) {
2524
2513
  order.length > 1 ? settings : null,
2525
2514
  order.length
2526
2515
  ? h('div', { className: 'mt-tools' },
2527
- filterBarOf(order, results),
2528
- line,
2516
+ h('div', { className: 'mt-row', inert: busy }, filterBarOf(order, results), line),
2529
2517
  (tableJobs ??= jobSlot('table')), // the same one every time: its Stop button isn't replaced under the mouse
2530
- view.length ? h('div', { className: 'mt-hwrap' }, header) : null)
2518
+ view.length ? h('div', { className: 'mt-hwrap', inert: busy }, header) : null)
2531
2519
  : null,
2532
2520
  order.length
2533
2521
  ? 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' },
@@ -2542,11 +2530,13 @@ function drawMine(s) {
2542
2530
  }
2543
2531
  // the table's cells: yes or no; where what it can do comes from
2544
2532
  const yes = (v) => h('span', { className: (v ? 'yes' : 'no') + ' mid', textContent: v ? '✓' : '–' })
2545
- // its place in LMArena's ranking of that skill (#1 is the best of all models there); the top tenth stands out
2533
+ // its score and place in LMArena's ranking of that skill (#1 is the best of all models there); the top tenth stands out
2546
2534
  const RANK_OF = { coding: 'coding', web: 'web apps (WebDev)', vision: 'vision' }
2547
2535
  const rankCell = (t, k) => {
2548
2536
  const r = t.ranks?.[k]
2549
- return h('span', { className: 'num rk' + (r && r.rank / r.of <= 0.1 ? ' top' : ''), textContent: r ? `#${r.rank}` : '–', title: r ? `#${r.rank} of ${r.of} models in LMArena's ${RANK_OF[k]} ranking (as "${r.as}")` : S.rankings ? `not in LMArena's ${RANK_OF[k]} ranking` : 'no rankings yet: Get rankings, above the list' })
2537
+ if (!r) return h('span', { className: 'num rk', textContent: '–', title: S.rankings ? `not in LMArena's ${RANK_OF[k]} ranking` : 'no scores yet: Update model info, at the top' })
2538
+ return h('span', { className: 'num rk' + (r.rank / r.of <= 0.1 ? ' top' : ''), title: `${r.score != null ? `score ${r.score}${r.votes ? ` from ${r.votes.toLocaleString()} votes` : ''}, ` : ''}#${r.rank} of ${r.of} models in LMArena's ${RANK_OF[k]} ranking (as "${r.as}")${r.score == null ? '. Update model info for the scores' : ''}` },
2539
+ r.score != null ? h('b', { textContent: r.score }) : '', `#${r.rank}`)
2550
2540
  }
2551
2541
  const src = (t) => {
2552
2542
  const x = t.tested
@@ -2567,9 +2557,10 @@ function tableRow(t, at, pick) {
2567
2557
  : 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) })
2568
2558
  : 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
2569
2559
  const going = Boolean(TRIES[keyOf(t)]?.going)
2560
+ const busy = locked()
2570
2561
  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` : '' },
2571
2562
  h('span', { className: 'grip', textContent: '⋮⋮', 'aria-hidden': 'true' }),
2572
- 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)) }),
2563
+ h('input', { type: 'checkbox', checked: picked, disabled: busy, 'aria-label': `select ${t.model}`, title: 'select (Shift: and every row up to the last one selected)', onclick: (e) => (e.preventDefault(), pick(e)) }),
2573
2564
  h('span', { className: 'n', textContent: `#${at + 1}`, title: SORT.length || filtering() ? 'its place in your list' : '' }),
2574
2565
  h('span', { className: 'm' }, h('span', { className: 'name', textContent: t.model, title: t.model }), tag),
2575
2566
  h('span', { className: 'p', textContent: isOff(t.provider) ? `${t.provider} · off` : t.provider, title: t.provider }),
@@ -2579,10 +2570,10 @@ function tableRow(t, at, pick) {
2579
2570
  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' }),
2580
2571
  triedCell(t),
2581
2572
  h('span', { className: 'acts' },
2582
- 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')),
2573
+ h('button', { type: 'button', className: 'small ghost ib k-test row-test', disabled: going || busy, 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')),
2583
2574
  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')),
2584
- 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')),
2585
- 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'))))
2575
+ h('button', { type: 'button', className: 'small ghost ib k-edit', disabled: busy, 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')),
2576
+ h('button', { type: 'button', className: 'small ghost ib k-del', disabled: busy, title: 'Remove it from your list (it stays under its provider)', 'aria-label': `remove ${t.model}`, onclick: () => removeMine(t.provider, t.model) }, ic('trash'))))
2586
2577
  }
2587
2578
 
2588
2579
  // your list changed: the rows and counts it touches, in place
@@ -2604,7 +2595,9 @@ function markCatalog() {
2604
2595
  function drawUsing(s) {
2605
2596
  const o = s.order.filter((t) => !isOff(t.provider))
2606
2597
  $('using').hidden = page() === 'providers' // there it's on the page itself
2607
- put($('using'), o.length ? [h('span', { className: 'k', textContent: 'HeartCode uses' }), h('b', { textContent: o[0].model }), h('span', { className: 'k', textContent: `${o[0].provider}${o.length > 1 ? ` · ${o.length - 1} fallback${o.length > 2 ? 's' : ''}` : ''}` })] : s.order.length ? [h('span', { className: 'k', textContent: 'The providers of all your models are switched off' }), h('a', { href: '#providers', textContent: 'Switch one on' })] : [h('span', { className: 'k', textContent: 'No model chosen yet' }), h('a', { href: '#providers', textContent: 'Choose one' })])
2598
+ const fit = s.settings.modelChoice === 'fit' // best fit: no one model is "the one"
2599
+ put($('using'), o.length && fit ? [h('span', { className: 'k', textContent: 'HeartCode picks' }), h('b', { textContent: 'the best for each task' }), h('span', { className: 'k', textContent: `from your ${o.length.toLocaleString()} model${o.length > 1 ? 's' : ''}` })]
2600
+ : o.length ? [h('span', { className: 'k', textContent: 'HeartCode uses' }), h('b', { textContent: o[0].model }), h('span', { className: 'k', textContent: `${o[0].provider}${o.length > 1 ? ` · ${o.length - 1} fallback${o.length > 2 ? 's' : ''}` : ''}` })] : s.order.length ? [h('span', { className: 'k', textContent: 'The providers of all your models are switched off' }), h('a', { href: '#providers', textContent: 'Switch one on' })] : [h('span', { className: 'k', textContent: 'No model chosen yet' }), h('a', { href: '#providers', textContent: 'Choose one' })])
2608
2601
  }
2609
2602
 
2610
2603
  // --- General ---
@@ -2997,7 +2990,7 @@ function drawPrompts(s) {
2997
2990
  const match = (p) => !promptQuery || `${p.id} ${p.title ?? ''} ${p.note}`.toLowerCase().includes(promptQuery)
2998
2991
  const item = (p) => ({ id: p.id, title: p.title ? p.title.replace(/^System prompt /, 'System ') : p.id.split('/')[1], sub: p.title ? p.id : p.note.split('\n')[0], badge: p.changed ? h('span', { className: 'tag brand', textContent: 'yours' }) : null, p })
2999
2992
  const groups = [{ title: 'System prompts', items: s.prompts.filter((p) => p.title && match(p)).map(item) }]
3000
- for (const file of ['agent', 'guided', 'compact', 'probe']) groups.push({ title: { agent: 'Tools, notes and replies', guided: 'Guided mode (models without tool calls)', compact: 'Summaries', probe: 'Model tests' }[file], items: s.prompts.filter((p) => !p.title && p.id.startsWith(file + '/') && match(p)).map(item) })
2993
+ for (const file of ['agent', 'guided', 'compact']) groups.push({ title: { agent: 'Tools, notes and replies', guided: 'Guided mode (models without tool calls)', compact: 'Summaries' }[file], items: s.prompts.filter((p) => !p.title && p.id.startsWith(file + '/') && match(p)).map(item) })
3001
2994
  masterDetail('prompts', $('r-items'), $('r-detail'), groups, (x) => {
3002
2995
  if (!x) return h('div', { className: 'card empty', textContent: 'No prompt matches.' })
3003
2996
  const p = x.p
package/src/settings.js CHANGED
@@ -1,4 +1,4 @@
1
- // The settings page: a small web server on this machine (127.0.0.1 only) where everything but
1
+ // The settings page: a small web server (on this machine, and on its network address for another device) where everything but
2
2
  // the chat can be changed: providers and their keys, the model, settings, MCP servers, hooks,
3
3
  // keys, colors, skills. Open with `heartcode settings` or /settings. A secret token in
4
4
  // the link guards it (another site, or another user on this machine, can't use it); API keys
@@ -30,7 +30,7 @@ import { log, LOGS, REQUESTS, useRequestLog, listRequests, readRequest, pruneLog
30
30
 
31
31
  const PAGE = new URL('./settings.html', import.meta.url)
32
32
  const EFFORTS = ['default', 'low', 'medium', 'high']
33
- const TOGGLES = { autoCompact: 'compact the conversation when it fills 85% of the model\'s context window', director: 'let the model add skills, MCP servers and change settings when asked', format: "run the project's formatter on every file HeartCode writes", lsp: "show the model a language server's errors after each edit", updateCheck: 'check once a day whether a newer HeartCode is out (shown in the status bar; /update installs it)' }
33
+ const TOGGLES = { autoCompact: 'compact the conversation when it fills 85% of the model\'s context window', director: 'let the model add skills, MCP servers and change settings when asked', format: "run the project's formatter on every file HeartCode writes", lsp: "show the model a language server's errors after each edit", updateCheck: 'check at every start whether a newer HeartCode is out (shown in the status bar; /update installs it)' }
34
34
  // The Logging page's: both off unless switched on; how much of each request ("full" or "summary")
35
35
  // The status-bar items the visual editor offers (id must match App.status in bin/heartcode.js).
36
36
  // `sample` is shown in the page's live preview.
@@ -61,7 +61,7 @@ const FILES = [
61
61
  ['HEARTCODE.md', 'Your instructions for every project (like AGENTS.md, for all of them)', false, '- Answer briefly.\n- Use pnpm, not npm.'],
62
62
  ]
63
63
  // The prompts the page edits: every section of these files (prompts/*.md); the system prompts first.
64
- const PROMPT_FILES = ['agent', 'guided', 'compact', 'probe']
64
+ const PROMPT_FILES = ['agent', 'guided', 'compact']
65
65
  const FIRST = { 'agent/system': 'System prompt (models with tool calls)', 'guided/system': 'System prompt (guided mode: models without tool calls)' }
66
66
  const ownPrompts = (file) => path.join(HOME, 'prompts', `${file}.md`)
67
67
  const tilde = (p) => (p.startsWith(os.homedir() + path.sep) ? '~' + p.slice(os.homedir().length) : p)
@@ -392,7 +392,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
392
392
 
393
393
  const routes = {
394
394
  'GET /api/state': () => state(),
395
- // the public rankings, fetched now (Get rankings / Refresh on Your models)
395
+ // the public rankings, fetched now (with models.dev: Update model info on Your models)
396
396
  'POST /api/rankings': async () => {
397
397
  if (!(await rankings({ now: true }))) throw new Error("couldn't get the rankings (huggingface.co)")
398
398
  return state()
@@ -513,7 +513,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
513
513
  const profile = loadProfile(new Client({ baseUrl: p.baseUrl, apiKey: p.apiKey, model: id }))
514
514
  return [id, {
515
515
  ...saved.details[id],
516
- tested: profile ? { mode: strategy(profile).actions, context: profile.context, thinking: Boolean(profile.thinking), vision: strategy(profile).vision } : undefined,
516
+ tested: profile ? ((st) => ({ mode: st.actions, context: profile.context, thinking: st.thinking, vision: st.vision }))(strategy(profile)) : undefined,
517
517
  known: limitsOf(name, p.baseUrl, id) ?? undefined,
518
518
  }]
519
519
  }))
@@ -937,9 +937,9 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
937
937
  res.end(type === 'application/json' ? JSON.stringify(body) : body)
938
938
  }
939
939
  try {
940
- // only as 127.0.0.1 or localhost (a site renamed to this address can't reach it), and only with the token
940
+ // only by this machine's own names and addresses (a site renamed to this address can't reach it), and only with the token
941
941
  const { port: p } = server.address()
942
- if (![`127.0.0.1:${p}`, `localhost:${p}`].includes(req.headers.host)) return send(403, { error: 'wrong host' })
942
+ if (!['127.0.0.1', 'localhost', ...addresses()].map((h) => `${h}:${p}`).includes(req.headers.host)) return send(403, { error: 'wrong host' })
943
943
  const url = new URL(req.url, `http://${req.headers.host}`)
944
944
  if (url.pathname === '/favicon.ico') return res.writeHead(204).end() // the browser asks, without the token
945
945
  const given = url.pathname === '/' || url.pathname === '/api/events' ? url.searchParams.get('t') : req.headers['x-heart-token']
@@ -972,20 +972,25 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
972
972
  return new Promise((resolve, reject) => {
973
973
  server.on('error', reject)
974
974
  forgetTests() // results of models no longer yours, left from before
975
- server.listen(port, '127.0.0.1', () => {
976
- const url = `http://127.0.0.1:${server.address().port}/?t=${token}`
977
- log('web', `settings page at 127.0.0.1:${server.address().port}`)
975
+ server.listen(port, '0.0.0.0', () => {
976
+ const at = (host) => `http://${host}:${server.address().port}/?t=${token}`
977
+ const local = at('127.0.0.1') // for a browser on this machine
978
+ const url = at(addresses()[0] ?? '127.0.0.1') // its network address when it has one: works from another device too
979
+ log('web', `settings page at ${new URL(url).host}`)
978
980
  // models.dev's list (its sizes for your models, whether their providers' lists are on or not):
979
981
  // loaded now, and your models' lines brought up to date when it's in
980
982
  loadPrices().then(() => {
981
983
  for (const t of state().order) testNews(`${t.provider}/${t.model}`, t)
982
984
  test(state().order) // any without a profile yet
983
985
  })
984
- resolve({ url, server, close: () => (watcher?.close(), server.closeAllConnections?.(), server.close()) })
986
+ resolve({ url, local, server, close: () => (watcher?.close(), server.closeAllConnections?.(), server.close()) })
985
987
  })
986
988
  })
987
989
  }
988
990
 
991
+ // This machine's IPv4 addresses on its networks (Wi-Fi, Ethernet, a VPN), not the loopback one
992
+ const addresses = () => Object.values(os.networkInterfaces()).flat().filter((n) => n && n.family === 'IPv4' && !n.internal).map((n) => n.address)
993
+
989
994
  // What a model costs at this provider, per million tokens, as its own model list says: { input,
990
995
  // output } (either may be missing), or undefined. Not models.dev's: the same model costs differently
991
996
  // at different providers. The forms lists use: pricing.prompt/completion (per token, OpenRouter's);