@hncode/hncode 0.8.2 → 0.8.4

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/tui.js CHANGED
@@ -39,7 +39,7 @@ const {
39
39
  reducedMotionOn, spinnerFrame, sweepSettle, sweepPulse,
40
40
  LIGHT_FRACTION, SPIN_TICK_MS, lightWidth, TAIL_CHARS, ANIM_FPS, FRAME_MS,
41
41
  STEP_MS, TOOL_STEP_MS, ENTRY_EXIT_CHARS, lightMargin, crossMs, REST_MS, cycleMs,
42
- lightOrigin, lightAt, shimmerText, STEP_CHARS, SWEEP_TICKS, SWEEP_TRAVEL_PAD, bandCharsFor, framesPerChar,
42
+ lightOrigin, lightAt, shimmerText, glintFor, STEP_CHARS, SWEEP_TICKS, SWEEP_TRAVEL_PAD, bandCharsFor, framesPerChar,
43
43
  breatheColour,
44
44
  } = anim;
45
45
  const {
@@ -81,7 +81,7 @@ import * as md from './markdown.js';
81
81
  const {
82
82
  MD_RENDER_VERSION, renderMdIncremental, splitBlocks, renderMdText, renderTable,
83
83
  markdownLineToRows, mathImageCapable, MATH_INK, mathCellHeight, mathBlockRows,
84
- stripMathDelimiters, placeTex, looksLikeInlineMath, inlineMarkdown,
84
+ stripMathDelimiters, placeTex, looksLikeInlineMath, inlineMarkdown, onMermaidReady,
85
85
  } = md;
86
86
 
87
87
  export {
@@ -162,7 +162,7 @@ import { buildTree, visibleRows, allDirs, renderTree, moveSel } from './file-tre
162
162
  import { walkFiles } from './tools/ignore.js';
163
163
 
164
164
 
165
- import { Agent, SYSTEM_PROMPT, addUsage } from './agent.js';
165
+ import { Agent, SYSTEM_PROMPT, THINKING_TAGS_INSTRUCTION, needsThinkingTags, addUsage } from './agent.js';
166
166
  import { LLM } from './llm.js';
167
167
  import * as sess from './session.js';
168
168
  import { convRowFor } from './session.js';
@@ -243,7 +243,6 @@ import { reviewLines, savePlan, filesReferenced, planStats, listPlans, plansDir
243
243
  import { loadMcpConfig, describeServers, getLiveConnections } from './mcp.js';
244
244
  import { killLspClientsSync } from './tools/diagnostics.js';
245
245
  import { startControlServer } from './ci.js';
246
- import { attachToDaemon } from './web-daemon-client.js';
247
246
 
248
247
  const VERSION = localVersion();
249
248
 
@@ -330,7 +329,10 @@ export function getUiLang() { return i18nGetUiLang(); }
330
329
  */
331
330
  export function tr(key, fallback, vars) {
332
331
  const s = tOr(uiLang, key, fallback);
333
- if (!vars || s === fallback) return s;
332
+ // The placeholders are filled in WHICHEVER string came back — the translation or the
333
+ // English fallback. Skipping the fallback left `[{n} task(s) running]` in the status
334
+ // line instead of `[{n}]` with the count in it, because the fallback WAS the template.
335
+ if (!vars) return s;
334
336
  let out = s;
335
337
  for (const k of Object.keys(vars)) out = out.split('{' + k + '}').join(String(vars[k]));
336
338
  return out;
@@ -1528,8 +1530,15 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
1528
1530
  // right edge in the one column the scrollbar does not own.
1529
1531
  // The same `↳ ` the finished result puts on its first row, so the block does not shift right when the
1530
1532
  // command completes. Continuation rows indent by two spaces, matching the result block.
1533
+ //
1534
+ // THE MARKER CARRIES THE STRUCTURAL COLOUR HERE TOO. A raw row is emitted as it is, so a bare `'↳ '`
1535
+ // took the terminal's DEFAULT foreground — dark on a dark page, which made a running command's arrow
1536
+ // the one unreadable thing on the screen while the finished result's arrow (rows-tool-result.js, which
1537
+ // does use `C.marker`) was bright. Same glyph, two colours, depending on whether the command had
1538
+ // finished.
1539
+ const marker = firstLive ? C.marker + '↳ ' + C.reset : ' ';
1531
1540
  const rowW = bodyW;
1532
- out.push({ text: C.termBg + fitAnsi(surfaced, rowW) + C.bgReset, ind: firstLive ? '↳ ' : ' ', raw: true });
1541
+ out.push({ text: C.termBg + fitAnsi(surfaced, rowW) + C.bgReset, ind: marker, raw: true });
1533
1542
  }
1534
1543
  }
1535
1544
  }
@@ -1541,9 +1550,15 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
1541
1550
  // the OS exposes no portable "blocked in read". A line that is true either way — this key sends what you
1542
1551
  // type to the command — is the honest form, and grey keeps it a footnote rather than a warning.
1543
1552
  if (msg.pending && msg.toolName === 'Bash') {
1544
- const stdinHintW = Math.max(1, width - visualCol(' '));
1553
+ // ON THE PAGE, NOT ON THE TERMINAL SURFACE.
1554
+ //
1555
+ // This sat inside `C.termBg` — the darkest recess, reserved for the command's own
1556
+ // OUTPUT so it reads as "a terminal ran this". A hint is not output: on that surface
1557
+ // a grey sentence on a near-black block reads as part of the command's result rather
1558
+ // than as a note about a key. Every other hint on this row (Ctrl+B, below) sits on
1559
+ // the page background, and this one now matches.
1545
1560
  out.push({
1546
- text: C.termBg + fitAnsi(col('Ctrl+G: send a line to this command', C.gray), stdinHintW) + C.bgReset,
1561
+ text: col(uiText('Ctrl+G: send a line to this command'), C.gray),
1547
1562
  ind: ' ', raw: true,
1548
1563
  });
1549
1564
  }
@@ -1557,7 +1572,9 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
1557
1572
  const waited = Date.now() - msg.startAt;
1558
1573
  const delay = name === 'Bash' ? DETACH_HINT_DELAY_MS : 0;
1559
1574
  if (waited >= delay) {
1560
- out.push({ text: col(DETACH_HINT_TEXT, C.gray), ind: indent, raw: true });
1575
+ // Translated at RENDER time, not at definition: the constant is module level and
1576
+ // `uiText` reads whichever language is active when the row is drawn.
1577
+ out.push({ text: col(uiText(DETACH_HINT_TEXT), C.gray), ind: indent, raw: true });
1561
1578
  }
1562
1579
  }
1563
1580
 
@@ -1599,21 +1616,30 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
1599
1616
  // The comment state travels between the rows, so a block comment that opens on one line and closes on
1600
1617
  // the next stays grey all the way down.
1601
1618
  let writeInComment = false;
1619
+ // THE MARKER AND THE INDENT ARE PADDED TO ONE WIDTH.
1620
+ //
1621
+ // `↳` is East Asian Ambiguous: one column on an English terminal, two on a Chinese
1622
+ // one. A fixed `'↳ '` beside a fixed `' '` therefore disagreed by a column on a CJK
1623
+ // machine, and every continuation row started a column early — a ragged gutter that
1624
+ // only showed up there. Both are built from the marker's own measured width instead,
1625
+ // so the block is square wherever it is drawn.
1626
+ const markerRaw = '↳ ';
1627
+ const contRaw = ' '.repeat(Math.max(1, visualCol(markerRaw)));
1602
1628
  lines.slice(0, MAX).forEach((ln, i) => {
1603
1629
  const num = String(i + 1).padStart(wNum);
1604
1630
  // A LINE LONGER THAN THE PANEL IS CUT, not wrapped. `raw: true` means the renderer does not wrap it for us,
1605
1631
  // and letting it through at full width made the terminal wrap it itself — which pushes every later row down
1606
1632
  // by one and desynchronises the frame, so the screen scrolled while the file was still arriving.
1607
- const room = Math.max(1, width - visualCol(indent) - num.length - 1);
1633
+ const room = Math.max(1, width - visualCol(contRaw) - num.length - 1);
1608
1634
  // The whole preview sits on the CODE SURFACE, number included, so the block reads as one recessed field.
1609
1635
  if (!writeLang) {
1610
- out.push({ text: C.codeBg + col(`${num} ${fitAnsi(ln, room)}`.replace(/\x1b\[0m/g, `\x1b[0m${C.codeBg}`), C.white) + C.bgReset, ind: i === 0 ? '↳ ' : indent, raw: true });
1636
+ out.push({ text: C.codeBg + col(`${num} ${fitAnsi(ln, room)}`.replace(/\x1b\[0m/g, `\x1b[0m${C.codeBg}`), C.white) + C.bgReset, ind: i === 0 ? markerRaw : contRaw, raw: true });
1611
1637
  return;
1612
1638
  }
1613
1639
  const painted = paintCode(ln, writeLang, '', writeInComment);
1614
1640
  writeInComment = painted.inComment;
1615
1641
  const writeRow = (col(num + ' ', C.white) + fitAnsi(painted.text, room)).replace(/\x1b\[0m/g, `\x1b[0m${C.codeBg}`);
1616
- out.push({ text: C.codeBg + writeRow + C.bgReset, ind: i === 0 ? '↳ ' : indent, raw: true });
1642
+ out.push({ text: C.codeBg + writeRow + C.bgReset, ind: i === 0 ? markerRaw : contRaw, raw: true });
1617
1643
  });
1618
1644
  const shown = Math.min(lines.length, MAX);
1619
1645
  if (totalLines > shown) out.push({ text: col(uiText(`… ${totalLines - shown} more lines, ctrl+o to expand`), C.gray), ind: indent, raw: true });
@@ -1697,7 +1723,7 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
1697
1723
  // The args line is omitted when there are none. `msg.text` is only the NAME and
1698
1724
  // `msg.args` the trailing text, so the body is built here rather than wrapped.
1699
1725
  if (msg.role === 'skill') {
1700
- lines.push({ text: prefix + 'Activated skill: ' + C.bold + String(msg.text || ''), ind: '', color: C.blue });
1726
+ lines.push({ text: prefix + uiText('Activated skill: ') + C.bold + String(msg.text || ''), ind: '', color: C.blue });
1701
1727
  const args = String(msg.args || '').trim();
1702
1728
  if (args) {
1703
1729
  const w = Math.max(1, width - 2);
@@ -2238,6 +2264,15 @@ export function renderChatLines(state, w, viewport) {
2238
2264
  && cached.diffRef === m.diff && cached.countsRef === m._diffCounts
2239
2265
  && cached.keyArgs === (m.toolArgs ? fpArgs(m.toolArgs) : '0')
2240
2266
  && cached.spinKey === spinKeyNow
2267
+ // THE GUTTER WIDTH COMES FROM THE LINE COUNT, so the count is part of the layout key.
2268
+ //
2269
+ // A streaming Write preview numbers its rows against the TOTAL line count, which is
2270
+ // what keeps `1` and `10` starting their text in the same column. When the count
2271
+ // crossed a digit (9 -> 10) the text and the content were unchanged, so the cache
2272
+ // still looked valid and the previous frame's rows were reused — the numbers kept
2273
+ // their old width and the stale glyphs stayed on screen, one column short of the
2274
+ // rows now being drawn under them.
2275
+ && cached.streamLines === (m._streamLineCount || 0)
2241
2276
  // The collapsible plugin log renders from `m.expanded` + `m.allLines`, which
2242
2277
  // the cache key must include: otherwise Ctrl+L only flipped the flag and the
2243
2278
  // cached (collapsed) rows were reused, so nothing visibly changed.
@@ -2348,6 +2383,9 @@ export function renderChatLines(state, w, viewport) {
2348
2383
  keyArgs: m.toolArgs ? fpArgs(m.toolArgs) : '0',
2349
2384
  pluginExpanded: m.pluginLog ? !!m.expanded : null,
2350
2385
  raw: !!state.rawMode,
2386
+ // The gutter width of a streaming preview follows the total line count, so the
2387
+ // count belongs to the layout key — see the `valid` test above.
2388
+ streamLines: m._streamLineCount || 0,
2351
2389
  rows: wrapped, spinRows: null,
2352
2390
  v: MD_RENDER_VERSION, // invalidates rows built by an older renderer
2353
2391
  };
@@ -2631,6 +2669,13 @@ export function messageSignature(m) {
2631
2669
  const mix = (v) => { h ^= (v | 0); h = Math.imul(h, 16777619) >>> 0; };
2632
2670
  mix(typeof m.text === 'string' ? m.text.length : 0);
2633
2671
  mix(typeof m.streamContent === 'string' ? m.streamContent.length : 0);
2672
+ // THE LINE COUNT CHANGES THE ROW'S SHAPE WITHOUT CHANGING ITS TEXT.
2673
+ //
2674
+ // A streaming Write preview pads its gutter to the width of the TOTAL line count, so
2675
+ // crossing 9 -> 10 re-lays out every row. The count is not text, so leaving it out meant
2676
+ // this message's signature did not move, the whole layout was declared unchanged, and the
2677
+ // previous frame's narrower gutter stayed on screen under the new rows.
2678
+ mix(m._streamLineCount || 0);
2634
2679
  mix(m.pending ? 1 : 0);
2635
2680
  mix(m.pluginLog && m.expanded ? 1 : 0);
2636
2681
  mix(m._cache ? 1 : 0);
@@ -3780,10 +3825,10 @@ export function startupChat(width, opts = {}) {
3780
3825
  // the two compete.
3781
3826
  rows.push(line(C.bold + C.heading + name + C.reset + ' ' + C.gray + 'v' + version + C.reset));
3782
3827
 
3783
- const model = modelLabel(cfg) || '(no model)';
3828
+ const model = modelLabel(cfg) || uiText('(no model)');
3784
3829
  // The effort is only meaningful when the model reasons; showing "off" for a model that never thinks is noise.
3785
3830
  const effort = cfg.reasoning && cfg.effort && cfg.effort !== 'off' ? ` (${cfg.effort})` : '';
3786
- rows.push(line(C.gray + 'Model: ' + model + effort + C.reset));
3831
+ rows.push(line(C.gray + uiText('Model: ') + model + effort + C.reset));
3787
3832
 
3788
3833
  const dir = opts.workspace || cfg.workspace || '';
3789
3834
  if (dir) rows.push(line(C.gray + dir + C.reset));
@@ -4004,7 +4049,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
4004
4049
  // wrapped it onto a second visual row while the `lines` array still had ONE,
4005
4050
  // so every row below — the text body included — sat one row lower on screen
4006
4051
  // than the code assumed. Clicks and the caret landed one line off.
4007
- lines.push(col(fitAnsi(ed.title || 'Edit', w), C.cyan + C.bold));
4052
+ lines.push(col(fitAnsi(ed.title || uiText('Edit'), w), C.cyan + C.bold));
4008
4053
  lines.push(rule);
4009
4054
  const hint = ed.hint || 'Ctrl+S save · Esc cancel · Enter newline';
4010
4055
  // Clamped like the title: an overlong hint would wrap on screen and shift the
@@ -4524,7 +4569,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
4524
4569
  for (let bi = 0; bi < ov.body.length; bi++) {
4525
4570
  const b = ov.body[bi];
4526
4571
  if (!b || !b.__categories) continue;
4527
- const PREFIX = 'Categories: ';
4572
+ const PREFIX = uiText('Categories: ');
4528
4573
  // `inner` IS the content box. The overlay already accounts for the panel's one-column
4529
4574
  // padding on each side when it pads each row, so subtracting two more made the usable
4530
4575
  // width narrower than the card — a strip that fitted the card exactly still wrapped.
@@ -4554,8 +4599,28 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
4554
4599
  out.push(line);
4555
4600
  }
4556
4601
  // Rows go back into the body in place of the sentinel, so the indices the hitbox step
4557
- // uses (`catBodyRow`) stay correct.
4602
+ // uses (`catBodyRow`) stay correct for the TABS.
4603
+ //
4604
+ // EVERY BODY INDEX RECORDED BEFORE THIS POINT MUST BE SHIFTED BY THE GROWTH. The
4605
+ // sentinel occupied ONE slot; a wrapped strip takes several. Body indices are what
4606
+ // `rowOf()` turns into screen rows, so leaving them unshifted moved every control
4607
+ // below the strip up by (out.length - 1) rows — on /model that made a click one row
4608
+ // too high, so clicking a model selected the one under it. Only a strip that FITS on
4609
+ // one line hid this, because then the growth is zero.
4610
+ const grew = out.length - 1;
4558
4611
  ov.body.splice(bi, 1, ...out);
4612
+ if (grew > 0) {
4613
+ const shift = (i) => (i > bi ? i + grew : i);
4614
+ if (Array.isArray(ov.itemBodyRows)) {
4615
+ for (let k = 0; k < ov.itemBodyRows.length; k++) ov.itemBodyRows[k] = shift(ov.itemBodyRows[k]);
4616
+ }
4617
+ if (Array.isArray(ov.fieldBodyRows)) {
4618
+ for (let k = 0; k < ov.fieldBodyRows.length; k++) ov.fieldBodyRows[k] = shift(ov.fieldBodyRows[k]);
4619
+ }
4620
+ if (ov.footerBodyRow > bi) ov.footerBodyRow += grew;
4621
+ if (ov.typeBodyRow > bi) ov.typeBodyRow += grew;
4622
+ if (ov.catBodyRow > bi) ov.catBodyRow += grew;
4623
+ }
4559
4624
  // The tabs, with their row recorded ABSOLUTELY: a hitbox carries one row and the
4560
4625
  // strip now spans several.
4561
4626
  if (Array.isArray(b.tabs)) {
@@ -4941,6 +5006,39 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
4941
5006
  const ORANGE_RGB = [255, 140, 0];
4942
5007
  const greyEsc = lerpColor(GREY_RGB[0], GREY_RGB[1], GREY_RGB[2], GREY_RGB[0], GREY_RGB[1], GREY_RGB[2], 0);
4943
5008
  const orangeEsc = lerpColor(ORANGE_RGB[0], ORANGE_RGB[1], ORANGE_RGB[2], ORANGE_RGB[0], ORANGE_RGB[1], ORANGE_RGB[2], 0);
5009
+ // COMPACTING IS ITS OWN COLOUR, AND IT ARRIVES SMOOTHLY.
5010
+ //
5011
+ // The row used to keep the Working orange and only change its WORDS, so the one
5012
+ // moment the session is doing something expensive looked identical to ordinary
5013
+ // work. Blue separates it, and it is the same blue the context bar uses for the
5014
+ // segments it is about to rewrite — the two read as one story.
5015
+ //
5016
+ // The switch is INTERPOLATED over `COMPACT_FADE_MS`, not swapped: an instant jump
5017
+ // from orange to blue reads as a state change on a row that is otherwise animating,
5018
+ // which is the thing the sweep exists to avoid. `compactingSince` is stamped the
5019
+ // first frame compaction is seen and cleared when it ends, so the fade runs once in
5020
+ // each direction.
5021
+ const BLUE_RGB = [90, 124, 255];
5022
+ const COMPACT_FADE_MS = 600;
5023
+ if (state.compacting && !state.compactingSince) state.compactingSince = Date.now();
5024
+ if (!state.compacting && state.compactingSince) {
5025
+ // Keep the stamp for one fade so the return to orange is smooth too.
5026
+ if (Date.now() - state.compactingSince > COMPACT_FADE_MS) state.compactingSince = null;
5027
+ }
5028
+ const compactT = state.compactingSince
5029
+ ? (state.compacting
5030
+ ? Math.min(1, (Date.now() - state.compactingSince) / COMPACT_FADE_MS)
5031
+ : Math.max(0, 1 - (Date.now() - state.compactingSince) / COMPACT_FADE_MS))
5032
+ : (state.compacting ? 1 : 0);
5033
+ const mixRgb = (a, b, t) => [
5034
+ Math.round(a[0] + (b[0] - a[0]) * t),
5035
+ Math.round(a[1] + (b[1] - a[1]) * t),
5036
+ Math.round(a[2] + (b[2] - a[2]) * t),
5037
+ ];
5038
+ const ACCENT_RGB = compactT > 0 ? mixRgb(ORANGE_RGB, BLUE_RGB, compactT) : ORANGE_RGB;
5039
+ const accentEsc = compactT > 0
5040
+ ? lerpColor(ACCENT_RGB[0], ACCENT_RGB[1], ACCENT_RGB[2], ACCENT_RGB[0], ACCENT_RGB[1], ACCENT_RGB[2], 0)
5041
+ : orangeEsc;
4944
5042
  const elapsed = state.turnStart
4945
5043
  ? col(` [${elapsedTail(Date.now() - state.turnStart, state.turnOutputTokens)}]`, greyEsc)
4946
5044
  : '';
@@ -4971,15 +5069,15 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
4971
5069
  // branches below cannot run at all.
4972
5070
  if (still) {
4973
5071
  const dim = frameInfo.dim;
4974
- const dotEsc = dim ? greyEsc : orangeEsc;
5072
+ const dotEsc = dim ? greyEsc : accentEsc;
4975
5073
  lines.push(
4976
5074
  (dim ? C.dim : '') + col(frame, dotEsc) + ' '
4977
- + col(workMsg, greyEsc) + elapsed + (dim ? C.reset : ''),
5075
+ + col(workMsg, compactT > 0 ? accentEsc : greyEsc) + elapsed + (dim ? C.reset : ''),
4978
5076
  );
4979
5077
  }
4980
5078
  // ---- turn-start animation ----
4981
5079
  // 0.25s: type out "Working..." in grey (chars appear left→right)
4982
- // 0.25s: fill with orange (chars change colour left→right)
5080
+ // 0.25s: fill with the accent colour — orange, or blue while compacting
4983
5081
  // After 0.5s total: start the normal pulse animation
4984
5082
  else if (state.startAnim) {
4985
5083
  // 0.5s total: 0.25s types `Working... [0s]` out in grey, then 0.25s sweeps the
@@ -5020,7 +5118,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5020
5118
  out.push(i < tailTyped ? col(tailAll[i], greyEsc) : ' ');
5021
5119
  }
5022
5120
  // The tail is already inside `out`, so do NOT append `elapsed` here.
5023
- lines.push(col(frame, orangeEsc) + ' ' + out.join(''));
5121
+ lines.push(col(frame, accentEsc) + ' ' + out.join(''));
5024
5122
  } else {
5025
5123
  // Colour sweep: only the PHRASE goes grey → orange. The tail stays grey
5026
5124
  // (it is appended as the colored `elapsed` chunk after `out`).
@@ -5038,12 +5136,12 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5038
5136
  for (let i = 0; i < phrase.length; i++) {
5039
5137
  const charAt = i / phrase.length;
5040
5138
  const tChar = sweepSettle(head - charAt, BAND, edge);
5041
- const r = Math.round(GREY_RGB[0] + (ORANGE_RGB[0] - GREY_RGB[0]) * tChar);
5042
- const g = Math.round(GREY_RGB[1] + (ORANGE_RGB[1] - GREY_RGB[1]) * tChar);
5043
- const b = Math.round(GREY_RGB[2] + (ORANGE_RGB[2] - GREY_RGB[2]) * tChar);
5139
+ const r = Math.round(GREY_RGB[0] + (ACCENT_RGB[0] - GREY_RGB[0]) * tChar);
5140
+ const g = Math.round(GREY_RGB[1] + (ACCENT_RGB[1] - GREY_RGB[1]) * tChar);
5141
+ const b = Math.round(GREY_RGB[2] + (ACCENT_RGB[2] - GREY_RGB[2]) * tChar);
5044
5142
  out.push(col(phrase[i], lerpColor(r, g, b, r, g, b, 0)));
5045
5143
  }
5046
- lines.push(col(frame, orangeEsc) + ' ' + out.join('') + elapsed + col(stepText, greyEsc));
5144
+ lines.push(col(frame, accentEsc) + ' ' + out.join('') + elapsed + col(stepText, greyEsc));
5047
5145
  }
5048
5146
  // The cutoff has to be the SAME number as `DUR`. They were separate literals (1000 here, 1000
5049
5147
  // above) and changing one alone left the preview exiting early or the animation running on into
@@ -5083,9 +5181,9 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5083
5181
  }
5084
5182
  // Colour: orange → grey over the animation. Uses the SAME shared constants
5085
5183
  // so the row does not shift shade when the finish morph begins.
5086
- const r = Math.round(ORANGE_RGB[0] + (GREY_RGB[0] - ORANGE_RGB[0]) * t);
5087
- const g = Math.round(ORANGE_RGB[1] + (GREY_RGB[1] - ORANGE_RGB[1]) * t);
5088
- const b = Math.round(ORANGE_RGB[2] + (GREY_RGB[2] - ORANGE_RGB[2]) * t);
5184
+ const r = Math.round(ACCENT_RGB[0] + (GREY_RGB[0] - ACCENT_RGB[0]) * t);
5185
+ const g = Math.round(ACCENT_RGB[1] + (GREY_RGB[1] - ACCENT_RGB[1]) * t);
5186
+ const b = Math.round(ACCENT_RGB[2] + (GREY_RGB[2] - ACCENT_RGB[2]) * t);
5089
5187
  const animColor = lerpColor(r, g, b, r, g, b, 0);
5090
5188
  lines.push(col(frame, animColor) + ' ' + col('[', animColor) + col(word, animColor) + col(tail, greyEsc));
5091
5189
  } else {
@@ -5128,12 +5226,17 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5128
5226
  //
5129
5227
  // These are the base with a lift in the same hue, so the animation reads as a sheen travelling across
5130
5228
  // the word rather than as the word changing colour.
5131
- const GLINT = [255, 205, 95];
5229
+ //
5230
+ // IT IS DERIVED FROM THE ACCENT, NOT FIXED. A single yellow glint was written for the orange base and
5231
+ // stayed yellow when the row turned blue for a compaction — a warm highlight over a cool base, which
5232
+ // reads as two colours fighting rather than as one sheen. `glintFor` lifts each channel part-way to
5233
+ // white, so the hue of whichever base is in force carries through.
5234
+ const GLINT = glintFor(ACCENT_RGB);
5132
5235
 
5133
5236
  const chars = workMsg;
5134
5237
  const lightEdge = state.shimmerEdge || (state.cfg && state.cfg.shimmerEdge) || 'cosine';
5135
5238
  // ONE shimmer for both rows — see `shimmerText`.
5136
- const out = shimmerText(chars, phaseMs, ORANGE_RGB, GLINT, lightEdge);
5239
+ const out = shimmerText(chars, phaseMs, ACCENT_RGB, GLINT, lightEdge);
5137
5240
  // A QUIET TURN FADES TOWARD THE WARNING COLOUR.
5138
5241
  //
5139
5242
  // `state.lastTokenAt` is stamped whenever output arrives; `state.hasActiveTools` is set while a tool
@@ -5141,14 +5244,20 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5141
5244
  //
5142
5245
  // The intensity is interpolated into the base colour rather than switching, so a slow model does not
5143
5246
  // look like a broken one for one frame and then fine the next.
5144
- const stall = stallIntensity({
5247
+ // A COMPACTION IS NOT A STALLED MODEL.
5248
+ //
5249
+ // The stall warning exists because a model that has sent nothing for a few seconds is
5250
+ // usually stuck. A manual /compact has no model output at all — its summariser is a
5251
+ // separate one-shot request that never stamps `lastTokenAt` — so the row announced
5252
+ // trouble for the whole round trip, which is the opposite of what is happening.
5253
+ const stall = state.compacting ? 0 : stallIntensity({
5145
5254
  sinceLastTokenMs: state.lastTokenAt ? Date.now() - state.lastTokenAt : 0,
5146
5255
  hasActiveTools: !!state.hasActiveTools,
5147
5256
  });
5148
5257
  const baseFrame = stall > 0 ? col(frame, lerpColor(
5149
- ORANGE_RGB[0], ORANGE_RGB[1], ORANGE_RGB[2],
5258
+ ACCENT_RGB[0], ACCENT_RGB[1], ACCENT_RGB[2],
5150
5259
  255, 90, 90, stall,
5151
- )) : col(frame, orangeEsc);
5260
+ )) : col(frame, accentEsc);
5152
5261
  lines.push(baseFrame + ' ' + out + elapsed + stepNote);
5153
5262
  }
5154
5263
  }
@@ -5470,8 +5579,18 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5470
5579
  const running = ts.filter((t) => t.status === 'running');
5471
5580
  const bashTasks = running.filter((t) => t.kind !== 'agent').length;
5472
5581
  const agentTasks = running.filter((t) => t.kind === 'agent').length;
5473
- if (bashTasks > 0) parts.push(col(`[${bashTasks} task${bashTasks === 1 ? '' : 's'} running]`, C.cyan));
5474
- if (agentTasks > 0) parts.push(col(`[${agentTasks} agent${agentTasks === 1 ? '' : 's'} running]`, C.spring));
5582
+ // The badges are CLICKABLE: they open the task panel, which is where the running
5583
+ // tasks are listed and can be read or stopped. A count the user cannot act on is
5584
+ // decoration; this one is a link.
5585
+ //
5586
+ // The text goes through the i18n table so the badge reads the same in every
5587
+ // language. The English form is kept in the table for the default language.
5588
+ if (bashTasks > 0) {
5589
+ pushPart(col(tr('status.tasksBash', '[{n} task(s) running]', { n: bashTasks }), C.cyan), { kind: 'statusTasks' });
5590
+ }
5591
+ if (agentTasks > 0) {
5592
+ pushPart(col(tr('status.tasksAgent', '[{n} agent(s) running]', { n: agentTasks }), C.spring), { kind: 'statusTasks' });
5593
+ }
5475
5594
  }
5476
5595
  if (state.slCwd !== false && cwd) parts.push(col(cwd, C.gray));
5477
5596
  // GIT badge: branch, then the working-tree diff totals. Placed AFTER the path so
@@ -5509,8 +5628,21 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5509
5628
  // AND the model must have prices (its own entry or the models.dev catalog). Either one
5510
5629
  // missing would mean inventing the number, so it is omitted rather than shown as `0$`,
5511
5630
  // which reads as "this was free".
5512
- const costSeg = state._costText ? `${state._costText} cost | ` : '';
5513
- const countsRight = col(`${costSeg}${state.rounds} turn${state.rounds === 1 ? '' : 's'} | ${state.steps} step${state.steps === 1 ? '' : 's'} | ${Math.round(state.tokRate)} tok/s`, C.white);
5631
+ const costSeg = state._costText ? `${state._costText} ${uiText('cost')} | ` : '';
5632
+ // THE TALLIES ARE COUNTED NOUNS, so they go through `tr` rather than `uiText`: a template
5633
+ // can sit the number where the language wants it, and the plural only exists in English.
5634
+ const countsRight = col(
5635
+ `${costSeg}`
5636
+ + (state.rounds === 1
5637
+ ? tr('status.turnsOne', '{n} turn', { n: state.rounds })
5638
+ : tr('status.turns', '{n} turns', { n: state.rounds }))
5639
+ + ' | '
5640
+ + (state.steps === 1
5641
+ ? tr('status.stepsOne', '{n} step', { n: state.steps })
5642
+ : tr('status.steps', '{n} steps', { n: state.steps }))
5643
+ + ` | ${Math.round(state.tokRate)} tok/s`,
5644
+ C.white,
5645
+ );
5514
5646
  const statusRight = countsRight;
5515
5647
  // Plugin TUI widgets render into the status bar's right side.
5516
5648
  try { const wid = renderWidgets(); if (wid) statusRight && (statusRight += ' '); if (wid) statusRight = (statusRight || '') + wid; } catch {}
@@ -5532,7 +5664,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
5532
5664
  //
5533
5665
  // No bar when the window is unknown: a bar claiming to be full is worse than no bar, and
5534
5666
  // `ctxMax` is 0 until the first usage report lands.
5535
- const ctxText = `context: ${state.ctxPercent}% (${fmtTokens(state.ctxTokens || 0)}/${fmtTokens(state.ctxMax || 1)})`;
5667
+ const ctxText = `${uiText('context')} ${state.ctxPercent}% (${fmtTokens(state.ctxTokens || 0)}/${fmtTokens(state.ctxMax || 1)})`;
5536
5668
  const ctxSegs = contextSegments(state, state.cfg);
5537
5669
  const barRow = lines.length;
5538
5670
  const bar = state.ctxMax > 0
@@ -7065,9 +7197,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7065
7197
  openPicker({
7066
7198
  title: 'Select permission mode',
7067
7199
  items: [
7068
- { label: 'Ask', sub: 'read-only tools and read-only shell commands run automatically; everything else asks', current: state.mode === 'ask', value: 'ask' },
7200
+ { label: 'Ask', sub: uiText('read-only tools and read-only shell commands run automatically; everything else asks'), current: state.mode === 'ask', value: 'ask' },
7069
7201
  { label: 'Yolo', sub: 'runs anything inside the workspace, and any non-destructive command; asks for a path OUTSIDE the workspace and for a destructive command', current: state.mode === 'yolo', value: 'yolo' },
7070
- { label: 'Auto', sub: 'never asks and never waits for approval: everything runs and is decided automatically (an explicit deny or ask rule still wins)', current: state.mode === 'auto', value: 'auto' },
7202
+ { label: 'Auto', sub: uiText('never asks and never waits for approval: everything runs and is decided automatically (an explicit deny or ask rule still wins)'), current: state.mode === 'auto', value: 'auto' },
7071
7203
  ],
7072
7204
  sel: ['ask', 'yolo', 'auto'].indexOf(state.mode),
7073
7205
  searchable: false,
@@ -7085,7 +7217,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7085
7217
  // `/plan saved` lists the plans persisted to <workspace>/.hncode/plans.
7086
7218
  if (a === 'saved' || a === 'list') {
7087
7219
  const items = listPlans(state.workspace || cfg.workspace);
7088
- if (!items.length) { say('No saved plans yet. Approve a plan in Plan mode to save it.'); return; }
7220
+ if (!items.length) { say(uiText('No saved plans yet. Approve a plan in Plan mode to save it.')); return; }
7089
7221
  h.openPanel('hncode — saved plans', [
7090
7222
  `${items.length} plan(s) in ${plansDir(state.workspace || cfg.workspace)}:`,
7091
7223
  '',
@@ -7093,13 +7225,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7093
7225
  ]);
7094
7226
  return;
7095
7227
  }
7096
- if (a === 'clear') { state.plan = false; state.planPath = null; persist(); app('Plan cleared.'); return; }
7228
+ if (a === 'clear') { state.plan = false; state.planPath = null; persist(); app(uiText('Plan cleared.')); return; }
7097
7229
  if (a === 'on') state.plan = true;
7098
7230
  else if (a === 'off') state.plan = false;
7099
7231
  else state.plan = !state.plan;
7100
7232
  if (state.plan) { state.focus = false; state.swarm = false; }
7101
7233
  persist();
7102
- app(`Plan mode: ${state.plan ? 'ON (read-only planning)' : 'OFF'}`);
7234
+ app(`Plan mode: ${state.plan ? uiText('ON (read-only planning)') : uiText('OFF')}`);
7103
7235
  return;
7104
7236
  }
7105
7237
  case 'focus': {
@@ -7110,7 +7242,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7110
7242
  state.focus = want;
7111
7243
  if (state.focus) { state.plan = false; state.swarm = false; }
7112
7244
  persist();
7113
- app(`Focus mode: ${state.focus ? 'ON (Read/Write/Edit/Bash only)' : 'OFF (all tools)'}`);
7245
+ app(`Focus mode: ${state.focus ? uiText('ON (Read/Write/Edit/Bash only)') : uiText('OFF (all tools)')}`);
7114
7246
  return;
7115
7247
  }
7116
7248
  case 'websearch-api': {
@@ -7131,8 +7263,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7131
7263
  applySetting('web_search_api_key', String(value == null ? '' : value));
7132
7264
  const count = String(value || '').split(/\r?\n/).map((s) => s.trim()).filter(Boolean).length;
7133
7265
  app(count
7134
- ? `Saved ${count} WebSearch key${count === 1 ? '' : 's'}. The next search uses them.`
7135
- : 'WebSearch keys cleared — searches use keyless mode (rate-limited per IP).');
7266
+ ? `${uiText('Saved')} ${count} WebSearch ${uiText('key')}${count === 1 ? '' : 's'}. ${uiText('The next search uses them.')}`
7267
+ : uiText('WebSearch keys cleared — searches use keyless mode (rate-limited per IP).'));
7136
7268
  },
7137
7269
  });
7138
7270
  return;
@@ -7275,12 +7407,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7275
7407
  const show = () => {
7276
7408
  const row = (label, v, note) => ` ${label.padEnd(18)} ${v == null ? '(provider default)' : v}${note ? ' ' + note : ''}`;
7277
7409
  sayPanel([
7278
- 'Sampling parameters',
7410
+ uiText('Sampling parameters'),
7279
7411
  '',
7280
7412
  row('send them', cfg.sampling === false ? 'off' : 'on', cfg.sampling === false ? 'nothing is sent' : ''),
7281
7413
  row('temperature', cfg.temperature),
7282
7414
  row('top_p', cfg.topP),
7283
- row('presence_penalty', cfg.presencePenalty, 'OpenAI-compatible only'),
7415
+ row('presence_penalty', cfg.presencePenalty, uiText('OpenAI-compatible only')),
7284
7416
  '',
7285
7417
  'Set with /sampling temperature 0.3, /sampling top_p 0.9, /sampling off',
7286
7418
  ].join('\n'));
@@ -7294,7 +7426,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7294
7426
  }
7295
7427
  const key = parts[0] === 'top-p' ? 'top_p' : parts[0] === 'presence-penalty' ? 'presence_penalty' : parts[0];
7296
7428
  if (!['temperature', 'top_p', 'presence_penalty'].includes(key)) {
7297
- appErr('Usage: /sampling [on|off] | temperature <0-2> | top_p <0-1> | presence_penalty <-2-2>');
7429
+ appErr(uiText('Usage: /sampling [on|off] | temperature <0-2> | top_p <0-1> | presence_penalty <-2-2>'));
7298
7430
  return;
7299
7431
  }
7300
7432
  if (parts.length === 1) { show(); return; }
@@ -7312,8 +7444,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7312
7444
  if (!parts.length) {
7313
7445
  const changed = changedSettings(cfg);
7314
7446
  if (!changed.length) {
7315
- sayPanel(['Nothing is set away from its default.', '', 'Browse everything with /settings,',
7316
- 'or set one directly: /set <key> <value>'].join('\n'));
7447
+ sayPanel([uiText('Nothing is set away from its default.'), '', uiText('Browse everything with /settings,'),
7448
+ uiText('or set one directly: /set <key> <value>')].join('\n'));
7317
7449
  return;
7318
7450
  }
7319
7451
  const lines = [`${changed.length} setting(s) differ from the default:`, ''];
@@ -7355,17 +7487,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7355
7487
  const want = String(raw || '').trim().toLowerCase();
7356
7488
  if (!want) {
7357
7489
  const now = getUiLang();
7358
- app(`Interface language: ${now === 'zh' ? '中文' : 'English'} (/lang zh|en)`);
7490
+ app(uiText(now === 'zh' ? 'Interface language: 中文' : 'Interface language: English') + ' (/lang zh|en)');
7359
7491
  return;
7360
7492
  }
7361
7493
  if (want !== 'zh' && want !== 'en') {
7362
- appErr('Usage: /lang zh|en');
7494
+ appErr(uiText('Usage: /lang zh|en'));
7363
7495
  return;
7364
7496
  }
7365
7497
  setUiLang(want);
7366
7498
  try { setConfigString('lang', want); } catch { /* an unwritable config must not undo the switch */ }
7367
7499
  if (cfg) cfg.lang = want;
7368
- app(want === 'zh' ? '界面语言:中文' : 'Interface language: English');
7500
+ app(uiText(want === 'zh' ? 'Interface language: 中文' : 'Interface language: English'));
7369
7501
  return;
7370
7502
  }
7371
7503
 
@@ -7375,7 +7507,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7375
7507
  if (!names.length) {
7376
7508
  const pr = (cfg.raw && cfg.raw.providers) || {};
7377
7509
  names = Object.keys(pr);
7378
- if (!names.length) { appErr('No providers configured. Add one first: /provider'); return; }
7510
+ if (!names.length) { appErr(uiText('No providers configured. Add one first: /provider')); return; }
7379
7511
  if (raw) {
7380
7512
  if (!pr[raw]) { appErr(`Unknown provider: ${raw}`); return; }
7381
7513
  applyModel(state, cfg, resolveProvider(cfg, raw));
@@ -7418,7 +7550,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7418
7550
  // window, output limit). These are exactly the fields resolveConfig reads,
7419
7551
  // so an edit takes effect on the next turn without editing config.toml by hand.
7420
7552
  onCtrlE: (item) => {
7421
- if (!item || item.action === 'add-model') { appErr('Select a model first, then Ctrl+E to edit it.'); return; }
7553
+ if (!item || item.action === 'add-model') { appErr(uiText('Select a model first, then Ctrl+E to edit it.')); return; }
7422
7554
  const entry = models[item.label] || {};
7423
7555
  const provider = entry.provider || cfg.provider || '';
7424
7556
  const modelId = entry.model || bareModelId(provider, item.label, entry);
@@ -7481,7 +7613,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7481
7613
  if (it.action === 'add-model') {
7482
7614
  const pr = (cfg.raw && cfg.raw.providers) || {};
7483
7615
  const providers = Object.keys(pr);
7484
- if (!providers.length) { appErr('No providers configured. Add one first: /provider'); return true; }
7616
+ if (!providers.length) { appErr(uiText('No providers configured. Add one first: /provider')); return true; }
7485
7617
  openPicker({
7486
7618
  title: 'Add model — choose a provider',
7487
7619
  items: providers.map((n) => ({ label: n, sub: ((pr[n] || {}).base_url || '').replace(/^https?:\/\//, ''), provider: n })),
@@ -7497,7 +7629,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7497
7629
  hideType: true,
7498
7630
  hint: 'Tab next field · Enter save · Esc cancel (display name defaults to the id)',
7499
7631
  onSubmit: (values) => {
7500
- if (!values.model) { appErr('Cancelled: model id is required.'); return; }
7632
+ if (!values.model) { appErr(uiText('Cancelled: model id is required.')); return; }
7501
7633
  const disp = values.display_name || values.model;
7502
7634
  addModel(pit.provider, values.model, { display_name: values.display_name });
7503
7635
  cfg.raw.models = cfg.raw.models || {};
@@ -7522,7 +7654,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7522
7654
  }
7523
7655
  case 'effort': {
7524
7656
  const opts = effortOptions(cfg);
7525
- if (!opts.length) { appErr('The current model has no thinking control.'); return; }
7657
+ if (!opts.length) { appErr(uiText('The current model has no thinking control.')); return; }
7526
7658
  if (raw) {
7527
7659
  const v = raw.toLowerCase();
7528
7660
  // NO VALIDATION against `opts`. The list is what a model is KNOWN to accept — from the catalog,
@@ -7595,7 +7727,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7595
7727
  // the whole models.dev catalog when the provider is a catalog one. Replaces
7596
7728
  // the provider's model entries rather than appending.
7597
7729
  onCtrlR: (it) => {
7598
- if (!it || it.action === 'add') { appErr('Select a provider first, then Ctrl+R to refresh its models.'); return; }
7730
+ if (!it || it.action === 'add') { appErr(uiText('Select a provider first, then Ctrl+R to refresh its models.')); return; }
7599
7731
  refreshProviderModels(state, cfg, it.label, h).catch((e) => appErr(`Refresh failed: ${e.message}`));
7600
7732
  },
7601
7733
  onDelete: (it) => {
@@ -7642,8 +7774,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7642
7774
  typeClickSubmits: true,
7643
7775
  hint: 'Tab next field · ↑/↓ field · ←/→ type · Enter save · Esc cancel',
7644
7776
  onSubmit: (values, type) => {
7645
- if (!values.name) { appErr('Cancelled: provider name is required.'); return; }
7646
- if (!type) { appErr('Cancelled: choose a Type (OpenAI / OpenAI Responses / Anthropic).'); return; }
7777
+ if (!values.name) { appErr(uiText('Cancelled: provider name is required.')); return; }
7778
+ if (!type) { appErr(uiText('Cancelled: choose a Type (OpenAI / OpenAI Responses / Anthropic).')); return; }
7647
7779
  const protocol = typeToProtocol(type);
7648
7780
  // A hand-entered provider is NOT from the catalog: known=false.
7649
7781
  registerProvider(state, cfg, h, values.name, values.base_url, values.api_key, protocol, type, false);
@@ -7652,7 +7784,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7652
7784
  return true;
7653
7785
  }
7654
7786
  // Known provider: load catalog and show list
7655
- app('Loading provider list…');
7787
+ app(uiText('Loading provider list…'));
7656
7788
  fetchCatalog().then((catalog) => {
7657
7789
  const entries = catalog
7658
7790
  ? Object.values(catalog)
@@ -7677,7 +7809,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7677
7809
  action: 'pickKnown',
7678
7810
  }));
7679
7811
  if (!items.length) {
7680
- appErr('No known providers found in catalog.');
7812
+ appErr(uiText('No known providers found in catalog.'));
7681
7813
  return;
7682
7814
  }
7683
7815
  openPicker({
@@ -7804,7 +7936,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7804
7936
  typeClickSubmits: true,
7805
7937
  hint: 'Tab next field · ←/→ type · Enter save · Esc cancel',
7806
7938
  onSubmit: (values, type) => {
7807
- if (!values.name) { appErr('Cancelled: provider name is required.'); return; }
7939
+ if (!values.name) { appErr(uiText('Cancelled: provider name is required.')); return; }
7808
7940
  // The chosen Type arrives as the SECOND arg (`values` holds only the
7809
7941
  // text fields) — `values.type` was undefined and silently saved 'openai'.
7810
7942
  const protocol = typeToProtocol(type);
@@ -7882,6 +8014,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7882
8014
  // The fresh session has no title yet, so this restores the default rather than leaving
7883
8015
  // the previous session's name on the window.
7884
8016
  writeWindowTitle(session, stdout);
8017
+ // A LONG SESSION'S FIRST FRAME IS SLOW, AND IT USED TO BE A BLANK SCREEN. The first paint
8018
+ // lays out every message once to learn the row count the scrollbar needs — ~570ms for a
8019
+ // 4000-message history, 8ms for a normal one — and until it finishes the screen is empty,
8020
+ // which is indistinguishable from a hang. Saying so costs nothing.
8021
+ {
8022
+ const n = (session && session.messages) ? session.messages.length : 0;
8023
+ if (n > 200) {
8024
+ const cols = Math.max(20, (stdout.columns || 80));
8025
+ stdout.write(fitAnsi(col(` ${tr('tui.state.restoring', 'Restoring {n} messages…', { n })}`, C.gray), cols) + '\n');
8026
+ }
8027
+ }
7885
8028
  // A fresh session has no history, so the context gauge must go back to 0
7886
8029
  // (otherwise it kept showing the PREVIOUS session's usage until the next
7887
8030
  // turn reported a new estimate). The window size is a property of the
@@ -7923,8 +8066,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7923
8066
  });
7924
8067
  if (!list.length) {
7925
8068
  app(everyWorkspace
7926
- ? 'No saved sessions.'
7927
- : (all.length ? `No sessions in this directory (${cwd}). Try /all-sessions.` : 'No saved sessions.'));
8069
+ ? uiText('No saved sessions.')
8070
+ : (all.length ? `No sessions in this directory (${cwd}). Try /all-sessions.` : uiText('No saved sessions.')));
7928
8071
  return;
7929
8072
  }
7930
8073
  openPicker({
@@ -7943,7 +8086,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
7943
8086
  onDelete: (it) => {
7944
8087
  if (!it || !it.id) return false;
7945
8088
  if (it.id === session.id) {
7946
- appErr('That is the session you are in. Use /new first, or pick another one.');
8089
+ appErr(uiText('That is the session you are in. Use /new first, or pick another one.'));
7947
8090
  return false;
7948
8091
  }
7949
8092
  const ok = sess.deleteSession(it.id);
@@ -8055,7 +8198,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8055
8198
  }
8056
8199
  cfg.raw.swarm_mode = want;
8057
8200
  app(want
8058
- ? 'Swarm mode ON - the model will decompose work across parallel subagents (AgentSwarm)'
8201
+ ? uiText('Swarm mode ON - the model will decompose work across parallel subagents (AgentSwarm)')
8059
8202
  : 'Swarm mode OFF');
8060
8203
  return;
8061
8204
  }
@@ -8075,7 +8218,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8075
8218
  const setSubagentModel = (value) => {
8076
8219
  const v = value || '';
8077
8220
  try { setConfigString('subagent_model', v); }
8078
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
8221
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
8079
8222
  cfg.subagentModel = v;
8080
8223
  cfg.raw.subagent_model = v;
8081
8224
  app(v ? `Subagent model → ${v}` : `Subagent model → default (this session's model)`);
@@ -8090,7 +8233,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8090
8233
  return;
8091
8234
  }
8092
8235
  if (!names.length) {
8093
- appErr('No models configured. Add one first: /provider');
8236
+ appErr(uiText('No models configured. Add one first: /provider'));
8094
8237
  return;
8095
8238
  }
8096
8239
  // The same model menu as /model, with a subagent-scoped title and a
@@ -8155,7 +8298,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8155
8298
  return;
8156
8299
  }
8157
8300
  if (!argStr) {
8158
- if (!promptIdx.length) { app('Nothing to undo.'); return; }
8301
+ if (!promptIdx.length) { app(uiText('Nothing to undo.')); return; }
8159
8302
  const items = promptIdx.map((mi, k) => {
8160
8303
  const text = String(msgs[mi].content == null ? '' : msgs[mi].content).replace(/\s+/g, ' ').trim();
8161
8304
  return {
@@ -8195,7 +8338,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8195
8338
  ],
8196
8339
  onPick: (it) => {
8197
8340
  if (it && it.label === 'Rewind') run();
8198
- else app('Rewind cancelled.');
8341
+ else app(uiText('Rewind cancelled.'));
8199
8342
  return true;
8200
8343
  },
8201
8344
  });
@@ -8213,7 +8356,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8213
8356
  if (j < 0) break;
8214
8357
  ci = j;
8215
8358
  }
8216
- if (ci >= cur.length) { app('Nothing to undo.'); return; }
8359
+ if (ci >= cur.length) { app(uiText('Nothing to undo.')); return; }
8217
8360
  // Truncate the model's context AND rebuild the displayed transcript from that point. The two have different
8218
8361
  // row counts because the transcript also contains receipts, notices and shell commands; slicing it by the
8219
8362
  // number of removed model messages leaves rows from the discarded turn on screen.
@@ -8256,12 +8399,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8256
8399
  if (a === 'on') want = true;
8257
8400
  else if (a === 'off') want = false;
8258
8401
  else if (a === '') { app(`Auto title: ${cfg.autoTitle === false ? 'off' : 'on'}. /auto-title [on|off]`); return; }
8259
- else { appErr('Usage: /auto-title [on|off]'); return; }
8402
+ else { appErr(uiText('Usage: /auto-title [on|off]')); return; }
8260
8403
  cfg.autoTitle = want;
8261
8404
  try { setConfigString('auto_title', want ? 'true' : 'false'); }
8262
8405
  catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
8263
8406
  app(want
8264
- ? 'Auto title: ON — the first message names the session.'
8407
+ ? uiText('Auto title: ON — the first message names the session.')
8265
8408
  : 'Auto title: OFF — the name comes only from /title.');
8266
8409
  return;
8267
8410
  }
@@ -8276,12 +8419,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8276
8419
  if (a === 'on') want = true;
8277
8420
  else if (a === 'off') want = false;
8278
8421
  else if (a === '') { app(`PTC mode: ${state.ptcMode ? 'on' : 'off'}. /ptc [on|off]`); return; }
8279
- else { appErr('Usage: /ptc [on|off]'); return; }
8422
+ else { appErr(uiText('Usage: /ptc [on|off]')); return; }
8280
8423
  state.ptcMode = want;
8281
8424
  if (session) session.ptcMode = want;
8282
8425
  try { sess.saveSession(session); } catch { /* a preference; a failed save must not block the mode */ }
8283
8426
  app(want
8284
- ? 'PTC mode: ON — the model gets only the PTC tool and reaches everything else through its sandbox.'
8427
+ ? uiText('PTC mode: ON — the model gets only the PTC tool and reaches everything else through its sandbox.')
8285
8428
  : 'PTC mode: OFF — direct tool calls are available again.');
8286
8429
  return;
8287
8430
  }
@@ -8291,7 +8434,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8291
8434
  saveSession(session);
8292
8435
  // The window title follows the session, in ONE place (see writeWindowTitle).
8293
8436
  writeWindowTitle(session, stdout);
8294
- app(`Session title set to: "${session.title || 'Untitled'}"`);
8437
+ app(`Session title set to: "${session.title || uiText('Untitled')}"`);
8295
8438
  } else {
8296
8439
  app(`Session title: ${session.title || 'not set'}`);
8297
8440
  }
@@ -8299,17 +8442,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8299
8442
  }
8300
8443
  case 'compact': {
8301
8444
  const msgs = session.messages || [];
8302
- if (msgs.length <= 2) { app('Nothing to compact yet.'); return; }
8445
+ if (msgs.length <= 2) { app(uiText('Nothing to compact yet.')); return; }
8303
8446
  const ratio = raw ? parseFloat(raw) : null; // optional slice ratio (0-1)
8304
8447
  if (ratio !== null && !(ratio > 0 && ratio < 1)) {
8305
- app('Invalid ratio; use 0-1 (e.g., 0.2 to drop the oldest 20% of messages)');
8448
+ app(uiText('Invalid ratio; use 0-1 (e.g., 0.2 to drop the oldest 20% of messages)'));
8306
8449
  return;
8307
8450
  }
8308
8451
 
8309
8452
  // Summarising is a full model round-trip. Without this, a second /compact
8310
8453
  // (or a message typed while it works) would edit the same history at the
8311
8454
  // same time — `state.running` is what submit() checks to queue instead.
8312
- if (state.running) { app('Busy — wait for the current turn to finish.'); return; }
8455
+ if (state.running) { app(uiText('Busy — wait for the current turn to finish.')); return; }
8313
8456
  state.running = true;
8314
8457
  // The Working row takes over the progress display: it shows `Compacting Context...` for as
8315
8458
  // long as this runs, so the summary round-trip is visible without adding a transcript row.
@@ -8469,11 +8612,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8469
8612
  const trimmed = String(value).trim();
8470
8613
  try {
8471
8614
  setConfigString('system_prompt', trimmed);
8472
- } catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
8615
+ } catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
8473
8616
  cfg.systemPrompt = trimmed;
8474
8617
  cfg.raw.system_prompt = trimmed;
8475
8618
  if (trimmed) app(`System prompt saved (${trimmed.length} chars) → ${hncodeConfigFile()}`);
8476
- else app('System prompt override cleared; the built-in prompt is in use again.');
8619
+ else app(uiText('System prompt override cleared; the built-in prompt is in use again.'));
8477
8620
  },
8478
8621
  });
8479
8622
  };
@@ -8512,10 +8655,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8512
8655
  }
8513
8656
  if (it.action === 'restore') {
8514
8657
  try { setConfigString('system_prompt', ''); }
8515
- catch (e) { appErr('Could not write config.toml: ' + e.message); return true; }
8658
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return true; }
8516
8659
  cfg.systemPrompt = '';
8517
8660
  cfg.raw.system_prompt = '';
8518
- app('System prompt override cleared; the built-in prompt is in use again.');
8661
+ app(uiText('System prompt override cleared; the built-in prompt is in use again.'));
8519
8662
  return true;
8520
8663
  }
8521
8664
  // Preset picker: the FAMILY is the list (↑↓), the TASK is a footer row
@@ -8575,7 +8718,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8575
8718
  caretCol: 0,
8576
8719
  onSave: (value) => {
8577
8720
  try { writePersonalPrompt(scope, workspace, value); }
8578
- catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
8721
+ catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
8579
8722
  if (String(value).trim()) app(`Personal preferences saved (${scope}) → ${file}`);
8580
8723
  else app(`Personal preferences cleared (${scope}); nothing will be injected.`);
8581
8724
  },
@@ -8599,7 +8742,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8599
8742
  });
8600
8743
  return;
8601
8744
  }
8602
- appErr('Usage: /personal [global|project]');
8745
+ appErr(uiText('Usage: /personal [global|project]'));
8603
8746
  return;
8604
8747
  }
8605
8748
 
@@ -8620,7 +8763,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8620
8763
  caretCol: 0,
8621
8764
  onSave: (value) => {
8622
8765
  try { writeMemoryRaw(scope, workspace, value); }
8623
- catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
8766
+ catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
8624
8767
  if (String(value).trim()) app(`Agent memory saved (${scope}) → ${file}`);
8625
8768
  else app(`Agent memory cleared (${scope}); nothing will be injected.`);
8626
8769
  },
@@ -8642,7 +8785,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8642
8785
  onPick: (it) => {
8643
8786
  const file = memoryFile(it.label, workspace);
8644
8787
  try { writeMemoryRaw(it.label, workspace, ''); }
8645
- catch (e) { appErr('Could not clear ' + file + ': ' + e.message); return true; }
8788
+ catch (e) { appErr(uiText('Could not clear ') + file + ': ' + e.message); return true; }
8646
8789
  app(`Agent memory cleared (${it.label}) — ${file}`);
8647
8790
  return true;
8648
8791
  },
@@ -8662,7 +8805,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8662
8805
  });
8663
8806
  return;
8664
8807
  }
8665
- appErr('Usage: /memory [global|project|clear]');
8808
+ appErr(uiText('Usage: /memory [global|project|clear]'));
8666
8809
  return;
8667
8810
  }
8668
8811
 
@@ -8683,7 +8826,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8683
8826
  caretCol: 0,
8684
8827
  onSave: (value) => {
8685
8828
  try { fs.writeFileSync(file, String(value)); }
8686
- catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
8829
+ catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
8687
8830
  // Re-read so the new rules apply on the NEXT tool call, without a restart.
8688
8831
  const fresh = resolveConfig();
8689
8832
  cfg.permissions = fresh.permissions;
@@ -8724,7 +8867,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8724
8867
  appErr(`${selfTest.failed.length} rule example(s) failed — see /permissions.`);
8725
8868
  }
8726
8869
  if (!n('allow') && !n('ask') && !n('deny')) {
8727
- app('No permission rules set — /permissions edit to add some.');
8870
+ app(uiText('No permission rules set — /permissions edit to add some.'));
8728
8871
  }
8729
8872
  return;
8730
8873
  }
@@ -8743,21 +8886,21 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8743
8886
  if (a === 'on' || a === 'true' || a === 'yes' || a === '1') want = true;
8744
8887
  else if (a === 'off' || a === 'false' || a === 'no' || a === '0') want = false;
8745
8888
  else if (a === '') want = !cur;
8746
- else { appErr('Usage: /external [on|off]'); return; }
8889
+ else { appErr(uiText('Usage: /external [on|off]')); return; }
8747
8890
 
8748
8891
  const envForced = process.env.HNCODE_ALLOW_EXTERNAL === '1';
8749
8892
  try { setConfigBool('tool_allow_external_paths', want); }
8750
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
8893
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
8751
8894
  cfg.allowExternal = want;
8752
8895
  if (cfg.raw) cfg.raw.tool_allow_external_paths = want;
8753
8896
  // Push it into the RUNNING agent too: it snapshotted cfg at construction, so
8754
8897
  // without this the switch would only take effect on the next turn.
8755
8898
  if (state.agent && state.agent.ctx) state.agent.ctx.allowExternal = want;
8756
8899
  app(want
8757
- ? 'External paths: ON — tools may read and write outside the workspace.'
8900
+ ? uiText('External paths: ON — tools may read and write outside the workspace.')
8758
8901
  : 'External paths: OFF — tools are confined to the workspace.');
8759
8902
  if (envForced && !want) {
8760
- appErr('Note: HNCODE_ALLOW_EXTERNAL=1 is set, so access stays ON until you unset it.');
8903
+ appErr(uiText('Note: HNCODE_ALLOW_EXTERNAL=1 is set, so access stays ON until you unset it.'));
8761
8904
  }
8762
8905
  return;
8763
8906
  }
@@ -8773,10 +8916,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8773
8916
  // of a stable address and a stable token.
8774
8917
  const a = raw.trim();
8775
8918
  if (a.toLowerCase() === 'off' || a.toLowerCase() === 'stop') {
8776
- app(h.stopWeb() ? 'Web UI stopped (this session is no longer listed).' : 'Web UI is not running.');
8919
+ app(h.stopWeb() ? uiText('Web UI stopped (this session is no longer listed).') : uiText('Web UI is not running.'));
8777
8920
  return;
8778
8921
  }
8779
- if (!h.startWebGlobal) { appErr('Web UI is unavailable in this build.'); return; }
8922
+ if (!h.startWebGlobal) { appErr(uiText('Web UI is unavailable in this build.')); return; }
8780
8923
  // Optional "[bindIp] [port]" — the same shapes `--web` accepts. The old
8781
8924
  // code threw these away and always bound loopback, so `/web 0.0.0.0` looked
8782
8925
  // like it worked while nothing was reachable from the network.
@@ -8795,7 +8938,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8795
8938
  sayPanel([
8796
8939
  `Web UI (this session only): ${srv.url}`,
8797
8940
  '',
8798
- 'The machine-wide daemon is unavailable, so this session is served',
8941
+ uiText('The machine-wide daemon is unavailable, so this session is served'),
8799
8942
  'directly. Open the address above; the token is below.',
8800
8943
  '',
8801
8944
  ` ${srv.token}`,
@@ -8810,15 +8953,15 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8810
8953
  `Bind: ${daemon.host}:${daemon.port}${lan ? ' (reachable from the network)' : ' (this machine only)'}`,
8811
8954
  daemon.spawned ? 'Daemon: started (was not running)' : 'Daemon: reused (already running)',
8812
8955
  '',
8813
- 'The root page lists every workspace and session — running ones live,',
8956
+ uiText('The root page lists every workspace and session — running ones live,'),
8814
8957
  'finished ones from disk. The token below is stored in config.toml, so',
8815
8958
  'it stays the same across restarts.',
8816
8959
  '',
8817
- 'Access token (paste it into the login page):',
8960
+ uiText('Access token (paste it into the login page):'),
8818
8961
  '',
8819
8962
  ` ${token || srv.token}`,
8820
8963
  '',
8821
- 'Anyone with this token can run commands as you. Stop this session with',
8964
+ uiText('Anyone with this token can run commands as you. Stop this session with'),
8822
8965
  '/web off.',
8823
8966
  ].join('\n'));
8824
8967
  notice(`Web UI at ${daemon.rootUrl}`);
@@ -8842,17 +8985,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8842
8985
  if (a === 'on') want = true;
8843
8986
  else if (a === 'off') want = false;
8844
8987
  else if (a === '') want = !cfg.calmMode;
8845
- else { appErr('Usage: /calm-mode [on|off]'); return; }
8988
+ else { appErr(uiText('Usage: /calm-mode [on|off]')); return; }
8846
8989
  try { setConfigString('calm_mode', want ? 'true' : 'false'); }
8847
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
8990
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
8848
8991
  cfg.calmMode = want;
8849
8992
  cfg.raw.calm_mode = want;
8850
- app(`Calm mode: ${want ? 'ON — the model will keep explanations to a minimum' : 'OFF'}`);
8993
+ app(`${uiText('Calm mode')}: ${want ? uiText('ON — the model will keep explanations to a minimum') : uiText('OFF')}`);
8851
8994
  return;
8852
8995
  }
8853
8996
 
8854
8997
  case 'init': {
8855
- if (!cfg.model) { appErr('LLM not set. Configure a provider with /provider first.'); return; }
8998
+ if (!cfg.model) { appErr(uiText('LLM not set. Configure a provider with /provider first.')); return; }
8856
8999
  // Optional free-text instructions, like /compact's optional ratio: whatever
8857
9000
  // the user types after `/init` steers what goes into the file (e.g.
8858
9001
  // `/init focus on the tRPC routers and our migration rules`). With no
@@ -8898,16 +9041,16 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8898
9041
  else say('No goal set. Start one with /goal <objective>.');
8899
9042
  return;
8900
9043
  }
8901
- if (a === 'pause') { applyGoal(state.objective, true); app('Goal paused. Use /goal resume to continue.'); return; }
9044
+ if (a === 'pause') { applyGoal(state.objective, true); app(uiText('Goal paused. Use /goal resume to continue.')); return; }
8902
9045
  if (a === 'resume') {
8903
- if (!state.objective) { app('No goal to resume.'); return; }
9046
+ if (!state.objective) { app(uiText('No goal to resume.')); return; }
8904
9047
  applyGoal(state.objective, false);
8905
- app('Goal resumed.');
9048
+ app(uiText('Goal resumed.'));
8906
9049
  sendPrompt('Resume the active goal.');
8907
9050
  return;
8908
9051
  }
8909
- if (a === 'cancel') { applyGoal('', false); app('Goal cancelled.'); return; }
8910
- if (a.startsWith('replace ')) { applyGoal(raw.slice(8).trim(), false); app('Goal replaced.'); return; }
9052
+ if (a === uiText('cancel')) { applyGoal('', false); app(uiText('Goal cancelled.')); return; }
9053
+ if (a.startsWith('replace ')) { applyGoal(raw.slice(8).trim(), false); app(uiText('Goal replaced.')); return; }
8911
9054
  applyGoal(raw, false);
8912
9055
  app(`Goal set: ${raw}`);
8913
9056
  // TELL THE MODEL IT IS IN GOAL MODE.
@@ -8975,13 +9118,15 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
8975
9118
  h.openPanel(title, [
8976
9119
  ...panel,
8977
9120
  tr('tui.help.skills', 'Skills'),
8978
- ` /${SKILL_PREFIX}<name> ${tr('tui.help.skillRun', 'run an installed skill (Tab completes the name)')}`,
8979
- ` /import-skill <file.md | owner/repo> ${tr('tui.help.skillImport', 'add a skill from a file, or install a repository of them')}`,
8980
- ` /skills ${tr('tui.help.skillOpen', 'open the skill manager (Tab switches tabs)')}`,
8981
- ` /skills install <name> ${tr('tui.help.skillInstall', 'download one from the repo, without the panel')}`,
8982
- ` /skills remove <name> ${tr('tui.help.skillRemove', 'delete the local copy')}`,
8983
- ` /plugins ${tr('tui.help.pluginOpen', 'open the plugin manager')}`,
8984
- ` /plugins install <name> ${tr('tui.help.pluginInstall', 'download one from the repo')}`,
9121
+ // A fixed command column keeps the descriptions aligned even though one command
9122
+ // is much longer than the rest; hand-spaced strings drifted as commands changed.
9123
+ ` ${`/${SKILL_PREFIX}<name>`.padEnd(38)} ${tr('tui.help.skillRun', 'run an installed skill (Tab completes the name)')}`,
9124
+ ` ${'/import-skill <file.md | owner/repo>'.padEnd(38)} ${tr('tui.help.skillImport', 'add a skill from a file, or install a repository of them')}`,
9125
+ ` ${'/skills'.padEnd(38)} ${tr('tui.help.skillOpen', 'open the skill manager (Tab switches tabs)')}`,
9126
+ ` ${'/skills install <name>'.padEnd(38)} ${tr('tui.help.skillInstall', 'download one from the repo, without the panel')}`,
9127
+ ` ${'/skills remove <name>'.padEnd(38)} ${tr('tui.help.skillRemove', 'delete the local copy')}`,
9128
+ ` ${'/plugins'.padEnd(38)} ${tr('tui.help.pluginOpen', 'open the plugin manager')}`,
9129
+ ` ${'/plugins install <name>'.padEnd(38)} ${tr('tui.help.pluginInstall', 'download one from the repo')}`,
8985
9130
  '',
8986
9131
  tr('tui.help.shortcuts', 'Shortcuts'),
8987
9132
  ` Enter ${tr('tui.key.send', 'send the message')}`,
@@ -9031,32 +9176,32 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9031
9176
  const g = C.gray, w = C.white, b = C.bold;
9032
9177
  const u = state.usage || {};
9033
9178
  const lines = [
9034
- w + b + 'Session usage' + C.reset,
9035
- ' ' + g + 'messages ' + C.reset + w + msgs.length + C.reset,
9179
+ w + b + uiText('Session usage') + C.reset,
9180
+ ' ' + g + uiText('messages') + ' ' + C.reset + w + msgs.length + C.reset,
9036
9181
  ];
9037
9182
  // Provider-reported totals when there are any: they are what the model
9038
9183
  // actually billed. The estimate is the fallback for an endpoint that reports
9039
9184
  // nothing (or predates `stream_options`).
9040
9185
  if (u.calls) {
9041
9186
  const cr = u.input ? Math.round((u.cached || 0) / u.input * 100) : 0;
9042
- lines.push(' ' + g + 'requests ' + C.reset + w + fmtCount(u.calls) + C.reset);
9043
- lines.push(' ' + g + 'input tokens ' + C.reset + w + fmtCount(u.input || 0) + C.reset
9187
+ lines.push(' ' + g + uiText('requests') + ' ' + C.reset + w + fmtCount(u.calls) + C.reset);
9188
+ lines.push(' ' + g + uiText('input tokens') + ' ' + C.reset + w + fmtCount(u.input || 0) + C.reset
9044
9189
  + (u.cached ? g + ` (${cr}% cached)` + C.reset : ''));
9045
- lines.push(' ' + g + 'output tokens ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
9190
+ lines.push(' ' + g + uiText('output tokens') + ' ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
9046
9191
  if (u.reasoning) {
9047
- lines.push(' ' + g + 'reasoning ' + C.reset + w + fmtCount(u.reasoning) + C.reset
9192
+ lines.push(' ' + g + uiText('reasoning') + ' ' + C.reset + w + fmtCount(u.reasoning) + C.reset
9048
9193
  + g + ' included in output' + C.reset);
9049
9194
  }
9050
- lines.push(' ' + g + 'total tokens ' + C.reset + w + fmtCount((u.input || 0) + (u.output || 0)) + C.reset);
9051
- lines.push(' ' + g + 'est. cost ' + C.reset + formatCost(usageCost(u, modelCost(cfg))) + C.reset);
9195
+ lines.push(' ' + g + uiText('total tokens') + ' ' + C.reset + w + fmtCount((u.input || 0) + (u.output || 0)) + C.reset);
9196
+ lines.push(' ' + g + uiText('est. cost') + ' ' + C.reset + formatCost(usageCost(u, modelCost(cfg))) + C.reset);
9052
9197
  } else {
9053
- lines.push(' ' + g + 'approx tokens ' + C.reset + w + fmtCount(approx) + C.reset);
9054
- lines.push(' ' + g + 'token totals ' + C.reset + C.gray
9198
+ lines.push(' ' + g + uiText('approx tokens') + ' ' + C.reset + w + fmtCount(approx) + C.reset);
9199
+ lines.push(' ' + g + uiText('token totals') + ' ' + C.reset + C.gray
9055
9200
  + 'not reported by this endpoint yet' + C.reset);
9056
9201
  }
9057
9202
  lines.push('');
9058
- lines.push(w + b + 'Context window' + C.reset);
9059
- lines.push(' ' + g + 'used ' + C.reset + w + `${state.ctxPercent}% `
9203
+ lines.push(w + b + uiText('Context window') + C.reset);
9204
+ lines.push(' ' + g + uiText('used') + ' ' + C.reset + w + `${state.ctxPercent}% `
9060
9205
  + g + `(${fmtTokens(state.ctxTokens)} / ${fmtTokens(state.ctxMax)})` + C.reset);
9061
9206
 
9062
9207
  // WHAT THE REQUEST IS MADE OF, itemised.
@@ -9071,13 +9216,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9071
9216
  .reduce((n, m) => n + messageTokens(m, cfg), 0);
9072
9217
  const toolTokens = cfg.toolDefTokens || 0;
9073
9218
  const rows = [
9074
- ['system prompt', sysTokens],
9075
- ['conversation', convTokens],
9076
- ['tool schemas', toolTokens],
9219
+ [uiText('system prompt'), sysTokens],
9220
+ [uiText('conversation'), convTokens],
9221
+ [uiText('tool schemas'), toolTokens],
9077
9222
  ].filter(([, v]) => v > 0).sort((a, b) => b[1] - a[1]);
9078
9223
  if (rows.length) {
9079
9224
  lines.push('');
9080
- lines.push(w + b + 'Where it goes' + C.reset);
9225
+ lines.push(w + b + uiText('Where it goes') + C.reset);
9081
9226
  for (const [label, v] of rows) {
9082
9227
  const share = state.ctxTokens ? Math.round((v / state.ctxTokens) * 100) : 0;
9083
9228
  lines.push(' ' + g + label.padEnd(14) + C.reset + w + fmtTokens(v).padStart(8) + C.reset
@@ -9149,7 +9294,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9149
9294
 
9150
9295
  if (byTool.size) {
9151
9296
  lines.push('');
9152
- lines.push(w + b + 'Tools used' + C.reset);
9297
+ lines.push(w + b + uiText('Tools used') + C.reset);
9153
9298
  // MOST-USED FIRST: a list in call order is a history of the session, which the transcript already is.
9154
9299
  for (const [name, n] of [...byTool.entries()].sort((a, c) => c[1] - a[1])) {
9155
9300
  row(name, fmtCount(n));
@@ -9158,7 +9303,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9158
9303
 
9159
9304
  if (files.size) {
9160
9305
  lines.push('');
9161
- lines.push(w + b + 'Files touched' + C.reset + g + ` (${files.size})` + C.reset);
9306
+ lines.push(w + b + uiText('Files touched') + C.reset + g + ` (${files.size})` + C.reset);
9162
9307
  // SORTED, because the set is built from calls that can repeat a path; the count is what matters, not order.
9163
9308
  for (const f of [...files].sort()) lines.push(' ' + w + f + C.reset);
9164
9309
  }
@@ -9167,10 +9312,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9167
9312
  if (u.calls) {
9168
9313
  lines.push('');
9169
9314
  lines.push(w + b + 'Spend' + C.reset);
9170
- row('requests', fmtCount(u.calls));
9315
+ row(uiText('requests'), fmtCount(u.calls));
9171
9316
  row('tokens', fmtCount((u.input || 0) + (u.output || 0)),
9172
9317
  `${fmtCount(u.input || 0)} in · ${fmtCount(u.output || 0)} out`);
9173
- row('est. cost', formatCost(usageCost(u, modelCost(cfg))));
9318
+ row(uiText('est. cost'), formatCost(usageCost(u, modelCost(cfg))));
9174
9319
  }
9175
9320
  sayRich(lines.join('\n'));
9176
9321
  return;
@@ -9193,7 +9338,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9193
9338
  const current = costCurrency(cfg);
9194
9339
  if (asked && asked !== current) {
9195
9340
  try { setConfigString('cost_currency', asked); }
9196
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
9341
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9197
9342
  cfg.raw.cost_currency = asked;
9198
9343
  }
9199
9344
  const wantCurrency = asked || current;
@@ -9222,9 +9367,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9222
9367
  sayRich(lines.join('\n'));
9223
9368
  return;
9224
9369
  }
9225
- lines.push(' ' + g + 'requests ' + C.reset + w + fmtCount(u.calls) + C.reset);
9370
+ lines.push(' ' + g + uiText('requests') + ' ' + C.reset + w + fmtCount(u.calls) + C.reset);
9226
9371
  lines.push(' ' + g + 'input tokens ' + C.reset + w + fmtCount(u.input || 0) + C.reset);
9227
- lines.push(' ' + g + 'output tokens ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
9372
+ lines.push(' ' + g + uiText('output tokens') + ' ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
9228
9373
  if (u.cached) lines.push(' ' + g + 'cache reads ' + C.reset + w + fmtCount(u.cached) + C.reset);
9229
9374
  if (u.cacheWrite) lines.push(' ' + g + 'cache writes ' + C.reset + w + fmtCount(u.cacheWrite) + C.reset);
9230
9375
  lines.push('');
@@ -9233,7 +9378,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9233
9378
  // direction that matters. Say the price is unknown, and show the exact TOML
9234
9379
  // to paste — a self-hosted or gateway provider (a local proxy, a company
9235
9380
  // endpoint) has no entry in models.dev, so the user is the only source.
9236
- lines.push(' ' + C.red + 'No pricing for this model.' + C.reset);
9381
+ lines.push(' ' + C.red + uiText('No pricing for this model.') + C.reset);
9237
9382
  lines.push(' ' + g + 'A provider not added from the models.dev catalog has no' + C.reset);
9238
9383
  lines.push(' ' + g + 'price to read. Add one to config.toml:' + C.reset);
9239
9384
  lines.push('');
@@ -9261,7 +9406,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9261
9406
  lines.push(' ' + w + b + 'estimated total ' + C.reset
9262
9407
  + formatCost(local, wantCurrency) + g + ` (${formatCost(usdCost)} @ ${fx.rate})` + C.reset);
9263
9408
  lines.push(' ' + g + `rate ${fx.rate} ${wantCurrency}/USD — ${fx.source}` + C.reset);
9264
- lines.push(' ' + g + 'Switch back with /cost usd.' + C.reset);
9409
+ lines.push(' ' + g + uiText('Switch back with /cost usd.') + C.reset);
9265
9410
  }
9266
9411
  sayRich(lines.join('\n'));
9267
9412
  return;
@@ -9274,14 +9419,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9274
9419
  if (a === 'on') want = true;
9275
9420
  else if (a === 'off') want = false;
9276
9421
  else if (a === '') want = !state.rawMode;
9277
- else { appErr('Usage: /raw [on|off]'); return; }
9422
+ else { appErr(uiText('Usage: /raw [on|off]')); return; }
9278
9423
  state.rawMode = want;
9279
9424
  // The layout cache keys on rawMode (see metricsSignature), so invalidating the
9280
9425
  // metrics memo is enough — but the per-message row caches also carry it, and
9281
9426
  // both are keyed on it now, so nothing else has to be dropped here.
9282
9427
  state._metrics = null;
9283
9428
  app(want
9284
- ? 'Raw mode: ON — replies shown exactly as the model sent them.'
9429
+ ? uiText('Raw mode: ON — replies shown exactly as the model sent them.')
9285
9430
  : 'Raw mode: OFF — Markdown rendering restored.');
9286
9431
  return;
9287
9432
  }
@@ -9294,11 +9439,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9294
9439
  if (a === 'on') want = true;
9295
9440
  else if (a === 'off') want = false;
9296
9441
  else if (a === '') want = !state.reducedMotion;
9297
- else { appErr('Usage: /reduced-motion [on|off]'); return; }
9442
+ else { appErr(uiText('Usage: /reduced-motion [on|off]')); return; }
9298
9443
  state.reducedMotion = want;
9299
9444
  try { setConfigString('reduced_motion', want ? 'true' : 'false'); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
9300
9445
  app(want
9301
- ? 'Reduced motion: ON — animation is replaced by a slow-breathing dot.'
9446
+ ? uiText('Reduced motion: ON — animation is replaced by a slow-breathing dot.')
9302
9447
  : 'Reduced motion: OFF — animation restored.');
9303
9448
  return;
9304
9449
  }
@@ -9311,7 +9456,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9311
9456
  app(`Shimmer edge: ${state.shimmerEdge}. /shimmer-edge cosine | linear`);
9312
9457
  return;
9313
9458
  }
9314
- if (a !== 'cosine' && a !== 'linear') { appErr('Usage: /shimmer-edge cosine|linear'); return; }
9459
+ if (a !== 'cosine' && a !== 'linear') { appErr(uiText('Usage: /shimmer-edge cosine|linear')); return; }
9315
9460
  state.shimmerEdge = a;
9316
9461
  try { setConfigString('shimmer_edge', a); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
9317
9462
  app(`Shimmer edge: ${a}.`);
@@ -9327,19 +9472,19 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9327
9472
  state.outputStyle = null;
9328
9473
  cfg.outputStyle = null;
9329
9474
  try { setConfigString('output_style', ''); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
9330
- app('Output style cleared.');
9475
+ app(uiText('Output style cleared.'));
9331
9476
  return;
9332
9477
  }
9333
9478
  if (lower === 'edit') {
9334
9479
  const file = state.outputStyle && state.outputStyle.file;
9335
- if (!file) { appErr('No style selected. Pick one with /output-style, or create one with /output-style new <name>.'); return; }
9480
+ if (!file) { appErr(uiText('No style selected. Pick one with /output-style, or create one with /output-style new <name>.')); return; }
9336
9481
  openEditor({
9337
9482
  title: `Output style — ${file}`,
9338
9483
  text: (() => { try { return fs.readFileSync(file, 'utf8'); } catch { return ''; } })(),
9339
9484
  caretRow: 0, caretCol: 0,
9340
9485
  onSave: (value) => {
9341
9486
  try { fs.writeFileSync(file, String(value)); }
9342
- catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
9487
+ catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
9343
9488
  // Re-read so an edit takes effect on the NEXT request.
9344
9489
  const again = findStyle(state.outputStyle.name, state.cwd);
9345
9490
  state.outputStyle = again;
@@ -9358,7 +9503,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9358
9503
  text: (() => { try { return fs.readFileSync(file, 'utf8'); } catch { return ''; } })(),
9359
9504
  caretRow: 3, caretCol: 0,
9360
9505
  onSave: (value) => {
9361
- try { fs.writeFileSync(file, String(value)); } catch (e) { appErr('Could not write: ' + e.message); return; }
9506
+ try { fs.writeFileSync(file, String(value)); } catch (e) { appErr(uiText('Could not write: ') + e.message); return; }
9362
9507
  const s = findStyle(nameFromFile(file), state.cwd);
9363
9508
  if (s) { state.outputStyle = s; cfg.outputStyle = s.name; app(`Output style → ${s.name}`); }
9364
9509
  else app(`Saved ${file} (no body yet, so it is not selectable).`);
@@ -9397,7 +9542,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9397
9542
  if (it.action === 'none') {
9398
9543
  state.outputStyle = null; cfg.outputStyle = null;
9399
9544
  try { setConfigString('output_style', ''); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
9400
- app('Output style cleared.');
9545
+ app(uiText('Output style cleared.'));
9401
9546
  return true;
9402
9547
  }
9403
9548
  state.outputStyle = it.style;
@@ -9448,17 +9593,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9448
9593
  if (parts[1] === 'on') want = true;
9449
9594
  else if (parts[1] === 'off') want = false;
9450
9595
  else if (!parts[1]) want = !stateNow[name];
9451
- else { appErr('Usage: /experiments <name> [on|off]'); return; }
9596
+ else { appErr(uiText('Usage: /experiments <name> [on|off]')); return; }
9452
9597
  const merged = mergeExperiments(cfg.raw.experiments, { [name]: want });
9453
9598
  try {
9454
9599
  setConfigString('experiments', JSON.stringify(merged));
9455
- } catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
9600
+ } catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9456
9601
  cfg.raw.experiments = merged;
9457
- app(`Experiment ${name}: ${want ? 'ON' : 'OFF'}`);
9602
+ app(`${uiText('Experiment')} ${name}: ${want ? uiText('ON') : uiText('OFF')}`);
9458
9603
  // A flag can only affect code that reads it, and most of them are read when a
9459
9604
  // request is built, so the change is announced as taking effect next turn
9460
9605
  // rather than pretending to be live.
9461
- app('Takes effect on the next request.');
9606
+ app(uiText('Takes effect on the next request.'));
9462
9607
  return;
9463
9608
  }
9464
9609
  case 'btw':
@@ -9474,10 +9619,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9474
9619
 
9475
9620
  if (!question) {
9476
9621
  // Bare `/btw`: open the box (asking nothing yet) or explain it.
9477
- if (state.btwPanel) { app('The side-thread box is already open — type a question, or press Esc to close it.'); return; }
9622
+ if (state.btwPanel) { app(uiText('The side-thread box is already open — type a question, or press Esc to close it.')); return; }
9478
9623
  state.btwPanel = { turns: [], model: '', reasoning: false };
9479
9624
  state.btwScroll = 0;
9480
- app('Side thread box open — type a question and press Enter. Esc closes it.');
9625
+ app(uiText('Side thread box open — type a question and press Enter. Esc closes it.'));
9481
9626
  renderFrame();
9482
9627
  return;
9483
9628
  }
@@ -9485,7 +9630,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9485
9630
  state.sideThread = null;
9486
9631
  state.btwPanel = null;
9487
9632
  state.btwScroll = 0;
9488
- app('Side thread closed.');
9633
+ app(uiText('Side thread closed.'));
9489
9634
  renderFrame();
9490
9635
  return;
9491
9636
  }
@@ -9493,7 +9638,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9493
9638
  if (!state.sideThread) {
9494
9639
  const modelCfg = secondaryModelCfg(cfg);
9495
9640
  state.sideThread = new SideThread({
9496
- basePrompt: (cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT,
9641
+ basePrompt: ((cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT)
9642
+ + (needsThinkingTags(cfg) ? `\n\n${THINKING_TAGS_INSTRUCTION}` : ''),
9497
9643
  // The fork: the conversation as it stands NOW. A copy, so nothing the side
9498
9644
  // thread appends can reach the session.
9499
9645
  history: forkMessages(session),
@@ -9517,7 +9663,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9517
9663
  const what = String(raw || '').trim().toLowerCase();
9518
9664
  const metrics = state._metrics;
9519
9665
  if (!metrics || !metrics.rowStart || !state.chat.length) {
9520
- app('Nothing to jump to yet.');
9666
+ app(uiText('Nothing to jump to yet.'));
9521
9667
  return;
9522
9668
  }
9523
9669
  const totalRows = metrics.total || 0;
@@ -9543,26 +9689,26 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9543
9689
  state.scroll = Math.max(0, Math.max(0, totalRows - 20));
9544
9690
  dropScrollPin(state);
9545
9691
  renderFrame();
9546
- app('Jumped to the top of the session.');
9692
+ app(uiText('Jumped to the top of the session.'));
9547
9693
  return;
9548
9694
  }
9549
9695
  if (what === 'error' || what === 'fail' || what === 'failure') {
9550
9696
  const i = lastIndex((m) => m && (m.failed === true || (m.role === 'tool_result' && /^\s*\[?error/i.test(String(m.text || '')))));
9551
- if (i < 0) { app('No failure in this session.'); return; }
9697
+ if (i < 0) { app(uiText('No failure in this session.')); return; }
9552
9698
  goToRow(rowOf(i));
9553
9699
  renderFrame();
9554
- app('Jumped to the last failure.');
9700
+ app(uiText('Jumped to the last failure.'));
9555
9701
  return;
9556
9702
  }
9557
9703
  if (what === 'reply' || what === 'answer' || what === 'last') {
9558
9704
  const i = lastIndex((m) => m && m.role === 'assistant' && String(m.text || '').trim());
9559
- if (i < 0) { app('No reply to jump to.'); return; }
9705
+ if (i < 0) { app(uiText('No reply to jump to.')); return; }
9560
9706
  goToRow(rowOf(i));
9561
9707
  renderFrame();
9562
- app('Jumped to the last reply.');
9708
+ app(uiText('Jumped to the last reply.'));
9563
9709
  return;
9564
9710
  }
9565
- app('Use /jump top, /jump error, or /jump reply.');
9711
+ app(uiText('Use /jump top, /jump error, or /jump reply.'));
9566
9712
  return;
9567
9713
  }
9568
9714
 
@@ -9574,7 +9720,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9574
9720
  // a very long session does not send its opening messages to answer "where am I".
9575
9721
  const history = forkMessages(session, { limit: 80 });
9576
9722
  if (!history.length) {
9577
- app('Nothing to recap yet — this session has no conversation.');
9723
+ app(uiText('Nothing to recap yet — this session has no conversation.'));
9578
9724
  return;
9579
9725
  }
9580
9726
  const modelCfg = secondaryModelCfg(cfg);
@@ -9582,8 +9728,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9582
9728
  notice(`Recapping (${modelCfg.model || cfg.model})…`, 'info');
9583
9729
  try {
9584
9730
  const text = await llm.requestText(recapMessages(history), { noTools: true, noReasoning: true });
9585
- if (text === null) { appErr('The recap request failed.'); return; }
9586
- if (!text.trim()) { appErr('The recap came back empty.'); return; }
9731
+ if (text === null) { appErr(uiText('The recap request failed.')); return; }
9732
+ if (!text.trim()) { appErr(uiText('The recap came back empty.')); return; }
9587
9733
  h.openPanel('Recap', [
9588
9734
  `${stats.users} prompt(s), ${stats.assistants} repl(y|ies), ${stats.total} entries`,
9589
9735
  '',
@@ -9613,7 +9759,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9613
9759
  onPick: (it) => {
9614
9760
  const value = it.action === 'off' ? '' : it.model;
9615
9761
  try { setConfigString('secondary_model', value); }
9616
- catch (e) { appErr('Could not write config.toml: ' + e.message); return true; }
9762
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return true; }
9617
9763
  cfg.secondaryModel = value;
9618
9764
  cfg.raw.secondary_model = value;
9619
9765
  app(value ? `Secondary model → ${value}` : 'Secondary model cleared — side work uses this session\'s model.');
@@ -9626,7 +9772,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9626
9772
  try { setConfigString('secondary_model', ''); } catch (e) { appErr(e.message); return; }
9627
9773
  cfg.secondaryModel = '';
9628
9774
  cfg.raw.secondary_model = '';
9629
- app('Secondary model cleared.');
9775
+ app(uiText('Secondary model cleared.'));
9630
9776
  return;
9631
9777
  }
9632
9778
  // Accept a partial name, like /model does, so the user does not have to type the
@@ -9646,7 +9792,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9646
9792
  case 'rollout': {
9647
9793
  // Step through the session. A read-only VIEW: nothing is resumed or re-sent.
9648
9794
  const steps = buildSteps(session.messages);
9649
- if (!steps.length) { app('This session has nothing to replay.'); return; }
9795
+ if (!steps.length) { app(uiText('This session has nothing to replay.')); return; }
9650
9796
  const arg = raw.trim().toLowerCase();
9651
9797
  const pos = (() => {
9652
9798
  const cur = Number.isFinite(state.replayStep) ? state.replayStep : steps.length - 1;
@@ -9683,7 +9829,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9683
9829
  sendPrompt(entry.prompt, { fromSchedule: id });
9684
9830
  return;
9685
9831
  }
9686
- if (sub && sub !== 'list') { appErr('Usage: /schedule [list | run <id>]'); return; }
9832
+ if (sub && sub !== 'list') { appErr(uiText('Usage: /schedule [list | run <id>]')); return; }
9687
9833
  const rows = listSchedules(cfg.schedule);
9688
9834
  const bad = rows.filter((e) => !e.valid);
9689
9835
  h.openPanel('Schedules', [
@@ -9707,7 +9853,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9707
9853
  const sub = (parts[0] || '').toLowerCase();
9708
9854
  if (sub === 'import') {
9709
9855
  const file = parts.slice(1).join(' ');
9710
- if (!file) { appErr('Usage: /teleport import <file>'); return; }
9856
+ if (!file) { appErr(uiText('Usage: /teleport import <file>')); return; }
9711
9857
  let text = '';
9712
9858
  try { text = fs.readFileSync(file, 'utf8'); }
9713
9859
  catch (e) { appErr(`Could not read ${file}: ${e.message}`); return; }
@@ -9724,7 +9870,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9724
9870
  app(`Imported "${imported.title || 'untitled'}" as ${imported.id} — resume it with /sessions.`);
9725
9871
  return;
9726
9872
  }
9727
- if (sub && sub !== 'export') { appErr('Usage: /teleport [export [path] | import <file>]'); return; }
9873
+ if (sub && sub !== 'export') { appErr(uiText('Usage: /teleport [export [path] | import <file>]')); return; }
9728
9874
  const pack = packSession(session, {
9729
9875
  from: state.workspace || cfg.workspace,
9730
9876
  to: state.workspace || cfg.workspace,
@@ -9740,11 +9886,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9740
9886
  '',
9741
9887
  describeTeleport(pack),
9742
9888
  '',
9743
- 'What travels: the conversation, with paths rewritten.',
9744
- 'What does not: background jobs, token totals, and session approvals —',
9889
+ uiText('What travels: the conversation, with paths rewritten.'),
9890
+ uiText('What does not: background jobs, token totals, and session approvals —'),
9745
9891
  'those describe THIS machine and would be wrong on another.',
9746
9892
  '',
9747
- 'Move it with scp/ssh, then on the other side:',
9893
+ uiText('Move it with scp/ssh, then on the other side:'),
9748
9894
  ` /teleport import ${path.basename(out)}`,
9749
9895
  ]);
9750
9896
  return;
@@ -9789,9 +9935,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9789
9935
  }
9790
9936
  // Advice, only when there is something worth saying.
9791
9937
  const tips = [];
9792
- if (byRole.tool > total * 0.4) tips.push('Tool results dominate — /compact or a narrower search would free the most.');
9793
- if (byRole.system > total * 0.3) tips.push('The system prompt is large — trim AGENTS.md / personal prompt.');
9794
- if (total / max > 0.8) tips.push('Over 80% — auto-compaction is close. /compact now to keep control.');
9938
+ if (byRole.tool > total * 0.4) tips.push(uiText('Tool results dominate — /compact or a narrower search would free the most.'));
9939
+ if (byRole.system > total * 0.3) tips.push(uiText('The system prompt is large — trim AGENTS.md / personal prompt.'));
9940
+ if (total / max > 0.8) tips.push(uiText('Over 80% — auto-compaction is close. /compact now to keep control.'));
9795
9941
  if (tips.length) lines.push('', ...tips.map((t) => g + ' ' + t + C.reset));
9796
9942
  sayRich(lines.join('\n'));
9797
9943
  return;
@@ -9855,11 +10001,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9855
10001
  else if (a === 'off') want = false;
9856
10002
  else want = !cfg.autoUpdate;
9857
10003
  try { setConfigString('auto_update', want ? 'true' : 'false'); }
9858
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
10004
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9859
10005
  cfg.autoUpdate = want;
9860
10006
  cfg.raw.auto_update = want;
9861
10007
  app(want
9862
- ? 'Auto-update ON — checks npm at startup and every 30 min, installs in the background'
10008
+ ? uiText('Auto-update ON — checks npm at startup and every 30 min, installs in the background')
9863
10009
  : 'Auto-update OFF');
9864
10010
  return;
9865
10011
  }
@@ -9886,7 +10032,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9886
10032
  if (v === null) { appErr(`Usage: /auto-compact ${sub} <0-1 | n%> (e.g. ${sub === 'threshold' ? '0.85 or 85%' : '0.2 or 20%'})`); return; }
9887
10033
  const key = sub === 'threshold' ? 'compact_threshold' : 'compact_keep_ratio';
9888
10034
  try { setConfigString(key, String(v)); }
9889
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
10035
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9890
10036
  if (sub === 'threshold') { cfg.compactThreshold = v; cfg.raw.compact_threshold = v; }
9891
10037
  else { cfg.compactKeepRatio = v; cfg.raw.compact_keep_ratio = v; }
9892
10038
  app(sub === 'threshold'
@@ -9900,7 +10046,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9900
10046
  else if (sub === 'off') want = false;
9901
10047
  else want = cfg.autoCompact === false; // flip from the current state
9902
10048
  try { setConfigString('auto_compact', want ? 'true' : 'false'); }
9903
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
10049
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9904
10050
  cfg.autoCompact = want;
9905
10051
  cfg.raw.auto_compact = want;
9906
10052
  const pct = Math.round((cfg.compactThreshold == null ? 0.85 : cfg.compactThreshold) * 100);
@@ -9948,7 +10094,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9948
10094
  }
9949
10095
  const key = sub === 'threshold' ? 'trim_threshold' : 'trim_keep_ratio';
9950
10096
  try { setConfigString(key, String(v)); }
9951
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
10097
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9952
10098
  if (sub === 'threshold') { cfg.trimThreshold = v; cfg.raw.trim_threshold = v; }
9953
10099
  else { cfg.trimKeepRatio = v; cfg.raw.trim_keep_ratio = v; }
9954
10100
  app(sub === 'threshold'
@@ -9964,14 +10110,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
9964
10110
  else if (sub === 'off') wantTrim = false;
9965
10111
  else wantTrim = cfg.autoTrim === false; // flip from the current state
9966
10112
  try { setConfigString('auto_trim', wantTrim ? 'true' : 'false'); }
9967
- catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
10113
+ catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
9968
10114
  cfg.autoTrim = wantTrim;
9969
10115
  cfg.raw.auto_trim = wantTrim;
9970
10116
  const thr = Math.round((cfg.trimThreshold == null ? 0.5 : cfg.trimThreshold) * 100);
9971
10117
  const keepPct = Math.round((cfg.trimKeepRatio == null ? 0.3 : cfg.trimKeepRatio) * 100);
9972
10118
  app(wantTrim
9973
10119
  ? `Auto-trim ON — old tool results are elided from the request once it reaches ${thr}% of the window, keeping ~${keepPct}% of them (use /trim to do it now)`
9974
- : 'Auto-trim OFF — tool results are sent in full (use /trim to elide them once)');
10120
+ : uiText('Auto-trim OFF — tool results are sent in full (use /trim to elide them once)'));
9975
10121
  return;
9976
10122
  }
9977
10123
  case 'trim': {
@@ -10008,10 +10154,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10008
10154
  keepRatio = v;
10009
10155
  }
10010
10156
  const target = (state.agent && state.agent.messages) || (session && session.messages);
10011
- if (!target || !target.length) { app('Nothing to trim.'); return; }
10157
+ if (!target || !target.length) { app(uiText('Nothing to trim.')); return; }
10012
10158
  const before = estimateMessagesTokens(target);
10013
10159
  const res = trimToolResults(target, { sessionId: session && session.id, keepRatio });
10014
- if (!res || !res.elided) { app('Nothing to trim — no tool result is large enough to elide.'); return; }
10160
+ if (!res || !res.elided) { app(uiText('Nothing to trim — no tool result is large enough to elide.')); return; }
10015
10161
  // `trimToolResults` rewrote content IN PLACE, and the target may be the agent's
10016
10162
  // own live message array. The agent keeps a rolling token total over it, so it
10017
10163
  // has to be told: otherwise its ledger still describes the pre-trim bodies, the
@@ -10044,7 +10190,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10044
10190
  // Manual update check. The automatic background check is silent, so this is where a
10045
10191
  // pending install is also reported: the install runs detached and its outcome lands in
10046
10192
  // the stamp file, which is the only thing that can say whether it worked.
10047
- app('Checking for updates...');
10193
+ app(uiText('Checking for updates...'));
10048
10194
  // A previous install may have failed without anyone seeing it.
10049
10195
  const prev = upd.readUpdateStamp();
10050
10196
  if (prev && prev.status === 'error' && prev.error) {
@@ -10057,9 +10203,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10057
10203
  if (r.status === 'installing') app(r.message);
10058
10204
  else if (r.status === 'busy') app(r.message);
10059
10205
  else if (r.status === 'uptodate') app(r.message);
10060
- else app('Update check: ' + (r.message || 'failed'));
10206
+ else app(uiText('Update check: ') + (r.message || uiText('failed')));
10061
10207
  } catch (e) {
10062
- appErr('Update check failed: ' + (e && e.message || e));
10208
+ appErr(uiText('Update check failed: ') + (e && e.message || e));
10063
10209
  } finally {
10064
10210
  cfg.updateRunning = false;
10065
10211
  }
@@ -10073,11 +10219,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10073
10219
  const cfgMcp = loadMcpConfig(state.workspace || cfg.workspace);
10074
10220
  const conns = getLiveConnections();
10075
10221
  const lines = describeServers(cfgMcp, conns);
10076
- if (cfgMcp.errors.length) lines.push('', 'Config problems:', ...cfgMcp.errors.map((e) => ` ! ${e}`));
10222
+ if (cfgMcp.errors.length) lines.push('', uiText('Config problems:'), ...cfgMcp.errors.map((e) => ` ! ${e}`));
10077
10223
  const showTools = String(raw || '').toLowerCase() === 'tools';
10078
10224
  if (showTools) {
10079
10225
  const found = conns.filter((c) => c.ok).map((c) => ` ${c.name}: ${c.toolCount} tool(s)`);
10080
- lines.push('', found.length ? 'Discovered tools:' : 'No servers connected — they connect at startup.');
10226
+ lines.push('', found.length ? uiText('Discovered tools:') : 'No servers connected — they connect at startup.');
10081
10227
  lines.push(...found);
10082
10228
  }
10083
10229
  h.openPanel('hncode — mcp', lines);
@@ -10180,7 +10326,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10180
10326
  onSubmit: (values) => {
10181
10327
  const n = (values.name || '').trim();
10182
10328
  const target = (values.target || '').trim();
10183
- if (!n || !target) { appErr('Name and command/URL are required.'); return; }
10329
+ if (!n || !target) { appErr(uiText('Name and command/URL are required.')); return; }
10184
10330
  const d = readDoc();
10185
10331
  d.mcpServers[n] = /^https?:\/\//.test(target)
10186
10332
  ? { url: target }
@@ -10232,13 +10378,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10232
10378
  }
10233
10379
  if (action === 'add') {
10234
10380
  const target = rest[0] || '';
10235
- if (!name || !target) { appErr('Usage: /mcp-config add <name> <command|url> [args...]'); return; }
10381
+ if (!name || !target) { appErr(uiText('Usage: /mcp-config add <name> <command|url> [args...]')); return; }
10236
10382
  doc.mcpServers[name] = /^https?:\/\//.test(target) ? { url: target } : { command: target, args: rest.slice(1) };
10237
10383
  writeDoc(doc);
10238
10384
  app(`MCP server added: ${name} → ${mcpFile}. Start a new session to apply.`);
10239
10385
  return;
10240
10386
  }
10241
- appErr('Usage: /mcp-config (manage) | list | add <name> <command|url> [args...] | remove <name>');
10387
+ appErr(uiText('Usage: /mcp-config (manage) | list | add <name> <command|url> [args...] | remove <name>'));
10242
10388
  return;
10243
10389
  }
10244
10390
 
@@ -10269,7 +10415,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10269
10415
  session.saveThinking = false;
10270
10416
  persist();
10271
10417
  } else if (what) {
10272
- appErr('Usage: /save-history [on|off|thinking|nothinking]');
10418
+ appErr(uiText('Usage: /save-history [on|off|thinking|nothinking]'));
10273
10419
  return;
10274
10420
  }
10275
10421
  say(`Saved history — display rows: ${on(state.saveHistory)} · reasoning: ${on(state.saveThinking)}`);
@@ -10349,7 +10495,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10349
10495
  if (sub === 'add') {
10350
10496
  const from = parts[1];
10351
10497
  const to = parts.slice(2).join(' ');
10352
- if (!from || !to) { appErr('Usage: /keybindings add <key> <key|/command> e.g. /keybindings add ctrl+e /theme'); return; }
10498
+ if (!from || !to) { appErr(uiText('Usage: /keybindings add <key> <key|/command> e.g. /keybindings add ctrl+e /theme')); return; }
10353
10499
  const src = normalizeKey(from);
10354
10500
  if (!src) { appErr(`"${from}" is not a usable key name.`); return; }
10355
10501
  // Validate BEFORE writing: a file the loader would reject is worse than a refusal,
@@ -10358,7 +10504,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10358
10504
  else {
10359
10505
  const dst = normalizeKey(to);
10360
10506
  if (!dst) { appErr(`"${to}" is not a usable key name or a /command.`); return; }
10361
- if (dst === src) { appErr('A key cannot be bound to itself.'); return; }
10507
+ if (dst === src) { appErr(uiText('A key cannot be bound to itself.')); return; }
10362
10508
  doc[src] = dst;
10363
10509
  }
10364
10510
  try { writeKeybindings(undefined, doc); } catch (e) { appErr(`Could not write: ${e.message}`); return; }
@@ -10370,7 +10516,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10370
10516
  }
10371
10517
  if (sub === 'remove' || sub === 'rm' || sub === 'delete') {
10372
10518
  const src = normalizeKey(parts[1] || '');
10373
- if (!src) { appErr('Usage: /keybindings remove <key>'); return; }
10519
+ if (!src) { appErr(uiText('Usage: /keybindings remove <key>')); return; }
10374
10520
  if (!(src in doc)) { appErr(`No binding for ${src}.`); return; }
10375
10521
  delete doc[src];
10376
10522
  try { writeKeybindings(undefined, doc); } catch (e) { appErr(`Could not write: ${e.message}`); return; }
@@ -10386,7 +10532,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10386
10532
  if (to.startsWith('/')) doc[src] = to.trim();
10387
10533
  else {
10388
10534
  const dst = normalizeKey(to);
10389
- if (!dst || dst === src) { appErr('Target must be a different key or a /command.'); return; }
10535
+ if (!dst || dst === src) { appErr(uiText('Target must be a different key or a /command.')); return; }
10390
10536
  doc[src] = dst;
10391
10537
  }
10392
10538
  try { writeKeybindings(undefined, doc); } catch (e) { appErr(`Could not write: ${e.message}`); return; }
@@ -10395,7 +10541,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10395
10541
  return;
10396
10542
  }
10397
10543
  }
10398
- appErr('Usage: /keybindings [list | add <key> <key|/command> | remove <key> | edit]');
10544
+ appErr(uiText('Usage: /keybindings [list | add <key> <key|/command> | remove <key> | edit]'));
10399
10545
  return;
10400
10546
  }
10401
10547
  case 'agents': {
@@ -10412,7 +10558,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10412
10558
  if (sub === 'message' || sub === 'msg') {
10413
10559
  const id = parts[1];
10414
10560
  const text = parts.slice(2).join(' ');
10415
- if (!id || !text) { appErr('Usage: /agents message <agent-id> <text>'); return; }
10561
+ if (!id || !text) { appErr(uiText('Usage: /agents message <agent-id> <text>')); return; }
10416
10562
  const r = sendToRun(id, text);
10417
10563
  if (r.ok) app(r.message); else appErr(r.message);
10418
10564
  return;
@@ -10421,7 +10567,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10421
10567
  const id = parts[1];
10422
10568
  if (!id || id === 'all') {
10423
10569
  const all = interruptAll();
10424
- app(all.ok ? `Interrupted ${all.count} subagent(s): ${all.agents.join(', ')}` : 'No subagent is running.');
10570
+ app(all.ok ? `Interrupted ${all.count} subagent(s): ${all.agents.join(', ')}` : uiText('No subagent is running.'));
10425
10571
  return;
10426
10572
  }
10427
10573
  const r = interruptRun(id);
@@ -10430,12 +10576,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10430
10576
  }
10431
10577
  if (sub === 'close') {
10432
10578
  const id = parts[1];
10433
- if (!id) { appErr('Usage: /agents close <agent-id>'); return; }
10579
+ if (!id) { appErr(uiText('Usage: /agents close <agent-id>')); return; }
10434
10580
  const r = closeRun(id);
10435
10581
  if (r.ok) app(r.message); else appErr(r.message);
10436
10582
  return;
10437
10583
  }
10438
- appErr('Usage: /agents [list | message <id> <text> | interrupt [id|all] | close <id>]');
10584
+ appErr(uiText('Usage: /agents [list | message <id> <text> | interrupt [id|all] | close <id>]'));
10439
10585
  return;
10440
10586
  }
10441
10587
  case 'team': {
@@ -10453,7 +10599,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10453
10599
  const current = () => leadTeam();
10454
10600
 
10455
10601
  const doAdd = (name, model) => {
10456
- if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
10602
+ if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
10457
10603
  const r = teamMod.addMember(current(), { name, model: model || '' });
10458
10604
  if (!r.ok) { appErr(r.error); return; }
10459
10605
  const shown = model
@@ -10513,7 +10659,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10513
10659
 
10514
10660
  if (verb === 'create') {
10515
10661
  const name = parts.slice(1).join(' ').trim();
10516
- if (!name) { appErr('Usage: /team create <name>'); return; }
10662
+ if (!name) { appErr(uiText('Usage: /team create <name>')); return; }
10517
10663
  const r = teamMod.createTeam({
10518
10664
  teamName: name,
10519
10665
  leadSessionId: (session && session.id) || '',
@@ -10522,13 +10668,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10522
10668
  if (!r.ok) { appErr(r.error); return; }
10523
10669
  setLeadTeam(name);
10524
10670
  app(`Team "${name}" created — you are team-lead.`);
10525
- app('Add members with /team add <name>; it asks which model each should run.');
10671
+ app(uiText('Add members with /team add <name>; it asks which model each should run.'));
10526
10672
  return;
10527
10673
  }
10528
10674
 
10529
10675
  if (verb === 'add') {
10530
10676
  const name = parts[1];
10531
- if (!name) { appErr('Usage: /team add <name> [model]'); return; }
10677
+ if (!name) { appErr(uiText('Usage: /team add <name> [model]')); return; }
10532
10678
  if (parts[2]) { doAdd(name, parts.slice(2).join(' ')); return; }
10533
10679
  askModel(name);
10534
10680
  return;
@@ -10537,8 +10683,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10537
10683
  if (verb === 'msg' || verb === 'message' || verb === 'tell') {
10538
10684
  const who = parts[1];
10539
10685
  const body = parts.slice(2).join(' ').trim();
10540
- if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
10541
- if (!who || !body) { appErr('Usage: /team msg <name> <text> -- "*" reaches every member'); return; }
10686
+ if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
10687
+ if (!who || !body) { appErr(uiText('Usage: /team msg <name> <text> -- "*" reaches every member')); return; }
10542
10688
 
10543
10689
  const roster = teamMod.rosterOf(current());
10544
10690
  const name = who === '*' ? null : who;
@@ -10559,7 +10705,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10559
10705
  const targets = name
10560
10706
  ? [name]
10561
10707
  : roster.filter((m) => m.name !== TEAM_LEAD_NAME).map((m) => m.name);
10562
- if (!targets.length) { appErr('There is nobody else on the team.'); return; }
10708
+ if (!targets.length) { appErr(uiText('There is nobody else on the team.')); return; }
10563
10709
  for (const t of targets) {
10564
10710
  mailMod.writeToMailbox(current(), t, { from: TEAM_LEAD_NAME, text: body });
10565
10711
  }
@@ -10568,20 +10714,20 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10568
10714
  }
10569
10715
 
10570
10716
  if (verb === 'panel' || verb === 'ui') {
10571
- if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
10717
+ if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
10572
10718
  state.teamPanel = makeTeamPanel(current());
10573
10719
  renderFrame();
10574
10720
  return;
10575
10721
  }
10576
10722
 
10577
10723
  if (verb === 'list') {
10578
- if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
10724
+ if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
10579
10725
  sayPanel(teamMod.readRoster(current()));
10580
10726
  return;
10581
10727
  }
10582
10728
 
10583
10729
  if (verb === 'delete' || verb === 'disband') {
10584
- if (!current()) { appErr('No team to delete.'); return; }
10730
+ if (!current()) { appErr(uiText('No team to delete.')); return; }
10585
10731
  // The name is captured BEFORE clearing, which is what the message needs. Reading
10586
10732
  // `current()` after the clear produced `Team "null" dissolved.` — the lead was gone by
10587
10733
  // the time it was asked for.
@@ -10613,7 +10759,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10613
10759
  hint: 'Enter create · Esc cancel',
10614
10760
  onSubmit: (values) => {
10615
10761
  const name = String((values && values.name) || '').trim();
10616
- if (!name) { appErr('Cancelled: a team needs a name.'); return; }
10762
+ if (!name) { appErr(uiText('Cancelled: a team needs a name.')); return; }
10617
10763
  const r = teamMod.createTeam({
10618
10764
  teamName: name,
10619
10765
  leadSessionId: (session && session.id) || '',
@@ -10630,7 +10776,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10630
10776
  // Ask who, then which model: two questions, one flow. `askModel` is the same chooser
10631
10777
  // `/team add <name>` uses, so the two paths cannot offer different models.
10632
10778
  const askAdd = () => {
10633
- if (!leadTeam()) { appErr('No team. Create one first.'); return; }
10779
+ if (!leadTeam()) { appErr(uiText('No team. Create one first.')); return; }
10634
10780
  openForm({
10635
10781
  title: 'Add a member',
10636
10782
  fields: [{ key: 'name', label: 'Name' }],
@@ -10641,7 +10787,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10641
10787
  hint: 'Enter next · Esc cancel',
10642
10788
  onSubmit: (values) => {
10643
10789
  const name = String((values && values.name) || '').trim();
10644
- if (!name) { appErr('Cancelled: a member needs a name.'); return; }
10790
+ if (!name) { appErr(uiText('Cancelled: a member needs a name.')); return; }
10645
10791
  askModel(name);
10646
10792
  },
10647
10793
  });
@@ -10728,13 +10874,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10728
10874
  return;
10729
10875
  }
10730
10876
  const n = Number(parts[1]);
10731
- if (!Number.isFinite(n) || n < 1) { appErr('Usage: /checkpoints [list | restore <n> | diff <n>]'); return; }
10877
+ if (!Number.isFinite(n) || n < 1) { appErr(uiText('Usage: /checkpoints [list | restore <n> | diff <n>]')); return; }
10732
10878
  const all = listCheckpoints(sid);
10733
10879
  const entry = all.find((c) => c.index === n);
10734
10880
  if (!entry) { appErr(`No checkpoint ${n}. /checkpoints lists them.`); return; }
10735
10881
  if (sub === 'diff') {
10736
10882
  const d = checkpointDelta(entry);
10737
- if (!d) { appErr('No size comparison available for that checkpoint.'); return; }
10883
+ if (!d) { appErr(uiText('No size comparison available for that checkpoint.')); return; }
10738
10884
  const rel = entry.path;
10739
10885
  sayPanel(`${rel}\nthen: ${d.before} line(s)\nnow: ${d.after} line(s)\nchange: ${d.lines >= 0 ? '+' : ''}${d.lines}`);
10740
10886
  return;
@@ -10747,7 +10893,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10747
10893
  : `Restored ${entry.path} from checkpoint ${n}.`);
10748
10894
  return;
10749
10895
  }
10750
- appErr('Usage: /checkpoints [list | restore <n> | diff <n>]');
10896
+ appErr(uiText('Usage: /checkpoints [list | restore <n> | diff <n>]'));
10751
10897
  return;
10752
10898
  }
10753
10899
  case 'statusline':
@@ -10784,7 +10930,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10784
10930
  return;
10785
10931
  case 'export-md': {
10786
10932
  const msgs = session.messages || [];
10787
- if (!msgs.length) { appErr('Nothing to export (empty session).'); return; }
10933
+ if (!msgs.length) { appErr(uiText('Nothing to export (empty session).')); return; }
10788
10934
  const out = raw || path.join(state.cwd, `hncode-export-${session.id}.md`);
10789
10935
  try {
10790
10936
  fs.mkdirSync(path.dirname(out), { recursive: true });
@@ -10801,14 +10947,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10801
10947
  if (!target) return;
10802
10948
  let abs;
10803
10949
  try { abs = path.resolve(state.cwd, target); } catch { abs = target; }
10804
- if (!/\.(md|markdown)$/i.test(abs)) { appErr('Only Markdown files are supported (.md / .markdown).'); return; }
10950
+ if (!/\.(md|markdown)$/i.test(abs)) { appErr(uiText('Only Markdown files are supported (.md / .markdown).')); return; }
10805
10951
  let text;
10806
10952
  try {
10807
10953
  const st = fs.statSync(abs);
10808
- if (!st.isFile()) { appErr('Not a file: ' + target); return; }
10954
+ if (!st.isFile()) { appErr(uiText('Not a file: ') + target); return; }
10809
10955
  text = fs.readFileSync(abs, 'utf8');
10810
- } catch (e) { appErr('Could not read ' + target + ': ' + e.message); return; }
10811
- if (!text.trim()) { appErr('That Markdown file is empty: ' + target); return; }
10956
+ } catch (e) { appErr(uiText('Could not read ') + target + ': ' + e.message); return; }
10957
+ if (!text.trim()) { appErr(uiText('That Markdown file is empty: ') + target); return; }
10812
10958
  const rel = path.relative(state.cwd, abs).replace(/\\/g, '/') || target;
10813
10959
  say(`/import-session — attaching ${rel} (${text.length} chars) to the prompt…`);
10814
10960
  // The file content travels WITH the message, so the model does not need
@@ -10837,7 +10983,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10837
10983
  }
10838
10984
  } catch { /* ignore */ }
10839
10985
  if (!found.length) {
10840
- appErr('No Markdown files found in ' + state.cwd + '. Pass a path: /import-session <file.md>');
10986
+ appErr(uiText('No Markdown files found in ') + state.cwd + '. Pass a path: /import-session <file.md>');
10841
10987
  return;
10842
10988
  }
10843
10989
  openPicker({
@@ -10855,28 +11001,28 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10855
11001
  }
10856
11002
  case 'copy': {
10857
11003
  const last = [...state.chat].reverse().find((m) => m.role === 'assistant' && (m.text || '').trim());
10858
- if (!last) { appErr('No assistant message to copy.'); return; }
11004
+ if (!last) { appErr(uiText('No assistant message to copy.')); return; }
10859
11005
  try {
10860
11006
  if (process.platform === 'win32') cp.execSync('clip', { input: last.text });
10861
11007
  else cp.execSync('pbcopy', { input: last.text });
10862
11008
  app(`Copied to clipboard (${last.text.length} characters).`);
10863
- } catch { appErr('Clipboard unavailable.'); }
11009
+ } catch { appErr(uiText('Clipboard unavailable.')); }
10864
11010
  return;
10865
11011
  }
10866
11012
  case 'add-dir': {
10867
11013
  state.addDirs = state.addDirs || [];
10868
11014
  if (!raw || raw === 'list') {
10869
- sayPanel(state.addDirs.length ? 'Additional directories:\n' + state.addDirs.map((d) => ` ${d}`).join('\n') : 'No additional directories.');
11015
+ sayPanel(state.addDirs.length ? 'Additional directories:\n' + state.addDirs.map((d) => ` ${d}`).join('\n') : uiText('No additional directories.'));
10870
11016
  return;
10871
11017
  }
10872
11018
  const dir = path.resolve(state.cwd, raw.replace(/^~/, os.homedir()));
10873
- if (!fs.existsSync(dir)) { appErr(`Directory does not exist: ${dir}`); return; }
11019
+ if (!fs.existsSync(dir)) { appErr(`${uiText('Directory does not exist')}: ${dir}`); return; }
10874
11020
  openPicker({
10875
- title: `Add directory to workspace: ${dir}`,
11021
+ title: `${uiText('Add directory to workspace')}: ${dir}`,
10876
11022
  items: [
10877
- { label: 'Yes, for this session', value: 'session' },
10878
- { label: 'Yes, and remember this directory', value: 'persist' },
10879
- { label: 'No', value: 'no' },
11023
+ { label: uiText('Yes, for this session'), value: 'session' },
11024
+ { label: uiText('Yes, and remember this directory'), value: 'persist' },
11025
+ { label: uiText('No'), value: 'no' },
10880
11026
  ],
10881
11027
  searchable: false,
10882
11028
  onPick: (it) => {
@@ -10894,7 +11040,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10894
11040
  }
10895
11041
 
10896
11042
  case 'move': {
10897
- if (!raw) { appErr('Usage: /move <target-directory>'); return; }
11043
+ if (!raw) { appErr(uiText('Usage: /move <target-directory>')); return; }
10898
11044
  const target = path.resolve(state.cwd, raw.replace(/^~/, os.homedir()));
10899
11045
  if (!fs.existsSync(target)) { appErr(`Directory does not exist: ${target}`); return; }
10900
11046
  // Create a new session in the target directory with the same messages.
@@ -10957,7 +11103,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10957
11103
  case 'vim': {
10958
11104
  // An external editor needs the actual terminal, not the TUI's alternate screen. The host owns the TTY and
10959
11105
  // restores its mouse/keyboard modes afterwards; dispatch only transfers the composer text.
10960
- if (!h.editComposerExternal) { appErr('External editor is unavailable in this session.'); return; }
11106
+ if (!h.editComposerExternal) { appErr(uiText('External editor is unavailable in this session.')); return; }
10961
11107
  // The command itself is consumed by submit before dispatch; the editor starts from an empty buffer and
10962
11108
  // creates its file only when the user writes it.
10963
11109
  const result = h.editComposerExternal('');
@@ -10988,8 +11134,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
10988
11134
  const changed = beforeMax !== state.ctxMax;
10989
11135
  app(changed
10990
11136
  ? `Config reloaded. Context window: ${fmtTokens(beforeMax)} -> ${fmtTokens(state.ctxMax)} (now ${state.ctxPercent}% used)`
10991
- : 'Config reloaded.');
10992
- app('Config and plugins reloaded.');
11137
+ : uiText('Config reloaded.'));
11138
+ app(uiText('Config and plugins reloaded.'));
10993
11139
  }
10994
11140
  // Re-load plugins so an added/edited plugin takes effect without a restart.
10995
11141
  if (h.reloadPlugins) {
@@ -11016,7 +11162,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11016
11162
  const changed = beforeMax !== state.ctxMax;
11017
11163
  app(changed
11018
11164
  ? `Config reloaded. Context window: ${fmtTokens(beforeMax)} -> ${fmtTokens(state.ctxMax)} (now ${state.ctxPercent}% used)`
11019
- : 'Config reloaded.');
11165
+ : uiText('Config reloaded.'));
11020
11166
  }
11021
11167
  } catch (e) { appErr(`Reload failed: ${e.message}`); }
11022
11168
  return;
@@ -11029,7 +11175,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11029
11175
 
11030
11176
  if (sub === 'remove' || sub === 'rm' || sub === 'delete') {
11031
11177
  const name = parts[1];
11032
- if (!name) { appErr('Usage: /plugins remove <name>'); return; }
11178
+ if (!name) { appErr(uiText('Usage: /plugins remove <name>')); return; }
11033
11179
  const ok = remote.removeLocalPlugin(name);
11034
11180
  if (!ok) { appErr(`No such plugin: ${name}`); return; }
11035
11181
  // Removing the files does not unload the code already registered in this
@@ -11045,14 +11191,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11045
11191
  const res = await remote.installRemotePlugin(name);
11046
11192
  if (!res.ok) { appErr(`Install failed: ${res.error}`); return; }
11047
11193
  app(`Plugin ${res.replaced ? 'updated' : 'installed'}: ${res.name} (${res.files.join(', ')})`);
11048
- app('Reload them with /plugins reload, or restart hncode.');
11194
+ app(uiText('Reload them with /plugins reload, or restart hncode.'));
11049
11195
  return;
11050
11196
  }
11051
11197
  if (sub === 'reload') {
11052
11198
  // Hot reload: unload every plugin (running its dispose + collected teardown),
11053
11199
  // then re-import the files with cache busting. The alternative was a restart,
11054
11200
  // which is what made plugin development painful.
11055
- if (!h.reloadPlugins) { appErr('Reload is unavailable in this host.'); return; }
11201
+ if (!h.reloadPlugins) { appErr(uiText('Reload is unavailable in this host.')); return; }
11056
11202
  const notes = await h.reloadPlugins();
11057
11203
  const errs = (notes || []).filter((n) => n.level === 'error').length;
11058
11204
  if (errs) {
@@ -11066,7 +11212,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11066
11212
  // kimi's panel). An unknown subcommand still errors rather than silently opening
11067
11213
  // it as if the word had been understood.
11068
11214
  if (sub !== 'list' && sub !== '') {
11069
- appErr('Usage: /plugins [list] | install <name> | remove <name> | reload');
11215
+ appErr(uiText('Usage: /plugins [list] | install <name> | remove <name> | reload'));
11070
11216
  return;
11071
11217
  }
11072
11218
  await h.openRegistryBrowser('plugins');
@@ -11078,7 +11224,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11078
11224
  const remote = await import('./remote.js');
11079
11225
  if (sub === 'remove' || sub === 'rm' || sub === 'delete') {
11080
11226
  const name = parts[1];
11081
- if (!name) { appErr('Usage: /skills remove <name>'); return; }
11227
+ if (!name) { appErr(uiText('Usage: /skills remove <name>')); return; }
11082
11228
  const ok = deleteSkill(name);
11083
11229
  app(ok ? `Skill removed: ${normalizeSkillName(name)}` : `No such skill: ${name}`);
11084
11230
  return;
@@ -11099,7 +11245,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11099
11245
  await h.openRegistryBrowser('skills');
11100
11246
  return;
11101
11247
  }
11102
- appErr('Usage: /skills [list] | install <name> | remove <name>');
11248
+ appErr(uiText('Usage: /skills [list] | install <name> | remove <name>'));
11103
11249
  return;
11104
11250
  }
11105
11251
  case 'import-skill': {
@@ -11107,7 +11253,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11107
11253
  const parts = raw.split(/\s+/).filter(Boolean);
11108
11254
  const source = parts[0];
11109
11255
  const nameArg = parts[1];
11110
- if (!source) { appErr('Usage: /import-skill <file.md | owner/repo[/subdir]> [name]'); return; }
11256
+ if (!source) { appErr(uiText('Usage: /import-skill <file.md | owner/repo[/subdir]> [name]')); return; }
11111
11257
 
11112
11258
  // A repository spec has no extension and carries a slash — a local Markdown path always ends in .md, and a
11113
11259
  // path that does not is not something this command ever accepted.
@@ -11128,7 +11274,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11128
11274
 
11129
11275
  const res = importSkill(source, nameArg);
11130
11276
  if (!res.ok) { appErr(res.error); return; }
11131
- app(`${res.replaced ? 'Skill overwritten' : 'Skill imported'}: ${res.name} → ${res.path}`);
11277
+ app(`${res.replaced ? uiText('Skill overwritten') : uiText('Skill imported')}: ${res.name} → ${res.path}`);
11132
11278
  say(`Activate it with /${SKILL_PREFIX}${res.name}`);
11133
11279
  return;
11134
11280
  }
@@ -11159,7 +11305,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11159
11305
  }
11160
11306
  const { hooks, errors } = loadHooks(workspace);
11161
11307
  const lines = describeHooks({ hooks }, workspace);
11162
- if (errors.length) lines.push('', 'Config problems:', ...errors.map((e) => ` ! ${e}`));
11308
+ if (errors.length) lines.push('', uiText('Config problems:'), ...errors.map((e) => ` ! ${e}`));
11163
11309
  h.openPanel('hncode — hooks', lines);
11164
11310
  return;
11165
11311
  }
@@ -11190,7 +11336,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11190
11336
  const r = gitmod.stage(paths, cwd);
11191
11337
  if (!r.ok) { appErr(`git add failed: ${r.error}`); return; }
11192
11338
  const staged = gitmod.stagedFiles(cwd);
11193
- app(paths.length ? `Staged ${paths.length} path(s).` : 'Staged all changes.');
11339
+ app(paths.length ? `Staged ${paths.length} path(s).` : uiText('Staged all changes.'));
11194
11340
  sayPanel(`Index now holds ${staged.length} file(s):\n` + staged.map((f) => ' ' + f).join('\n'));
11195
11341
  return;
11196
11342
  }
@@ -11201,8 +11347,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11201
11347
  const path = raw.replace(/--staged|--cached/g, '').trim();
11202
11348
  const r = gitmod.diffText(cwd, { staged, path: path || undefined });
11203
11349
  if (!r.ok) { appErr(`git diff failed: ${r.error}`); return; }
11204
- if (r.empty) { say(staged ? 'No staged changes.' : 'No uncommitted changes.'); return; }
11205
- sayPanel((staged ? 'Staged changes' : 'Uncommitted changes') + (path ? ` in ${path}` : '') + ':\n' + r.text);
11350
+ if (r.empty) { say(staged ? uiText('No staged changes.') : uiText('No uncommitted changes.')); return; }
11351
+ sayPanel((staged ? uiText('Staged changes') : uiText('Uncommitted changes')) + (path ? ` in ${path}` : '') + ':\n' + r.text);
11206
11352
  return;
11207
11353
  }
11208
11354
  case 'log': {
@@ -11213,7 +11359,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11213
11359
  const path = parts.join(' ') || undefined;
11214
11360
  const r = gitmod.logText(cwd, { count, path });
11215
11361
  if (!r.ok) { appErr(`git log failed: ${r.error}`); return; }
11216
- if (r.empty) { say('No commits yet.'); return; }
11362
+ if (r.empty) { say(uiText('No commits yet.')); return; }
11217
11363
  sayPanel(`Recent commits${path ? ` for ${path}` : ''}:\n` + r.text);
11218
11364
  return;
11219
11365
  }
@@ -11237,7 +11383,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11237
11383
  searchable: false,
11238
11384
  hint: '↑↓ navigate · Enter select · Esc cancel',
11239
11385
  onPick: (it) => {
11240
- if (it.label !== 'Push') { app('Push cancelled.'); return true; }
11386
+ if (it.label !== 'Push') { app(uiText('Push cancelled.')); return true; }
11241
11387
  const r = gitmod.push(cwd, { branch: branchArg || undefined, force, setUpstream: !upstream });
11242
11388
  if (!r.ok) appErr(`Push failed: ${r.error}`);
11243
11389
  else { app(`Pushed ${branch}.`); sayPanel(`git push output:\n${r.output}`); }
@@ -11260,23 +11406,23 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11260
11406
  const msg = parts.slice(1).join(' ') || undefined;
11261
11407
  const r = gitmod.stashPush(cwd, msg);
11262
11408
  if (!r.ok) { appErr(`git stash failed: ${r.error}`); return; }
11263
- app('Stashed changes.'); sayPanel(r.output || 'Changes stashed.');
11409
+ app(uiText('Stashed changes.')); sayPanel(r.output || uiText('Changes stashed.'));
11264
11410
  return;
11265
11411
  }
11266
11412
  if (sub === 'pop') {
11267
11413
  const r = gitmod.stashPop(cwd);
11268
11414
  if (!r.ok) { appErr(`git stash pop failed: ${r.error}`); return; }
11269
- app('Restored from stash.'); sayPanel(r.output || 'Stash popped.');
11415
+ app(uiText('Restored from stash.')); sayPanel(r.output || uiText('Stash popped.'));
11270
11416
  return;
11271
11417
  }
11272
- appErr('Usage: /stash [list] | push [message] | pop');
11418
+ appErr(uiText('Usage: /stash [list] | push [message] | pop'));
11273
11419
  return;
11274
11420
  }
11275
11421
  case 'rebase': {
11276
11422
  const cwd = state.cwd || cfg.workspace || process.cwd();
11277
11423
  if (!gitmod.isRepo(cwd)) { appErr(`Not a git repository: ${cwd}`); return; }
11278
11424
  const onto = String(raw || '').trim();
11279
- if (!onto) { appErr('Usage: /rebase <branch>'); return; }
11425
+ if (!onto) { appErr(uiText('Usage: /rebase <branch>')); return; }
11280
11426
  const cur = gitmod.currentBranch(cwd);
11281
11427
  // Rewrites history on the current branch: confirm before running.
11282
11428
  h.openPicker({
@@ -11288,10 +11434,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11288
11434
  searchable: false,
11289
11435
  hint: '↑↓ navigate · Enter select · Esc cancel',
11290
11436
  onPick: (it) => {
11291
- if (it.label !== 'Rebase') { app('Rebase cancelled.'); return true; }
11437
+ if (it.label !== 'Rebase') { app(uiText('Rebase cancelled.')); return true; }
11292
11438
  const r = gitmod.rebase(cwd, onto);
11293
11439
  if (!r.ok) appErr(`Rebase failed (resolve conflicts, then /rebase --continue or git rebase --abort): ${r.error}`);
11294
- else { app(`Rebased ${cur} onto ${onto}.`); sayPanel(r.output || 'Rebase complete.'); }
11440
+ else { app(`Rebased ${cur} onto ${onto}.`); sayPanel(r.output || uiText('Rebase complete.')); }
11295
11441
  return true;
11296
11442
  },
11297
11443
  });
@@ -11307,9 +11453,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11307
11453
  const status = gitmod.status(cwd);
11308
11454
  if (!status.ok) { appErr(`git status failed: ${status.error}`); return; }
11309
11455
  const relevant = target ? status.entries.filter((e) => e.path === target || e.path.startsWith(target + '/')) : status.entries;
11310
- if (!relevant.length) { app('No uncommitted changes to review.'); return; }
11456
+ if (!relevant.length) { app(uiText('No uncommitted changes to review.')); return; }
11311
11457
  if (stagedOnly && !relevant.some((e) => e.x !== ' ' && e.x !== '?')) {
11312
- app('No staged changes to review.'); return;
11458
+ app(uiText('No staged changes to review.')); return;
11313
11459
  }
11314
11460
  const scope = stagedOnly ? 'staged changes' : 'working tree changes, including staged and untracked files';
11315
11461
  const pathHint = target ? `Limit the review to ${JSON.stringify(target)}. ` : '';
@@ -11334,7 +11480,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11334
11480
  const message = String(raw || '').trim();
11335
11481
  if (!message) {
11336
11482
  const s = gitmod.status(cwd);
11337
- if (s.ok && !s.entries.length) { app('Nothing to commit — working tree is clean.'); return; }
11483
+ if (s.ok && !s.entries.length) { app(uiText('Nothing to commit — working tree is clean.')); return; }
11338
11484
  const branch = gitmod.currentBranch(cwd);
11339
11485
  const pending = gitmod.statusLines(cwd).slice(0, 40).join('\n');
11340
11486
  await submit(
@@ -11371,7 +11517,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11371
11517
  }
11372
11518
  if (sub === '-c' || sub === 'create' || sub === 'new') {
11373
11519
  const name = parts[1];
11374
- if (!name) { appErr('Usage: /branch -c <name> [from]'); return; }
11520
+ if (!name) { appErr(uiText('Usage: /branch -c <name> [from]')); return; }
11375
11521
  const r = gitmod.createBranch(name, cwd, parts[2]);
11376
11522
  if (!r.ok) { appErr(`Could not create branch: ${r.error}`); return; }
11377
11523
  app(`Switched to new branch: ${name}`);
@@ -11387,7 +11533,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11387
11533
  if (!gitmod.isRepo(cwd)) { appErr(`Not a git repository: ${cwd}`); return; }
11388
11534
  const base = String(raw || '').trim() || 'main';
11389
11535
  const url = gitmod.prUrl(cwd, base);
11390
- if (!url) { appErr('No git remote named "origin" — cannot build a PR URL.'); return; }
11536
+ if (!url) { appErr(uiText('No git remote named "origin" — cannot build a PR URL.')); return; }
11391
11537
  const branch = gitmod.currentBranch(cwd);
11392
11538
  sayPanel(`Open a pull request for ${branch} → ${base}:\n ${url}`);
11393
11539
  // ACTUALLY COPY IT, and report what happened.
@@ -11397,7 +11543,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11397
11543
  // so its result is what decides the message — a try/catch around it announced success either way.
11398
11544
  let copied = false;
11399
11545
  try { copied = copyText(url); } catch { copied = false; }
11400
- if (copied) app('PR link copied to your clipboard');
11546
+ if (copied) app(uiText('PR link copied to your clipboard'));
11401
11547
  else app('Could not reach the clipboard \u2014 the link is on screen above.');
11402
11548
  return;
11403
11549
  }
@@ -11415,7 +11561,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11415
11561
  ? 'The stable prefix (tools + system + conversation head) is marked cacheable.\n'
11416
11562
  + 'Providers bill cached input at a fraction of the normal rate. Effective\n'
11417
11563
  + 'for: anthropic (cache_control), openai-compatible (prompt_cache_key).'
11418
- : 'Prompt caching disabled — every request sends the full prompt as fresh input.');
11564
+ : uiText('Prompt caching disabled — every request sends the full prompt as fresh input.'));
11419
11565
  return;
11420
11566
  }
11421
11567
  case 'worktree': {
@@ -11430,7 +11576,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11430
11576
  }
11431
11577
  if (sub === 'add') {
11432
11578
  const dir = parts[1];
11433
- if (!dir) { appErr('Usage: /worktree add <dir> [branch]'); return; }
11579
+ if (!dir) { appErr(uiText('Usage: /worktree add <dir> [branch]')); return; }
11434
11580
  const r = gitmod.addWorktree(dir, parts[2], cwd);
11435
11581
  if (!r.ok) { appErr(`Could not add worktree: ${r.error}`); return; }
11436
11582
  app(r.reused ? `Worktree already exists: ${r.path}` : `Worktree created: ${r.path}${r.branch ? ` [${r.branch}]` : ''}`);
@@ -11467,7 +11613,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11467
11613
  }
11468
11614
  if (sub === 'remove' || sub === 'rm') {
11469
11615
  const dir = parts[1];
11470
- if (!dir) { appErr('Usage: /worktree remove <dir>'); return; }
11616
+ if (!dir) { appErr(uiText('Usage: /worktree remove <dir>')); return; }
11471
11617
  const force = parts.includes('--force');
11472
11618
  const doRemove = () => {
11473
11619
  const r = gitmod.removeWorktree(dir, cwd, { force });
@@ -11488,7 +11634,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11488
11634
  ],
11489
11635
  onPick: (it) => {
11490
11636
  if (it && it.label === 'Force remove') doRemove();
11491
- else app('Worktree removal cancelled.');
11637
+ else app(uiText('Worktree removal cancelled.'));
11492
11638
  return true;
11493
11639
  },
11494
11640
  });
@@ -11498,13 +11644,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11498
11644
  doRemove();
11499
11645
  return;
11500
11646
  }
11501
- appErr('Usage: /worktree [list] | new [name] [--branch] | add <dir> [branch] | remove <dir>');
11647
+ appErr(uiText('Usage: /worktree [list] | new [name] [--branch] | add <dir> [branch] | remove <dir>'));
11502
11648
  return;
11503
11649
  }
11504
11650
  case 'logout': {
11505
11651
  const pr = (cfg.raw && cfg.raw.providers) || {};
11506
11652
  const names = Object.keys(pr);
11507
- if (!names.length) { app('Nothing to logout.'); return; }
11653
+ if (!names.length) { app(uiText('Nothing to logout.')); return; }
11508
11654
  const doLogout = (name) => {
11509
11655
  const p = pr[name] || {};
11510
11656
  delete p.api_key;
@@ -11532,7 +11678,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11532
11678
  // Without a `|` the FIRST word is the title and the rest is the body, which
11533
11679
  // keeps the common one-liner short to type.
11534
11680
  const parts = String(raw || '').trim();
11535
- if (!parts) { appErr('Usage: /feedback <title> | <body>'); return; }
11681
+ if (!parts) { appErr(uiText('Usage: /feedback <title> | <body>')); return; }
11536
11682
  const bar = parts.indexOf('|');
11537
11683
  let title, body;
11538
11684
  if (bar !== -1) {
@@ -11543,7 +11689,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11543
11689
  title = sp === -1 ? parts : parts.slice(0, sp);
11544
11690
  body = sp === -1 ? '' : parts.slice(sp + 1).trim();
11545
11691
  }
11546
- if (!title) { appErr('Usage: /feedback <title> | <body>'); return; }
11692
+ if (!title) { appErr(uiText('Usage: /feedback <title> | <body>')); return; }
11547
11693
  // The body is EXACTLY what the user typed. Nothing is appended — a report
11548
11694
  // the user did not write (an environment footer, a template) reads as noise
11549
11695
  // in the issue form and has to be deleted before submitting.
@@ -11551,7 +11697,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
11551
11697
  + `?title=${encodeURIComponent(title)}`
11552
11698
  + (body ? `&body=${encodeURIComponent(body)}` : '');
11553
11699
  sayPanel(`Open a GitHub issue:\n ${url}`);
11554
- app('Issue link copied to the transcript (Ctrl+Shift+C to copy).');
11700
+ app(uiText('Issue link copied to the transcript (Ctrl+Shift+C to copy).'));
11555
11701
  return;
11556
11702
  }
11557
11703
  case 'exit': quit(); return;
@@ -11749,7 +11895,8 @@ export async function askSideQuestion(state, cfg, question, repaint) {
11749
11895
  try {
11750
11896
  if (!state.sideThread) {
11751
11897
  state.sideThread = new SideThread({
11752
- basePrompt: (cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT,
11898
+ basePrompt: ((cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT)
11899
+ + (needsThinkingTags(cfg) ? `\n\n${THINKING_TAGS_INSTRUCTION}` : ''),
11753
11900
  tools: SIDE_RO_TOOLS,
11754
11901
  model: modelCfg.model || cfg.model,
11755
11902
  });
@@ -12501,6 +12648,19 @@ async function runTurn(deps, text, opts = {}, viewArg) {
12501
12648
  const basePrompt = (cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT;
12502
12649
  let sysText = basePrompt;
12503
12650
 
12651
+ // THE INLINE-REASONING INSTRUCTION, ONLY WHERE IT IS THE ONLY WAY TO GET IT.
12652
+ //
12653
+ // A model with its own reasoning channel reports it through the API (Anthropic's
12654
+ // `thinking`, OpenAI's and DeepSeek's `reasoning_content`), and hncode already renders
12655
+ // that as the thinking block. Telling such a model to ALSO wrap its reasoning in
12656
+ // `<|thinking|>…<|/thinking|>` asks for the same reasoning twice — once in the channel
12657
+ // and once as literal text in the answer, which ends up duplicated on screen or left in
12658
+ // the reply as noise. A model with no channel has nothing but the tag, so there it is
12659
+ // attached.
12660
+ if (needsThinkingTags(cfg)) {
12661
+ sysText += '\n\n' + THINKING_TAGS_INSTRUCTION;
12662
+ }
12663
+
12504
12664
  // APPEND rather than replace — the safer of the two prompt knobs, and the one to reach
12505
12665
  // for when the built-in prompt already does most of what you want.
12506
12666
  if (cfg.appendSystemPrompt && String(cfg.appendSystemPrompt).trim()) {
@@ -13581,15 +13741,38 @@ const agents = readAgentsMd(state.cwd || state.workspace || cfg.workspace, state
13581
13741
  if (state.running) return;
13582
13742
  const label = task.status === 'completed' ? 'finished' : String(task.status || 'finished');
13583
13743
  const id = task.taskId || task.id || '';
13584
- const excerpt = body ? body.split('\n').slice(0, 40).join('\n') : '(no output)';
13585
- void sessHost.submit([
13744
+ // THE CONCLUSION, NOT THE OUTPUT.
13745
+ //
13746
+ // This used to hand the model the first 40 lines of the task's raw output. A
13747
+ // backgrounded build, a test run or a deploy log is thousands of lines, and
13748
+ // pasting a slice of it into the conversation costs tokens on EVERY later turn,
13749
+ // because the history keeps it. The model does not need the log to decide what
13750
+ // to do — it needs to know the task finished, what it was, and that the output
13751
+ // is there to be read.
13752
+ //
13753
+ // So the message is a status line and a pointer. If the model decides the output
13754
+ // matters, it calls TaskOutput for the slice it wants; if it does not, the log
13755
+ // never enters the conversation at all.
13756
+ const lines = [
13586
13757
  `A background task you started has ${label}${id ? ': ' + id : ''}.`,
13587
- '',
13588
- 'Its output:',
13589
- excerpt,
13590
- '',
13591
- 'Read it and decide what to do next. If it finished, summarise the result for the user; if it failed, say why and what you will change.',
13592
- ].join('\n'));
13758
+ ];
13759
+ const what = String(task.description || task.command || '').trim();
13760
+ if (what) lines.push(`What it was: ${what}`);
13761
+ if (task.exitCode != null) lines.push(`Exit code: ${task.exitCode}`);
13762
+ if (task.stopReason) lines.push(`Reason: ${String(task.stopReason).slice(0, 200)}`);
13763
+ const outBytes = Number(task._bytes) || 0;
13764
+ lines.push(
13765
+ outBytes
13766
+ ? `Its output is ${Math.round(outBytes / 1024)} KB and has NOT been included here.`
13767
+ : 'It produced no output.',
13768
+ );
13769
+ lines.push('');
13770
+ lines.push(
13771
+ 'Do not guess at the result from the status alone. If the output matters, read it with '
13772
+ + `TaskOutput { task_id: "${id}" } — it takes a head_limit. Then decide what to do next: `
13773
+ + 'if it finished, summarise the result for the user; if it failed, say why and what you will change.',
13774
+ );
13775
+ void sessHost.submit(lines.join('\n'));
13593
13776
  };
13594
13777
  }
13595
13778
  await agent.run();
@@ -14734,6 +14917,15 @@ export async function startTUI(opts) {
14734
14917
  if (wait === 0) { setImmediate(paintNow); return; }
14735
14918
  setTimeout(paintNow, wait);
14736
14919
  }
14920
+ // THE MERMAID REPAINT HOOK.
14921
+ //
14922
+ // The mermaid renderer is loaded on first use, so the first frame of a diagram draws
14923
+ // its source and the module arrives a moment later. Nothing repainted at that point, so
14924
+ // the source stayed on screen for the rest of the session — the diagram never appeared
14925
+ // at all. The renderer cannot ask for a frame itself (it is a pure function), so the
14926
+ // repaint is injected here.
14927
+ onMermaidReady(() => renderSoon());
14928
+
14737
14929
  function openPicker(p) {
14738
14930
  let footer = p.footer ? { focused: false, ...p.footer } : null;
14739
14931
  if (p.footerFor) {
@@ -15151,9 +15343,9 @@ export async function startTUI(opts) {
15151
15343
  if (!ap) return [];
15152
15344
  const out = [];
15153
15345
  const tool = String(ap.toolName || 'a tool');
15154
- out.push('The agent is waiting for permission to run ' + tool + '.');
15346
+ out.push(uiText('The agent is waiting for permission to run ') + tool + '.');
15155
15347
  out.push('');
15156
- if (ap.desc) { out.push('Summary: ' + ap.desc); out.push(''); }
15348
+ if (ap.desc) { out.push(uiText('Summary: ') + ap.desc); out.push(''); }
15157
15349
 
15158
15350
  // EVERY ARGUMENT, ITS OWN NAME, IN FULL.
15159
15351
  const args = ap.args && typeof ap.args === 'object' ? ap.args : null;
@@ -16236,7 +16428,7 @@ export async function startTUI(opts) {
16236
16428
  } else if (stamp && stamp.status === 'error') {
16237
16429
  // Left in place: /update reports it with the full npm output on demand, and the
16238
16430
  // one-line summary here would be lost in the startup scroll.
16239
- notice('The last background update failed. Run /update to see why.');
16431
+ notice(uiText('The last background update failed. Run /update to see why.'));
16240
16432
  }
16241
16433
  }
16242
16434
  const runAutoCheck = async () => {
@@ -16522,6 +16714,13 @@ export async function startTUI(opts) {
16522
16714
  dispatchFromStatusBar('model');
16523
16715
  return true;
16524
16716
  }
16717
+ case 'statusTasks': {
16718
+ // Click the running-task badge -> the task panel, where the tasks are listed and
16719
+ // can be read or stopped. The count is the only place on the screen that says
16720
+ // something is running, so it is the place to open the list from.
16721
+ dispatchFromStatusBar('tasks');
16722
+ return true;
16723
+ }
16525
16724
  case 'composerRow': {
16526
16725
  const { cols } = dims();
16527
16726
  const insideW = Math.max(0, cols - 2);
@@ -16904,7 +17103,7 @@ export async function startTUI(opts) {
16904
17103
  // The notice line is the second half of the cue: the highlight says WHICH, the hint says WHAT a
16905
17104
  // click would do. It is cleared when the pointer leaves, so it never outlives the pointer being
16906
17105
  // on the chip.
16907
- if (pasteHover != null) notice('Ctrl+Click to expand it', 'info');
17106
+ if (pasteHover != null) notice(uiText('Ctrl+Click to expand it'), 'info');
16908
17107
  else clearNotice();
16909
17108
  renderFrame();
16910
17109
  }
@@ -17138,14 +17337,14 @@ export async function startTUI(opts) {
17138
17337
  // clipboard, and the old code ignored that — it announced "Copied 0 chars"
17139
17338
  // while the clipboard kept whatever was in it, which reads as "copy did not
17140
17339
  // work" with no way to tell why.
17141
- if (!text) { notice('Nothing to copy', 'error'); return; }
17340
+ if (!text) { notice(uiText('Nothing to copy'), 'error'); return; }
17142
17341
  try {
17143
17342
  const ok = copyText(text); // src/clipboard.js: clip.exe on Windows
17144
- if (ok === false) { notice('Clipboard unavailable', 'error'); return; }
17343
+ if (ok === false) { notice(uiText('Clipboard unavailable'), 'error'); return; }
17145
17344
  const n = text.split('\n').length;
17146
17345
  notice(`Copied ${text.length} chars (${n} line${n === 1 ? '' : 's'})`, 'info');
17147
17346
  } catch (e) {
17148
- notice('Clipboard unavailable: ' + (e && e.message ? e.message : e), 'error');
17347
+ notice(uiText('Clipboard unavailable: ') + (e && e.message ? e.message : e), 'error');
17149
17348
  }
17150
17349
  }
17151
17350
  // Insert pasted text into the composer, collapsing a multi-line paste into a
@@ -17284,19 +17483,19 @@ export async function startTUI(opts) {
17284
17483
  // temp file path. On submit the chip expands back to that path, which is what
17285
17484
  // the agent's ReadMediaFile needs.
17286
17485
  insertComposerPaste(text, via === 'image' ? 'image' : 'paste');
17287
- notice(via === 'image' ? 'Pasted image' : (via === 'text' ? 'Pasted' : `Pasted ${via} as path`), 'info');
17486
+ notice(via === 'image' ? uiText('Pasted image') : (via === 'text' ? 'Pasted' : `Pasted ${via} as path`), 'info');
17288
17487
  renderFrame();
17289
17488
  return;
17290
17489
  }
17291
17490
  // Fast path failed — only fall back to the slow warm-helper reader when this
17292
17491
  // is a full paste (Ctrl+Shift+V), not a right-click quick paste.
17293
17492
  if (fastPathOnly) {
17294
- notice('Clipboard empty or unavailable', 'error');
17493
+ notice(uiText('Clipboard empty or unavailable'), 'error');
17295
17494
  renderFrame();
17296
17495
  return;
17297
17496
  }
17298
17497
  const result = await readText();
17299
- if (!result.text) { notice('Clipboard empty or unavailable', 'error'); renderFrame(); return; }
17498
+ if (!result.text) { notice(uiText('Clipboard empty or unavailable'), 'error'); renderFrame(); return; }
17300
17499
  insertComposerPaste(result.text);
17301
17500
  notice(`Pasted via ${result.via}`, 'info');
17302
17501
  renderFrame();
@@ -17308,7 +17507,7 @@ export async function startTUI(opts) {
17308
17507
  // call, since nothing can be injected into a request already in flight.
17309
17508
  function steerAll() {
17310
17509
  if (!state.running || !state.agent) {
17311
- notice('Nothing to steer into (the agent is idle)', 'error');
17510
+ notice(uiText('Nothing to steer into (the agent is idle)'), 'error');
17312
17511
  renderFrame();
17313
17512
  return;
17314
17513
  }
@@ -17322,7 +17521,7 @@ export async function startTUI(opts) {
17322
17521
  const draft = rawDraft.trim() ? expandPastes(rawDraft, state.pastes).trim() : '';
17323
17522
  if (draft) items.push(draft);
17324
17523
  if (!items.length) {
17325
- notice('Nothing queued to steer', 'error');
17524
+ notice(uiText('Nothing queued to steer'), 'error');
17326
17525
  renderFrame();
17327
17526
  return;
17328
17527
  }
@@ -17381,11 +17580,11 @@ export async function startTUI(opts) {
17381
17580
  onPick: (it) => {
17382
17581
  if (it.action === 'editor-copy') {
17383
17582
  const text = editorSelectedText();
17384
- if (text) copyToClipboard(text); else notice('Nothing selected', 'error');
17583
+ if (text) copyToClipboard(text); else notice(uiText('Nothing selected'), 'error');
17385
17584
  }
17386
17585
  else if (it.action === 'editor-cut') {
17387
17586
  const text = editorSelectedText();
17388
- if (!text) { notice('Nothing selected', 'error'); return true; }
17587
+ if (!text) { notice(uiText('Nothing selected'), 'error'); return true; }
17389
17588
  copyToClipboard(text);
17390
17589
  editorReplace('');
17391
17590
  }
@@ -17393,7 +17592,7 @@ export async function startTUI(opts) {
17393
17592
  const clip = readClipboardContentAsync();
17394
17593
  void clip.then((r) => {
17395
17594
  const text = r && r.text ? String(r.text) : '';
17396
- if (!text) { notice('Clipboard is empty', 'error'); return; }
17595
+ if (!text) { notice(uiText('Clipboard is empty'), 'error'); return; }
17397
17596
  editorReplace(text);
17398
17597
  });
17399
17598
  }
@@ -17434,7 +17633,7 @@ export async function startTUI(opts) {
17434
17633
  // guard returned '' — Copy always answered "Nothing to copy".
17435
17634
  const text = selectionText(true);
17436
17635
  if (text) copyToClipboard(text);
17437
- else notice('Nothing to copy — select text first', 'error');
17636
+ else notice(uiText('Nothing to copy — select text first'), 'error');
17438
17637
  }
17439
17638
  else if (it.action === 'copy-composer') {
17440
17639
  const sel = state.composerSel;
@@ -17455,7 +17654,7 @@ export async function startTUI(opts) {
17455
17654
  }
17456
17655
  else if (it.action === 'copy-last') {
17457
17656
  const last = [...state.chat].reverse().find((m) => m.role === 'assistant' && (m.text || '').trim());
17458
- if (last) copyToClipboard(last.text); else notice('No assistant message to copy', 'error');
17657
+ if (last) copyToClipboard(last.text); else notice(uiText('No assistant message to copy'), 'error');
17459
17658
  } else if (it.action === 'clear') { state.selection = null; }
17460
17659
  else if (it.action === 'clear-composer') { state.composerSel = null; }
17461
17660
  else if (it.action === 'paste') {
@@ -17673,7 +17872,7 @@ export async function startTUI(opts) {
17673
17872
  try { state.agent.interrupt(); } catch { /* an already-finished turn */ }
17674
17873
  // THE GOAL MUST NOT RESTART THIS TURN. See `_userInterrupted` at the goal decision below.
17675
17874
  state._userInterrupted = true;
17676
- notice('Interrupted', 'info');
17875
+ notice(uiText('Interrupted'), 'info');
17677
17876
  renderFrame();
17678
17877
  return;
17679
17878
  }
@@ -17722,6 +17921,15 @@ export async function startTUI(opts) {
17722
17921
  // exit" prompt, because a key whose whole meaning here is "stop this" must not also be able
17723
17922
  // to quit. An open overlay is excluded so Esc keeps its other job of closing one.
17724
17923
  if (state.agent) state.agent.interrupt();
17924
+ // MANUAL /compact RUNS WITHOUT AN AGENT, so `interrupt()` above does nothing and
17925
+ // this branch used to return having done NOTHING AT ALL — Esc appeared dead for the
17926
+ // whole summariser round-trip, which is the one operation the user most wants to
17927
+ // stop (it can take a minute on a long history). The summariser is abortable, and
17928
+ // the /compact handler checks the flag before it trims.
17929
+ if (state._compactLlm) {
17930
+ state._compactAborted = true;
17931
+ try { state._compactLlm.abort(); } catch { /* already finished */ }
17932
+ }
17725
17933
  // THE GOAL MUST NOT RESTART THIS TURN. See `_userInterrupted` at the goal decision below.
17726
17934
  state._userInterrupted = true;
17727
17935
  return;
@@ -17901,7 +18109,7 @@ export async function startTUI(opts) {
17901
18109
  // next question and left this one unanswered. The user could not tell "submitted nothing" from
17902
18110
  // "submitted", and the skipped question came back at the end looking like a fresh prompt.
17903
18111
  if (!labels.length) {
17904
- appErr('Pick at least one option with Space, or type an answer under Other.');
18112
+ appErr(uiText('Pick at least one option with Space, or type an answer under Other.'));
17905
18113
  renderFrame();
17906
18114
  return;
17907
18115
  }
@@ -17953,7 +18161,7 @@ export async function startTUI(opts) {
17953
18161
  if (!(state.picker || state.form || state.panel || state.editor || state.question || state.menuOpen)) {
17954
18162
  const current = (cfg && cfg.provider) || '';
17955
18163
  if (!current) {
17956
- notice('No provider selected — use /model to pick one.', 'error');
18164
+ notice(uiText('No provider selected — use /model to pick one.'), 'error');
17957
18165
  } else {
17958
18166
  // Fire and forget: the notice reports the outcome, and blocking the key handler on a network
17959
18167
  // round-trip would freeze input for as long as the endpoint takes.
@@ -18026,7 +18234,7 @@ export async function startTUI(opts) {
18026
18234
  const cur = state.input || '';
18027
18235
  if (!cur) {
18028
18236
  // Nothing to select: say so rather than silently doing nothing, which reads as a dead key.
18029
- notice('Nothing to select', 'error');
18237
+ notice(uiText('Nothing to select'), 'error');
18030
18238
  renderFrame();
18031
18239
  return;
18032
18240
  }
@@ -18056,7 +18264,7 @@ export async function startTUI(opts) {
18056
18264
  copyToClipboard(removed);
18057
18265
  refreshMenu(state);
18058
18266
  } else {
18059
- notice('Nothing selected to cut', 'error');
18267
+ notice(uiText('Nothing selected to cut'), 'error');
18060
18268
  }
18061
18269
  renderFrame();
18062
18270
  return;
@@ -18076,7 +18284,7 @@ export async function startTUI(opts) {
18076
18284
  if (state.selection && state.selection.anchor && state.selection.head) {
18077
18285
  const sel = selectionText();
18078
18286
  if (sel) copyToClipboard(sel);
18079
- else notice('Nothing to copy — the selection is empty', 'error');
18287
+ else notice(uiText('Nothing to copy — the selection is empty'), 'error');
18080
18288
  } else {
18081
18289
  const composerSel = state.composerSel;
18082
18290
  if (composerSel && composerSel.anchor !== composerSel.head) {
@@ -18084,7 +18292,7 @@ export async function startTUI(opts) {
18084
18292
  const h = Math.max(composerSel.anchor, composerSel.head);
18085
18293
  copyToClipboard((state.input || '').slice(a, h));
18086
18294
  } else {
18087
- notice('Nothing to copy — select text first (or use the right-click menu)', 'error');
18295
+ notice(uiText('Nothing to copy — select text first (or use the right-click menu)'), 'error');
18088
18296
  }
18089
18297
  }
18090
18298
  renderFrame();
@@ -18126,8 +18334,8 @@ export async function startTUI(opts) {
18126
18334
  // SAY SO. Ctrl+B with no foreground command used to fall through silently, so there was no way to tell "the
18127
18335
  // shortcut is broken" from "nothing was running" — and a steer arriving mid-turn made that confusion easy.
18128
18336
  notice(state.running
18129
- ? 'Nothing to background — no command is running in the foreground'
18130
- : 'Nothing to background — the agent is idle', 'error');
18337
+ ? uiText('Nothing to background — no command is running in the foreground')
18338
+ : uiText('Nothing to background — the agent is idle'), 'error');
18131
18339
  renderFrame();
18132
18340
  return;
18133
18341
  }
@@ -18137,7 +18345,7 @@ export async function startTUI(opts) {
18137
18345
  // because the composer has to go back to the model when the answer is done.
18138
18346
  const fg = state.agent && state.agent.ctx && state.agent.ctx._foreground;
18139
18347
  if (!fg || typeof fg.write !== 'function') {
18140
- notice('Nothing is waiting for input — no command is running in the foreground', 'error');
18348
+ notice(uiText('Nothing is waiting for input — no command is running in the foreground'), 'error');
18141
18349
  renderFrame();
18142
18350
  return;
18143
18351
  }
@@ -18145,8 +18353,8 @@ export async function startTUI(opts) {
18145
18353
  // The renderer is module-level and cannot read `state`, so the mode rides on the RUNNING Bash message.
18146
18354
  for (const m of state.chat || []) if (m.role === 'tool' && m.toolName === 'Bash' && m.pending) m._stdinMode = state.stdinMode;
18147
18355
  notice(state.stdinMode
18148
- ? 'Input goes to the running command (Ctrl+G to stop)'
18149
- : 'Input goes back to the model', 'info');
18356
+ ? uiText('Input goes to the running command (Ctrl+G to stop)')
18357
+ : uiText('Input goes back to the model'), 'info');
18150
18358
  renderFrame();
18151
18359
  return;
18152
18360
  }
@@ -18174,7 +18382,7 @@ export async function startTUI(opts) {
18174
18382
  const after = todoRowCount(state);
18175
18383
  if (before === after) {
18176
18384
  state.todosExpanded = !state.todosExpanded; // undo: nothing to toggle
18177
- notice(total ? `Todo panel already shows all ${total}` : 'No todos yet', 'info');
18385
+ notice(total ? `Todo panel already shows all ${total}` : uiText('No todos yet'), 'info');
18178
18386
  renderFrame();
18179
18387
  return;
18180
18388
  }
@@ -18187,7 +18395,7 @@ export async function startTUI(opts) {
18187
18395
 
18188
18396
  if (t.key === 'c-o' && !state.editor) {
18189
18397
  state.expanded = !state.expanded;
18190
- notice(state.expanded ? 'Expanded tool output' : 'Collapsed tool output', 'info');
18398
+ notice(state.expanded ? uiText('Expanded tool output') : uiText('Collapsed tool output'), 'info');
18191
18399
  renderFrame();
18192
18400
  return;
18193
18401
  }
@@ -18217,7 +18425,7 @@ export async function startTUI(opts) {
18217
18425
  const target = [...state.chat].reverse().find((m) => m
18218
18426
  && (m.role === 'tool_result' || m.role === 'assistant')
18219
18427
  && String(m.text || '').trim());
18220
- if (!target) { notice('Nothing to show yet', 'info'); renderFrame(); return; }
18428
+ if (!target) { notice(uiText('Nothing to show yet'), 'info'); renderFrame(); return; }
18221
18429
  const title = target.role === 'tool_result'
18222
18430
  ? `Output — ${target.toolName || 'tool'}`
18223
18431
  : 'Reply';
@@ -18395,7 +18603,7 @@ export async function startTUI(opts) {
18395
18603
  if (t.key === 'c-s') {
18396
18604
  const cb = ed.onSave;
18397
18605
  state.editor = null;
18398
- try { if (cb) cb(ed.text); } catch (e) { notice('Save failed: ' + e.message, 'error'); }
18606
+ try { if (cb) cb(ed.text); } catch (e) { notice(uiText('Save failed: ') + e.message, 'error'); }
18399
18607
  renderFrame();
18400
18608
  return;
18401
18609
  }
@@ -18686,7 +18894,7 @@ export async function startTUI(opts) {
18686
18894
  state.btwPanel = null;
18687
18895
  state.btwScroll = 0;
18688
18896
  state.sideThread = null;
18689
- notice('Side thread closed.', 'info');
18897
+ notice(uiText('Side thread closed.'), 'info');
18690
18898
  renderFrame();
18691
18899
  return;
18692
18900
  }
@@ -19286,14 +19494,14 @@ function wheelStep(state, family) {
19286
19494
  if (text.startsWith('@')) {
19287
19495
  const m = /^@([\w-]+)\s+([\s\S]+)$/.exec(text);
19288
19496
  if (!m) {
19289
- notice('Use `@name message` to send straight to a member.', 'error');
19497
+ notice(uiText('Use `@name message` to send straight to a member.'), 'error');
19290
19498
  renderFrame();
19291
19499
  return;
19292
19500
  }
19293
19501
  const [, who, body] = m;
19294
19502
  const teamName = leadTeam();
19295
19503
  if (!teamName) {
19296
- notice('No team. Create one: /team create <name>', 'error');
19504
+ notice(uiText('No team. Create one: /team create <name>'), 'error');
19297
19505
  renderFrame();
19298
19506
  return;
19299
19507
  }
@@ -19356,7 +19564,7 @@ function wheelStep(state, family) {
19356
19564
  // The command is gone; the write reported failure, so the line was NOT delivered.
19357
19565
  state.stdinMode = false;
19358
19566
  for (const m of state.chat || []) if (m._stdinMode) m._stdinMode = false;
19359
- notice('That command has finished — input goes to the model again', 'error');
19567
+ notice(uiText('That command has finished — input goes to the model again'), 'error');
19360
19568
  renderFrame();
19361
19569
  return;
19362
19570
  }
@@ -19950,7 +20158,7 @@ function wheelStep(state, family) {
19950
20158
  }
19951
20159
 
19952
20160
  function stopWeb() {
19953
- if (!web) { notice('Web UI is not running', 'error'); return false; }
20161
+ if (!web) { notice(uiText('Web UI is not running'), 'error'); return false; }
19954
20162
  // Tell the daemon first, so its directory stops listing this session instead
19955
20163
  // of showing a link to a port that is about to disappear.
19956
20164
  if (webDaemon) {
@@ -19987,6 +20195,10 @@ function wheelStep(state, family) {
19987
20195
  // The session's own server first: the daemon needs a port to proxy to.
19988
20196
  const srv = await startWeb(host, port == null ? 0 : port);
19989
20197
  try {
20198
+ // IMPORTED HERE, NOT AT THE TOP. This chain pulls in web-daemon.js and measures ~76ms
20199
+ // to evaluate, and only /web ever reaches it — every other session paid that on
20200
+ // startup for a command it never runs.
20201
+ const { attachToDaemon } = await import('./web-daemon-client.js');
19990
20202
  webDaemon = await attachToDaemon({
19991
20203
  id: (session && session.id) || 'session',
19992
20204
  port: srv.port,
@@ -20665,7 +20877,7 @@ function quit() {
20665
20877
  `Web UI: ${srv.url}`,
20666
20878
  `Bind: ${srv.host}:${srv.port}${lan ? ' (reachable from the network)' : ' (this machine only)'}`,
20667
20879
  '',
20668
- 'Access token (paste it into the login page):',
20880
+ uiText('Access token (paste it into the login page):'),
20669
20881
  '',
20670
20882
  ` ${srv.token}`,
20671
20883
  '',