From 993550e9f3dc532554338c34d8fe46430dfce16f Mon Sep 17 00:00:00 2001 From: Darknode-Official Date: Sun, 15 Nov 2026 12:27:06 -0800 Subject: [PATCH] Fix Ctrl+X after a queued send, and /btw with a queue - Ctrl+X with a newly typed draft now always sends it now. Before, once an earlier Ctrl+X had started the queue, a second Ctrl+X only queued the draft. An empty Ctrl+X while the queue is already running still does nothing. - Ctrl+X on a side command (/btw, /cost, /find...) opens it at once instead of pushing it into the queue or interrupting the turn. - Picking /btw from the menu mid-turn puts "/btw " in the box for the question instead of queueing a bare /btw. --- darknode.js | 7 +++++-- test/run.js | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/darknode.js b/darknode.js index 6b2426f..535b7ae 100755 --- a/darknode.js +++ b/darknode.js @@ -6899,12 +6899,15 @@ function nexusTui(engine, cwd, nexusMd, autoResume, launch) { // existing queue now. if (s === "\x18" || s === "\x13") { const v = (composer.submit() || "").trim(); flush(); hIdx = composer.histIndex; input = ""; curPos = 0; menuSel = 0; + // a side command (/btw, /cost, /find...) never waits in the queue or stops the turn: it opens now + if (v && isInstant(v)) { handleSlash(v); render(); return; } if (v) nextQueue.unshift(v); if (!nextQueue.length) { pasteNotice = "nothing to send yet — type a prompt, then Ctrl+X/Ctrl+S to run it now"; render(); return; } // Interrupt ONLY the original turn. Once the first press has started the // queue flushing, the running turn is itself a queued prompt — a second // press must not kill it, or it would cancel the message it just launched. - if (curTurnFromQueue) { pasteNotice = (v ? "queued to run next — " : "already running your queue — ") + nextQueue.length + " in line"; } + // A NEWLY typed draft is an explicit "send this now", so it always interrupts. + if (curTurnFromQueue && !v) { pasteNotice = "already running your queue — " + nextQueue.length + " in line"; } else if (ctl && ctl.kill) { ctl.kill(); transcript.push({ role: "system", text: "sending the next queued prompt now — interrupting the current turn" }); } render(); return; } @@ -6912,7 +6915,7 @@ function nexusTui(engine, cwd, nexusMd, autoResume, launch) { // completes, Enter queues the highlighted command to run after the turn if (cm.length && s === "\x1b") { input = ""; curPos = 0; menuSel = 0; render(); return; } if (cm.length && s === "\t") { if (_mm.length) { input = (_mm[menuSel] || _mm[0])[0] + " "; refreshArgCache(); } else { const sp = input.indexOf(" "); input = input.slice(0, sp) + " " + (_am[menuSel] || _am[0])[0] + " "; } curPos = input.length; menuSel = 0; render(); return; } - if (_mm.length && (s === "\r" || s === "\n")) { const t = (_mm[menuSel] || _mm[0])[0]; if (isInstant(t) && t !== "/btw") { input = ""; curPos = 0; menuSel = 0; handleSlash(t); return; } nextQueue.push(t); input = ""; curPos = 0; menuSel = 0; render(); return; } + if (_mm.length && (s === "\r" || s === "\n")) { const t = (_mm[menuSel] || _mm[0])[0]; if (t === "/btw") { input = "/btw "; curPos = input.length; composer.text = input; composer.cursor = curPos; menuSel = 0; render(); return; } if (isInstant(t)) { input = ""; curPos = 0; menuSel = 0; handleSlash(t); return; } nextQueue.push(t); input = ""; curPos = 0; menuSel = 0; render(); return; } if (s === "\x1b" || s === "\x03") { if (ctl && ctl.kill) { ctl.kill(); transcript.push({ role: "system", text: "interrupting current turn…" }); } render(); return; } if (isDown && agentSel < 0 && !agentView && agents.length && !input) { agentSel = 0; render(); return; } // Down on an empty prompt drops focus into the Agents panel if (isUp || isDown) { arrowVert(isUp ? -1 : 1); return; } // same as idle: visual row, then history / queued recall diff --git a/test/run.js b/test/run.js index 334a134..2ac66c1 100644 --- a/test/run.js +++ b/test/run.js @@ -1632,6 +1632,9 @@ group("help reference (single source of truth)"); ok("undo: a turn that changed no file leaves no checkpoint, so /undo reverts the last real change", /if \(ckObj\.paths\.length\) bits\.push\("undo #" \+ checkpoints\.length\); else \{ const _i = checkpoints\.indexOf\(ckObj\); if \(_i >= 0\) checkpoints\.splice\(_i, 1\); \}/.test(src)); ok("undo: restore checks files out of the snapshot tree (no commit, so no git identity needed); the agents base commit falls back to a nexus identity", /const commit = tree;/.test(src) && !/commit-tree " \+ tree \+ " -m nexus-restore/.test(src) && /env: gitIdEnv\(cwd\)(, stdio: \[[^\]]*\])? \}\)/.test(src)); ok("side panel: a known /command typed in the follow-up box runs (or queues mid-turn) instead of being sent to the model as a question; a /path question still asks", /if \(\/\^\\\/\[a-z\]\/i\.test\(q\) && allCmds\(\)\.some\(\(c\) => c\[0\] === sideName\(q\)\)\) \{ btw = null; if \(busy && !isInstant\(q\)\) nextQueue\.push\(q\); else handleSlash\(q\);/.test(src)); + ok("Ctrl+X: a side command draft (/btw, /cost...) opens now instead of being queued or interrupting the turn", /if \(v && isInstant\(v\)\) \{ handleSlash\(v\); render\(\); return; \}/.test(src)); + ok("Ctrl+X: a newly typed draft always sends now, even after an earlier Ctrl+X started the queue", /if \(curTurnFromQueue && !v\) \{ pasteNotice = "already running your queue/.test(src) && !/queued to run next — /.test(src)); + ok("mid-turn: picking /btw from the menu opens it for a question instead of queueing a bare /btw", /if \(t === "\/btw"\) \{ input = "\/btw "; curPos = input\.length; composer\.text = input;/.test(src)); ok("/notify rejects an unknown value instead of silently toggling; /export writes to that path", /if \(a && a !== "on" && a !== "off"\) \{ transcript\.push\(\{ role: "system", text: "usage: \/notify \[on\|off\]/.test(src) && /const fp = argstr \? path\.resolve\(cwd, /.test(src)); ok("nexus \"task\" runs the task then exits, as --help promises (no line-mode chat afterwards)", /if \(printMode \|\| oneShot\) return;/.test(src)); ok("/commit and /pr pass model-written messages to git/gh as argv (never a shell string), and /commit shows why git refused", !/execSync\("git commit -m "/.test(src) && !/execSync\("gh pr create/.test(src) && /_cp\.execFileSync\("git", \["commit", "-m", subj\]/.test(src) && /_cp\.spawnSync\("gh", \["pr", "create", "--title", title/.test(src) && /git said: /.test(src));