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): allow portal consent in desktop viewer deadline
Dash Huange07e53c33e2d
diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerLifecycle.test.ts b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerLifecycle.test.tsindex a777ee6f7d..8213e6d5c2 100644--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerLifecycle.test.ts+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerLifecycle.test.ts@@ -39,6 +39,7 @@ async function fixture(delayStart?: boolean;busy?: boolean;alwaysTimeout?: boolean;+ portal?: boolean;} = {},) {const start = deferred();@@ -63,7 +64,7 @@ async function fixture(canControl: true,connectionTakeover: true,automaticReconnect: options.legacyTimeout ? undefined : true,- displays: ['one', 'two', 'three'].map((id) => ({+ displays: (options.portal ? ['wayland-portal'] : ['one', 'two', 'three']).map((id) => ({id,name: id,width: 1280,@@ -165,6 +166,43 @@ it('times out a lease that never presents a frame and releases only that lease',expect(snapshot.error).toBe('connectionTimeout');});+it.each(['streaming', 'framePresented'])(+ 'allows portal consent after 60 seconds before %s',+ async (type) => {+ const current = await fixture({ portal: true });+ await vi.advanceTimersByTimeAsync(90_000);+ expect(snapshot).toMatchObject({ error: null, ready: false });+ expect(current.hostLease()).toBe('lease-wayland-portal');+ runtime.post?.({ type, epoch: 'lease-wayland-portal' });+ await vi.advanceTimersByTimeAsync(200_000);+ expect(snapshot).toMatchObject({ error: null, ready: true });+ expect(current.requests.filter((r) => r.op === 'stop')).toEqual([]);+ },+);++it('keeps the portal deadline bounded across fallback and rejects a late frame', async () => {+ const current = await fixture({ portal: true });+ await vi.advanceTimersByTimeAsync(90_000);+ runtime.post?.({ type: 'fallback', epoch: 'lease-wayland-portal' });+ await vi.advanceTimersByTimeAsync(89_999);+ expect(snapshot.error).toBeNull();+ await vi.advanceTimersByTimeAsync(1);+ expect(snapshot.error).toBe('connectionTimeout');+ expect(current.hostLease()).toBeNull();+ runtime.post?.({ type: 'streaming', epoch: 'lease-wayland-portal' });+ expect(snapshot.ready).toBe(false);+});++it('retires a portal start arriving after the extended deadline', async () => {+ const current = await fixture({ portal: true, delayStart: true });+ await vi.advanceTimersByTimeAsync(180_000);+ expect(snapshot.error).toBe('connectionTimeout');+ current.start.resolve();+ await vi.advanceTimersByTimeAsync(0);+ expect(current.hostLease()).toBeNull();+ expect(snapshot).toMatchObject({ error: 'connectionTimeout', ready: false });+});+it('retires a start reply arriving after the connection deadline', async () => {const current = await fixture({ delayStart: true });await vi.advanceTimersByTimeAsync(60_000);diff --git a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts b/apps/desktop/src/renderer/features/remote-desktop/viewerController.tsindex 7b30e5d832..e4bf07a79f 100644--- a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts+++ b/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts@@ -36,6 +36,14 @@ export interface ViewerSnapshot {ready: boolean;}+function connectionBudget(caps: RemoteDesktopCapabilities | null): number {+ // Match Mobile: system consent has its own two-minute host deadline.+ return (+ REMOTE_DESKTOP_CONNECTION_TIMEOUT_MS ++ (caps?.displays.some((display) => display.id === 'wayland-portal') ? 120_000 : 0)+ );+}+/** Desktop presentation adapter. Reuses the Mobile lease, browser media and* input queue; only window visibility and native clipboard live on Desktop.*/@@ -112,7 +120,15 @@ export class DesktopViewerController {];}private publish(patch: Partial<ViewerSnapshot>): void {+ const previousBudget = connectionBudget(this.state.caps);this.state = { ...this.state, ...patch };+ const budget = connectionBudget(this.state.caps);+ // Capabilities arrive after the initial timer starts. Change its budget+ // only when the backend changes, never on repeated caps or media retries.+ if (budget !== previousBudget && this.connectionTimer !== null) {+ clearTimeout(this.connectionTimer);+ this.connectionTimer = null;+ }const waiting =this.scope.active &&!this.disposed &&@@ -125,7 +141,7 @@ export class DesktopViewerController {// Transient failures and media fallback must not renew the total budget.this.connectionTimer = setTimeout(() => {this.fail(new Error('DESKTOP_CONNECTION_TIMEOUT'));- }, REMOTE_DESKTOP_CONNECTION_TIMEOUT_MS);+ }, budget);}if (!this.disposed) this.changed(this.state);}