Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions darknode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6899,20 +6899,23 @@ 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;
}
// the menu stays usable mid-turn: Esc dismisses it (not the turn), Tab
// 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
Expand Down
3 changes: 3 additions & 0 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> 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));
Expand Down
Loading