The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(desktop): use pane-local coordinates for terminal scrolling (#450)
Leo8e48089558df
diff --git a/desktop/test/swarm_terminal_scroll_test.dart b/desktop/test/swarm_terminal_scroll_test.dartnew file mode 100644index 000000000..bfe8c441e--- /dev/null+++ b/desktop/test/swarm_terminal_scroll_test.dart@@ -0,0 +1,90 @@+import 'dart:convert';++import 'package:flutter/gestures.dart';+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/state/pane_preset.dart';+import 'package:harness/terminal/terminal_binary.dart';+import 'package:harness/widgets/pane_grid.dart';+import 'package:xterm/xterm.dart';++import 'swarm_state_test.dart' show createApp;+import 'swarm_screen_test.dart' show terminal;++void main() {+ for (final alt in [false, true]) {+ testWidgets('four panes scroll ${alt ? 'TUI' : 'history'} with wheel', (+ tester,+ ) async {+ final app = createApp();+ app.machineStates['m']!.nodeOnline = true;+ final inputs = List.generate(4, (_) => <TerminalBinaryFrame>[]);+ for (var i = 0; i < 4; i++) {+ final session = terminal('a$i', inputs[i]);+ session.terminal.write(+ List.generate(200, (n) => 'pane $i line $n\r\n').join(),+ );+ if (alt) session.terminal.write('\x1b[?1049h\x1b[?1000h\x1b[?1006h');+ app.adoptSessionForTest(session);+ }+ tester.view.devicePixelRatio = 1;+ tester.view.physicalSize = const Size(1200, 800);+ addTearDown(tester.view.reset);+ await tester.pumpWidget(+ MaterialApp(home: PaneGrid(notifier: app, swarmMode: true)),+ );+ await tester.pump();+ for (final preset in PanePreset.forCount(4)) {+ app.setPreset(4, preset);+ await tester.pump();+ for (var i = 0; i < 4; i++) {+ final view = find.byWidgetPredicate(+ (w) =>+ w is TerminalView &&+ w.terminal == app.panes[i].session!.terminal,+ );+ await tester.ensureVisible(view);+ await tester.pump();+ final controller = tester+ .widget<TerminalView>(view)+ .scrollController!;+ if (!alt) controller.jumpTo(controller.position.maxScrollExtent);+ await tester.pump();+ inputs[i].clear();+ final before = controller.offset;+ final center = tester.getCenter(view);+ final pointer = TestPointer(2, PointerDeviceKind.mouse);+ await tester.sendEventToBinding(pointer.hover(center));+ await tester.sendEventToBinding(pointer.scroll(const Offset(0, -60)));+ await tester.pump(const Duration(milliseconds: 400));+ if (alt) {+ expect(+ inputs[i],+ isNotEmpty,+ reason: '${preset.id} pane $i must send scroll to TUI',+ );+ final render = tester.state<TerminalViewState>(view).renderTerminal;+ final cell = render.getCellOffset(render.globalToLocal(center));+ final reports = inputs[i]+ .map((frame) => utf8.decode(frame.bytes))+ .join();+ expect(+ reports,+ contains('\x1b[<64;${cell.x + 1};${cell.y + 1}M'),+ reason:+ '${preset.id} pane $i must report pane-local mouse coordinates',+ );+ } else {+ expect(+ controller.offset,+ lessThan(before),+ reason: '${preset.id} pane $i must scroll history',+ );+ }+ }+ }+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ });+ }+}diff --git a/desktop/third_party/xterm/README.autonomous.md b/desktop/third_party/xterm/README.autonomous.mdindex 2e37b1389..9aeba298a 100644--- a/desktop/third_party/xterm/README.autonomous.md+++ b/desktop/third_party/xterm/README.autonomous.md@@ -13,6 +13,14 @@ fix and the regression in `test/terminal_session_test.dart` passes against it.## Local patches+- **Pane-local wheel coordinates** (`lib/src/terminal_view.dart`). Convert the+ pointer's global position to renderer-local coordinates before constructing+ alternate-screen mouse-wheel reports. Offset panes otherwise report the+ wrong cell (often clamped to the bottom/right edge), so a TUI can receive a+ wheel event over its prompt instead of its scrollable content. Regression:+ `test/swarm_terminal_scroll_test.dart` checks every four-pane preset, exact+ emitted coordinates, and normal-buffer history scrolling.+- **Browser accessibility input and editor switching**(`lib/src/ui/custom_text_edit.dart`). The browser's text-input strategy needsan editable semantics node when accessibility is enabled. The custom adapterdiff --git a/desktop/third_party/xterm/lib/src/terminal_view.dart b/desktop/third_party/xterm/lib/src/terminal_view.dartindex 9edca8c25..30b04c84d 100644--- a/desktop/third_party/xterm/lib/src/terminal_view.dart+++ b/desktop/third_party/xterm/lib/src/terminal_view.dart@@ -298,7 +298,9 @@ class TerminalViewState extends State<TerminalView> {terminal: widget.terminal,simulateScroll: widget.simulateScroll,onAltBufferScroll: widget.onAltBufferScroll,- getCellOffset: (offset) => renderTerminal.getCellOffset(offset),+ // Pointer events carry window coordinates; each pane owns a local grid.+ getCellOffset: (offset) =>+ renderTerminal.getCellOffset(renderTerminal.globalToLocal(offset)),getLineHeight: () => renderTerminal.lineHeight,child: child,);