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): require native capture for Linux viewer displays
Dash Huang951bb1d749d0
diff --git a/apps/desktop/src/main/remote-desktop/__tests__/linuxViewerDisplay.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/linuxViewerDisplay.test.tsindex 882ae56046..e3f303fa24 100644--- a/apps/desktop/src/main/remote-desktop/__tests__/linuxViewerDisplay.test.ts+++ b/apps/desktop/src/main/remote-desktop/__tests__/linuxViewerDisplay.test.ts@@ -15,6 +15,7 @@ const h = vi.hoisted(() => ({vi.mock('electron', () => ({ app: { isPackaged: false, getAppPath: () => '/test/app' } }));vi.mock('node:fs', () => ({ accessSync: vi.fn(), constants: { X_OK: 1, R_OK: 4 } }));vi.mock('node:child_process', () => ({ spawn: () => h.child }));+vi.mock('../hyprlandCapture', () => ({ supportsHyprlandCapture: () => true }));vi.mock('../linuxDesktop', () => ({supportsLinuxDisplay: () => true,linuxMonitor: h.monitor,diff --git a/apps/desktop/src/main/remote-desktop/__tests__/viewerDisplaySupport.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/viewerDisplaySupport.test.tsindex d5d6c84a09..18bdcbc186 100644--- a/apps/desktop/src/main/remote-desktop/__tests__/viewerDisplaySupport.test.ts+++ b/apps/desktop/src/main/remote-desktop/__tests__/viewerDisplaySupport.test.ts@@ -4,11 +4,13 @@ const mocks = vi.hoisted(() => ({app: { isPackaged: false, getAppPath: () => '/fake/app', getPath: () => '/fake/profile' },exec: vi.fn(),access: vi.fn(),+ accessSync: vi.fn(),displays: vi.fn(),}));vi.mock('electron', () => ({ app: mocks.app, screen: { getAllDisplays: mocks.displays } }));vi.mock('node:child_process', () => ({ execFile: vi.fn(), spawn: vi.fn() }));vi.mock('node:util', () => ({ promisify: () => mocks.exec }));+vi.mock('node:fs', () => ({ accessSync: mocks.accessSync, constants: { X_OK: 1, R_OK: 4 } }));vi.mock('node:fs/promises', () => ({default: {readFile: async () => 'source',@@ -23,13 +25,35 @@ beforeEach(() => {mocks.app.isPackaged = false;mocks.exec.mockReset().mockResolvedValue({ stdout: '{"available":true}' });mocks.access.mockReset().mockResolvedValue(undefined);+ mocks.accessSync.mockReset();vi.spyOn(process, 'platform', 'get').mockReturnValue('darwin');});afterEach(() => {+ vi.unstubAllEnvs();vi.restoreAllMocks();vi.useRealTimers();});+it.each(['grim', 'hyprctl', 'python3', 'linux-viewer-display.py', null])(+ 'advertises Linux viewer displays only with all dependencies (missing=%s)',+ async (missing) => {+ vi.spyOn(process, 'platform', 'get').mockReturnValue('linux');+ vi.stubEnv('XDG_SESSION_TYPE', 'wayland');+ vi.stubEnv('HYPRLAND_INSTANCE_SIGNATURE', 'test');+ mocks.accessSync.mockImplementation((file: string) => {+ if (missing && file.endsWith(missing)) throw new Error('missing dependency');+ });+ const { viewerDisplaySupported, createViewerDisplay } = await import('../viewerDisplay');+ expect(await viewerDisplaySupported()).toBe(missing === null);+ if (missing) {+ await expect(createViewerDisplay('wayland-portal', () => true, vi.fn())).rejects.toThrow(+ 'DESKTOP_VIEWER_DISPLAY_UNAVAILABLE',+ );+ expect(mocks.exec).not.toHaveBeenCalled();+ }+ },+);+it('waits for Electron to observe restored geometry and mirror removal', async () => {vi.useFakeTimers();const { waitForDisplayRestore } = await import('../viewerDisplay');diff --git a/apps/desktop/src/main/remote-desktop/linuxViewerDisplay.ts b/apps/desktop/src/main/remote-desktop/linuxViewerDisplay.tsindex f42e2cd458..c203c455a0 100644--- a/apps/desktop/src/main/remote-desktop/linuxViewerDisplay.ts+++ b/apps/desktop/src/main/remote-desktop/linuxViewerDisplay.ts@@ -5,6 +5,7 @@ import path from 'node:path';import type { RemoteDesktopDisplay } from '@cindy/device-link';import type { ViewerDisplayHandle } from './viewerDisplay';import { linuxDisplay, linuxMonitor, linuxMonitors, supportsLinuxDisplay } from './linuxDesktop';+import { supportsHyprlandCapture } from './hyprlandCapture';function script(): string {return app.isPackaged@@ -12,7 +13,8 @@ function script(): string {: path.join(app.getAppPath(), 'native', 'remote-desktop', 'linux-viewer-display.py');}export function supportsLinuxViewerDisplay(): boolean {- if (!supportsLinuxDisplay()) return false;+ // Portal capture cannot select the helper's Hyprland-only display IDs.+ if (!supportsHyprlandCapture() || !supportsLinuxDisplay()) return false;try {accessSync('/usr/bin/python3', constants.X_OK);accessSync(script(), constants.R_OK);diff --git a/docs/remote-desktop.md b/docs/remote-desktop.mdindex c3b22429b4..45b98d6102 100644--- a/docs/remote-desktop.md+++ b/docs/remote-desktop.md@@ -537,7 +537,10 @@ it to the original output. A Python standard-library helper owns the mirror andworkspace moves. EOF, missed heartbeats and termination restore the source andremove only its own output; restoration retries keep the in-memory snapshot alivethrough temporary compositor errors. A missing source is treated as unplugged.-The helper requires a running user compositor and Python 3. It does not provide+The helper requires a running user compositor, Python 3 and the native Hyprland+capture prerequisites (including `grim`). Capability advertisement and creation+share this check: portal capture cannot target its Hyprland-only display IDs.+It does not providepre-login access or a physical privacy screen. Explicit mirror/special-workspaceconfigurations are rejected rather than being silently replaced. Live scratchoutput tests cover resize, EOF, heartbeat timeout and SIGTERM cleanup.