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): 修复ESC键中断team任务后session无法恢复的问题
hwxiajingb2e7e9cf3c0b
diff --git a/jiuwenswarm/agents/harness/team/team_manager.py b/jiuwenswarm/agents/harness/team/team_manager.pyindex 3967085b03..826eb449c6 100644--- a/jiuwenswarm/agents/harness/team/team_manager.py+++ b/jiuwenswarm/agents/harness/team/team_manager.py@@ -1678,7 +1678,8 @@ class TeamManager:cleaned = await self._destroy_team(session_id)else:cleaned = False- await self._cleanup_runtime_locals(session_id)++ await self._cleanup_runtime_locals(session_id)self.clear_active_runtime(session_id)self.clear_pending_runtime(session_id)@@ -1743,10 +1744,7 @@ class TeamManager:exc,)- if has_local_team_runtime:- cleaned = await self._destroy_team(session_id)- else:- cleaned = False+ cleaned = False# Cleanup locals (watcher, stream, monitor, skill rails)await self._cleanup_runtime_locals(session_id)diff --git a/jiuwenswarm/channels/tui/frontend/src/app-state.ts b/jiuwenswarm/channels/tui/frontend/src/app-state.tsindex a8b588f6c8..be712ef5e6 100644--- a/jiuwenswarm/channels/tui/frontend/src/app-state.ts+++ b/jiuwenswarm/channels/tui/frontend/src/app-state.ts@@ -894,7 +894,7 @@ export class CliPiAppState {return null;}if (this.streamingState !== StreamingState.Idle) {- this.sendEventOnly("chat.interrupt", { intent: "cancel" });+ this.sendEventOnly("chat.interrupt", { intent: "cancel", mode: this.mode });}const requestId = this.sendEventOnly("chat.send",@@ -939,6 +939,7 @@ export class CliPiAppState {const requestId = this.sendEventOnly("chat.interrupt", {intent: "supplement",new_input: trimmed,+ mode: this.mode,...(attachments?.length ? { attachments } : {}),});this.lastError = null;@@ -978,13 +979,23 @@ export class CliPiAppState {// Set local interrupt flag immediately for long-running command detectionthis.interruptRequested = true;const hadLocalWork = this.getSnapshot().cancellableWork;- this.sendEventOnly("chat.interrupt", { intent: "cancel" });+ this.sendEventOnly("chat.interrupt", { intent: "cancel", mode: this.mode });if (options?.showNotice !== false && hadLocalWork) {this.addItem(addInfo(this.sessionId, "Request Interrupted", "i"));}return true;}+ pause(): boolean {+ if (this.connectionStatus !== "connected") {+ return false;+ }+ this.interruptRequested = true;+ const hadLocalWork = this.getSnapshot().cancellableWork;+ this.sendEventOnly("chat.interrupt", { intent: "pause", mode: this.mode });+ return hadLocalWork;+ }+resume(): void {this.sendEventOnly("chat.resume", {});}diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/cancel.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/cancel.tsindex a615fdad11..31335cbae0 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/cancel.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/cancel.ts@@ -10,7 +10,7 @@ export function createCancelCommand(): SlashCommand {isSafeConcurrent: true,kind: CommandKind.BUILT_IN,action: (ctx) => {- ctx.sendEventOnly("chat.interrupt", { intent: "cancel" });+ ctx.sendEventOnly("chat.interrupt", { intent: "cancel", mode: ctx.mode });ctx.addItem(addInfo(ctx.sessionId, "Task interrupted", "i"));},};diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.tsindex df953bba1b..edf0feb761 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts@@ -791,7 +791,11 @@ export class AppScreen implements Component, Focusable {this.configEditorState !== null;if (!pendingQuestion && snapshot.cancellableWork && matchesKey(data, "escape") && !hasOverlay) {- this.state.cancel();+ if (isTeamMode(snapshot.mode)) {+ this.state.pause();+ } else {+ this.state.cancel();+ }return;}