Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote-desktop): 滚轮批次也按当前指针位置保持穿透
Dash5b8893fcb64f
diff --git a/apps/desktop/src/main/remote-desktop/__tests__/inputHost.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/inputHost.test.tsindex f1cd8f67d1..a9a0fd5b6d 100644--- a/apps/desktop/src/main/remote-desktop/__tests__/inputHost.test.ts+++ b/apps/desktop/src/main/remote-desktop/__tests__/inputHost.test.ts@@ -397,6 +397,25 @@ describe('native input lifecycle', () => {await flush();// A batch without pointer events never reports.expect(pointer).toHaveBeenCalledTimes(2);+ // A wheel has no position: it reports where the pointer already is, even before a move.+ host.input([+ { kind: 'scroll', dx: 0, dy: 3 },+ { kind: 'move', x: 0.9, y: 0.9 },+ ]);+ await flush();+ c.child.stdout.emit('data', Buffer.from('ok\n'));+ await flush();+ expect(pointer.mock.calls.at(-1)![0]).toEqual([+ { x: 10, y: 10 },+ { x: 89, y: 89 },+ ]);+ host.input([{ kind: 'scroll', dx: 0, dy: -3 }]);+ await flush();+ c.child.stdout.emit('data', Buffer.from('ok\n'));+ await flush();+ expect(pointer.mock.calls.at(-1)![0]).toEqual([{ x: 89, y: 89 }]);+ // Before any pointer position is known there is nothing to report.+ expect(pointer).toHaveBeenCalledTimes(4);host.stop();c.exit();});diff --git a/apps/desktop/src/main/remote-desktop/inputHost.ts b/apps/desktop/src/main/remote-desktop/inputHost.tsindex 3b99dd0f58..2c05c500e8 100644--- a/apps/desktop/src/main/remote-desktop/inputHost.ts+++ b/apps/desktop/src/main/remote-desktop/inputHost.ts@@ -213,6 +213,8 @@ export class DesktopInputHost {private heartbeat: ReturnType<typeof setInterval> | null = null;private stopping: Promise<void> = Promise.resolve();private privacyPaused = false;+ /** Where the viewer's pointer is once everything queued so far has been injected. */+ private lastPoint: { x: number; y: number } | null = null;private linuxPoint: ((x: number, y: number) => { x: number; y: number }) | null = null;/** 代输入 live view: the helper confines input to this window and maps 0–1 fractions itself. */private window: { windowId: number; pid: number } | null = null;@@ -233,6 +235,7 @@ export class DesktopInputHost {) {}async start(displayId: string, window?: { windowId: number; pid: number }): Promise<void> {this.stop();+ this.lastPoint = null;const platform = this.runtime.platform ?? process.platform;if (platform !== 'darwin' && platform !== 'win32' && platform !== 'linux')throw new Error('DESKTOP_INPUT_UNSUPPORTED');@@ -383,20 +386,22 @@ export class DesktopInputHost {if (events.length === 0) return;const batch = this.activity!.begin(events);const points: { x: number; y: number }[] = [];- this.write(- events.map((event) => {- if (event.kind !== 'move' && event.kind !== 'button') return event;- const point = {- x: Math.round(display.bounds.x + event.x * (display.bounds.width - 1)),- y: Math.round(display.bounds.y + event.y * (display.bounds.height - 1)),- };- points.push(point);- const native = process.platform === 'win32' ? screen.dipToScreenPoint(point) : point;- return { ...event, ...native };- }),- batch,- points,- );+ const native = events.map((event) => {+ if (event.kind !== 'move' && event.kind !== 'button') return event;+ const point = {+ x: Math.round(display.bounds.x + event.x * (display.bounds.width - 1)),+ y: Math.round(display.bounds.y + event.y * (display.bounds.height - 1)),+ };+ points.push(point);+ const mapped = process.platform === 'win32' ? screen.dipToScreenPoint(point) : point;+ return { ...event, ...mapped };+ });+ // A wheel carries no position: it lands where the pointer is when it is injected,+ // which, in serialized order, is the last position queued before this batch.+ if (this.lastPoint && events.some((event) => event.kind === 'scroll'))+ points.unshift(this.lastPoint);+ if (points.length) this.lastPoint = points[points.length - 1];+ this.write(native, batch, points);}private write(events: unknown[],