heartcode 0.1.95 → 0.1.101

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/CHANGELOG.md CHANGED
@@ -2,6 +2,51 @@
2
2
 
3
3
  What changed in each version of HeartCode, newest first.
4
4
 
5
+ ## 0.1.101 (2026-11-24)
6
+
7
+ - **Room above the status line**: three empty rows between the conversation and "thinking · 27s"
8
+ while it works (one on a short terminal), so the two don't run together.
9
+
10
+ ## 0.1.100 (2026-11-24)
11
+
12
+ - The 0.1.99 note named the wrong key for the whole plan: it's Alt+L.
13
+
14
+ ## 0.1.99 (2026-11-24)
15
+
16
+ - **One quiet row under the conversation while it works**: what's happening in a few words
17
+ ("thinking", "running a command", "searching the web"), the plan's progress and helpers as a
18
+ count ("plan 2/5 · 2 helpers"), the time, and Esc. The command, its output, the helpers' doings
19
+ and the plan's steps are no longer listed there: what's being done is in the conversation above
20
+ (each step as it runs). The whole plan: Alt+L (`show_plan`) as before.
21
+ - **The ♥ by the input beats while HeartCode works on your message** (lub-dub, then a rest).
22
+
23
+ ## 0.1.98 (2026-11-24)
24
+
25
+ - **No more stray lines under the spinner.** A multi-line command (a script run with `node -e "…"`,
26
+ a heredoc) put its line breaks into the spinner ("running … › its last output line") and into its
27
+ step ("✓ Run …"); the terminal wrote them on rows the screen didn't track, which stayed there
28
+ ("s = s… › ok · 8m 53s") or scrambled the lines around them. Both are one line now, and nothing
29
+ drawn under the conversation can carry a line break or a tab.
30
+
31
+ ## 0.1.97 (2026-11-24)
32
+
33
+ - **`/update` shows the whole changelog**, newest first, with the versions since yours marked
34
+ `· new`; PgUp/PgDn or the mouse wheel scroll it (↑↓ still choose Update now / Not now). It said
35
+ "no changelog found": it was read from GitHub's main branch, which can be behind npm; now it's
36
+ the changelog of the version on offer, from its npm package.
37
+ - Any question with a long text above its choices scrolls the same way.
38
+
39
+ ## 0.1.96 (2026-11-24)
40
+
41
+ - **A test no longer passes a model that only seemed to answer.** Asked to reply "OK":
42
+ - **Answered with an error** (`✗ error reply`): its answer is an error as text ("doesn't have enough
43
+ credits", "Upgrade your plan", `Model "…" is not available`): the request went through, the
44
+ model doesn't work.
45
+ - **Didn't answer** (`✗ off-topic`): something else altogether (an image or audio link, a safety
46
+ verdict, a persona's greeting): likely not a chat model.
47
+ Both count as not working (helpers, Doesn't work) and are in the Result filter. Results already
48
+ saved are judged the same way, without testing again.
49
+
5
50
  ## 0.1.95 (2026-11-23)
6
51
 
7
52
  - **The Providers page, rewritten**: one state (the filters, the folds, the ticked models) and one way
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartcode",
3
- "version": "0.1.95",
3
+ "version": "0.1.101",
4
4
  "description": "A coding CLI for any local or OpenAI-compatible model, including small models without tool calling.",
5
5
  "keywords": [
6
6
  "ai",
package/src/settings.html CHANGED
@@ -1960,13 +1960,15 @@ const MEANS = {
1960
1960
  502: '502: the provider (or a proxy before it) couldn\'t reach the model',
1961
1961
  503: '503: the model or provider is unavailable now',
1962
1962
  504: '504: the provider timed out',
1963
+ 'answered with an error': 'the request went through, but its answer is an error: not enough credits, upgrade your plan, a model that isn\'t available… (as text, not as an error code)',
1964
+ "didn't answer": 'the request went through, but it didn\'t answer the question (asked to reply "OK"): an image or audio link, a safety verdict, something else altogether. Likely not a chat model',
1963
1965
  empty: 'it answered, but with no text at all',
1964
1966
  'no answer': 'no answer within the test timeout (Tests wait, above the list)',
1965
1967
  failed: 'it failed without a status code (a lost connection, an unreadable reply…)',
1966
1968
  }
1967
1969
  // What a test came to, in a word: works, its status code (402, 429…), empty, no answer or failed;
1968
1970
  // null while it runs or before it's tested
1969
- const outcome = (r) => (!r || r.going ? null : r.ok ? 'works' : r.status ? String(r.status) : r.kind === 'empty' || (!r.kind && /nothing/.test(r.error)) ? 'empty' : r.kind === 'timeout' || (!r.kind && /within/.test(r.error)) ? 'no answer' : 'failed') // kind: said by the server (older results: their words)
1971
+ const outcome = (r) => (!r || r.going ? null : r.ok ? 'works' : r.kind === 'said-error' ? 'answered with an error' : r.kind === 'off-task' ? "didn't answer" : r.status ? String(r.status) : r.kind === 'empty' || (!r.kind && /nothing/.test(r.error)) ? 'empty' : r.kind === 'timeout' || (!r.kind && /within/.test(r.error)) ? 'no answer' : 'failed') // kind: said by the server (older results: their words)
1970
1972
  // The Works? cell: the last result (cut short, all of it on hover) and Test.
1971
1973
  function triedCell(t) {
1972
1974
  const r = TRIES[keyOf(t)]
@@ -1975,7 +1977,7 @@ function triedCell(t) {
1975
1977
  : r.going ? ['going', 'testing…', 'sending it a short message']
1976
1978
  : r.ok && r.toolsOk === false ? ['ok', `✓ ${(r.ms / 1000).toFixed(1)}s · ✗ tools`, `it answers ("${r.reply}"), but it couldn't do a small job with a tool, so it's a poor choice for work: ${r.toolsWhy}${secs}`]
1977
1979
  : r.ok ? ['ok', `✓ ${(r.ms / 1000).toFixed(1)}s`, `works: it answered "${r.reply}"${r.toolsOk ? ', and did a small job with a tool' : ''}${secs}`]
1978
- : ['bad', `✗ ${outcome(r)}`, `doesn't work: ${r.error}${secs}`] // the reason on hover
1980
+ : ['bad', `✗ ${{ 'answered with an error': 'error reply', "didn't answer": 'off-topic' }[outcome(r)] ?? outcome(r)}`, `doesn't work: ${r.error}${secs}`] // short in the cell, the reason on hover
1979
1981
  return h('div', { className: 'try ' + cls }, h('span', { className: 'msg', textContent: text, title: about }))
1980
1982
  }
1981
1983
  function showTried(t) {
package/src/settings.js CHANGED
@@ -264,7 +264,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
264
264
  // doesn't stop them. Each result is kept in ~/.heart/model-tests.json ("provider/model" → { ok, ms,
265
265
  // reply | error, status, at }) and sent to the page as it comes.
266
266
  const TESTS_FILE = path.join(HOME, 'model-tests.json')
267
- const tests = readJson(TESTS_FILE, {})
267
+ const tests = Object.fromEntries(Object.entries(readJson(TESTS_FILE, {})).map(([k, r]) => [k, judged(r)])) // older results judged the same way
268
268
  let saving = null
269
269
  const gone = new Set() // tests forgotten here since the last write
270
270
  // merged with the file as it is now: another HeartCode's results written meanwhile stay
@@ -309,7 +309,9 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
309
309
  const reply = (r.content || '').trim()
310
310
  if (!reply && !r.toolCalls.length) return { ok: false, kind: 'empty', ms: Date.now() - t0, error: `it answered with nothing${r.usage?.completion_tokens ? ` (${r.usage.completion_tokens} tokens it said it wrote)` : ''}` }
311
311
  const ms = Date.now() - t0
312
- return { ok: true, ms, reply: reply.slice(0, 80), ...(testedOf({ provider, model })?.mode === 'tools' && !c.cli && (await toolTest(c, stop))) }
312
+ const verdict = judged({ ok: true, ms, reply: reply.slice(0, 200) })
313
+ if (!verdict.ok) return verdict // an error said as its answer, or no answer to the question: no tool test
314
+ return { ...verdict, ...(testedOf({ provider, model })?.mode === 'tools' && !c.cli && (await toolTest(c, stop))) }
313
315
  } catch (e) {
314
316
  if (stop?.aborted) return { stopped: true }
315
317
  return { ok: false, ms: Date.now() - t0, status: e.status ?? null, ...(e.name === 'TimeoutError' && { kind: 'timeout' }), error: e.name === 'TimeoutError' ? noAnswer() : whyFailed(e), ...(e.retryAfter > 0 && { retryAfter: Number(e.retryAfter) }) }
@@ -1283,6 +1285,20 @@ function warm() {
1283
1285
  step(0)
1284
1286
  }
1285
1287
 
1288
+ // A test's answer, judged: asked to reply with just "OK", a model that answered with an error as its
1289
+ // text (a provider's "not enough credits", a CLI's "Model … is not available") or with something else
1290
+ // altogether (an image link, a safety verdict, a persona's greeting) doesn't work for HeartCode,
1291
+ // though the request went through. OK with more around it (thinking written into the answer) works.
1292
+ const SAID_ERROR = /\b(error|exception|execution failed|not available|unavailable|not supported|insufficient|not enough credits|enough credits|top ?up|upgrade your plan|recharg\w*|quota|rate.?limit\w*|unauthori[sz]ed|forbidden|invalid (api )?key|access denied|not allowed|exceeded|billing|payment required)\b/i
1293
+ export function judged(r) {
1294
+ if (!r?.ok || typeof r.reply !== 'string') return r
1295
+ const text = r.reply.trim()
1296
+ if (/^\W*ok(ay)?\W*$/i.test(text)) return r
1297
+ if (SAID_ERROR.test(text)) return { ...r, ok: false, kind: 'said-error', error: `it answered with an error: "${clip(text.replace(/\s+/g, ' '), 160)}"` }
1298
+ if (!/\bok(ay)?\b/i.test(text)) return { ...r, ok: false, kind: 'off-task', error: `it didn't answer the question (asked to reply "OK"): "${clip(text.replace(/\s+/g, ' '), 160)}"` }
1299
+ return r
1300
+ }
1301
+
1286
1302
  // This machine's IPv4 addresses on its networks (Wi-Fi, Ethernet, a VPN), not the loopback one
1287
1303
  const addresses = () => Object.values(os.networkInterfaces()).flat().filter((n) => n && n.family === 'IPv4' && !n.internal).map((n) => n.address)
1288
1304
 
package/src/tools.js CHANGED
@@ -573,13 +573,7 @@ export async function runConfirmed(s, cmd, signal, background = false, wait) {
573
573
  const secs = Number(wait) > 0 ? Number(wait) : background ? 3 : 30
574
574
  const before = snapshot(s)
575
575
  const job = startJob(s.root, cmd)
576
- // its latest output line beside it, read a few times a second (the label is re-read every frame)
577
- let last = ''
578
- let readAt = 0
579
- s.ui.spinner(() => {
580
- if (Date.now() - readAt > 250) [readAt, last] = [Date.now(), tailLines(job, 3).filter((l) => l.trim()).at(-1)?.trim() ?? '']
581
- return `running ${clip(cmd, 50)}${last ? ` › ${clip(last, 60)}` : ''}`
582
- })
576
+ s.ui.spinner('running a command') // the command itself is the step above, in the conversation
583
577
  await waitFor(job, secs * 1000, signal)
584
578
  s.ui.stopSpin()
585
579
  if (!job.exited) {
@@ -623,7 +617,7 @@ async function backgroundTool(s, a, signal) {
623
617
  return was ? `Stopped #${job.id} (${job.command}).` : `#${job.id} had already exited with ${job.code}.`
624
618
  }
625
619
  if (Number(a.wait) > 0) {
626
- s.ui.spinner(`waiting on #${job.id} ${clip(job.command, 60)}`)
620
+ s.ui.spinner('waiting for a background command')
627
621
  await waitFor(job, Number(a.wait) * 1000, signal)
628
622
  s.ui.stopSpin()
629
623
  }
@@ -1200,7 +1194,7 @@ async function webTool(s, name, args, signal) {
1200
1194
  log('research', `"${what}": ${saved.length} saved page(s) offered first`)
1201
1195
  return prompt('agent/research-saved', { query: what, pages: saved.map((r) => `- ${r.title} — ${r.url} (read ${r.fetched}${r.used_for ? `; used for: ${r.used_for}` : ''}) → ${r.file}`).join('\n') })
1202
1196
  }
1203
- s.ui.spinner(`searching: ${clip(what, 60)}`)
1197
+ s.ui.spinner('searching the web')
1204
1198
  const out = await webSearch(what, { signal })
1205
1199
  if (s.root && !s.noResearch && !/^(error:|no results)/.test(out)) {
1206
1200
  const { file } = saveSearch(s.root, what, out)
@@ -1208,7 +1202,7 @@ async function webTool(s, name, args, signal) {
1208
1202
  }
1209
1203
  return out
1210
1204
  }
1211
- s.ui.spinner(`fetching ${clip(what, 60)}`)
1205
+ s.ui.spinner('reading a web page')
1212
1206
  const allowed = hostsIn(s.task) // a local or private host you named: may be fetched
1213
1207
  if (!s.root || s.noResearch) return await webFetch(what, { start: args.start, signal, allowed }) // nothing kept (--no-memory)
1214
1208
  const page = await fetchPage(what, { signal, allowed })
@@ -1411,7 +1405,7 @@ async function callMcp(s, server, tool, a, signal) {
1411
1405
  s.mcpRead.add(`${server.name}\n${tool}`)
1412
1406
  }
1413
1407
  const done = await s.mcpGate?.() // a helper may be using the MCP servers (a browser): its turn first
1414
- s.ui.spinner(`${server.name} · ${tool}`)
1408
+ s.ui.spinner(`using ${server.name}`)
1415
1409
  const started = Date.now()
1416
1410
  let r
1417
1411
  try {
package/src/ui.js CHANGED
@@ -202,6 +202,7 @@ function sliceCols(text, from, to) {
202
202
  return out
203
203
  }
204
204
  const FRAMES = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
205
+ const BEAT = [1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0] // the ♥ while it works, a frame (80 ms) each: lub, dub, rest
205
206
 
206
207
  // 75000 → "1 minute 15 seconds"; the two biggest units: "5 hours 33 minutes", "2 days 3 hours"
207
208
  export function duration(ms) {
@@ -830,6 +831,12 @@ export class UI {
830
831
  if (was && was !== dialog) was.close?.()
831
832
  this.render()
832
833
  }
834
+ // a question's long text moved by n lines (drawn in #question, which keeps it in range)
835
+ #scrollText(n) {
836
+ const p = this.menu.pick
837
+ p.textTop = Math.max(0, Math.min((p.textTop ?? 0) + n, p.textMax))
838
+ this.render()
839
+ }
833
840
  // Text to read (a command's answer: /help, /context, /diff…) in a dialog: ↑/↓, PgUp/PgDn, Home/End
834
841
  // and the wheel scroll it, Esc closes it (and toggle: a key's action, as the key that opened it).
835
842
  // Without the full screen: printed.
@@ -938,6 +945,18 @@ export class UI {
938
945
  const r = wrapWords(t, w)
939
946
  return r.length <= n ? r : [...r.slice(0, n - 1), `${fit(r[n - 1], w - 1)}…`]
940
947
  }
948
+ // a picker's text longer than its room (the whole changelog on /update): a window of it, which
949
+ // PgUp/PgDn and the wheel move (↑↓ still choose), and where it is under it
950
+ const scrolled = (lines, n) => {
951
+ if (!pick) return clip(lines, n)
952
+ const room = Math.max(1, n - 1)
953
+ pick.textMax = Math.max(0, lines.length - room)
954
+ if (!pick.textMax) return lines
955
+ pick.textTop = Math.max(0, Math.min(pick.textTop ?? 0, pick.textMax))
956
+ pick.textPage = Math.max(1, room - 1)
957
+ const t = pick.textTop
958
+ return [...lines.slice(t, t + room), c.faint(`${t + 1}–${Math.min(lines.length, t + room)} of ${lines.length} lines · PgUp/PgDn or the wheel scroll`)]
959
+ }
941
960
  let at = 0
942
961
  return {
943
962
  title: long || title.length > 200 ? '' : title,
@@ -969,7 +988,7 @@ export class UI {
969
988
  })
970
989
  const want = cards ? blocks.flat().length : Math.max(1, m.items.length)
971
990
  const least = Math.min(want, cards ? Math.max(...blocks.map((b) => b.length)) + 2 : 3) // the choices give way first, down to this
972
- const top0 = clip(intro, Math.max(3, h - tail.length - filter.length - least))
991
+ const top0 = scrolled(intro, Math.max(3, h - tail.length - filter.length - least))
973
992
  const room = Math.max(1, h - tail.length - filter.length - top0.length)
974
993
  let list
975
994
  if (!choices.length) list = [c.faint(`nothing matches "${rl.line}"`)]
@@ -997,21 +1016,6 @@ export class UI {
997
1016
  }
998
1017
  }
999
1018
 
1000
- // The plan (todo list) while it works, kept in sight under the spinner: how much is done, and three
1001
- // of its steps (what's being done, then what's next); the rest on a key (show_plan).
1002
- #todoLines(cols) {
1003
- const todos = this.todos?.() ?? []
1004
- const open = todos.filter((t) => t.status !== 'completed')
1005
- if (!open.length) return []
1006
- const done = todos.length - open.length
1007
- const mark = { pending: c.muted('☐'), in_progress: c.info('◐'), completed: c.faint('☑'), stuck: c.warn('⚠') }
1008
- const by = (t) => (t.by ? c.faint(' · ') + (t.status === 'in_progress' ? c.info(t.by) : c.faint(t.by)) : '') // the model a part was given to
1009
- // one line: how far it is, the step being done now (the whole plan: show_plan)
1010
- const now = todos.find((t) => t.status === 'in_progress') ?? open[0]
1011
- const k = this.keyFor('show_plan')
1012
- return [fit(` ${c.muted(`Plan ${done}/${todos.length}`)} ${mark[now.status]} ${c.info(now.content)}${by(now)}${k ? c.faint(` · ${k} all of it`) : ''}`, cols)]
1013
- }
1014
-
1015
1019
  // The whole plan in a box (show_plan, /todos): every step and its state; the key closes it again.
1016
1020
  showPlan() {
1017
1021
  const todos = this.todos?.() ?? []
@@ -1188,6 +1192,7 @@ export class UI {
1188
1192
  if (b & 64) {
1189
1193
  if ((b & 0xc3) !== 64 && (b & 0xc3) !== 65) return
1190
1194
  if (this.dialog) return this.dialog.key?.({ name: b & 1 ? 'down' : 'up', wheel: true }), this.render()
1195
+ if (this.asking && this.menu.pick?.textMax) return this.#scrollText(b & 1 ? 3 : -3) // a question's long text
1191
1196
  return this.#wheel(b & 1 ? -1 : 1) // 64 up, 65 down
1192
1197
  }
1193
1198
  if ((b & 3) !== 0 && !up) return // the left button only (a release says 3 in some terminals)
@@ -1382,7 +1387,9 @@ export class UI {
1382
1387
  const asked = this.asking && !this.histOn && rl
1383
1388
  // The input box: the rows around the cursor, at most INPUT_ROWS; the rules count the rest.
1384
1389
  const typing = !this.asking && rl && this.mainPrompt // working: what's typed meanwhile shows in the box
1385
- const input = asked ? layoutInput(this.mainPrompt ?? ' ', '', 0, cols) : this.asking || typing ? layoutInput(this.asking ? rl._prompt : this.mainPrompt, rl.line, rl.cursor, cols) : { rows: [''], cur: { row: 0, col: 0 } }
1390
+ // while it works on your message, the input's ♥ beats (lub-dub, then a rest), a beat a second
1391
+ const prompt = typing && this.busySince && this.timer && !BEAT[this.frame % BEAT.length] ? this.mainPrompt.replace('♥', '♡') : this.mainPrompt
1392
+ const input = asked ? layoutInput(this.mainPrompt ?? ' ', '', 0, cols) : this.asking || typing ? layoutInput(this.asking ? rl._prompt : prompt, rl.line, rl.cursor, cols) : { rows: [''], cur: { row: 0, col: 0 } }
1386
1393
  const first = Math.max(0, Math.min(input.cur.row - INPUT_ROWS + 1, input.rows.length - INPUT_ROWS))
1387
1394
  const box = input.rows.slice(first, first + INPUT_ROWS)
1388
1395
  const inputRows = box.length
@@ -1398,15 +1405,17 @@ export class UI {
1398
1405
  const request = this.requestSince?.()
1399
1406
  const label = this.#label()
1400
1407
  const waiting = request && !(this.tokenAt >= request) && this.beforeRetry === undefined && Date.now() - request > 2000
1401
- const status = waiting ? `${/^(working|thinking|answering)$/.test(plainOf(label)) ? '' : `${label} · `}waiting for ${this.waitingFor?.() || 'the model'}` : label
1408
+ const status = String(waiting ? `${/^(working|thinking|answering)$/.test(plainOf(label)) ? '' : `${label} · `}waiting for ${this.waitingFor?.() || 'the model'}` : label).replace(/\s*[\r\n\t]+\s*/g, ' ') // never a line break or tab to the terminal: it would write on a row the screen doesn't know about, left there
1402
1409
  const timer = this.busySince ? `${short(this.worked())} · Esc twice to stop` : ''
1403
- // one row; a long status (a retry, a command's last line) wraps instead of being cut
1404
- wrapParts(`${status}${timer ? ` · ${timer}` : ''}`, cols - 2).forEach((r, i) => bottom.push(fit(`${i ? ' ' : c.brand(FRAMES[this.frame % FRAMES.length])} ${c.muted(r)}`, cols)))
1405
- // helpers at work (agent.js keeps them in this.helpers: label → what it's doing), then the plan
1406
- const helpers = [...this.helpers]
1407
- for (const [name, { model, what }] of helpers.slice(0, helpers.length > 6 ? 5 : 6)) bottom.push(fit(` ${c.faint('◦')} ${c.muted(name)}${model ? `${c.faint(' · ')}${c.info(model)}` : ''}${what ? c.faint(` · ${what}`) : ''}`, cols))
1408
- if (helpers.length > 6) bottom.push(c.faint(` … ${helpers.length - 5} more`))
1409
- bottom.push(...this.#todoLines(cols))
1410
+ // One row, always: what's happening in a few words, how far the plan is, helpers at work, the
1411
+ // time. What's being done shows in the conversation above (its steps); nothing more here.
1412
+ const todos = this.todos?.() ?? []
1413
+ const done = todos.filter((t) => t.status === 'completed').length
1414
+ const extra = [todos.length && done < todos.length ? `plan ${done}/${todos.length}` : '', this.helpers.size ? `${this.helpers.size} helper${this.helpers.size === 1 ? '' : 's'}` : ''].filter(Boolean)
1415
+ const what = plainOf(status).split(' › ')[0]
1416
+ const tail = [...extra, timer].filter(Boolean).join(' · ')
1417
+ const room = Math.max(10, cols - 3 - width(tail) - (tail ? 3 : 0))
1418
+ bottom.push(...Array(rows >= 24 ? 3 : 1).fill(''), fit(`${c.brand(FRAMES[this.frame % FRAMES.length])} ${c.muted(width(what) > room ? `${fit(what, room - 1)}…` : what)}${tail ? c.faint(` · ${tail}`) : ''}`, cols)) // apart from the conversation above it: three empty rows (one on a short screen)
1410
1419
  }
1411
1420
  if (this.scroll) bottom.push(c.dim(` ↓ ${Number.isFinite(this.scroll) ? this.scroll : 'more'} lines below · held here for reading${this.keyFor('scroll_bottom') ? ` · ${this.keyFor('scroll_bottom')} to the bottom` : ''}`))
1412
1421
  if (this.ahead.length) {
@@ -1429,6 +1438,7 @@ export class UI {
1429
1438
  if (this.noticeText) bottom.push(fit(this.noticeMark ? `${c.warn(this.noticeMark)} ${c.muted(this.noticeText)}` : ` ${c.muted(this.noticeText)}`, cols))
1430
1439
  if (menu.on && !asked) bottom.push(...this.#menuLines(cols))
1431
1440
  bottom.push(first ? note(first, '↑') : rule)
1441
+ for (let i = 0; i < bottom.length; i++) bottom[i] = bottom[i].replace(/[\r\n\t]/g, ' ') // a row is one row: a break in a label (a helper's, a command's) would be written on a row the screen doesn't track
1432
1442
  const head = [...(this.tabBar?.(cols) ?? []), ...(this.header?.(cols) ?? [])].map((l) => fit(l, cols))
1433
1443
  const inputTop = rows - below.length - inputRows + 1 // first row of the input
1434
1444
  const avail = Math.max(0, inputTop - 1 - bottom.length - head.length)
@@ -1581,6 +1591,7 @@ export class UI {
1581
1591
  return this.render()
1582
1592
  }
1583
1593
  }
1594
+ if ((key.name === 'pageup' || key.name === 'pagedown') && this.menu.pick?.textMax) return this.#scrollText(key.name === 'pageup' ? -this.menu.pick.textPage : this.menu.pick.textPage)
1584
1595
  if (key.name === 'pageup' || key.name === 'pagedown') return this.scrollBy(key.name === 'pageup' ? this.page() : -this.page())
1585
1596
  const m = this.menu
1586
1597
  const it = m.on && m.items[m.sel]
@@ -2389,6 +2400,7 @@ export class UI {
2389
2400
  // are indented under it, kept apart from the others')
2390
2401
  // note: says what happened (learned, reviewed, removed), no result to wait for; ok false: a bad one
2391
2402
  step(name, detail = '', who = '', { sub = '', note = false, ok = true } = {}) {
2403
+ detail = String(detail ?? '').replace(/\s*[\r\n\t]+\s*/g, ' ') // one line (a multi-line command): a step is a row, and a break in it scrambles the rows around it
2392
2404
  const key = sub
2393
2405
  if (note) {
2394
2406
  if (this.afterBlock) this.gap()
@@ -2426,6 +2438,7 @@ export class UI {
2426
2438
  // got, summed over a group (90 lines, 12 matches); files: the files a search found them in.
2427
2439
  // Called again for the same step: its words are added (an edit: "formatted with prettier").
2428
2440
  result(text = '', { ok = true, refused = false, none = false, n, unit, files, sub = '' } = {}) {
2441
+ text = String(text ?? '').replace(/\s*[\r\n\t]+\s*/g, ' ') // one line, as the step's
2429
2442
  const st = this.steps?.get(sub)
2430
2443
  const item = st?.items.at(-1)
2431
2444
  if (!this.full || !st || st.log !== this.log) {
package/src/update.js CHANGED
@@ -43,15 +43,19 @@ export function installKind() {
43
43
  export const UPDATE_COMMANDS = { npm: 'npm install -g heartcode@latest', pnpm: 'pnpm add -g heartcode@latest', yarn: 'yarn global add heartcode@latest', bun: 'bun add -g heartcode@latest' }
44
44
  export const packageDir = PKG
45
45
 
46
- // The changelog's sections from the newest down to (not including) the one running, or ''.
46
+ // The whole changelog of the version on offer, newest first (scrolled in the dialog): from its npm
47
+ // package (the version you'd get; GitHub's main branch can be behind npm), else GitHub. '' if none.
48
+ // The versions since the one running are marked new.
47
49
  export async function whatsNew(current, latest) {
48
- try {
49
- const r = await fetch('https://raw.githubusercontent.com/p32929/HeartCode/main/CHANGELOG.md', { signal: AbortSignal.timeout(8000) })
50
- const text = await r.text()
51
- const start = text.indexOf(`## ${latest}`)
52
- const end = text.indexOf(`## ${current}`)
53
- return start >= 0 ? text.slice(start, end > start ? end : undefined).trim().replace(/\n {2,}(?=\S)/g, ' ') : '' // a list item's wrapped lines joined: the box wraps it to its width
54
- } catch {
55
- return ''
50
+ for (const url of [`https://cdn.jsdelivr.net/npm/heartcode@${latest}/CHANGELOG.md`, `https://unpkg.com/heartcode@${latest}/CHANGELOG.md`, 'https://raw.githubusercontent.com/p32929/HeartCode/main/CHANGELOG.md']) {
51
+ try {
52
+ const r = await fetch(url, { signal: AbortSignal.timeout(8000) })
53
+ const text = r.ok ? await r.text() : ''
54
+ const start = text.indexOf('\n## ')
55
+ if (start < 0) continue
56
+ const body = text.slice(start + 1).trim().replace(/\n {2,}(?![-*] )(?=\S)/g, ' ') // a list item's wrapped lines joined (the box wraps it to its width); a sub-item stays its own
57
+ return body.replace(/^## (\d+\.\d+\.\d+)(.*)$/gm, (line, v, rest) => (newer(v, current) ? `## ${v}${rest} · new` : line))
58
+ } catch {}
56
59
  }
60
+ return ''
57
61
  }