@tiens.nguyen/gonext-local-worker 1.0.304 → 1.0.306

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.
Files changed (2) hide show
  1. package/gonext-repl.mjs +35 -9
  2. package/package.json +1 -1
package/gonext-repl.mjs CHANGED
@@ -304,6 +304,8 @@ rl.on("line", (l) => {
304
304
  slashSel = -1;
305
305
  slashNames = [];
306
306
  }
307
+ // Overlay is gone — restore readline history so ↑/↓ recall past tasks again (bug #109).
308
+ slashRestoreHistory();
307
309
  const clean = stripAnsiEscapes(submitted);
308
310
  if (_lineWaiter) {
309
311
  const w = _lineWaiter;
@@ -323,14 +325,39 @@ rl.on("line", (l) => {
323
325
  // scrollback copies. Relative cursor moves so it survives terminal scrolling.
324
326
  // (slashSel / slashNames / slashPrefix are declared above, near rl.on("line").)
325
327
  const inputCol = () => 4 + rl.cursor; // ">> " is 3 cols; content starts at col 4 (1-based)
328
+ // While the slash-hint overlay is open, EMPTY readline's history so ↑/↓ don't recall a
329
+ // history entry and trigger readline's OWN line-refresh — that refresh fought our overlay
330
+ // and reprinted the whole ">> /" + hint block on every arrow press (bug #109). With no
331
+ // history to recall, readline's ↑/↓ are inert and our keypress handler owns the highlight.
332
+ // Restored the instant the overlay closes, so normal task-history recall still works.
333
+ let _slashSavedHistory = null;
334
+ function slashNeutralizeHistory() {
335
+ if (_slashSavedHistory === null && Array.isArray(rl.history)) {
336
+ _slashSavedHistory = rl.history;
337
+ rl.history = [];
338
+ rl.historyIndex = -1;
339
+ }
340
+ }
341
+ function slashRestoreHistory() {
342
+ if (_slashSavedHistory !== null) {
343
+ rl.history = _slashSavedHistory;
344
+ _slashSavedHistory = null;
345
+ rl.historyIndex = -1;
346
+ }
347
+ }
326
348
  function clearSlashHint() {
327
- if (slashHintRows === 0) return;
349
+ if (slashHintRows === 0) {
350
+ slashRestoreHistory();
351
+ return;
352
+ }
328
353
  process.stdout.write("\n\x1b[J" + `\x1b[1A\x1b[${inputCol()}G`);
329
354
  slashHintRows = 0;
330
355
  slashSel = -1;
331
356
  slashNames = [];
357
+ slashRestoreHistory();
332
358
  }
333
359
  function drawSlashHint(prefix, sel) {
360
+ slashNeutralizeHistory();
334
361
  const cmds = filteredCommands(prefix);
335
362
  slashNames = cmds.map((c) => c.name);
336
363
  if (sel >= cmds.length) sel = cmds.length - 1;
@@ -370,18 +397,16 @@ if (process.stdin.isTTY) {
370
397
  }
371
398
  // Enter is handled by rl.on("line") — don't redraw the hint on the way out.
372
399
  if (key && (key.name === "return" || key.name === "enter")) return;
373
- // ↑/↓ while the menu is up = move the highlight, NOT recall shell history. readline
374
- // already ran history-nav (may have changed the line); restore the typed "/…" prefix
375
- // and redraw with the new selection.
400
+ // ↑/↓ while the menu is up = move the highlight IN PLACE. History is neutralized
401
+ // (slashNeutralizeHistory), so readline's ↑/↓ did nothing the input line is intact
402
+ // and we just move the selection and redraw the hint below it (bug #109).
376
403
  if (slashHintRows > 0 && key && (key.name === "up" || key.name === "down")) {
377
- rl.line = slashPrefix;
378
- rl.cursor = slashPrefix.length;
404
+ rl.historyIndex = -1;
379
405
  const n = slashNames.length;
380
406
  if (n > 0) {
381
407
  slashSel =
382
408
  key.name === "down" ? (slashSel + 1 + n) % n : (slashSel - 1 + n) % n;
383
409
  }
384
- rl._refreshLine();
385
410
  drawSlashHint(slashPrefix, slashSel);
386
411
  return;
387
412
  }
@@ -2143,9 +2168,10 @@ async function main() {
2143
2168
  // Only for turns that actually used the code model (plain-reply greetings = 0/0).
2144
2169
  if ((inputTokens ?? 0) > 0 || (outputTokens ?? 0) > 0) {
2145
2170
  console.log(
2146
- dim(" tokens · in ") +
2171
+ dim("tokens ·in ") +
2147
2172
  fmtTokens(inputTokens ?? 0) +
2148
- cyan(` · out ${fmtTokens(outputTokens ?? 0)}`)
2173
+ dim(" · ") +
2174
+ cyan(`↓ out ${fmtTokens(outputTokens ?? 0)}`)
2149
2175
  );
2150
2176
  }
2151
2177
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.304",
3
+ "version": "1.0.306",
4
4
  "description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
5
5
  "type": "module",
6
6
  "license": "MIT",