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: enhance mouse tracking logic for terminal interactions
zhengkailan91df25472280
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.tsindex 1d48345966..99cd59e0ed 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts@@ -126,15 +126,18 @@ const CONFIRM_TOOL_RE = /(?:Tool|工具)\s*:\s*`([^`]+)`/i;/*** Terminal mouse reporting takes ownership of drag events, which prevents the- * terminal's native text selection and copy behaviour. Keep it scoped to UI- * states that actually need mouse events; a scrollable transcript can still be- * navigated with the keyboard without making the whole chat unselectable.+ * terminal's native text selection and copy behaviour. Scope it to UI states+ * that actually need mouse events (pending questions / interactive overlays)+ * AND to scrollable transcripts: a transcript taller than the viewport needs+ * mouse tracking so the wheel can page history, which costs native selection+ * only while content overflows. Short transcripts stay selectable.*/export function shouldCaptureTerminalMouse(pendingQuestionActive: boolean,interactiveOverlayActive: boolean,+ transcriptMayScroll: boolean,): boolean {- return pendingQuestionActive || interactiveOverlayActive;+ return pendingQuestionActive || interactiveOverlayActive || transcriptMayScroll;}const CONFIRM_ACTION_RE = /\*\*(?:Agent wants to|Tool `[^`]+` requires your approval)([^*]*)\*\*/i;const PLAN_REJECT_INPUT_RE = /(\s+\[ .+ \])$/;@@ -3041,6 +3044,10 @@ export class AppScreen implements Component, Focusable {pendingInput,pendingInputBaseline,).length;+ const approximateFixedHeight =+ questionLines.length + editorLines.length + composerPreviewLines.length + 2;+ const transcriptMayScroll =+ transcriptLineCount > Math.max(0, this.tui.terminal.rows - approximateFixedHeight);const interactiveOverlayActive =this.startupPromptList !== null ||this.resumeSessionList !== null ||@@ -3055,7 +3062,11 @@ export class AppScreen implements Component, Focusable {this.configEditorState !== null ||this.questionList !== null;this.setMouseTrackingEnabled(- shouldCaptureTerminalMouse(snapshot.pendingQuestion !== null, interactiveOverlayActive),+ shouldCaptureTerminalMouse(+ snapshot.pendingQuestion !== null,+ interactiveOverlayActive,+ transcriptMayScroll,+ ),);if (this.transcriptScrollOffset > 0 &&diff --git a/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs b/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjsindex aefdfbbc90..cc9718f262 100644--- a/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs+++ b/jiuwenswarm/channels/tui/frontend/tests/run-tests.mjs@@ -145,11 +145,14 @@ assert.ok(.includes("完整审计记录"),);-// A long/scrollable transcript must not capture drag events: users should be-// able to select and copy completed responses with the terminal's native UI.-assert.equal(shouldCaptureTerminalMouse(false, false), false);-assert.equal(shouldCaptureTerminalMouse(true, false), true);-assert.equal(shouldCaptureTerminalMouse(false, true), true);+// Mouse tracking is enabled for pending questions, interactive overlays, and+// scrollable transcripts (so the wheel can page history). When the transcript+// fits on screen (transcriptMayScroll=false) and no overlay is active, tracking+// stays off to preserve the terminal's native text selection / copy.+assert.equal(shouldCaptureTerminalMouse(false, false, false), false);+assert.equal(shouldCaptureTerminalMouse(true, false, false), true);+assert.equal(shouldCaptureTerminalMouse(false, true, false), true);+assert.equal(shouldCaptureTerminalMouse(false, false, true), true);const teamSnapshot = {connectionStatus: "connected",