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): 桌面版显示桌面按钮生效,工具栏与手机端对齐 (#5521)
Dashc3ab4d672cde
diff --git a/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx b/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsxindex efd83e49b0..7a939daf82 100644--- a/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx+++ b/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx@@ -4,12 +4,11 @@ import {SlidersHorizontal,Clipboard,Shield,- AppWindow,- LayoutGrid,ZoomIn,ZoomOut,X,Monitor,+ createLucideIcon,} from 'lucide-react';import {REMOTE_DESKTOP_VIDEO_QUALITIES,@@ -176,6 +175,12 @@ export function RemoteDesktopViewerWindow() {setSelectOpen(open);if (open) controller.current?.releaseInput();};+ const workspaceAction = (action: 'workspaceLeft' | 'workspaceRight' | 'omarchyMenu') => {+ const owner = generation.current;+ void controller.current?.workspaceAction(action).catch(() => {+ if (owner === generation.current) setNotice(t('remoteDesktop.viewer.actionFailed'));+ });+ };const action = 'remote-viewer-action';const network = state?.ready && (<span className="remote-viewer-network">@@ -289,30 +294,62 @@ export function RemoteDesktopViewerWindow() {role="group"aria-label={t('remoteDesktop.viewer.controlGroup')}>- <ViewerTool- label={t('remoteDesktop.allWindows')}- disabled={!state?.controlling || state.controlPending}- onClick={() =>- controller.current?.keys(- state?.caps?.platform === 'darwin'- ? ['ControlLeft', 'ArrowUp']- : ['MetaLeft', 'Tab'],- )- }- >- <LayoutGrid size={16} />- </ViewerTool>- <ViewerTool- label={t('remoteDesktop.showDesktop')}- disabled={!state?.controlling || state.controlPending}- onClick={() =>- controller.current?.keys(- state?.caps?.platform === 'darwin' ? ['MetaLeft', 'F3'] : ['MetaLeft', 'KeyD'],- )- }- >- <AppWindow size={16} />- </ViewerTool>+ {state?.caps?.workspaceNavigation ? (+ <>+ <ViewerTool+ label={t('remoteDesktop.workspaceLeft')}+ disabled={!state.controlling || state.controlPending}+ onClick={() => workspaceAction('workspaceLeft')}+ >+ <WorkspaceLeftIcon size={16} />+ </ViewerTool>+ <ViewerTool+ label={t('remoteDesktop.workspaceRight')}+ disabled={!state.controlling || state.controlPending}+ onClick={() => workspaceAction('workspaceRight')}+ >+ <WorkspaceRightIcon size={16} />+ </ViewerTool>+ </>+ ) : (+ <>+ <ViewerTool+ label={t('remoteDesktop.allWindows')}+ disabled={!state?.controlling || state.controlPending}+ onClick={() =>+ controller.current?.keys(+ state?.caps?.platform === 'darwin'+ ? ['ControlLeft', 'ArrowUp']+ : ['MetaLeft', 'Tab'],+ )+ }+ >+ <AllWindowsIcon size={16} />+ </ViewerTool>+ <ViewerTool+ label={t('remoteDesktop.showDesktop')}+ disabled={!state?.controlling || state.controlPending}+ onClick={() =>+ // Cmd+F3 only works from the physical Mission Control key; a+ // synthesized F3 keycode never triggers it. F11 is the default.+ controller.current?.keys(+ state?.caps?.platform === 'darwin' ? ['F11'] : ['MetaLeft', 'KeyD'],+ )+ }+ >+ <ShowDesktopIcon size={16} />+ </ViewerTool>+ </>+ )}+ {state?.caps?.omarchyMenu && (+ <ViewerTool+ label={t('remoteDesktop.omarchyMenu')}+ disabled={!state.controlling || state.controlPending}+ onClick={() => workspaceAction('omarchyMenu')}+ >+ <OmarchyMenuIcon size={16} />+ </ViewerTool>+ )}</div><div className="remote-viewer-zoom-group" role="group" aria-label={t('remoteDesktop.fit')}><ViewerTool@@ -755,6 +792,47 @@ export function RemoteDesktopViewerWindow() {);}+// Same glyphs as Mobile's remote desktop toolbar+// (apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx).+const WorkspaceLeftIcon = createLucideIcon('RemoteDesktopWorkspaceLeft', [+ ['rect', { x: '3', y: '3', width: '18', height: '14', rx: '2', key: 'screen' }],+ ['path', { d: 'M12 17v4M8 21h8M15 10H9m3-3-3 3 3 3', key: 'direction' }],+]);++const WorkspaceRightIcon = createLucideIcon('RemoteDesktopWorkspaceRight', [+ ['rect', { x: '3', y: '3', width: '18', height: '14', rx: '2', key: 'screen' }],+ ['path', { d: 'M12 17v4M8 21h8M9 10h6m-3-3 3 3-3 3', key: 'direction' }],+]);++// Official Omarchy mark: https://omarchy.org/brand/omarchy-logo.svg+// Preserve its path and proportions; inherit the toolbar's Light/Dark foreground.+const OmarchyMenuIcon = createLucideIcon('RemoteDesktopOmarchyMenu', [+ [+ 'path',+ {+ d: 'm1200 1200h-480v-80h400v-1040h-479.996v160h-400v720h720v-720h-80v-80h159.996v880h-400v160h-640v-1200h1200zm-1120-80h480v-80h-400l.004-400h-80.004zm0-560h80.004v-400h400v-80h-480.004z',+ transform: 'scale(0.02)',+ fill: 'currentColor',+ fillRule: 'evenodd',+ clipRule: 'evenodd',+ stroke: 'none',+ key: 'official-mark',+ },+ ],+]);++const AllWindowsIcon = createLucideIcon('RemoteDesktopAllWindows', [+ ['path', { d: 'M4 16a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v1', key: 'rear' }],+ ['rect', { x: '7', y: '8', width: '15', height: '13', rx: '2', key: 'front' }],+ ['path', { d: 'M7 12h15', key: 'titlebar' }],+]);++const ShowDesktopIcon = createLucideIcon('RemoteDesktopShowDesktop', [+ ['rect', { x: '2', y: '3', width: '20', height: '14', rx: '2', key: 'screen' }],+ ['path', { d: 'M8 13h8', key: 'dock' }],+ ['path', { d: 'M12 17v4M8 21h8', key: 'stand' }],+]);+function ZoomModeIcon({ actual = false }: { actual?: boolean }) {return (<svgdiff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.tsindex ef40a45312..85551f8c13 100644--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts@@ -295,6 +295,33 @@ it('shows a reconnectable error when host input is busy during control acquisitiexpect(snapshot).toMatchObject({ ready: true, controlling: true, error: null });});+it('sends workspace actions on the current lease only while controlling', async () => {+ const f = await fixture();+ present();+ const request = vi.spyOn(f.api, 'request');+ const sent = () =>+ request.mock.calls.flatMap(([, value]) => (value.op === 'windowAction' ? [value] : []));+ await controller.workspaceAction('workspaceLeft');+ await controller.workspaceAction('omarchyMenu');+ expect(sent()).toEqual([+ { op: 'windowAction', action: 'workspaceLeft', lease: 'lease' },+ { op: 'windowAction', action: 'omarchyMenu', lease: 'lease' },+ ]);+ request.mockRejectedValueOnce(new Error('[PRECONDITION_FAILED] DESKTOP_INPUT_UNSUPPORTED'));+ await expect(controller.workspaceAction('workspaceRight')).rejects.toThrow(+ 'DESKTOP_INPUT_UNSUPPORTED',+ );+ controller.dispose();++ // The lease is live but control is still pending: nothing may reach the host.+ const pending = await fixture(deferred<{ controlling: boolean }>().promise);+ present();+ expect(snapshot).toMatchObject({ controlling: false, controlPending: true });+ const pendingRequest = vi.spyOn(pending.api, 'request');+ await controller.workspaceAction('workspaceRight');+ expect(pendingRequest.mock.calls.some(([, value]) => value.op === 'windowAction')).toBe(false);+});+it('stops input and viewing after input queue overflow', async () => {await fixture();present();diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsxindex 9c8553b84d..1eb59e91e0 100644--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx@@ -13,6 +13,8 @@ const lifecycle = vi.hoisted(() => ({zoom: vi.fn(),fit: vi.fn(),actualSize: vi.fn(),+ keys: vi.fn(),+ workspaceAction: vi.fn(async () => {}),update: null as ((state: ViewerSnapshot) => void) | null,}));vi.mock('../viewerController', () => ({@@ -31,6 +33,8 @@ vi.mock('../viewerController', () => ({zoom = lifecycle.zoom;fit = lifecycle.fit;actualSize = lifecycle.actualSize;+ keys = lifecycle.keys;+ workspaceAction = lifecycle.workspaceAction;close = () => this._api.close(1);},}));@@ -240,6 +244,32 @@ it('hides view-only controls and enables desktop actions only after control is c};await act(async () => lifecycle.update?.(supported));expect(desktop.disabled).toBe(false);+ fireEvent.click(desktop);+ expect(lifecycle.keys).toHaveBeenLastCalledWith(['MetaLeft', 'KeyD']);+ // A synthesized Cmd+F3 never reaches Mission Control; F11 is the macOS default.+ await act(async () =>+ lifecycle.update?.({ ...supported, caps: { ...supported.caps, platform: 'darwin' } }),+ );+ fireEvent.click(desktop);+ expect(lifecycle.keys).toHaveBeenLastCalledWith(['F11']);+ // Linux workspace hosts swap the shortcut buttons for host-side window actions, as on Mobile.+ await act(async () =>+ lifecycle.update?.({+ ...supported,+ caps: { ...supported.caps, platform: 'linux', workspaceNavigation: true, omarchyMenu: true },+ }),+ );+ expect(screen.queryByRole('button', { name: i18n.t('remoteDesktop.showDesktop') })).toBeNull();+ expect(screen.queryByRole('button', { name: i18n.t('remoteDesktop.allWindows') })).toBeNull();+ for (const action of ['workspaceLeft', 'workspaceRight', 'omarchyMenu'] as const) {+ fireEvent.click(screen.getByRole('button', { name: i18n.t(`remoteDesktop.${action}`) }));+ expect(lifecycle.workspaceAction).toHaveBeenLastCalledWith(action);+ }+ lifecycle.workspaceAction.mockRejectedValueOnce(new Error('DESKTOP_INPUT_UNSUPPORTED'));+ fireEvent.click(screen.getByRole('button', { name: i18n.t('remoteDesktop.workspaceLeft') }));+ expect(await screen.findByText(i18n.t('remoteDesktop.viewer.actionFailed'))).toBeDefined();+ expect(lifecycle.keys).toHaveBeenCalledTimes(2);+ await act(async () => lifecycle.update?.(supported));expect((panel.getByRole('switch', {diff --git a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts b/apps/desktop/src/renderer/features/remote-desktop/viewerController.tsindex 4f7ce4183f..c272a68c3e 100644--- a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts+++ b/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts@@ -676,6 +676,11 @@ export class DesktopViewerController {];this.runtime.receive({ type: 'events', events });}+ async workspaceAction(action: 'workspaceLeft' | 'workspaceRight' | 'omarchyMenu'): Promise<void> {+ const lease = this.session.lease;+ if (!lease || !this.state.controlling) return;+ await this.request({ op: 'windowAction', action, lease: lease.lease });+ }async clipboard(action: 'copy' | 'paste'): Promise<void> {if (!this.state.controlling) throw new Error('DESKTOP_VIEW_ONLY');if (this.clipboardQueued >= 8) throw new Error('CLIPBOARD_BUSY');diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex c1117ceaa8..5d472cc2d0 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -273,6 +273,9 @@"keys": "Keys","showDesktop": "Desktop","allWindows": "All windows",+ "workspaceLeft": "Left desktop",+ "workspaceRight": "Right desktop",+ "omarchyMenu": "Omarchy","reconnecting": "Reconnecting…","connectionTimeout": "Connection timed out. Check your network and that the computer is online, then reconnect.","connectionBusy": "Another device is connected to this remote desktop. Exit remote desktop on that device, then try connecting again.",@@ -316,6 +319,7 @@"resolution": "Computer resolution","clipboardFailed": "Could not transfer clipboard content. Check control access and try again.","settingsFailed": "Could not save this setting. Try again.",+ "actionFailed": "Could not complete this action. Try again.","inputHint": "Click the picture to type; shortcuts, including Cmd/Ctrl+W, go to the remote computer. Press Ctrl+Alt+Esc to release keyboard focus, then Cmd/Ctrl+W closes this window.","controlPending": "Requesting control…","controlRequired": "View only. Take control to interact with the remote computer.",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 1c1300009a..be52012aa8 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -273,6 +273,9 @@"keys": "キー","showDesktop": "デスクトップ","allWindows": "すべてのウィンドウ",+ "workspaceLeft": "左のデスクトップ",+ "workspaceRight": "右のデスクトップ",+ "omarchyMenu": "Omarchy","reconnecting": "再接続中…","connectionTimeout": "接続がタイムアウトしました。ネットワークとコンピューターがオンラインであることを確認してから、再接続してください。","connectionBusy": "別のデバイスがこのリモートデスクトップに接続しています。そのデバイスでリモートデスクトップを終了してから、もう一度接続してください。",@@ -316,6 +319,7 @@"resolution": "コンピュータの解像度","clipboardFailed": "クリップボードの内容を転送できませんでした。操作権限を確認して再試行してください。","settingsFailed": "設定を保存できませんでした。再試行してください。",+ "actionFailed": "操作を完了できませんでした。再試行してください。","inputHint": "画面をクリックして入力します。ショートカット(Cmd/Ctrl+W を含む)はリモートのコンピュータに送信されます。Ctrl+Alt+Esc でキーボードのフォーカスを解除すると、Cmd/Ctrl+W でこのウィンドウを閉じます。","controlPending": "操作権限を取得中…","controlRequired": "表示のみです。リモートのパソコンを操作するには操作権限を取得してください。",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 3dcf19d89f..72ed6d8bc4 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -273,6 +273,9 @@"keys": "키","showDesktop": "데스크톱","allWindows": "모든 창",+ "workspaceLeft": "왼쪽 데스크톱",+ "workspaceRight": "오른쪽 데스크톱",+ "omarchyMenu": "Omarchy","reconnecting": "다시 연결 중…","connectionTimeout": "연결 시간이 초과되었습니다. 네트워크와 컴퓨터의 온라인 상태를 확인한 후 다시 연결하세요.","connectionBusy": "다른 기기가 이 원격 데스크톱에 연결되어 있습니다. 해당 기기에서 원격 데스크톱을 종료한 후 다시 연결하세요.",@@ -316,6 +319,7 @@"resolution": "컴퓨터 해상도","clipboardFailed": "클립보드 내용을 전송하지 못했습니다. 제어 권한을 확인하고 다시 시도하세요.","settingsFailed": "설정을 저장하지 못했습니다. 다시 시도하세요.",+ "actionFailed": "작업을 완료하지 못했습니다. 다시 시도하세요.","inputHint": "화면을 클릭하여 입력하세요. 단축키(Cmd/Ctrl+W 포함)는 원격 컴퓨터로 전송됩니다. Ctrl+Alt+Esc로 키보드 포커스를 해제한 뒤 Cmd/Ctrl+W로 이 창을 닫습니다.","controlPending": "제어 권한을 가져오는 중…","controlRequired": "보기 전용입니다. 원격 컴퓨터를 조작하려면 제어 권한을 가져오세요.",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 42a1f5b2c7..17dc793c03 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -273,6 +273,9 @@"keys": "按键","showDesktop": "桌面","allWindows": "所有窗口",+ "workspaceLeft": "左侧桌面",+ "workspaceRight": "右侧桌面",+ "omarchyMenu": "Omarchy","reconnecting": "正在重新连接…","connectionTimeout": "连接超时。请检查网络和电脑是否在线,然后重新连接。","connectionBusy": "已有其他设备连接此远程桌面。请先在那台设备上退出远程桌面,再尝试连接。",@@ -316,6 +319,7 @@"resolution": "电脑分辨率","clipboardFailed": "剪贴板内容传输失败,请检查控制权限后重试。","settingsFailed": "设置未能保存,请重试。",+ "actionFailed": "操作未能完成,请重试。","inputHint": "点击画面即可输入,快捷键(包括 Cmd/Ctrl+W)会发送到远端电脑。按 Ctrl+Alt+Esc 释放键盘焦点后,Cmd/Ctrl+W 关闭这个窗口。","controlPending": "正在取得控制权…","controlRequired": "当前仅查看。接管后可操作远端电脑。",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex c9e698d9bf..5b0b4da0f4 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -273,6 +273,9 @@"keys": "按鍵","showDesktop": "桌面","allWindows": "所有視窗",+ "workspaceLeft": "左側桌面",+ "workspaceRight": "右側桌面",+ "omarchyMenu": "Omarchy","reconnecting": "正在重新連線…","connectionTimeout": "連線逾時。請檢查網路及電腦是否在線,然後重新連線。","connectionBusy": "已有其他裝置連線至此遠端桌面。請先在該裝置上退出遠端桌面,再嘗試連線。",@@ -316,6 +319,7 @@"resolution": "電腦解析度","clipboardFailed": "剪貼簿內容傳輸失敗,請檢查控制權限後重試。","settingsFailed": "設定未能儲存,請重試。",+ "actionFailed": "操作未能完成,請重試。","inputHint": "點擊畫面即可輸入,快捷鍵(包括 Cmd/Ctrl+W)會傳送到遠端電腦。按 Ctrl+Alt+Esc 釋放鍵盤焦點後,Cmd/Ctrl+W 關閉這個視窗。","controlPending": "正在取得控制權…","controlRequired": "目前僅供檢視。取得控制權後可操作遠端電腦。",