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): 桌面远控默认操作并移除仅查看 (#5184)
Dashda3fd3052d2f
diff --git a/apps/desktop/scripts/remote-desktop-viewer-smoke.mjs b/apps/desktop/scripts/remote-desktop-viewer-smoke.mjsindex 3090d85dcf..4e63f1ee7f 100644--- a/apps/desktop/scripts/remote-desktop-viewer-smoke.mjs+++ b/apps/desktop/scripts/remote-desktop-viewer-smoke.mjs@@ -412,17 +412,8 @@ try {path: path.join(artifacts, 'settings-zh-light.png'),});await checkSelect(settings.getByRole('combobox').nth(1), 'quality-select-zh-light.png');- const releaseLabel = await viewer.evaluate(async () =>- (await import('/i18n/index.ts')).default.t('remoteDesktop.releaseControl'),- );- await viewer.getByRole('button', { name: releaseLabel, exact: true }).click();const desktopButton = settings.getByRole('button', { name: '桌面', exact: true });- assert(await desktopButton.isDisabled(), 'view-only actions explain why control is required');- await settings.getByText('当前仅查看,取得控制权后可使用剪贴板和桌面操作。').waitFor();- const takeLabel = await viewer.evaluate(async () =>- (await import('/i18n/index.ts')).default.t('remoteDesktop.takeControl'),- );- await settings.getByRole('button', { name: takeLabel, exact: true }).click();+ assert(await desktopButton.isEnabled(), 'desktop viewer opens with control');await viewer.waitForFunction(() => {const button = [...document.querySelectorAll('aside button')].find((item) => item.textContent === '桌面',diff --git a/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx b/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsxindex a8fe87cb8c..d6858993af 100644--- a/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx+++ b/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx@@ -162,27 +162,6 @@ export function RemoteDesktopViewerWindow() {)}</span>);- const controlPrompt = !state?.controlling && (- <div className="flex flex-col gap-2" role="status">- <p>- {t(- !state?.ready- ? 'remoteDesktop.connecting'- : state.controlPending- ? 'remoteDesktop.viewer.controlPending'- : 'remoteDesktop.viewer.controlRequired',- )}- </p>- <Button- variant="secondary"- disabled={!state?.ready || !state.caps?.canControl || state.controlPending}- loading={state?.controlPending}- onClick={() => void controller.current?.setControl(true)}- >- {t('remoteDesktop.takeControl')}- </Button>- </div>- );const preference = (key: 'privacyScreen' | 'hostMute' | 'clipboardSync' | 'lockOnExit') =>state && (<div className="remote-viewer-preference" key={key}>@@ -243,8 +222,8 @@ export function RemoteDesktopViewerWindow() {? 'remoteDesktop.lockingOnExit': 'remoteDesktop.disconnecting',)- : state?.ready- ? t(state.controlling ? 'remoteDesktop.controlling' : 'remoteDesktop.viewOnly')+ : state?.ready && state.controlling+ ? t('remoteDesktop.controlling'): t('remoteDesktop.connecting')}</span>{state?.ready && (@@ -479,7 +458,6 @@ export function RemoteDesktopViewerWindow() {)}{preference('hostMute')}</div>- {controlPrompt}{network && <div className="remote-viewer-panel-section">{network}</div>}</ViewerPanel><ViewerPanel@@ -523,7 +501,6 @@ export function RemoteDesktopViewerWindow() {<p>{t('remoteDesktop.viewer.clipboardShortcutHint', { modifier: isMac ? '⌘' : 'Ctrl' })}</p>- {controlPrompt}</ViewerPanel><ViewerPanellabel={t('remoteDesktop.viewer.securityPanel')}@@ -589,7 +566,6 @@ export function RemoteDesktopViewerWindow() {</>)}</div>- {controlPrompt}</ViewerPanel></div>{!isMac && <WindowControls onClose={requestClose} />}@@ -620,51 +596,57 @@ export function RemoteDesktopViewerWindow() {<span id="mouse-wheel-grip" /></Button></div>- {!state?.closing && (!state?.ready || state?.error || state?.status === 'reconnecting') && (- <div className="remote-viewer-connection" role="status">- <span>- {state?.error- ? t(+ {!state?.closing &&+ (!state?.ready ||+ !state.controlling ||+ state.error ||+ state.status === 'reconnecting') && (+ <div className="remote-viewer-connection" role="status">+ <span>+ {state?.error+ ? t(+ state.error === 'connectionBusy' && state.caps?.connectionTakeover+ ? 'remoteDesktop.connectionBusyTakeover'+ : `remoteDesktop.${state.error}`,+ )+ : t(+ state?.controlPending+ ? 'remoteDesktop.viewer.controlPending'+ : state?.status === 'reconnecting'+ ? 'remoteDesktop.reconnecting'+ : 'remoteDesktop.connecting',+ )}+ </span>+ {state?.error && (+ <Button+ variant="secondary"+ className={action}+ onClick={() => controller.current?.retry()}+ >+ {t(state.error === 'connectionBusy' && state.caps?.connectionTakeover- ? 'remoteDesktop.connectionBusyTakeover'- : `remoteDesktop.${state.error}`,- )- : t(- state?.status === 'reconnecting'- ? 'remoteDesktop.reconnecting'- : 'remoteDesktop.connecting',+ ? 'remoteDesktop.takeoverConnection'+ : 'remoteDesktop.connect',)}- </span>- {state?.error && (- <Button- variant="secondary"- className={action}- onClick={() => controller.current?.retry()}- >- {t(- state.error === 'connectionBusy' && state.caps?.connectionTakeover- ? 'remoteDesktop.takeoverConnection'- : 'remoteDesktop.connect',- )}- </Button>- )}- {state?.error === 'permissionHint' && (- <Button- variant="secondary"- className={action}- onClick={() => {- void controller.current- ?.permissionGuide()- .then(() => setNotice(t('remoteDesktop.permissionGuideOpened')))- .catch(() => setNotice(t('remoteDesktop.permissionActionFailed')));- setSettings('security');- }}- >- {t('remoteDesktop.openGuideOnComputer')}- </Button>- )}- </div>- )}+ </Button>+ )}+ {state?.error === 'permissionHint' && (+ <Button+ variant="secondary"+ className={action}+ onClick={() => {+ void controller.current+ ?.permissionGuide()+ .then(() => setNotice(t('remoteDesktop.permissionGuideOpened')))+ .catch(() => setNotice(t('remoteDesktop.permissionActionFailed')));+ setSettings('security');+ }}+ >+ {t('remoteDesktop.openGuideOnComputer')}+ </Button>+ )}+ </div>+ )}{isFullscreen && network && <div className="remote-viewer-network-overlay">{network}</div>}{(notice || state?.safety.notice || state?.safety.privacyActive) && (<div className="remote-viewer-feedback" role="status">@@ -773,9 +755,8 @@ function ViewerTool({disabled?: boolean;pressed?: boolean;}) {- const { t } = useTranslation();return (- <Tip text={disabled ? t('remoteDesktop.viewer.controlRequired') : label} side="bottom">+ <Tip text={label} side="bottom"><Buttonvariant="secondary"className="remote-viewer-icon"diff --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 93e784d88f..dec12189d5 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@@ -192,7 +192,7 @@ it('orders quick copy/paste shortcuts and reports transfer failure without reconexpect(current.clipboard).toHaveBeenCalledTimes(4);});-it('drops queued clipboard work after control is released and ignores stale shortcut epochs', async () => {+it('drops queued clipboard work after host control is lost and ignores stale shortcut epochs', async () => {const current = await fixture();present();const gate = deferred<void>();@@ -203,8 +203,8 @@ it('drops queued clipboard work after control is released and ignores stale shorruntime.post?.({ type: 'clipboard', action: 'copy', epoch: 'lease' });runtime.post?.({ type: 'clipboard', action: 'paste', epoch: 'lease' });await vi.advanceTimersByTimeAsync(0);- await controller.setControl(false);- await controller.setControl(true);+ current.heartbeat.mockResolvedValue({ controlling: false });+ await vi.advanceTimersByTimeAsync(3000);gate.resolve();await vi.advanceTimersByTimeAsync(0);expect(current.clipboard).toHaveBeenCalledExactlyOnceWith(1, 'copy');@@ -234,66 +234,98 @@ it.each([true, false])(},);-it('pauses actions and input during release and does not send duplicate control requests', async () => {- const f = await fixture();+it('does not present a usable desktop when the host refuses initial control', async () => {+ const f = await fixture(Promise.resolve({ controlling: false }));present();- const gate = deferred<{ controlling: boolean }>();- f.control.mockImplementationOnce(() => gate.promise);- const pending = controller.setControl(false);- await controller.setControl(true);- expect(f.control).toHaveBeenCalledTimes(2); // Initial grant + one release.- expect(snapshot).toMatchObject({ controlling: false, controlPending: true });- expect(inputEnabled()).toBe(false);+ expect(f.control).toHaveBeenCalledExactlyOnceWith(true);+ expect(snapshot).toMatchObject({ ready: false, controlling: false, error: 'controlUnavailable' });+});++it('shows a reconnectable error when host input is busy during control acquisition', async () => {+ const firstControl = Promise.reject(new Error('[PRECONDITION_FAILED] DESKTOP_INPUT_BUSY'));+ const f = await fixture(firstControl);+ await vi.advanceTimersByTimeAsync(0);+ expect(snapshot).toMatchObject({ ready: false, controlling: false, error: 'controlUnavailable' });+ controller.retry();+ await vi.advanceTimersByTimeAsync(0);+ present();+ expect(f.control).toHaveBeenCalledTimes(2);+ expect(snapshot).toMatchObject({ ready: true, controlling: true, error: null });+});++it('stops input and viewing after input queue overflow', async () => {+ await fixture();+ present();+ runtime.post?.({ type: 'inputOverflow', epoch: 'lease' });+ expect(snapshot).toMatchObject({ controlling: false, ready: false, error: 'controlUnavailable' });+ expect(runtime.receive).toHaveBeenCalledWith({ type: 'stop', preserveFrame: true });await expect(controller.clipboard('paste')).rejects.toThrow('DESKTOP_VIEW_ONLY');- runtime.receive.mockClear();- controller.keys(['MetaLeft', 'KeyD']);- expect(runtime.receive).not.toHaveBeenCalled();- gate.resolve({ controlling: false });- await pending;- expect(snapshot).toMatchObject({ controlling: false, controlPending: false });- expect(f.clipboard).not.toHaveBeenCalled();});it('ignores a pre-transition heartbeat without briefly disabling newly granted control', async () => {- const f = await fixture();- present();- await controller.setControl(false);const gate = deferred<{ controlling: boolean }>();- f.heartbeat.mockImplementationOnce(() => gate.promise);+ const f = await fixture(gate.promise);+ present();+ f.heartbeat.mockResolvedValueOnce({ controlling: false });await vi.advanceTimersByTimeAsync(3000);- await controller.setControl(true);- gate.resolve({ controlling: false });+ gate.resolve({ controlling: true });await vi.advanceTimersByTimeAsync(0);expect(snapshot.controlling).toBe(true);expect(inputEnabled()).toBe(true);});-it('retains view-only after the host revokes control and the viewer reconnects', async () => {+it('requires control again after the host revokes it and the viewer reconnects', async () => {const f = await fixture();present();f.heartbeat.mockResolvedValue({ controlling: false });await vi.advanceTimersByTimeAsync(3000);expect(snapshot.controlling).toBe(false);- expect(inputEnabled()).toBe(false);+ expect(snapshot.ready).toBe(false);+ expect(snapshot.error).toBe('controlUnavailable');+ expect(runtime.receive).toHaveBeenCalledWith({ type: 'stop', preserveFrame: true });controller.retry();await vi.advanceTimersByTimeAsync(0);present();- expect(f.control).toHaveBeenCalledOnce();- expect(snapshot.controlling).toBe(false);- expect(inputEnabled()).toBe(false);+ expect(f.control).toHaveBeenCalledTimes(2);+ expect(snapshot.controlling).toBe(true);+ expect(inputEnabled()).toBe(true);});-it('does not re-enable input when a failed release is followed by another video frame', async () => {+it('keeps confirmed control on an input timeout until the heartbeat settles it', async () => {const f = await fixture();present();- f.control.mockRejectedValueOnce(new Error('INVOKE_TIMEOUT'));- await controller.setControl(false);+ const original = f.api.request;+ vi.spyOn(f.api, 'request').mockImplementation(async (generation, request) => {+ if (request.op === 'input') throw new Error('[PRECONDITION_FAILED] INVOKE_TIMEOUT');+ return original(generation, request);+ });+ runtime.post?.({+ type: 'input',+ epoch: 'lease',+ sequence: 1,+ events: [{ kind: 'release' }],+ });+ await vi.advanceTimersByTimeAsync(0);+ expect(snapshot).toMatchObject({ controlling: true, ready: true, error: null });+ expect(inputEnabled()).toBe(true);+});++it('leaves the desktop when the host rejects an input batch', async () => {+ const f = await fixture();present();- expect(snapshot).toMatchObject({ controlling: false, controlPending: false });- expect(inputEnabled()).toBe(false);- await vi.advanceTimersByTimeAsync(3000);- expect(f.control).toHaveBeenLastCalledWith(false);- expect(inputEnabled()).toBe(false);+ const original = f.api.request;+ vi.spyOn(f.api, 'request').mockImplementation(async (generation, request) => {+ if (request.op === 'input') throw new Error('[PRECONDITION_FAILED] DESKTOP_VIEW_ONLY');+ return original(generation, request);+ });+ runtime.post?.({+ type: 'input',+ epoch: 'lease',+ sequence: 1,+ events: [{ kind: 'release' }],+ });+ await vi.advanceTimersByTimeAsync(0);+ expect(snapshot).toMatchObject({ ready: false, controlling: false, error: 'controlUnavailable' });});it('coalesces rapid quality changes and waits for the current negotiation to present', async () => {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 094aaaae2b..985ebb4cc3 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@@ -252,7 +252,7 @@ it('keeps a healthy viewer on the same host connected when another viewer timesreturn {version: 1,enabled: true,- canControl: false,+ canControl: true,automaticReconnect: true,displays: [{ id: 'one', width: 1280, height: 720 }],};@@ -265,6 +265,7 @@ it('keeps a healthy viewer on the same host connected when another viewer times};}if (request.op === 'stop') leases.delete(request.lease);+ if (request.op === 'control' || request.op === 'heartbeat') return { controlling: true };return { controlling: false, jpeg: null };},} satisfies RemoteDesktopViewerApi;diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerTransport.test.ts b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerTransport.test.tsindex 9e6e5ed394..6f55395e71 100644--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerTransport.test.ts+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerTransport.test.ts@@ -38,7 +38,7 @@ beforeEach(async () => {return {version: 1,enabled: true,- canControl: false,+ canControl: true,displays: [{ id: 'one', width: 1280, height: 720 }],};if (request.op === 'start')@@ -47,6 +47,7 @@ beforeEach(async () => {controlling: false,display: { id: 'one', width: 1280, height: 720 },};+ if (request.op === 'control' || request.op === 'heartbeat') return { controlling: true };return {};},} satisfies RemoteDesktopViewerApi;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 0ce537a842..01986a8abc 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@@ -152,7 +152,7 @@ it('confirms toolbar and native exits, keeps cancellation connected, and discardexpect(close).toHaveBeenCalledOnce();});-it('explains view-only actions and enables the same actions when control is confirmed', async () => {+it('hides view-only controls and enables desktop actions only after control is confirmed', async () => {await i18n.changeLanguage('zh-CN');Object.assign(window, {electronAPI: {@@ -202,6 +202,7 @@ it('explains view-only actions and enables the same actions when control is conf},};await act(async () => lifecycle.update?.(state));+ expect(screen.queryByText(i18n.t('remoteDesktop.viewOnly'))).toBeNull();const openPanel = (label: string) => {fireEvent.click(screen.getByRole('button', { name: label }));return within(screen.getByRole('dialog', { name: label }));@@ -215,15 +216,13 @@ it('explains view-only actions and enables the same actions when control is conf).disabled,).toBe(true);expect(panel.getByText(i18n.t('remoteDesktop.settingUnsupported'))).toBeDefined();- expect(panel.getByText(i18n.t('remoteDesktop.viewer.controlRequired'))).toBeDefined();+ expect(panel.queryByRole('button', { name: i18n.t('remoteDesktop.takeControl') })).toBeNull();const desktop = screen.getByRole('button', {name: i18n.t('remoteDesktop.showDesktop'),}) as HTMLButtonElement;expect(desktop.disabled).toBe(true);- fireEvent.click(panel.getByRole('button', { name: i18n.t('remoteDesktop.takeControl') }));- expect(lifecycle.setControl).toHaveBeenCalledWith(true);await act(async () => lifecycle.update?.({ ...state, controlPending: true }));- expect(panel.getByText(i18n.t('remoteDesktop.viewer.controlPending'))).toBeDefined();+ expect(panel.queryByRole('button', { name: i18n.t('remoteDesktop.takeControl') })).toBeNull();const supported = {...state,controlling: true,diff --git a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts b/apps/desktop/src/renderer/features/remote-desktop/viewerController.tsindex fcf9886597..3e7ab162a6 100644--- a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts+++ b/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts@@ -87,7 +87,6 @@ export class DesktopViewerController {private opening = false;private epoch = 0;private resuming = false;- private wantsControl = true;private retryAt = 0;private retryDelay = 1000;private connectionTimer: ReturnType<typeof setTimeout> | null = null;@@ -312,7 +311,8 @@ export class DesktopViewerController {: 'control',});this.runtime.receive({ type: 'mode', mode: 'pointer' });- if (caps.canControl && this.wantsControl) await this.setControl(true);+ if (!caps.canControl) throw new Error('DESKTOP_INPUT_UNSUPPORTED');+ await this.acquireControl();} catch (error) {if (epoch === this.epoch) this.fail(error);} finally {@@ -321,7 +321,11 @@ export class DesktopViewerController {}private fail(error: unknown): void {const code = error instanceof Error ? error.message : '';- const blocked = remoteDesktopFailureKey(code);+ const blocked =+ remoteDesktopFailureKey(code) ??+ (/DESKTOP_(VIEW_ONLY|INPUT_(BUSY|UNSUPPORTED|UNAVAILABLE|TIMEOUT))/.test(code)+ ? 'controlUnavailable'+ : null);this.cancel(true);this.publish({ status: 'reconnecting', error: blocked });this.retryAt = Date.now() + this.retryDelay;@@ -333,27 +337,17 @@ export class DesktopViewerController {this.resuming = false;void this.connect(this.state.error === 'connectionBusy');}- async setControl(enabled: boolean): Promise<void> {+ private async acquireControl(): Promise<void> {if (this.state.closing || this.state.controlPending || !this.session.lease) return;- this.wantsControl = enabled;this.runtime.receive({ type: 'releaseInput' });const lease = this.session.lease;this.publish({ controlPending: true });this.syncControl();try {- const result = await this.session.control(enabled);+ const result = await this.session.control(true);if (lease !== this.session.lease) return;- if (!result.controlling) this.wantsControl = false;+ if (!result.controlling) throw new Error('DESKTOP_VIEW_ONLY');this.publish({ error: null });- } catch (error) {- if (lease !== this.session.lease) return;- this.wantsControl = false;- const code = error instanceof Error ? error.message : '';- if (/DESKTOP_(LEASE_EXPIRED|STOPPED|DISABLED)|ACCESS_REVOKED|REMOTE_DISABLED/.test(code)) {- this.fail(error);- return;- }- this.publish({ error: enabled ? (remoteDesktopFailureKey(code) ?? 'busy') : null });} finally {if (lease === this.session.lease) {this.publish({ controlPending: false });@@ -366,10 +360,7 @@ export class DesktopViewerController {* Menu focus only releases held keys; it does not revoke desktop control. */private syncControl(): void {const controlling =- this.state.ready &&- this.wantsControl &&- !this.state.controlPending &&- this.session.lease?.controlling === true;+ this.state.ready && !this.state.controlPending && this.session.lease?.controlling === true;if (controlling === this.state.controlling) return;this.clipboardRevision++;this.publish({ controlling });@@ -669,8 +660,9 @@ export class DesktopViewerController {try {const result = await this.session.heartbeat();if (epoch === this.epoch) {- if (!result.controlling && this.state.controlling) this.wantsControl = false;- this.syncControl();+ if (!result.controlling && !this.opening && !this.state.controlPending)+ this.fail(new Error('DESKTOP_VIEW_ONLY'));+ else this.syncControl();}} catch (error) {if (epoch === this.epoch && !(error instanceof Error && error.message === 'INVOKE_TIMEOUT'))@@ -797,7 +789,7 @@ export class DesktopViewerController {break;}case 'inputOverflow':- void this.setControl(false);+ this.fail(new Error('DESKTOP_INPUT_UNAVAILABLE'));break;case 'input':if (@@ -813,8 +805,12 @@ export class DesktopViewerController {sequence: message.sequence as number,events: message.events,})- .catch(() => {- if (this.session.lease === lease) void this.setControl(false);+ .catch((error) => {+ if (+ this.session.lease === lease &&+ !(error instanceof Error && error.message === 'INVOKE_TIMEOUT')+ )+ this.fail(error);}).finally(() => {if (this.session.lease === lease)diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 02df457c50..9b59287e3b 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -189,6 +189,7 @@"allow": "Allow remote desktop","allowHint": "Allow your signed-in devices to view and operate all apps on this computer. Also enable device control above.","permissionHint": "On the computer, allow screen recording and accessibility in system settings, then reconnect.",+ "controlUnavailable": "The remote computer cannot accept input. Check its control permissions and connection, then reconnect.","beingControlled": "Your desktop is being controlled","beingViewed": "Your desktop is being viewed","disconnect": "Disconnect",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex fd40954378..cc391d708b 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -189,6 +189,7 @@"allow": "リモートデスクトップを許可","allowHint": "同じアカウントのデバイスから、このコンピューターの全アプリの表示と操作を許可します。上のデバイス操作も有効にしてください。","permissionHint": "コンピューターのシステム設定で画面収録とアクセシビリティを許可し、再接続してください。",+ "controlUnavailable": "リモートコンピューターで操作を受け付けられません。操作権限と接続を確認して再接続してください。","beingControlled": "デスクトップが操作されています","beingViewed": "デスクトップが表示されています","disconnect": "切断",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex a3df51bd23..008d8ccb92 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -189,6 +189,7 @@"allow": "원격 데스크톱 허용","allowHint": "같은 계정의 기기에서 이 컴퓨터의 모든 앱을 보고 조작하도록 허용합니다. 위의 기기 제어도 켜주세요.","permissionHint": "컴퓨터 시스템 설정에서 화면 기록과 손쉬운 사용을 허용한 후 다시 연결하세요.",+ "controlUnavailable": "원격 컴퓨터에서 입력을 받을 수 없습니다. 제어 권한과 연결을 확인한 다음 다시 연결하세요.","beingControlled": "데스크톱을 원격으로 제어 중","beingViewed": "데스크톱을 원격으로 보는 중","disconnect": "연결 끊기",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 1e73309c09..86be956739 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -189,6 +189,7 @@"allow": "允许远程桌面","allowHint": "允许已登录的同账号设备查看和操作这台电脑的所有应用。需同时开启上方的设备控制。","permissionHint": "请在电脑的系统设置中允许屏幕录制和辅助功能,然后重新连接。",+ "controlUnavailable": "远端电脑暂时无法接受操作,请检查远端控制权限和连接,然后重新连接。","beingControlled": "桌面正在被远程控制","beingViewed": "桌面正在被远程查看","disconnect": "断开连接",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 769b72f728..858ebeca01 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -189,6 +189,7 @@"allow": "允許遠端桌面","allowHint": "允許已登入的同帳號裝置檢視和操作這台電腦的所有應用程式。需同時開啟上方的裝置控制。","permissionHint": "請在電腦的系統設定中允許螢幕錄製和輔助使用,然後重新連線。",+ "controlUnavailable": "遠端電腦暫時無法接受操作,請檢查遠端控制權限和連線,然後重新連線。","beingControlled": "桌面正在被遠端控制","beingViewed": "桌面正在被遠端檢視","disconnect": "中斷連線",diff --git a/docs/remote-desktop.md b/docs/remote-desktop.mdindex d2b9741319..0ec88e8b2b 100644--- a/docs/remote-desktop.md+++ b/docs/remote-desktop.md@@ -270,14 +270,15 @@ Control is a lease-scoped capability, not the session itself. When the host canno longer inject input — the native helper died, it reported a failed injection,or its write path failed — it releases control and keeps everything else: thelease, the capture owner, the video track and the last picture. It does not call-`stop()`, so an input fault can never surface as an ended desktop session.+`stop()` on the host. A desktop viewer may still end its own lease when it sees+the lost control; the mobile viewer can keep watching.The host also releases control when its own input path refuses a batch beforeinjecting anything, so the two sides cannot disagree about who controls: a latertake-control genuinely restarts the helper instead of being skipped as "alreadycontrolling".-The viewer follows the host's control bit instead of rebuilding the session. A+The mobile viewer follows the host's control bit instead of rebuilding the session. Arejected input batch, a failed control request or a heartbeat that reports`controlling: false` all drop the phone to view only with the existing view-onlyhint and take-control action; media and lease identity are untouched. A dropped@@ -299,18 +300,27 @@ release that discards its key-up, and the heartbeat still owns liveness. Errorsthat do mean the lease is gone (`DESKTOP_LEASE_EXPIRED`, `DESKTOP_STOPPED`,revocation, an unsupported channel) still recover the session as before.+Desktop viewers require control. They request it on every connection and do not+offer a view-only action. If the host refuses control, revokes it later, rejects+an input batch, or the viewer input queue overflows, the desktop viewer stops its+lease and media, retains the last picture, and shows an error with a reconnect+action. Reconnecting requests control again before the desktop becomes usable.+An input request whose outcome is unknown (`INVOKE_TIMEOUT`) waits for the+heartbeat instead of immediately discarding the lease.+This matters most on Windows, where the SendInput helper reports a failedinjection as a helper failure whereas the macOS helper posts events without aresult path. On Windows the helper now costs control only; whether a specificmachine can inject at all (elevated foreground window, secure desktop, a sessionworker outside the interactive window station) is a separate, still unverified-question, and the helper's `error` line does not yet carry a reason.+question, and the helper's `error` line does not yet carry a reason. On the+desktop viewer, losing that control also ends the current viewer lease.Deterministic tests cover the controller release (lease, media and single-viewerarbitration retained; later input refused as view-only; control can be taken-again), the desktop wiring that turns a refused or failed input batch into a-release rather than a stop, the failure classification (release, unknown outcome,-rebuild), and the viewer paths that drop to view only without reconnecting.+again), the host failure classification (release, unknown outcome, rebuild),+the mobile viewer's view-only recovery, and the desktop viewer's stop and+reconnect behavior after control or input failure.## Authority and lifetime@@ -1030,8 +1040,8 @@ An optional `shape` hint selects a bounded standard cursor keyword (text, hand,resize, etc.); size, DPI and accessibility appearance remain owned by the localOS and do not follow the remote screen zoom. Missing, custom or unknown shapesfall back to the local arrow. Old viewers ignore the hint and Mobile retains the-raster path. Desktop view-only mode shows the local arrow rather than a second-remote pointer overlay.+raster path. While desktop control is unavailable, the connection overlay stays+visible instead of presenting a view-only desktop.Checked: desktop/mobile types, native compilation, a bounded read-only nativecapture returning cursor geometry/raster metadata. Real phone gestures,@@ -1111,8 +1121,7 @@ An overflowing picture can be panned with the middle mouse button or by hoveringwithin 28 local pixels of a viewport edge. Edge panning accelerates toward theedge, supports diagonal movement, and stops at the desktop bounds, on pointerleave or focus loss. Remote hover/drag coordinates follow the moving picture;-view-only sessions pan locally without sending input. Window maximization/fullscreen-uses the native window controls.+window maximization/fullscreen uses the native window controls.Zoom out can go below fit, down to 10% of the smaller of fit and actual size.Exposed margins use the same fixed-fit, three-segment ambient canvas as Mobile,with 16px blur, 1.12 overscan and 0.72 opacity. Same-aspect desktops also retain