junecoder 1.0.12 → 1.0.14
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/package.json +1 -1
- package/tui.mjs +29 -23
package/package.json
CHANGED
package/tui.mjs
CHANGED
|
@@ -261,9 +261,9 @@ export async function startTUI(agent, opts = {}) {
|
|
|
261
261
|
const frame = out.join("\r\n");
|
|
262
262
|
if (frame !== lastFrame) { lastFrame = frame; process.stdout.write(frame); }
|
|
263
263
|
|
|
264
|
-
if (state.processing || state.
|
|
264
|
+
if (state.processing || state.question || (state.permission && !state.permission.reasonMode)) process.stdout.write(ansi.hideCursor);
|
|
265
265
|
else {
|
|
266
|
-
const cursorRow = 1 + convH + taskPanelH + 2 + (layout.cursorLine - inputOffset);
|
|
266
|
+
const cursorRow = 1 + convH + taskPanelH + subOutLen + permPreviewLen + 2 + (layout.cursorLine - inputOffset);
|
|
267
267
|
const cursorCol = 3 + layout.cursorCol;
|
|
268
268
|
process.stdout.write(ESC + "[" + cursorRow + ";" + cursorCol + "H" + ansi.showCursor);
|
|
269
269
|
}
|
|
@@ -272,19 +272,32 @@ export async function startTUI(agent, opts = {}) {
|
|
|
272
272
|
|
|
273
273
|
keyStream.on("keypress", (str, key) => {
|
|
274
274
|
if (state.permission) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
if (state.permission.reasonMode) {
|
|
276
|
+
// In reason mode: Escape cancels, everything else passes through for typing
|
|
277
|
+
if (key.name === "escape") {
|
|
278
|
+
state.input = []; state.cursor = 0;
|
|
279
|
+
const resolve = state.permission.resolve;
|
|
280
|
+
state.permission = null; state.permissionPreview = [];
|
|
281
|
+
state.status = state.processing ? "Processing..." : "Ready";
|
|
282
|
+
resolve({ allowed: false });
|
|
283
|
+
render(); return;
|
|
284
|
+
}
|
|
285
|
+
// Fall through to normal key handling (typing, Enter→submit, Ctrl+C, etc.)
|
|
286
|
+
} else {
|
|
287
|
+
const ch = (str || key.name || "").toLowerCase();
|
|
288
|
+
if (ch === "y" || key.name === "y") state.permission.resolve({ allowed: true });
|
|
289
|
+
else if (ch === "a" || key.name === "a") { agent.autoApprove = true; state.permission.resolve({ allowed: true }); pushLine(" [auto] Auto-approve ON.", C.warn); }
|
|
290
|
+
else if (ch === "n" || key.name === "n") {
|
|
291
|
+
// Enter reason mode
|
|
292
|
+
state.permission.reasonMode = true;
|
|
293
|
+
state.input = []; state.cursor = 0;
|
|
294
|
+
state.status = "Denied — why? (Enter to send, Esc to skip)";
|
|
295
|
+
render();
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
else return;
|
|
299
|
+
state.permission = null; state.permissionPreview = []; state.status = state.processing ? "Processing..." : "Ready"; render(); return;
|
|
285
300
|
}
|
|
286
|
-
else return;
|
|
287
|
-
state.permission = null; state.permissionPreview = []; state.status = state.processing ? "Processing..." : "Ready"; render(); return;
|
|
288
301
|
}
|
|
289
302
|
if (state.question) {
|
|
290
303
|
if (key.name === "return" || key.name === "enter") {
|
|
@@ -301,14 +314,6 @@ export async function startTUI(agent, opts = {}) {
|
|
|
301
314
|
if (state.question.options.length === 0) { editInput(str, key); render(); return; }
|
|
302
315
|
return;
|
|
303
316
|
}
|
|
304
|
-
if (state.permission?.reasonMode && key.name === "escape") {
|
|
305
|
-
state.input = []; state.cursor = 0;
|
|
306
|
-
const resolve = state.permission.resolve;
|
|
307
|
-
state.permission = null; state.permissionPreview = [];
|
|
308
|
-
state.status = state.processing ? "Processing..." : "Ready";
|
|
309
|
-
resolve({ allowed: false });
|
|
310
|
-
render(); return;
|
|
311
|
-
}
|
|
312
317
|
if (key.name === "c" && key.ctrl) {
|
|
313
318
|
if (state.processing && state.controller) { state.controller.abort(); state.status = "Aborting..."; render(); }
|
|
314
319
|
else { cleanup(); process.exit(0); }
|
|
@@ -360,7 +365,8 @@ export async function startTUI(agent, opts = {}) {
|
|
|
360
365
|
|
|
361
366
|
async function submit() {
|
|
362
367
|
const text = state.input.join("").trim();
|
|
363
|
-
if (!text
|
|
368
|
+
if (!text && !state.permission?.reasonMode) return;
|
|
369
|
+
if (state.processing && !state.permission?.reasonMode) return;
|
|
364
370
|
|
|
365
371
|
// ─── Permission reason mode ────────────────────────────────────────────
|
|
366
372
|
if (state.permission?.reasonMode) {
|