Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(team):Press Ctrl+C, but remain on the approval interface and do not exit.

openJiuwen-bot87d1e4e21611
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
index d29380c13b..26e8fad1c4 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
@@ -2261,12 +2261,12 @@ export class AppScreen implements Component, Focusable {
return;
}
- // Ctrl+C during pending question: first press shows hint, second press within 1s cancels
+ // Ctrl+C during pending question: first press shows hint, second press within 3s exits
if (pendingQuestion && matchesKey(data, "ctrl+c")) {
if (this.ctrlCPendingForQuestion) {
this.clearCtrlCPendingForQuestion();
this.transientNotice = null;
- this.interruptTask();
+ this.exit();
return;
}
this.ctrlCPendingForQuestion = true;
diff --git a/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs b/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs
index c16c4c5905..7488f7e35f 100644
--- a/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs
+++ b/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs
@@ -95,4 +95,47 @@ assert.deepEqual(
["swarmflows", "workspace"],
);
+const pendingQuestionScreen = Object.create(AppScreen.prototype);
+let pendingQuestionExitCount = 0;
+let pendingQuestionInterruptCount = 0;
+let pendingQuestionRenderCount = 0;
+Object.assign(pendingQuestionScreen, {
+ activeQuestionIndex: 0,
+ ctrlCPendingForQuestion: false,
+ ctrlCPendingForQuestionTimer: null,
+ transientNotice: null,
+ startupPromptList: null,
+ fileViewerState: null,
+ diffViewerState: null,
+ state: {
+ recordActivity: () => undefined,
+ getSnapshot: () => ({
+ pendingQuestion: {
+ requestId: "plan-approval",
+ source: "confirm_interrupt",
+ questions: [{ header: "Exit Plan and Execute", question: planQuestion, options: [] }],
+ },
+ }),
+ },
+ tui: {
+ requestRender: () => {
+ pendingQuestionRenderCount += 1;
+ },
+ },
+ exit: () => {
+ pendingQuestionExitCount += 1;
+ },
+ interruptTask: () => {
+ pendingQuestionInterruptCount += 1;
+ },
+});
+
+pendingQuestionScreen.handleInput("\x03");
+assert.equal(pendingQuestionScreen.transientNotice, "Press Ctrl+C again to exit");
+assert.equal(pendingQuestionExitCount, 0);
+pendingQuestionScreen.handleInput("\x03");
+assert.equal(pendingQuestionExitCount, 1);
+assert.equal(pendingQuestionInterruptCount, 0);
+assert.equal(pendingQuestionRenderCount, 1);
+
console.log("frontend tests passed");