* feat(remote-desktop): 手机记住桌面分辨率,切换分辨率不重建视频 - 手机按电脑和显示器记住上次选的系统分辨率或「适配此屏幕」尺寸,下次连接在第一帧前恢复; 选回电脑原分辨率或恢复原始比例时清除记忆。 - 被控端新增可选能力 liveDisplaySwitch:切换显示时请求带 keepVideo,原生画布截屏保留同一条 视频连接,响应带 videoKept;手机只更新画面布局,不再重新协商视频。回执缺失时按原流程重建。 - 切分辨率不再重复读取模式列表,并在切换的同时预取 ICE 配置。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> * fix(remote-desktop): 只有截屏页确认原生流仍在时才回报已保留视频 - 切换显示前通知截屏页 display-hold,暂停“5 秒无新帧即停流”,慢的虚拟显示创建(最长约 8 秒) 不再把视频停掉。 - 切换后 display-swap 改为请求-回复:截屏页确认当前确实是原生截屏且视频轨道仍在才回 true。 浏览器截屏(未声明鼠标叠加时的 macOS/Windows 默认路径)、流已结束或确认超时都回 false, 主进程按原流程拆掉重建,手机也跟着重建,不会停在旧显示器上。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> * test(mobile): 远程桌面分辨率记忆测试改用内存 AsyncStorage Node >= 25 默认的 webstorage 全局是缺方法的 stub,会顶掉 jsdom 的 localStorage, 新增测试依赖 AsyncStorage 网页 fallback 时在 Node 25 下必挂。按 apps/mobile 惯例 vi.mock 成内存实现,不再依赖运行环境的 localStorage。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> * fix(mobile): 记住的适配分辨率只在同一窗口尺寸下提前套用 连接前还量不到画面区域,原先只比较横竖方向就复用旧的适配尺寸;折叠屏展开、 分屏或窗口改变尺寸但方向不变时会套用过期的比例。记忆里额外保存适配时的 App 窗口尺寸,只有窗口完全一致才在首帧前套用,否则走首帧后重新测量的路径。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> * fix(mobile): 记住适配时请求的尺寸,而不是宿主返回的逻辑尺寸 HiDPI 宿主可能用同比例更小的逻辑模式回应 viewerDisplay 请求(带 viewerDisplayRequest 回执)。若把实际尺寸写入记忆,每次重连都会按更小的尺寸 再请求一次,画面越来越小。改为记住请求尺寸,实际尺寸只用于当前画面几何。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> * fix(mobile): 提前套用记住的分辨率失败时不再中断连接 提前套用是连接前的可选步骤,原先失败就把错误抛给 connect,拆掉整个会话, 绕过了 controlFailure.ts 的分类(控制被抢应降为只看、结果未知应交给下次尝试)。 现在失败时保持当前分辨率继续连接,由首帧后的路径再套用;只有租约已结束 (DESKTOP_LEASE_EXPIRED / DESKTOP_STOPPED),或显示器切换请求本身回复丢失 (几何未知,与手动切换一致)才重建。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> * fix(mobile): 记住的分辨率切换失败后重建连接,且不再反复重试 显示器切换请求一旦发出,宿主在切换中出错会自行结束租约;此前只把超时和 明确的租约结束当作需要重建,其余错误继续用旧租约连接,随后在 offer/control 阶段失败。现在只有宿主改动前就拒绝的 DESKTOP_VIEW_ONLY / DESKTOP_DISPLAY_BUSY / DESKTOP_INPUT_BUSY 继续连接,其余一律重建。 提前套用或首帧后套用失败并重建后,本屏不再重试记住的选择,避免持续故障时 新租约反复触发重连。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com> --------- Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
6.9 KiB
Viewer aspect ratio prototype
The new Match Current View action uses the controller's usable picture area to choose independent width/height, with an even-pixel 1920-pixel long-edge limit. Mobile excludes its toolbar from the measured area. Desktop uses the viewer content area. Resizing is explicit: rotating the phone or changing window size does not continually reconfigure the remote computer.
On Mobile, after matching, the action becomes Restore Computer Screen Ratio
while the current viewport still matches. Rotating to a different ratio offers
Match Current View again. Restore removes the temporary display, waits for
the original monitor mode to return, and renegotiates video/control on the same
lease. This uses the optional viewerDisplayRestore capability; older hosts
continue to offer matching only.
Current scope
- macOS source-development hosts only advertise
viewerDisplay. Packaged hosts and Windows/Linux retain the existing display-mode behavior. - Both Mobile and Desktop viewers expose the action only for capable hosts. The same authenticated, controlling lease is required. No new relay kind, server change, IPC channel, credential access or Mobile native dependency.
- A temporary virtual display becomes the mirror source for the selected existing display, so the current desktop is shown instead of an empty extended desktop. This changes the local monitor's layout too; large application windows may require resizing. Existing mirror sets are not supported by this prototype.
- The helper retains the virtual display only for the lease. Explicit exit, expiry, revocation and helper failure dispose it. EOF/SIGTERM restore the source display mode. Original window positions are not snapshotted or restored. A new lease waits for the prior temporary display's restoration before reading its geometry, including takeover. A failed restoration can be retried by the next start; it never creates a lease from unconfirmed geometry.
- Resizing preserves the lease and input sequence; old video/input are stopped,
queued old-geometry input is discarded, and the viewer negotiates video and
reacquires control on the confirmed new display. Shared Device Link connections
are not restarted. Hosts advertising
liveDisplaySwitchinstead keep the existing video connection when the Mobile viewer asks withkeepVideo; the viewer only updates its layout (displayGeometry) and reacquires control. - Mobile remembers the last choice per computer and monitor (system mode, or the fitted size with the viewport and app window it was fitted in) and reapplies it before the first frame of the next connection. A fit is reused early only in the same app window; after a rotation, fold, split view or resize it is refitted from a fresh measurement after the first frame. Choosing the computer's own mode or restoring forgets it.
- Failure ends only this remote-desktop lease and restores its temporary display. The viewer's existing recovery remains responsible for reconnecting.
- On hosts advertising both viewer-display capabilities, the resolution dropdown resizes the temporary display without ending the lease for dimensions within 320–2560 per edge. Larger system modes (such as 4K) retain the legacy mode-ID path and its existing reconnect/persistent-mode behavior. Exiting a temporary display completes before a legacy mode write, so cleanup cannot overwrite it. Mode enumeration and native mode-ID writes use the lease's original source monitor; video and input use the current capture display. Exiting a temporary display restores the original monitor mode. The list still includes all macOS-reported modes, including different aspect ratios such as 800 × 600; filtering the list to the matched ratio is not implemented in this prototype.
Native dependency
CGVirtualDisplay is a private CoreGraphics interface, resolved at runtime.
Chromium's virtual display test implementation
is the reference for its interface shape. No new third-party binary or package is
installed. The helper is compiled from source by the development host. Enabling
it in packaged releases requires a separate supported-OS, signing and packaging
decision and validation; this prototype deliberately does not advertise it there.
Try it
Start the development host from this worktree using the repository's Desktop development instructions. Connect using this worktree's Mobile or Desktop viewer, take control, then open Controls → Display → Match Current View (Mobile) or the viewer's controls panel (Desktop). Rotate/resize and apply again to change the target ratio. Disconnect to restore the original monitor resolution.
The interactive HTML preview uses sample content and does not touch the computer display.
Explicit native integration check (temporarily changes the main monitor layout):
node apps/desktop/scripts/viewer-display-native-smoke.mjs
The check compiles in an OS temporary directory, verifies 900 × 1600 and 1600 × 900 on the same virtual display, ends the helper, and compares the complete online display list and geometry against the initial snapshot. It does not capture pixels or inject input, and is not in the ordinary unit suite.
Real Mobile-to-Mac video/input, multiple monitors, HiDPI, lock/sleep and signed packaged execution still require device testing. Native mode readback and unit tests are not evidence that those end-to-end paths have passed.
Validation in this worktree
- 238 focused tests passed across the protocol/session, host lifecycle, Desktop viewer, Mobile screen, viewport and RTC suites.
- Desktop and Mobile
typecheck, and device-link'sbuild(tsc --noEmit) passed. - The shared package's full
buildreports eight existing diagnostics inbrandIdentity.test.ts,composerPalette.test.ts,historyView.test.tsandworkRunGrouping.ts. An unmodified HEAD archive produced the same eight diagnostics, with no added or removed errors. - Native smoke passed both orientations and restoration. A separate real
Electron process also exercised the production
createViewerDisplayadapter at 888 × 1920 and 1920 × 888, and verified the original Electron screen snapshot (bounds, scale factor and display count) after disposal. - The HTML preview was exercised in Chromium in Light/Dark and both orientations; Light/Dark portrait screenshots were visually inspected. This is sample-content preview evidence, not native Mobile screenshots.
- Five-language i18n consistency, terminology and generated-viewer synchronization checks passed. No release was made.
- The physical iPhone Air now has a separately signed Cindy Aspect test app with an embedded JS bundle; app launch was verified. Full video/input acceptance remains separate from installation and startup.