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): 手机画中画期间保留电脑防窥与静音
Dasha45d9b39a030
diff --git a/apps/desktop/src/main/remote-desktop/__tests__/controller.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/controller.test.tsindex e6a7c25831..68e0ef9761 100644--- a/apps/desktop/src/main/remote-desktop/__tests__/controller.test.ts+++ b/apps/desktop/src/main/remote-desktop/__tests__/controller.test.ts@@ -1624,9 +1624,7 @@ describe('remote desktop authority and lifecycle', () => {await h.controller.request('phone', { op: 'hostMute', lease, enabled: true });await h.controller.request('phone', { op: 'clipboardSync', lease, enabled: true });if (failed)- vi.mocked(h.deps.startInput).mockRejectedValueOnce(- new Error('DESKTOP_INPUT_UNAVAILABLE'),- );+ vi.mocked(h.deps.startInput).mockRejectedValueOnce(new Error('DESKTOP_INPUT_UNAVAILABLE'));await h.controller.releaseControl(true);expect(h.deps.stopPrivacyScreen).toHaveBeenCalledTimes(failed ? 1 : 0);expect(h.deps.stopHostMute).toHaveBeenCalledTimes(failed ? 1 : 0);@@ -1635,7 +1633,7 @@ describe('remote desktop authority and lifecycle', () => {},);});-it.each(['control', 'presentation', 'failure', 'stop'] as const)(+it.each(['control', 'failure', 'stop'] as const)('releases input before failing safety restoration on %s, without stopping replacement input',async (kind) => {const h = harness(),@@ -1652,8 +1650,7 @@ it.each(['control', 'presentation', 'failure', 'stop'] as const)(let result: Promise<unknown> | undefined;if (kind === 'failure') h.controller.releaseControl();else if (kind === 'stop') h.controller.stop();- else- result = h.controller.request('phone', { op: kind, lease, enabled: kind === 'presentation' });+ else result = h.controller.request('phone', { op: kind, lease, enabled: false });// Critical cleanup cannot wait for slow/failing operating-system restoration.expect(h.deps.stopInput).toHaveBeenCalledOnce();expect(h.deps.stopPrivacyScreen).toHaveBeenCalledOnce();@@ -1668,7 +1665,7 @@ it.each(['control', 'presentation', 'failure', 'stop'] as const)(expect(h.controller.state?.controlling).toBe(true);},);-it.each(['control', 'presentation', 'failure'] as const)(+it.each(['control', 'failure'] as const)('revokes safety effects on %s control loss',async (kind) => {const h = harness(),@@ -1687,12 +1684,49 @@ it.each(['control', 'presentation', 'failure'] as const)(await h.controller.request('phone', { op: 'privacyScreen', lease, enabled: true });await h.controller.request('phone', { op: 'hostMute', lease, enabled: true });if (kind === 'failure') h.controller.releaseControl();- else await h.controller.request('phone', { op: kind, lease, enabled: kind === 'presentation' });+ else await h.controller.request('phone', { op: kind, lease, enabled: false });expect(h.deps.stopPrivacyScreen).toHaveBeenCalledOnce();expect(h.deps.stopHostMute).toHaveBeenCalledOnce();expect(h.deps.stopVideo).not.toHaveBeenCalled();},);+it('keeps privacy and host mute through phone picture-in-picture, stopping only clipboard sync', async () => {+ const h = harness(),+ { lease } = await h.start();+ let privacyCurrent!: () => boolean;+ h.deps.privacyScreen = vi.fn(async (_enabled, current) => {+ privacyCurrent = current;+ });+ h.deps.hostMute = vi.fn(async () => {});+ h.deps.stopPrivacyScreen = vi.fn();+ h.deps.stopHostMute = vi.fn(async () => {});+ h.deps.clipboardVersion = vi.fn(async () => '1');+ h.deps.stopClipboardVersion = vi.fn();+ await h.controller.request('phone', { op: 'control', lease, enabled: true });+ await h.controller.request('phone', { op: 'privacyScreen', lease, enabled: true });+ await h.controller.request('phone', { op: 'hostMute', lease, enabled: true });+ await h.controller.request('phone', { op: 'clipboardSync', lease, enabled: true });+ await h.controller.request('phone', { op: 'presentation', lease, enabled: true });+ expect(h.controller.state?.controlling).toBe(false);+ // Long-lived mask owners (Linux) poll this while the phone shows PiP.+ expect(privacyCurrent()).toBe(true);+ expect(h.deps.stopPrivacyScreen).not.toHaveBeenCalled();+ expect(h.deps.stopHostMute).not.toHaveBeenCalled();+ expect(h.deps.stopClipboardVersion).toHaveBeenCalledOnce();+ await expect(h.controller.request('phone', { op: 'clipboardVersion', lease })).rejects.toThrow(+ 'DESKTOP_CLIPBOARD_UNAVAILABLE',+ );+ // Returning from PiP re-sends the unchanged preference and joins the live mask.+ await h.controller.request('phone', { op: 'presentation', lease, enabled: false });+ await h.controller.request('phone', { op: 'control', lease, enabled: true });+ await expect(+ h.controller.request('phone', { op: 'privacyScreen', lease, enabled: true }),+ ).resolves.toEqual({ enabled: true });+ expect(h.deps.privacyScreen).toHaveBeenCalledOnce();+ await h.controller.request('phone', { op: 'stop', lease });+ expect(h.deps.stopPrivacyScreen).toHaveBeenCalledOnce();+ expect(privacyCurrent()).toBe(false);+});it('joins duplicate privacy initialization and invalidates it on control loss', async () => {const h = harness(),{ lease } = await h.start();diff --git a/apps/desktop/src/main/remote-desktop/controller.ts b/apps/desktop/src/main/remote-desktop/controller.tsindex 3962a3cee0..2bc494e811 100644--- a/apps/desktop/src/main/remote-desktop/controller.ts+++ b/apps/desktop/src/main/remote-desktop/controller.ts@@ -222,12 +222,15 @@ export class RemoteDesktopController {private privacyGeneration = 0;private privacyOperation: { enabled: boolean; promise: Promise<{ enabled: boolean }> } | null =null;- private async clearSafety(): Promise<void> {- this.privacyGeneration++;- this.privacyOperation = null;+ private stopClipboardSync(): void {this.syncGeneration++;this.deps.stopClipboardVersion?.();if (this.active) this.active.clipboardSync = false;+ }+ private async clearSafety(): Promise<void> {+ this.privacyGeneration++;+ this.privacyOperation = null;+ this.stopClipboardSync();try {this.deps.stopPrivacyScreen?.();} finally {@@ -956,11 +959,11 @@ export class RemoteDesktopController {if (this.privacyOperation?.enabled === request.enabled)return this.privacyOperation.promise;const generation = ++this.privacyGeneration;+ // Masks outlive control while PiP views the lease; every revocation+ // that must expose the desktop clears safety and bumps the generation.const current = () => {this.tick();- return (- this.active === active && active.controlling && generation === this.privacyGeneration- );+ return this.active === active && generation === this.privacyGeneration;};const promise = this.deps.privacyScreen(request.enabled, current)@@ -1119,7 +1122,10 @@ export class RemoteDesktopController {case 'presentation': {this.setBackgroundViewing(active, request.enabled);if (request.enabled) {- await this.revokeControl();+ // PiP keeps watching the same lease: the masked, muted desktop stays+ // protected; only input and clipboard sync need control.+ await this.revokeControl(true);+ this.stopClipboardSync();} else {this.deps.changed();}