Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(remote-desktop): 被控端显示置顶浮窗提示远程连接 (#5496)

Dashb0d84de661aa
diff --git a/apps/desktop/src/main/__tests__/mainWindowBackgroundThrottling.test.ts b/apps/desktop/src/main/__tests__/mainWindowBackgroundThrottling.test.ts
index 5442c3fb4f..297df9d967 100644
--- a/apps/desktop/src/main/__tests__/mainWindowBackgroundThrottling.test.ts
+++ b/apps/desktop/src/main/__tests__/mainWindowBackgroundThrottling.test.ts
@@ -58,7 +58,7 @@ describe('主 BrowserWindow 后台节流', () => {
expect(source).toContain('const nextAllowed = !hasRunningTurn;');
expect(source).toMatch(/setBackgroundThrottling\(\s*mainWindowBackgroundThrottlingAllowed,?\s*\)/);
expect(source).not.toContain('isRemoteDesktopVideoActive');
- expect(source).toContain('registerRemoteDesktopIpc(isGlobalVoiceInputOverlaySender);');
+ expect(source).toContain('registerRemoteDesktopIpc(isGlobalVoiceInputOverlaySender, {');
expect(source).toContain('onAnySessionTurnKeepaliveChange: (isRunning) => {');
expect(source).toContain('setMainWindowBackgroundThrottlingForActiveTurn(isRunning);');
expect(source).toContain('notifyUpdateAutoRelaunchBusyStateChanged();');
diff --git a/apps/desktop/src/main/bootstrap-electron.ts b/apps/desktop/src/main/bootstrap-electron.ts
index 9ce3f158d0..56125500a5 100644
--- a/apps/desktop/src/main/bootstrap-electron.ts
+++ b/apps/desktop/src/main/bootstrap-electron.ts
@@ -600,6 +600,8 @@ import {
isSharedTaskAvailable,
releaseDeviceLinkOwnershipBeforeLogout,
handleDeviceLinkSystemResume,
+ getControllerName,
+ revokeController,
} from './device-link';
import { closeSharedTasksBeforeLogout } from './device-link/sharedTaskRuntime.js';
import { closeSharedTasksBeforeAccountHandover } from './device-link/sharedTaskAccountBoundary.js';
@@ -9706,7 +9708,10 @@ app.on('ready', async () => {
);
registerSharedTaskIpc(isSharedTaskAvailable, () => getDeviceLinkStatus() === 'online');
registerFilePeerIpc();
- registerRemoteDesktopIpc(isGlobalVoiceInputOverlaySender);
+ registerRemoteDesktopIpc(isGlobalVoiceInputOverlaySender, {
+ name: getControllerName,
+ revoke: revokeController,
+ });
void startupPurgeDrain
.then(({ purged, pending }) => {
if (purged > 0 || pending > 0) {
diff --git a/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts b/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts
index b1aa5d5c20..57f8da339e 100644
--- a/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts
+++ b/apps/desktop/src/main/device-link/__tests__/dispatchWeakNetwork.test.ts
@@ -61,6 +61,10 @@ vi.mock('../sharedTaskDispatch.js', async (original) => ({
import {
__testing,
+ clearControllerDisplayNames,
+ getControllerDisplayName,
+ setControllerDisplayName,
+ setControllerFallbackDisplayName,
deactivateAllControllers,
deactivateController,
flushRemoteInvokeResultOutboxOnReconnect,
@@ -867,3 +871,22 @@ describe('[6] active controller 生命周期与故障半径', () => {
expect(__testing.getActiveControllers()).toEqual([]);
});
});
+
+describe('被控浮窗读取控制端展示名', () => {
+ afterEach(() => clearControllerDisplayNames());
+
+ it('旧 presence 主机名作为最后一级回退,权威展示名优先', () => {
+ setControllerFallbackDisplayName('ctrl-legacy', 'Legacy Mac');
+ expect(getControllerDisplayName('ctrl-legacy')).toBe('Legacy Mac');
+ setControllerDisplayName('ctrl-legacy', 'Dash 的 MacBook');
+ expect(getControllerDisplayName('ctrl-legacy')).toBe('Dash 的 MacBook');
+ clearControllerDisplayNames();
+ expect(getControllerDisplayName('ctrl-legacy')).toBeUndefined();
+ });
+
+ it('权威名被显式清空时同时清掉旧 presence 主机名', () => {
+ setControllerFallbackDisplayName('ctrl-legacy', 'Legacy Mac');
+ setControllerDisplayName('ctrl-legacy', '');
+ expect(getControllerDisplayName('ctrl-legacy')).toBeUndefined();
+ });
+});
diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.ts
index a4cd9f41e4..c8b3aa6e5b 100644
--- a/apps/desktop/src/main/device-link/dispatch.ts
+++ b/apps/desktop/src/main/device-link/dispatch.ts
@@ -861,6 +861,8 @@ const controllerLinkGenerationByDevice = new Map<string, number>();
const controllerDisplayNameByDevice = new Map<string, string>();
/** 控制帧自报名称仅作数据库展示名缺失时的兼容回退。 */
const reportedControllerNameByDevice = new Map<string, string>();
+/** 旧 relay presence 主机名:最后一级回退,与自报名同生命周期,供被控浮窗读取。 */
+const fallbackControllerNameByDevice = new Map<string, string>();
/** `sessions` 订阅出现时通知 host replay 当前列表级轻量状态。 */
type SessionsSubscribedListener = (controllerDeviceId: string) => void;
@@ -903,6 +905,7 @@ function resolveControllerName(deviceId: string, reportedName: unknown): string
function clearReportedControllerName(deviceId: string): void {
reportedControllerNameByDevice.delete(deviceId);
+ fallbackControllerNameByDevice.delete(deviceId);
}
function readConnectionEpoch(client: DeviceLinkClient): number | undefined {
@@ -935,6 +938,8 @@ export function setControllerDisplayName(deviceId: string, name: string): void {
controllerDisplayNameByDevice.set(deviceId, normalized);
} else {
controllerDisplayNameByDevice.delete(deviceId);
+ // An explicit clear also retires the legacy host name, matching the banner.
+ fallbackControllerNameByDevice.delete(deviceId);
}
const displayName = normalized
?? reportedControllerNameByDevice.get(deviceId)
@@ -948,6 +953,7 @@ export function setControllerDisplayName(deviceId: string, name: string): void {
*/
export function setControllerFallbackDisplayName(deviceId: string, name: string): void {
const normalized = normalizeControllerName(name);
+ if (normalized) fallbackControllerNameByDevice.set(deviceId, normalized);
if (
!normalized
|| controllerDisplayNameByDevice.has(deviceId)
@@ -958,10 +964,20 @@ export function setControllerFallbackDisplayName(deviceId: string, name: string)
if (subscriptions.updateControllerMetadata(deviceId, normalized)) syncForwarding();
}
+/** 与被控横幅同一优先级的控制端展示名;未知时返回 undefined,由调用方决定兜底。 */
+export function getControllerDisplayName(deviceId: string): string | undefined {
+ return (
+ controllerDisplayNameByDevice.get(deviceId)
+ ?? reportedControllerNameByDevice.get(deviceId)
+ ?? fallbackControllerNameByDevice.get(deviceId)
+ );
+}
+
/** 账号切换 / 链路 teardown 时清空 presence 展示名,避免串到下一段身份。 */
export function clearControllerDisplayNames(): void {
controllerDisplayNameByDevice.clear();
reportedControllerNameByDevice.clear();
+ fallbackControllerNameByDevice.clear();
}
export function getActiveControllers(): ActiveController[] {
diff --git a/apps/desktop/src/main/device-link/index.ts b/apps/desktop/src/main/device-link/index.ts
index eb4d1273e5..7df5cd8050 100644
--- a/apps/desktop/src/main/device-link/index.ts
+++ b/apps/desktop/src/main/device-link/index.ts
@@ -94,6 +94,7 @@ import {
setControllerDisplayName,
setControllerFallbackDisplayName,
clearControllerDisplayNames,
+ getControllerDisplayName,
setDispatchPresenceOfflineCheck,
} from './dispatch';
import {
@@ -1437,6 +1438,11 @@ export async function setKeepAwakeEnabled(enabled: boolean): Promise<void> {
log.info(`keep-awake ${enabled ? 'enabled' : 'disabled'}`);
}
+/** 被控端:控制端展示名(链路/presence 优先,其次本机缓存);都没有时返回 undefined。 */
+export function getControllerName(deviceId: string): string | undefined {
+ return getControllerDisplayName(deviceId) ?? readLastKnownDeviceNames()[deviceId];
+}
+
/** 被控端:一键断开当前所有控制链路(WS 与开关保持) */
export function disconnectAllControllers(): void {
if (client) dropAllControllers(client, 'user');
diff --git a/apps/desktop/src/main/remote-desktop/__tests__/controlledOverlay.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/controlledOverlay.test.ts
new file mode 100644
index 0000000000..40131a0516
--- /dev/null
+++ b/apps/desktop/src/main/remote-desktop/__tests__/controlledOverlay.test.ts
@@ -0,0 +1,410 @@
+import { EventEmitter } from 'node:events';
+import { beforeEach, expect, it, vi, type Mock } from 'vitest';
+
+interface Bounds {
+ x: number;
+ y: number;
+ width: number;
+ height: number;
+}
+type Options = Record<string, unknown> & { width: number; height: number };
+interface FakeWindow extends EventEmitter {
+ destroyed: boolean;
+ options: Options;
+ html: string;
+ loadURL: Mock;
+ webContents: EventEmitter & { executeJavaScript: Mock };
+ setContentProtection: Mock;
+ setAlwaysOnTop: Mock;
+ getBounds(): Bounds;
+ setBounds(bounds: Bounds): void;
+ isVisible(): boolean;
+}
+
+const state = vi.hoisted(() => ({
+ windows: [] as FakeWindow[],
+ displays: [] as Array<{ id: number; bounds: Bounds; workArea: Bounds }>,
+ events: [] as string[],
+ /** Optional per-load hook: return a promise to hold or fail a page load. */
+ load: null as null | ((window: FakeWindow) => Promise<void> | void),
+ confirm: vi.fn(),
+ themeMode: 'system' as 'system' | 'light' | 'dark',
+}));
+vi.mock('../../i18n', () => ({
+ t: (key: string) => (key.endsWith('ByDevice') ? `${key}:{{name}}` : key),
+}));
+vi.mock('../../window-theme-mode-store', () => ({
+ readWindowThemeSnapshot: () => ({ mode: state.themeMode }),
+}));
+vi.mock('../../logger', () => ({ createLogger: () => ({ debug: vi.fn(), warn: vi.fn() }) }));
+vi.mock('../privacyScreenHtml', () => ({
+ escapeHtml: (value: string) =>
+ value.replace(
+ /[&<>"']/g,
+ (char) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]!,
+ ),
+}));
+vi.mock('electron', () => ({
+ app: { focus: vi.fn() },
+ dialog: { showMessageBox: state.confirm },
+ nativeTheme: { shouldUseDarkColors: false },
+ BrowserWindow: class extends EventEmitter {
+ id = state.windows.length + 1;
+ destroyed = false;
+ visible = false;
+ html = '';
+ options: Options;
+ bounds: Bounds;
+ webContents = Object.assign(new EventEmitter(), {
+ setWindowOpenHandler: vi.fn(),
+ // The page width follows the label that was actually loaded.
+ executeJavaScript: vi.fn(async () =>
+ this.html.includes('ByDevice') ? 240 : this.html.includes('beingControlled') ? 180 : 160,
+ ),
+ });
+ constructor(options: Options) {
+ super();
+ this.options = options;
+ this.bounds = { x: 0, y: 0, width: options.width, height: options.height };
+ state.windows.push(this as unknown as FakeWindow);
+ }
+ setMenuBarVisibility() {}
+ loadURL = vi.fn(async (url: string) => {
+ await state.load?.(this as unknown as FakeWindow);
+ this.html = decodeURIComponent(url.slice(url.indexOf(',') + 1));
+ });
+ setContentProtection = vi.fn();
+ setVisibleOnAllWorkspaces = vi.fn();
+ setAlwaysOnTop = vi.fn();
+ getMediaSourceId() {
+ return `window:${100 + this.id}:0`;
+ }
+ getBounds() {
+ return this.bounds;
+ }
+ setBounds(bounds: Bounds) {
+ this.bounds = bounds;
+ }
+ showInactive() {
+ state.events.push(`show:${100 + this.id}`);
+ this.visible = true;
+ }
+ isVisible() {
+ return this.visible;
+ }
+ isDestroyed() {
+ return this.destroyed;
+ }
+ destroy() {
+ this.destroyed = true;
+ this.emit('closed');
+ }
+ },
+ screen: Object.assign(new EventEmitter(), {
+ getAllDisplays: () => state.displays,
+ getPrimaryDisplay: () => state.displays[0],
+ }),
+ session: {
+ fromPartition: () => ({
+ setPermissionCheckHandler() {},
+ setPermissionRequestHandler() {},
+ webRequest: { onBeforeRequest() {} },
+ }),
+ },
+}));
+
+import { screen } from 'electron';
+import { ControlledOverlay } from '../controlledOverlay';
+
+const primary = {
+ id: 1,
+ bounds: { x: 0, y: 0, width: 1440, height: 900 },
+ workArea: { x: 0, y: 25, width: 1440, height: 875 },
+};
+const secondary = {
+ id: 2,
+ bounds: { x: 1440, y: 0, width: 1920, height: 1080 },
+ workArea: { x: 1440, y: 0, width: 1920, height: 1040 },
+};
+const phone = { displayId: '1', controlling: true, peer: 'phone', name: 'iPhone' };
+const laptop = { displayId: '1', controlling: true, peer: 'laptop', name: 'MacBook' };
+const settle = async () => {
+ for (let i = 0; i < 20; i++) await Promise.resolve();
+};
+function fixture() {
+ const excluded = vi.fn((ids: number[]) => state.events.push(`exclude:${ids.join(',')}`));
+ const revoke = vi.fn<(peer: string) => Promise<void>>(async () => {});
+ return { overlay: new ControlledOverlay(excluded, revoke), excluded, revoke };
+}
+const navigate = (window: FakeWindow, url: string) => {
+ const event = { url, preventDefault: vi.fn() };
+ window.webContents.emit('will-navigate', event);
+ return event;
+};
+/** Clicks the revoke link of the page the window currently shows. */
+const clickRevoke = (window: FakeWindow) => {
+ const href = /<a href="([^"]+)"/.exec(window.html)?.[1].replaceAll('&amp;', '&');
+ return navigate(window, href!);
+};
+
+beforeEach(() => {
+ screen.removeAllListeners();
+ state.windows.length = 0;
+ state.events.length = 0;
+ state.displays = [primary, secondary];
+ state.load = null;
+ state.confirm.mockReset().mockResolvedValue({ response: 1 });
+ state.themeMode = 'system';
+});
+
+it('filters the overlay from capture before its first visible frame', async () => {
+ const { overlay } = fixture();
+ overlay.update({ displayId: '1', controlling: false, peer: 'phone' });
+ await settle();
+ const [window] = state.windows;
+ expect(window.options).toMatchObject({
+ show: false,
+ frame: false,
+ transparent: true,
+ focusable: false,
+ skipTaskbar: true,
+ webPreferences: expect.objectContaining({ sandbox: true, contextIsolation: true }),
+ });
+ expect(window.options.closable).toBeUndefined();
+ expect(window.setContentProtection).toHaveBeenCalledWith(true);
+ expect(window.setAlwaysOnTop).toHaveBeenCalledWith(true, 'screen-saver');
+ expect(state.events).toEqual(['exclude:101', 'show:101']);
+ expect(window.html).toContain('remoteDesktop.beingViewed');
+ // Measured pill width, centred under the top of the shared display's work area.
+ expect(window.getBounds()).toEqual({ x: 640, y: 37, width: 160, height: 28 });
+});
+
+it('reloads the label in place when control is granted', async () => {
+ const { overlay, excluded } = fixture();
+ overlay.update({ displayId: '1', controlling: false, peer: 'phone' });
+ await settle();
+ overlay.update({ displayId: '1', controlling: true, peer: 'phone' });
+ await settle();
+ expect(state.windows).toHaveLength(1);
+ expect(state.windows[0].html).toContain('remoteDesktop.beingControlled');
+ expect(state.windows[0].getBounds()).toMatchObject({ x: 640, width: 180 });
+ expect(excluded).toHaveBeenCalledTimes(1);
+});
+
+it('keeps a dragged overlay on the shared display and remembers it for the run', async () => {
+ const { overlay } = fixture();
+ const target = { displayId: '1', controlling: true, peer: 'phone' };
+ overlay.update(target);
+ await settle();
+ const window = state.windows[0];
+ window.setBounds({ x: 1400, y: 500, width: 180, height: 28 });
+ window.emit('moved');
+ expect(window.getBounds()).toEqual({ x: 1260, y: 500, width: 180, height: 28 });
+ overlay.update(null);
+ overlay.update(target);
+ await settle();
+ expect(state.windows[1].getBounds()).toEqual({ x: 1260, y: 500, width: 180, height: 28 });
+ // A lease on another display starts from that display's default spot.
+ overlay.update({ ...target, displayId: '2' });
+ await settle();
+ expect(state.windows[1].getBounds()).toEqual({ x: 2310, y: 12, width: 180, height: 28 });
+});
+
+it('removes the window and its capture filter when the lease or privacy ends it', async () => {
+ const { overlay, excluded } = fixture();
+ overlay.update(phone);
+ await settle();
+ overlay.update(null);
+ expect(state.windows[0].destroyed).toBe(true);
+ expect(excluded).toHaveBeenLastCalledWith([]);
+ expect(screen.listenerCount('display-metrics-changed')).toBe(0);
+ overlay.update(null);
+ expect(excluded).toHaveBeenCalledTimes(2);
+});
+
+it('never shows or filters a window whose lease ended while it loaded', async () => {
+ let finish!: () => void;
+ state.load = () => new Promise<void>((resolve) => (finish = resolve));
+ const { overlay, excluded } = fixture();
+ overlay.update(phone);
+ overlay.update(null);
+ finish();
+ await settle();
+ expect(state.windows[0].destroyed).toBe(true);
+ expect(state.windows[0].isVisible()).toBe(false);
+ expect(excluded).not.toHaveBeenCalledWith([101]);
+});
+
+it('drops the filter if the renderer dies and recreates on the next sync', async () => {
+ const { overlay, excluded } = fixture();
+ overlay.update(phone);
+ await settle();
+ state.windows[0].webContents.emit('render-process-gone');
+ expect(excluded).toHaveBeenLastCalledWith([]);
+ overlay.update(phone);
+ await settle();
+ expect(state.events.at(-1)).toBe('show:102');
+});
+
+it('renders the viewing device name as escaped markup and skips unchanged targets', async () => {
+ const { overlay, revoke } = fixture();
+ const target = { displayId: '1', controlling: true, peer: 'p&1', name: 'x</span><b>y' };
+ overlay.update(target);
+ await settle();
+ const window = state.windows[0];
+ expect(window.html).toContain('remoteDesktop.controlledByDevice:x&lt;/span&gt;&lt;b&gt;y');
+ expect(window.html).not.toContain('<b>');
+ expect(window.html).toContain('remoteDevice.revokeAccess');
+ expect(window.getBounds()).toMatchObject({ x: 600, width: 240 });
+ // Only constant code is ever executed in the page.
+ expect(new Set(window.webContents.executeJavaScript.mock.calls.map(([code]) => code)).size).toBe(
+ 1,
+ );
+ overlay.update({ ...target });
+ await settle();
+ expect(window.loadURL).toHaveBeenCalledTimes(1);
+ clickRevoke(window);
+ await settle();
+ expect(revoke).toHaveBeenCalledExactlyOnceWith('p&1');
+});
+
+it('revokes the device named on the clicked page, only after confirmation', async () => {
+ const { overlay, revoke } = fixture();
+ overlay.update(phone);
+ await settle();
+ const window = state.windows[0];
+ state.confirm.mockResolvedValueOnce({ response: 0 });
+ expect(clickRevoke(window).preventDefault).toHaveBeenCalled();
+ await settle();
+ expect(revoke).not.toHaveBeenCalled();
+
+ // The lease moves to another viewer, but its page is still loading.
+ let finishLoad!: () => void;
+ state.load = () => new Promise<void>((resolve) => (finishLoad = resolve));
+ overlay.update(laptop);
+ // The periodic sync repeats the same target while it loads.
+ overlay.update(laptop);
+ await settle();
+ expect(window.loadURL).toHaveBeenCalledTimes(2);
+ let answer!: (value: { response: number }) => void;
+ state.confirm.mockReturnValueOnce(new Promise((resolve) => (answer = resolve)));
+ clickRevoke(window);
+ // A second click while the dialog is open does not stack another dialog.
+ clickRevoke(window);
+ answer({ response: 1 });
+ await settle();
+ expect(state.confirm).toHaveBeenCalledTimes(2);
+ expect(revoke).toHaveBeenCalledExactlyOnceWith('phone');
+
+ finishLoad();
+ await settle();
+ clickRevoke(window);
+ await settle();
+ expect(revoke).toHaveBeenLastCalledWith('laptop');
+});
+
+it('cancels every other navigation without acting', async () => {
+ const { overlay, revoke } = fixture();
+ overlay.update(phone);
+ await settle();
+ expect(navigate(state.windows[0], 'https://example.com/').preventDefault).toHaveBeenCalled();
+ expect(
+ navigate(state.windows[0], 'https://cindy-overlay.invalid/revoke?peer=').preventDefault,
+ ).toHaveBeenCalled();
+ await settle();
+ expect(state.confirm).not.toHaveBeenCalled();
+ expect(revoke).not.toHaveBeenCalled();
+});
+
+it('stops recreating after repeated renderer crashes until the lease ends', async () => {
+ const { overlay } = fixture();
+ for (let i = 0; i < 3; i++) {
+ overlay.update(phone);
+ await settle();
+ state.windows.at(-1)!.webContents.emit('render-process-gone');
+ }
+ overlay.update(phone);
+ await settle();
+ expect(state.windows).toHaveLength(3);
+ overlay.update(null);
+ overlay.update(phone);
+ await settle();
+ expect(state.windows).toHaveLength(4);
+});
+
+it('does not charge a lease for loads aborted by a newer page or an earlier lease', async () => {
+ const { overlay } = fixture();
+ // An earlier lease ends mid-load; its aborted load must not count later.
+ let abortFirst!: (error: Error) => void;
+ state.load = () => new Promise<void>((_, reject) => (abortFirst = reject));
+ overlay.update(phone);
+ overlay.update(null);
+ state.load = null;
+ overlay.update(laptop);
+ abortFirst(new Error('ERR_ABORTED'));
+ await settle();
+ expect(state.events.at(-1)).toBe('show:102');
+ // A newer label aborts the pending one; the overlay stays up.
+ const window = state.windows[1];
+ let abortPending!: (error: Error) => void;
+ state.load = () => new Promise<void>((_, reject) => (abortPending = reject));
+ overlay.update(phone);
+ state.load = null;
+ overlay.update({ ...phone, controlling: false });
+ abortPending(new Error('ERR_ABORTED'));
+ await settle();
+ expect(window.destroyed).toBe(false);
+ expect(window.html).toContain('remoteDesktop.viewedByDevice');
+ for (let i = 0; i < 2; i++) {
+ overlay.update(laptop);
+ await settle();
+ state.windows.at(-1)!.webContents.emit('render-process-gone');
+ }
+ // Two real crashes so far: one more recreation is still allowed.
+ overlay.update(laptop);
+ await settle();
+ expect(state.windows.at(-1)!.isVisible()).toBe(true);
+});
+
+it('never shows a window whose first page could not be measured', async () => {
+ const { overlay, excluded } = fixture();
+ state.load = (window) => {
+ window.webContents.executeJavaScript.mockRejectedValueOnce(new Error('x'));
+ };
+ overlay.update(phone);
+ await settle();
+ expect(state.windows[0].destroyed).toBe(true);
+ expect(state.windows[0].isVisible()).toBe(false);
+ expect(excluded).not.toHaveBeenCalledWith([101]);
+});
+
+it("follows Cindy's selected appearance rather than only the OS", async () => {
+ const { overlay } = fixture();
+ state.themeMode = 'dark';
+ overlay.update(phone);
+ await settle();
+ const window = state.windows[0];
+ expect(window.html).toContain('<html class="dark">');
+ state.themeMode = 'light';
+ overlay.update(phone);
+ await settle();
+ expect(window.html).toContain('<html>');
+});
+
+it('does not fail when a newer page interrupts the previous measurement', async () => {
+ const { overlay } = fixture();
+ overlay.update(phone);
+ await settle();
+ const window = state.windows[0];
+ let interrupt!: (error: Error) => void;
+ window.webContents.executeJavaScript.mockImplementationOnce(
+ () => new Promise((_, reject) => (interrupt = reject)),
+ );
+ overlay.update(laptop);
+ await settle();
+ overlay.update({ ...laptop, controlling: false });
+ interrupt(new Error('Execution context was destroyed'));
+ await settle();
+ expect(window.destroyed).toBe(false);
+ expect(window.html).toContain('remoteDesktop.viewedByDevice:MacBook');
+});
diff --git a/apps/desktop/src/main/remote-desktop/controlledOverlay.ts b/apps/desktop/src/main/remote-desktop/controlledOverlay.ts
new file mode 100644
index 0000000000..10cdf6bee1
--- /dev/null
+++ b/apps/desktop/src/main/remote-desktop/controlledOverlay.ts
@@ -0,0 +1,361 @@
+import {
+ app,
+ BrowserWindow,
+ dialog,
+ nativeTheme,
+ screen,
+ session,
+ type Display,
+ type Rectangle,
+} from 'electron';
+import { createLogger } from '../logger';
+import { t } from '../i18n';
+import { resolveAppThemeIsDark } from '../resolved-app-theme';
+import { readWindowThemeSnapshot } from '../window-theme-mode-store';
+import { escapeHtml } from './privacyScreenHtml';
+
+const log = createLogger('remote-desktop:overlay');
+
+const HEIGHT = 28;
+const INITIAL_WIDTH = 220;
+const TOP_MARGIN = 12;
+// Renderer crashes / load failures tolerated per lease before giving up.
+const MAX_FAILURES = 3;
+// Never loaded: the page has no script, so its only way to talk to Main is
+// its revoke link, which will-navigate cancels and recognizes by this prefix.
+const REVOKE_URL = 'https://cindy-overlay.invalid/revoke?peer=';
+// Constant code only: every label is rendered into the page markup itself.
+const MEASURE_SCRIPT = "Math.ceil(document.querySelector('main').getBoundingClientRect().width)";
+
+export interface ControlledOverlayTarget {
+ displayId: string;
+ controlling: boolean;
+ /** Device id of the viewer holding the lease. */
+ peer: string;
+ name?: string;
+}
+
+/** Isolated data page: mirrors surface / border / text / chip-neutral / Thinking Orange tokens (DESIGN.md §2, §10). */
+function overlayHtml(text: string, label: string, dark: boolean, peer: string): string {
+ return `<!doctype html><html${dark ? ' class="dark"' : ''}><head><meta charset="utf-8">
+<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'">
+<style>
+:root{color-scheme:light;--surface:#ffffff;--border:#d7d7d4;--text-primary:#262626;--accent:#ea6b17;--chip:#e5e5e5}
+:root.dark{color-scheme:dark;--surface:#2c2c2a;--border:#3c3c3a;--text-primary:#d4d4d4;--chip:#3c3c3a}
+html,body{margin:0;height:100%;overflow:hidden;background:transparent}
+body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;user-select:none;cursor:default;-webkit-app-region:drag}
+main{display:inline-flex;align-items:center;gap:8px;box-sizing:border-box;height:${HEIGHT}px;padding:0 4px 0 12px;border:1px solid var(--border);border-radius:9999px;background:var(--surface);color:var(--text-primary);font-size:12px;white-space:nowrap}
+i{flex:none;width:6px;height:6px;border-radius:50%;background:var(--accent);animation:breathe 1.5s ease-in-out infinite}
+span{max-width:260px;overflow:hidden;text-overflow:ellipsis}
+a{flex:none;-webkit-app-region:no-drag;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:9999px;background:var(--chip);color:var(--text-primary);text-decoration:none;-webkit-user-drag:none}
+a:hover{opacity:.8}
+@keyframes breathe{0%,100%{opacity:.3}50%{opacity:1}}
+@media(prefers-reduced-motion:reduce){i{animation:none}}
+</style></head><body><main><i></i><span>${escapeHtml(text)}</span><a href="${escapeHtml(REVOKE_URL + encodeURIComponent(peer))}" draggable="false">${escapeHtml(label)}</a></main></body></html>`;
+}
+
+/** The device named on the page whose revoke link was clicked. */
+function revokedPeer(url: string): string | null {
+ if (!url.startsWith(REVOKE_URL)) return null;
+ try {
+ return decodeURIComponent(url.slice(REVOKE_URL.length)) || null;
+ } catch {
+ return null;
+ }
+}
+
+/** Cindy's selected Light / Dark mode, not just the OS appearance. */
+function overlayIsDark(): boolean {
+ const theme = readWindowThemeSnapshot();
+ return resolveAppThemeIsDark(nativeTheme.shouldUseDarkColors, theme.mode, theme.resolvedIsDark);
+}
+
+function clamp(bounds: Rectangle, area: Rectangle): Rectangle {
+ const x = Math.min(Math.max(bounds.x, area.x), area.x + area.width - bounds.width);
+ const y = Math.min(Math.max(bounds.y, area.y), area.y + area.height - bounds.height);
+ return { ...bounds, x: Math.round(x), y: Math.round(y) };
+}
+
+/** Local-only reminder that this desktop is shared: above every app, draggable,
+ * and excluded from what the viewer receives. Frameless and never focused, it
+ * has no close affordance; the lease alone decides its lifetime.
+ *
+ * Every label change loads a fresh static page whose revoke link carries the
+ * device it names, so a click always revokes exactly the device on screen.
+ * The revoke button first asks in a visible system dialog, so a blind click
+ * from the viewer (who cannot see the overlay) cannot revoke anything itself.
+ * (`closable: false` is avoided: on macOS it cancels window-list closes.)
+ */
+export class ControlledOverlay {
+ private window: BrowserWindow | null = null;
+ private target: ControlledOverlayTarget | null = null;
+ private shown = false;
+ private failures = 0;
+ /** Page currently loaded, and the one being loaded (superseded loads are ignored). */
+ private loadedKey = '';
+ private loadingKey = '';
+ private loadSeq = 0;
+ private placedDisplay: string | null = null;
+ private generation = 0;
+ private partitionConfigured = false;
+ private confirming = false;
+ /** Last dragged origin, kept for this app run only. */
+ private position: { x: number; y: number } | null = null;
+
+ constructor(
+ private readonly excluded: (ids: number[]) => void,
+ private readonly revoke: (peer: string) => Promise<void>,
+ ) {}
+
+ /** Idempotent; `null` removes the overlay. */
+ update(target: ControlledOverlayTarget | null): void {
+ if (!target) {
+ // A new lease gets a fresh recreation budget.
+ this.failures = 0;
+ this.stop();
+ return;
+ }
+ this.target = target;
+ const window = this.window;
+ if (!window) {
+ if (this.failures < MAX_FAILURES) void this.create(this.generation + 1);
+ return;
+ }
+ // Until it is shown, create() renders the latest target itself.
+ if (this.shown) {
+ const generation = this.generation;
+ void this.render(window, generation).catch((error) => this.fail(window, generation, error));
+ }
+ }
+
+ stop(): void {
+ this.generation++;
+ this.target = null;
+ const window = this.window;
+ if (!window) return;
+ this.window = null;
+ this.shown = false;
+ this.loadedKey = '';
+ this.loadingKey = '';
+ this.placedDisplay = null;
+ if (!window.isDestroyed()) window.destroy();
+ this.excluded([]);
+ }
+
+ /** The only failure path: counts against the lease that owns this window. */
+ private fail(window: BrowserWindow, generation: number, error: unknown): void {
+ if (generation !== this.generation || this.window !== window) return;
+ log.warn('overlay unavailable', error);
+ this.failures++;
+ this.stop();
+ }
+
+ private display(): Display {
+ return (
+ screen.getAllDisplays().find((display) => String(display.id) === this.target?.displayId) ??
+ screen.getPrimaryDisplay()
+ );
+ }
+
+ /** Keeps the overlay on the shared display: the capture filter needs it there. */
+ private layout(window: BrowserWindow, width = window.getBounds().width): void {
+ const display = this.display();
+ const current = window.getBounds();
+ let origin = { x: current.x, y: current.y };
+ if (this.placedDisplay !== String(display.id)) {
+ const remembered = this.position;
+ const { bounds, workArea } = display;
+ origin =
+ remembered &&
+ remembered.x >= bounds.x &&
+ remembered.y >= bounds.y &&
+ remembered.x < bounds.x + bounds.width &&
+ remembered.y < bounds.y + bounds.height
+ ? remembered
+ : {
+ x: workArea.x + Math.round((workArea.width - width) / 2),
+ y: workArea.y + TOP_MARGIN,
+ };
+ this.placedDisplay = String(display.id);
+ }
+ const next = clamp({ ...origin, width, height: HEIGHT }, display.bounds);
+ if (
+ next.x !== current.x ||
+ next.y !== current.y ||
+ next.width !== current.width ||
+ next.height !== current.height
+ )
+ window.setBounds(next, false);
+ }
+
+ /** Loads the page for the current target. Throws on real failure; a load
+ * superseded by a newer target or lease returns quietly. */
+ private async render(window: BrowserWindow, generation: number): Promise<void> {
+ const target = this.target;
+ if (!target || generation !== this.generation || this.window !== window) return;
+ const text = target.name
+ ? t(
+ target.controlling ? 'remoteDesktop.controlledByDevice' : 'remoteDesktop.viewedByDevice',
+ ).replaceAll('{{name}}', target.name)
+ : t(target.controlling ? 'remoteDesktop.beingControlled' : 'remoteDesktop.beingViewed');
+ const label = t('remoteDevice.revokeAccess');
+ const dark = overlayIsDark();
+ const key = JSON.stringify([text, label, dark, target.peer]);
+ if (key === this.loadedKey) {
+ if (this.placedDisplay !== String(this.display().id)) this.layout(window);
+ return;
+ }
+ if (key === this.loadingKey) return;
+ const seq = ++this.loadSeq;
+ this.loadingKey = key;
+ const current = () =>
+ seq === this.loadSeq && generation === this.generation && !window.isDestroyed();
+ let width: unknown;
+ try {
+ await window.loadURL(
+ `data:text/html;charset=utf-8,${encodeURIComponent(overlayHtml(text, label, dark, target.peer))}`,
+ );
+ if (!current()) return;
+ width = await window.webContents.executeJavaScript(MEASURE_SCRIPT);
+ } catch (error) {
+ // A newer page aborts this load or its measurement; that is not a failure.
+ if (!current()) return;
+ throw error;
+ }
+ if (!current()) return;
+ if (typeof width !== 'number' || !Number.isFinite(width) || width <= 0)
+ throw new Error('overlay label unavailable');
+ this.loadingKey = '';
+ this.loadedKey = key;
+ this.layout(window, width);
+ }
+
+ private async confirmRevoke(peer: string): Promise<void> {
+ if (this.confirming) return;
+ this.confirming = true;
+ try {
+ app.focus({ steal: true });
+ const { response } = await dialog.showMessageBox({
+ type: 'warning',
+ message: t('settings.remoteControl.revokeConfirm.title'),
+ detail: t('settings.remoteControl.revokeConfirm.description'),
+ buttons: [t('privacyExit.cancel'), t('settings.remoteControl.revokeConfirm.confirm')],
+ defaultId: 0,
+ cancelId: 0,
+ noLink: true,
+ });
+ if (response === 1) await this.revoke(peer);
+ } catch (error) {
+ log.warn('overlay revoke failed', error);
+ } finally {
+ this.confirming = false;
+ }
+ }
+
+ private async create(generation: number): Promise<void> {
+ this.generation = generation;
+ const partition = session.fromPartition('cindy-desktop-overlay', { cache: false });
+ if (!this.partitionConfigured) {
+ partition.setPermissionCheckHandler(() => false);
+ partition.setPermissionRequestHandler((_webContents, _permission, callback) =>
+ callback(false),
+ );
+ partition.webRequest.onBeforeRequest((details, callback) =>
+ callback({ cancel: !details.url.startsWith('data:') }),
+ );
+ this.partitionConfigured = true;
+ }
+ let window: BrowserWindow;
+ try {
+ window = new BrowserWindow({
+ width: INITIAL_WIDTH,
+ height: HEIGHT,
+ show: false,
+ // A non-activating panel joins full-screen Spaces without converting
+ // the whole app into a UI element (no Dock flicker per session).
+ ...(process.platform === 'darwin' ? { type: 'panel' } : {}),
+ frame: false,
+ transparent: true,
+ backgroundColor: '#00000000',
+ hasShadow: false,
+ roundedCorners: false,
+ acceptFirstMouse: true,
+ focusable: false,
+ resizable: false,
+ minimizable: false,
+ maximizable: false,
+ fullscreenable: false,
+ skipTaskbar: true,
+ webPreferences: {
+ session: partition,
+ sandbox: true,
+ contextIsolation: true,
+ nodeIntegration: false,
+ nodeIntegrationInSubFrames: false,
+ nodeIntegrationInWorker: false,
+ webSecurity: true,
+ allowRunningInsecureContent: false,
+ experimentalFeatures: false,
+ plugins: false,
+ navigateOnDragDrop: false,
+ devTools: false,
+ },
+ });
+ } catch (error) {
+ log.warn('overlay unavailable', error);
+ this.failures++;
+ return;
+ }
+ this.window = window;
+ const relayout = () => {
+ if (this.window === window && this.shown && !window.isDestroyed()) this.layout(window);
+ };
+ screen.on('display-metrics-changed', relayout);
+ window.on('moved', () => {
+ if (this.window !== window || window.isDestroyed()) return;
+ this.layout(window);
+ const { x, y } = window.getBounds();
+ this.position = { x, y };
+ });
+ window.on('closed', () => {
+ screen.removeListener('display-metrics-changed', relayout);
+ if (this.window !== window) return;
+ this.window = null;
+ this.shown = false;
+ this.loadedKey = '';
+ this.loadingKey = '';
+ this.placedDisplay = null;
+ this.excluded([]);
+ });
+ window.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
+ window.webContents.on('will-navigate', (event) => {
+ event.preventDefault();
+ const peer = revokedPeer(event.url);
+ if (peer && this.window === window) void this.confirmRevoke(peer);
+ });
+ window.webContents.on('render-process-gone', () =>
+ this.fail(window, generation, new Error('overlay renderer gone')),
+ );
+ try {
+ window.setMenuBarVisibility(false);
+ window.setContentProtection(true);
+ window.setVisibleOnAllWorkspaces(true, {
+ visibleOnFullScreen: true,
+ skipTransformProcessType: true,
+ });
+ window.setAlwaysOnTop(true, 'screen-saver');
+ await this.render(window, generation);
+ // Pick up a target that changed while the first page loaded.
+ await this.render(window, generation);
+ if (generation !== this.generation || window.isDestroyed() || !this.loadedKey) return;
+ const id = Number(window.getMediaSourceId().split(':')[1]);
+ if (!Number.isSafeInteger(id) || id <= 0) throw new Error('overlay window id unavailable');
+ // Install the capture filter before the first visible frame.
+ this.excluded([id]);
+ window.showInactive();
+ this.shown = true;
+ } catch (error) {
+ this.fail(window, generation, error);
+ }
+ }
+}
diff --git a/apps/desktop/src/main/remote-desktop/index.ts b/apps/desktop/src/main/remote-desktop/index.ts
index c7f0bb18d4..e0e7a45a27 100644
--- a/apps/desktop/src/main/remote-desktop/index.ts
+++ b/apps/desktop/src/main/remote-desktop/index.ts
@@ -74,6 +74,7 @@ import {
import { readLinuxCursorSupport } from './linuxCapture';
import { LinuxDesktopMute, supportsLinuxMute } from './linuxMute';
import { PrivacyScreen } from './privacyScreen';
+import { ControlledOverlay } from './controlledOverlay';
import { LinuxPrivacyScreen, supportsLinuxPrivacy, prepareLinuxPrivacy } from './linuxPrivacy';
import { LinuxWindowActions, supportsOmarchyMenu } from './linuxWindowActions';
import { systemAudioMuteGuard } from '../voice-input/SystemAudioMuteGuard.js';
@@ -167,8 +168,16 @@ const linuxMute = new LinuxDesktopMute();
const linuxWindows = new LinuxWindowActions();
const nativeWayland = () => wayland() && supportsHyprlandCapture();
const portalWayland = () => wayland() && !nativeWayland();
+// Privacy masks and the controlled-desktop overlay share one capture filter.
+let privacyExcluded: number[] = [];
+let overlayExcluded: number[] = [];
+const applyExcludedWindows = () =>
+ nativeCapture.setExcludedWindows([...privacyExcluded, ...overlayExcluded]);
const privacyScreen = new PrivacyScreen(
- (ids) => nativeCapture.setExcludedWindows(ids),
+ (ids) => {
+ privacyExcluded = ids;
+ applyExcludedWindows();
+ },
() => {
return remoteDesktop
.stopPrivacyByUser()
@@ -185,6 +194,41 @@ const supportsPrivacyScreen =
typeof process.getSystemVersion === 'function' &&
Number(process.getSystemVersion().split('.')[0]) >= 14) ||
(process.platform === 'win32' && Number(osRelease().split('.')[2]) >= 19041);
+// Windows honours content protection in capture; modern macOS capture needs the
+// explicit filter. Same platform floor as the privacy masks.
+const controlledOverlay = new ControlledOverlay(
+ (ids) => {
+ if (process.platform !== 'darwin') return;
+ overlayExcluded = ids;
+ applyExcludedWindows();
+ },
+ async (peer) => {
+ if (!controllerDirectory) throw new Error('controller directory unavailable');
+ await controllerDirectory.revoke(peer);
+ },
+);
+/** Device-link owns names and revocation; injected at registration (no import cycle). */
+export interface RemoteDesktopControllerDirectory {
+ name(peer: string): string | undefined;
+ revoke(peer: string): Promise<void>;
+}
+let controllerDirectory: RemoteDesktopControllerDirectory | null = null;
+// The privacy masks replace the overlay for as long as they are requested.
+let privacyRequested = false;
+function syncControlledOverlay(): void {
+ const state = remoteDesktop.state;
+ const displayId = remoteDesktop.displayId;
+ controlledOverlay.update(
+ supportsPrivacyScreen && state && displayId && !privacyRequested
+ ? {
+ displayId,
+ controlling: state.controlling,
+ peer: state.peer,
+ name: controllerDirectory?.name(state.peer),
+ }
+ : null,
+ );
+}
let displayAwake: number | null = null;
let nativeDisplay: string | null = null;
let windowsAvailable = false;
@@ -551,6 +595,33 @@ export async function requestRemoteDesktop(peer: string, value: unknown): Promis
: remoteDesktop.request(peer, value);
}
+async function setPrivacyScreen(enabled: boolean, current: () => boolean): Promise<void> {
+ if (enabled && process.platform === 'darwin' && videoLease && nativeDisplay) {
+ nativeOverlay = true;
+ await privacyScreen.set(true, current);
+ try {
+ await nativeCapture.preparePrivacy(nativeDisplay, nativeSettings);
+ } catch (error) {
+ if (current()) privacyScreen.stop();
+ throw error;
+ }
+ if (!current()) {
+ throw new Error('DESKTOP_LEASE_EXPIRED');
+ }
+ return;
+ }
+ await privacyScreen.set(enabled, current);
+ if (!enabled || process.platform === 'win32') return;
+ const deadline = Date.now() + 4500;
+ while (current() && !nativeCapture.privacyReady && Date.now() < deadline)
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ if (!current()) throw new Error('DESKTOP_LEASE_EXPIRED');
+ if (!nativeCapture.privacyReady) {
+ privacyScreen.stop();
+ throw new Error('DESKTOP_PRIVACY_UNAVAILABLE');
+ }
+}
+
export const remoteDesktop: RemoteDesktopController = new RemoteDesktopController({
prepare: async (current) => {
if (nativeWayland() && (await supportsLinuxPrivacy())) {
@@ -703,34 +774,32 @@ export const remoteDesktop: RemoteDesktopController = new RemoteDesktopControlle
privacyScreen: async (enabled, current) => {
if (process.platform === 'linux') return linuxPrivacy.set(enabled, current);
if (!supportsPrivacyScreen) throw new Error('DESKTOP_PRIVACY_UNAVAILABLE');
- if (enabled && process.platform === 'darwin' && videoLease && nativeDisplay) {
- nativeOverlay = true;
- await privacyScreen.set(true, current);
- try {
- await nativeCapture.preparePrivacy(nativeDisplay, nativeSettings);
- } catch (error) {
- if (current()) privacyScreen.stop();
- throw error;
- }
- if (!current()) {
- throw new Error('DESKTOP_LEASE_EXPIRED');
- }
- return;
+ // The masks replace the overlay: remove it before they appear, restore it
+ // after they are gone, so the privacy filter only ever covers masks.
+ if (enabled) {
+ privacyRequested = true;
+ syncControlledOverlay();
}
- await privacyScreen.set(enabled, current);
- if (!enabled || process.platform === 'win32') return;
- const deadline = Date.now() + 4500;
- while (current() && !nativeCapture.privacyReady && Date.now() < deadline)
- await new Promise((resolve) => setTimeout(resolve, 50));
- if (!current()) throw new Error('DESKTOP_LEASE_EXPIRED');
- if (!nativeCapture.privacyReady) {
- privacyScreen.stop();
- throw new Error('DESKTOP_PRIVACY_UNAVAILABLE');
+ let restoreOverlay = !enabled;
+ try {
+ await setPrivacyScreen(enabled, current);
+ } catch (error) {
+ restoreOverlay = true;
+ throw error;
+ } finally {
+ // A newer privacy request or the lease teardown owns the flag otherwise.
+ if (restoreOverlay && current()) {
+ privacyRequested = false;
+ syncControlledOverlay();
+ }
}
},
stopPrivacyScreen: () => {
privacyScreen.stop();
linuxPrivacy.stop();
+ privacyRequested = false;
+ // Called from inside lease teardown; read controller state afterwards.
+ queueMicrotask(syncControlledOverlay);
},
windowAction: (action, id, display, current) => {
if (!nativeWayland()) throw new Error('DESKTOP_INPUT_UNSUPPORTED');
@@ -820,14 +889,21 @@ export const remoteDesktop: RemoteDesktopController = new RemoteDesktopControlle
powerSaveBlocker.stop(displayAwake);
displayAwake = null;
}
+ syncControlledOverlay();
},
});
export function registerRemoteDesktopIpc(
isVoiceInputOwner?: Parameters<typeof denyAppDesktopCapture>[1],
+ controllers?: RemoteDesktopControllerDirectory,
): void {
+ controllerDirectory = controllers ?? null;
denyAppDesktopCapture(session.defaultSession, isVoiceInputOwner);
- const timer = setInterval(() => remoteDesktop.tick(), 1000);
+ const timer = setInterval(() => {
+ remoteDesktop.tick();
+ // Device names can arrive after the lease starts (presence refresh).
+ syncControlledOverlay();
+ }, 1000);
timer.unref();
onQuit('remote-desktop-clipboard', stopLinuxClipboardWriter);
onQuit('remote-desktop-stop', () => {
diff --git a/apps/desktop/src/main/remote-desktop/privacyScreenHtml.ts b/apps/desktop/src/main/remote-desktop/privacyScreenHtml.ts
index 208d42c2c7..392db843af 100644
--- a/apps/desktop/src/main/remote-desktop/privacyScreenHtml.ts
+++ b/apps/desktop/src/main/remote-desktop/privacyScreenHtml.ts
@@ -2,7 +2,7 @@ import illustration from '../../renderer/assets/splash/illustration.webp?inline'
import wordmarkDark from '../../renderer/assets/splash/wordmark.png?inline';
import wordmarkLight from '../../renderer/assets/splash/wordmark-light.png?inline';
-const escape = (value: string) =>
+export const escapeHtml = (value: string) =>
value.replace(
/[&<>"']/g,
(char) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]!,
@@ -30,6 +30,6 @@ p{font-size:14px;line-height:1.8;color:var(--text-secondary);margin:20px 0 0;tex
</style></head><body><main>
<img class="hero" src="${illustration}" alt="">
<section class="copy"><picture><source media="(prefers-color-scheme:dark)" srcset="${wordmarkDark}"><img class="wordmark" src="${wordmarkLight}" alt="Cindy"></picture>
-<h1>${escape(status)}</h1><p>${escape(hint)}</p></section>
+<h1>${escapeHtml(status)}</h1><p>${escapeHtml(hint)}</p></section>
</main></body></html>`;
}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 259bea326f..5b5792fc86 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -240,6 +240,8 @@
"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",
+ "controlledByDevice": "{{name}} is controlling your desktop",
+ "viewedByDevice": "{{name}} is viewing your desktop",
"disconnect": "Disconnect",
"back": "Back",
"connect": "Connect",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 331d6798af..6e59558c1b 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -240,6 +240,8 @@
"controlUnavailable": "リモートコンピューターで操作を受け付けられません。操作権限と接続を確認して再接続してください。",
"beingControlled": "デスクトップが操作されています",
"beingViewed": "デスクトップが表示されています",
+ "controlledByDevice": "{{name}} がデスクトップを操作しています",
+ "viewedByDevice": "{{name}} がデスクトップを表示しています",
"disconnect": "切断",
"back": "戻る",
"connect": "接続",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 14374d2077..b9eb462d7c 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -240,6 +240,8 @@
"controlUnavailable": "원격 컴퓨터에서 입력을 받을 수 없습니다. 제어 권한과 연결을 확인한 다음 다시 연결하세요.",
"beingControlled": "데스크톱을 원격으로 제어 중",
"beingViewed": "데스크톱을 원격으로 보는 중",
+ "controlledByDevice": "{{name}}에서 데스크톱을 원격으로 제어 중",
+ "viewedByDevice": "{{name}}에서 데스크톱을 원격으로 보는 중",
"disconnect": "연결 끊기",
"back": "뒤로",
"connect": "연결",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 52397af587..7cd9249774 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -240,6 +240,8 @@
"controlUnavailable": "远端电脑暂时无法接受操作,请检查远端控制权限和连接,然后重新连接。",
"beingControlled": "桌面正在被远程控制",
"beingViewed": "桌面正在被远程查看",
+ "controlledByDevice": "{{name}} 正在远程控制桌面",
+ "viewedByDevice": "{{name}} 正在远程查看桌面",
"disconnect": "断开连接",
"back": "返回",
"connect": "连接",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 3151a3cf1b..48a3ab16f6 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -240,6 +240,8 @@
"controlUnavailable": "遠端電腦暫時無法接受操作,請檢查遠端控制權限和連線,然後重新連線。",
"beingControlled": "桌面正在被遠端控制",
"beingViewed": "桌面正在被遠端檢視",
+ "controlledByDevice": "{{name}} 正在遠端控制桌面",
+ "viewedByDevice": "{{name}} 正在遠端檢視桌面",
"disconnect": "中斷連線",
"back": "返回",
"connect": "連線",