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:修复/export esc退出问题
openJiuwen-bot83b9d1f7081f
diff --git a/jiuwenswarm/channels/tui/frontend/src/app-state.ts b/jiuwenswarm/channels/tui/frontend/src/app-state.tsindex d3a37ba9a1..cce3cbe82f 100644--- a/jiuwenswarm/channels/tui/frontend/src/app-state.ts+++ b/jiuwenswarm/channels/tui/frontend/src/app-state.ts@@ -931,6 +931,13 @@ export class CliPiAppState {if (options?.showNotice === false) {this.suppressInterruptResult = true;}+ // Reject local pending question immediately so local commands (e.g. /export) can terminate+ if (this.localPendingQuestion) {+ this.localPendingQuestion.reject(new Error("interrupted by Ctrl+C"));+ this.localPendingQuestion = null;+ this.pendingQuestion = null;+ this.streamingState = StreamingState.Idle;+ }// Set local interrupt flag immediately for long-running command detectionthis.interruptRequested = true;const hadLocalWork = this.getSnapshot().cancellableWork;diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.tsindex 01bf620b8c..548ce93a5b 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts@@ -492,6 +492,8 @@ export class AppScreen implements Component, Focusable {private questionList: SelectList | null = null;private questionDetailsMap: Map<string, string[]> | null = null;private otherInputMode = false;+ private ctrlCPendingForQuestion = false;+ private ctrlCPendingForQuestionTimer: ReturnType<typeof setTimeout> | null = null;private resumeSessionList: ResumeSessionListState | null = null;private modelList: ModelListState | null = null;private mcpList: McpListState | null = null;@@ -616,6 +618,7 @@ export class AppScreen implements Component, Focusable {clearTimeout(this.transientNoticeTimer);this.transientNoticeTimer = null;}+ this.clearCtrlCPendingForQuestion();if (this.animationTimer) {clearInterval(this.animationTimer);this.animationTimer = null;@@ -623,6 +626,14 @@ export class AppScreen implements Component, Focusable {this.unsubscribe();}+ private clearCtrlCPendingForQuestion(): void {+ this.ctrlCPendingForQuestion = false;+ if (this.ctrlCPendingForQuestionTimer) {+ clearTimeout(this.ctrlCPendingForQuestionTimer);+ this.ctrlCPendingForQuestionTimer = null;+ }+ }+invalidate(): void {this.editor.invalidate();}@@ -790,6 +801,28 @@ export class AppScreen implements Component, Focusable {return;}+ // Ctrl+C double-press for pending questions (aligns with Claude Code behavior):+ // First press: show "Press Ctrl+C again to exit" notice, don't cancel yet.+ // Second press within 1s: actually cancel the question.+ if (pendingQuestion && matchesKey(data, "ctrl+c")) {+ if (this.ctrlCPendingForQuestion) {+ this.clearCtrlCPendingForQuestion();+ this.transientNotice = null;+ this.interruptTask();+ return;+ }+ this.ctrlCPendingForQuestion = true;+ this.transientNotice = "Press Ctrl+C again to exit";+ this.ctrlCPendingForQuestionTimer = setTimeout(() => {+ this.ctrlCPendingForQuestion = false;+ this.ctrlCPendingForQuestionTimer = null;+ this.transientNotice = null;+ this.tui.requestRender();+ }, 1000);+ this.tui.requestRender();+ return;+ }+const handled = handleAppScreenKeyInput(data, {interruptTask: () => this.interruptTask(),exitApp: () => this.exit(),@@ -1073,6 +1106,7 @@ export class AppScreen implements Component, Focusable {if (snapshot.pendingQuestion && this.otherInputMode) {if (matchesKey(data, "escape")) {this.otherInputMode = false;+ this.editor.setText("");this.syncQuestionList(this.state.getSnapshot());this.tui.requestRender();return;@@ -1360,6 +1394,7 @@ export class AppScreen implements Component, Focusable {this.editor.setText(this.draftBeforeQuestion);}this.draftBeforeQuestion = "";+ this.clearCtrlCPendingForQuestion();}this.syncTeamPanelSelection(snapshot);this.syncAnimationLoop(snapshot);