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。

fix(remote-desktop): 省流不再限制帧率,并精简画质说明 (#5526)

Dash104e136cdc52
diff --git a/apps/desktop/src/main/remote-desktop/__tests__/macNativeCapture.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/macNativeCapture.test.ts
index b8300f4b40..081277ec3e 100644
--- a/apps/desktop/src/main/remote-desktop/__tests__/macNativeCapture.test.ts
+++ b/apps/desktop/src/main/remote-desktop/__tests__/macNativeCapture.test.ts
@@ -35,7 +35,7 @@ function setup() {
it.each([
['auto', 60, ['60', '0.8', '2560', '1500000']],
- ['saver', 60, ['30', '0.65', '0', '1000000']],
+ ['saver', 60, ['60', '0.65', '0', '1000000']],
['hd', 30, ['30', '0.9', '3840', '3000000']],
] as const)('passes the %s tier capture budget to the macOS helper', async (quality, fps, args) => {
const { owner } = setup();
diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/captureAudioRecovery.test.ts b/apps/desktop/src/renderer/features/remote-desktop/__tests__/captureAudioRecovery.test.ts
index 83ede37cfd..df24981143 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/captureAudioRecovery.test.ts
+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/captureAudioRecovery.test.ts
@@ -180,7 +180,8 @@ function nativeSound() {
it.each([
[undefined, 60, 'maintain-framerate', 60, 20_000_000, ''],
['auto', 60, 'maintain-framerate', 60, 20_000_000, ''],
- ['saver', 60, 'maintain-framerate', 30, 2_000_000, ''],
+ ['saver', 60, 'maintain-framerate', 60, 2_000_000, ''],
+ ['saver', 30, 'maintain-framerate', 30, 2_000_000, ''],
['hd', 60, 'maintain-resolution', 60, 20_000_000, 'text'],
['hd', 30, 'maintain-resolution', 30, 20_000_000, 'text'],
] as const)(
diff --git a/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css b/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css
index 4cd0d9249b..effe97ae48 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css
+++ b/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css
@@ -266,7 +266,8 @@
grid-template-columns: auto minmax(0, 1fr);
column-gap: var(--space-3);
}
-.remote-viewer-field-wide > :nth-child(n + 3) {
+/* Hints and errors sit below the label/control row and use its full width. */
+.remote-viewer-field > :nth-child(n + 3) {
grid-column: 1 / -1;
}
.remote-viewer-display-select {
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 8238c7edcf..c012ade3ba 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -315,7 +315,7 @@
"automatic": "Automatic",
"saver": "Data saver",
"hd": "HD",
- "qualityHint": "Auto keeps motion smooth and sharpens when your network allows. Data saver limits usage (up to 30 fps). HD keeps text sharp and lowers the frame rate when bandwidth is short.",
+ "qualityHint": "Automatic favors smoothness, Data saver uses less data, HD favors sharp text.",
"resolution": "Computer resolution",
"clipboardFailed": "Could not transfer clipboard content. Check control access and try again.",
"settingsFailed": "Could not save this setting. Try again.",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 29f0c8fd70..09c20d3dac 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -315,7 +315,7 @@
"automatic": "自動",
"saver": "データ節約",
"hd": "高画質",
- "qualityHint": "自動は滑らかさを優先し、通信に余裕があれば鮮明にします。データ節約は通信量を抑えます(最大 30 fps)。高画質は文字の鮮明さを優先し、帯域が足りないときはフレームレートを下げます。",
+ "qualityHint": "自動は滑らかさ優先、データ節約は通信量を抑え、高画質は文字の鮮明さ優先。",
"resolution": "コンピュータの解像度",
"clipboardFailed": "クリップボードの内容を転送できませんでした。操作権限を確認して再試行してください。",
"settingsFailed": "設定を保存できませんでした。再試行してください。",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 6cfc435d2e..287d9b5d84 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -315,7 +315,7 @@
"automatic": "자동",
"saver": "데이터 절약",
"hd": "고화질",
- "qualityHint": "자동은 부드러움을 우선하고 네트워크가 좋으면 더 선명하게 표시합니다. 데이터 절약은 사용량을 줄입니다(최대 30fps). 고화질은 글자 선명도를 우선하며 대역폭이 부족하면 프레임 속도를 낮춥니다.",
+ "qualityHint": "자동은 부드러움 우선, 데이터 절약은 사용량을 줄이고, 고화질은 글자 선명도 우선.",
"resolution": "컴퓨터 해상도",
"clipboardFailed": "클립보드 내용을 전송하지 못했습니다. 제어 권한을 확인하고 다시 시도하세요.",
"settingsFailed": "설정을 저장하지 못했습니다. 다시 시도하세요.",
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 c0f6f2cd9d..695e7f5a9b 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -315,7 +315,7 @@
"automatic": "自动",
"saver": "省流",
"hd": "高清",
- "qualityHint": "自动优先保证流畅,网络好时尽量清晰;省流会限制流量(最高 30 帧);高清优先保证文字清晰,网络不够时会降低帧率。",
+ "qualityHint": "自动优先流畅,省流少用流量,高清优先文字清晰。",
"resolution": "电脑分辨率",
"clipboardFailed": "剪贴板内容传输失败,请检查控制权限后重试。",
"settingsFailed": "设置未能保存,请重试。",
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 fac16391dd..3bc398d0fe 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -315,7 +315,7 @@
"automatic": "自動",
"saver": "省流量",
"hd": "高清",
- "qualityHint": "自動優先確保流暢,網路良好時盡量清晰;省流量會限制用量(最高 30 幀);高清優先確保文字清晰,頻寬不足時會降低幀率。",
+ "qualityHint": "自動優先流暢,省流量減少用量,高清優先文字清晰。",
"resolution": "電腦解析度",
"clipboardFailed": "剪貼簿內容傳輸失敗,請檢查控制權限後重試。",
"settingsFailed": "設定未能儲存,請重試。",
diff --git a/apps/desktop/src/shared/__tests__/remoteDesktopQuality.test.ts b/apps/desktop/src/shared/__tests__/remoteDesktopQuality.test.ts
index bccef51d5d..febce95ed6 100644
--- a/apps/desktop/src/shared/__tests__/remoteDesktopQuality.test.ts
+++ b/apps/desktop/src/shared/__tests__/remoteDesktopQuality.test.ts
@@ -26,13 +26,13 @@ const offer = [
].join('\r\n');
describe('remote desktop quality tiers', () => {
- it('lets the host own each tier, including the frame-rate ceiling', () => {
+ it('lets the host own each tier while the viewer owns the frame rate', () => {
expect(desktopVideoProfile().degradation).toBe('maintain-framerate');
expect(desktopVideoProfile({ fps: 60, quality: 'hd', audio: false })).toMatchObject({
degradation: 'maintain-resolution',
sharpWhenStill: false,
});
- expect(desktopVideoFramerate({ fps: 60, quality: 'saver', audio: false })).toBe(30);
+ expect(desktopVideoFramerate({ fps: 60, quality: 'saver', audio: false })).toBe(60);
expect(desktopVideoFramerate({ fps: 60, quality: 'auto', audio: false })).toBe(60);
for (const quality of ['auto', 'saver', 'hd'] as const) {
const p = desktopVideoProfile({ fps: 30, quality, audio: false });
diff --git a/apps/desktop/src/shared/remoteDesktopQuality.ts b/apps/desktop/src/shared/remoteDesktopQuality.ts
index 8b41df9192..63be04c141 100644
--- a/apps/desktop/src/shared/remoteDesktopQuality.ts
+++ b/apps/desktop/src/shared/remoteDesktopQuality.ts
@@ -11,8 +11,6 @@ export interface DesktopVideoProfile {
* collapse the estimate to ~100 kbps and pin the encoder to a low resolution. */
minBitrateKbps: number;
startBitrateKbps: number;
- /** Upper bound on the viewer's requested frame rate. */
- maxFramerate: 30 | 60;
/** What WebRTC gives up first while the screen is changing. */
degradation: 'maintain-framerate' | 'maintain-resolution';
/** While the screen is (nearly) still, keep full resolution regardless of tier:
@@ -36,7 +34,6 @@ const PROFILES: Record<RemoteDesktopVideoSettings['quality'], DesktopVideoProfil
maxBitrate: 20_000_000,
minBitrateKbps: 1_000,
startBitrateKbps: 4_000,
- maxFramerate: 60,
degradation: 'maintain-framerate',
sharpWhenStill: true,
contentHint: '',
@@ -50,7 +47,6 @@ const PROFILES: Record<RemoteDesktopVideoSettings['quality'], DesktopVideoProfil
maxBitrate: 2_000_000,
minBitrateKbps: 500,
startBitrateKbps: 1_500,
- maxFramerate: 30,
degradation: 'maintain-framerate',
sharpWhenStill: true,
contentHint: '',
@@ -64,7 +60,6 @@ const PROFILES: Record<RemoteDesktopVideoSettings['quality'], DesktopVideoProfil
maxBitrate: 20_000_000,
minBitrateKbps: 1_000,
startBitrateKbps: 4_000,
- maxFramerate: 60,
degradation: 'maintain-resolution',
sharpWhenStill: false,
contentHint: 'text',
@@ -79,14 +74,14 @@ export function desktopVideoProfile(settings?: RemoteDesktopVideoSettings): Desk
return PROFILES[settings?.quality ?? 'auto'];
}
-/** Effective capture/encode frame rate for the requested settings. */
+/** Capture/encode frame rate. Quality tiers never override the viewer's choice. */
export function desktopVideoFramerate(settings?: RemoteDesktopVideoSettings): 30 | 60 {
- return Math.min(settings?.fps ?? 30, desktopVideoProfile(settings).maxFramerate) as 30 | 60;
+ return settings?.fps ?? 30;
}
/** Live encoder ceilings. A background viewer (phone picture-in-picture) only
- * shows a small window, so it gets the saver tier until it returns to fullscreen;
- * the viewer's own choice is untouched and applies again once it is back. */
+ * shows a small window, so it gets the saver tier at 30 fps until it returns to
+ * fullscreen; the viewer's own choice is untouched and applies again once it is back. */
export function desktopEncoderLimits(
settings: RemoteDesktopVideoSettings,
background: boolean,
@@ -97,7 +92,12 @@ export function desktopEncoderLimits(
? { ...settings, quality: 'saver' }
: settings;
const { maxBitrate, degradation, sharpWhenStill } = desktopVideoProfile(tier);
- return { maxBitrate, degradation, sharpWhenStill, maxFramerate: desktopVideoFramerate(tier) };
+ return {
+ maxBitrate,
+ degradation,
+ sharpWhenStill,
+ maxFramerate: background ? 30 : desktopVideoFramerate(settings),
+ };
}
const BITRATE_HINTS = ['x-google-start-bitrate', 'x-google-min-bitrate', 'x-google-max-bitrate'];
diff --git a/apps/mobile/src/i18n/locales/en/remoteDesktop.json b/apps/mobile/src/i18n/locales/en/remoteDesktop.json
index 01213dca5f..7628b7f68c 100644
--- a/apps/mobile/src/i18n/locales/en/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/en/remoteDesktop.json
@@ -126,7 +126,7 @@
"automatic": "Auto",
"saver": "Data saver",
"hd": "HD",
- "qualityHint": "Auto keeps motion smooth and sharpens when your network allows. Data saver limits usage (up to 30 fps). HD keeps text sharp and lowers the frame rate when bandwidth is short.",
+ "qualityHint": "Automatic favors smoothness, Data saver uses less data, HD favors sharp text.",
"resolution": "Computer resolution",
"settingUnsupported": "This computer does not support this setting yet",
"loadingSettings": "Loading…",
diff --git a/apps/mobile/src/i18n/locales/ja/remoteDesktop.json b/apps/mobile/src/i18n/locales/ja/remoteDesktop.json
index 5505e8ea31..ea6d64c03e 100644
--- a/apps/mobile/src/i18n/locales/ja/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/ja/remoteDesktop.json
@@ -126,7 +126,7 @@
"automatic": "自動",
"saver": "データ節約",
"hd": "高画質",
- "qualityHint": "自動は滑らかさを優先し、通信に余裕があれば鮮明にします。データ節約は通信量を抑えます(最大 30 fps)。高画質は文字の鮮明さを優先し、帯域が足りないときはフレームレートを下げます。",
+ "qualityHint": "自動は滑らかさ優先、データ節約は通信量を抑え、高画質は文字の鮮明さ優先。",
"resolution": "パソコンの解像度",
"settingUnsupported": "このパソコンはまだこの設定に対応していません",
"loadingSettings": "読み込み中…",
diff --git a/apps/mobile/src/i18n/locales/ko/remoteDesktop.json b/apps/mobile/src/i18n/locales/ko/remoteDesktop.json
index 0371f12b85..8095d5b068 100644
--- a/apps/mobile/src/i18n/locales/ko/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/ko/remoteDesktop.json
@@ -126,7 +126,7 @@
"automatic": "자동",
"saver": "데이터 절약",
"hd": "고화질",
- "qualityHint": "자동은 부드러움을 우선하고 네트워크가 좋으면 더 선명하게 표시합니다. 데이터 절약은 사용량을 줄입니다(최대 30fps). 고화질은 글자 선명도를 우선하며 대역폭이 부족하면 프레임 속도를 낮춥니다.",
+ "qualityHint": "자동은 부드러움 우선, 데이터 절약은 사용량을 줄이고, 고화질은 글자 선명도 우선.",
"resolution": "컴퓨터 해상도",
"settingUnsupported": "이 컴퓨터는 아직 이 설정을 지원하지 않습니다",
"loadingSettings": "불러오는 중…",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json b/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json
index be49728471..1da705d125 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json
@@ -126,7 +126,7 @@
"automatic": "自动",
"saver": "省流",
"hd": "高清",
- "qualityHint": "自动优先保证流畅,网络好时尽量清晰;省流会限制流量(最高 30 帧);高清优先保证文字清晰,网络不够时会降低帧率。",
+ "qualityHint": "自动优先流畅,省流少用流量,高清优先文字清晰。",
"resolution": "电脑分辨率",
"settingUnsupported": "当前电脑端暂不支持此设置",
"loadingSettings": "读取中…",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json b/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json
index 80c4b4f814..f7f802d00d 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json
@@ -126,7 +126,7 @@
"automatic": "自動",
"saver": "省流量",
"hd": "高清",
- "qualityHint": "自動優先確保流暢,網路良好時盡量清晰;省流量會限制用量(最高 30 幀);高清優先確保文字清晰,頻寬不足時會降低幀率。",
+ "qualityHint": "自動優先流暢,省流量減少用量,高清優先文字清晰。",
"resolution": "電腦解析度",
"settingUnsupported": "目前電腦端尚不支援此設定",
"loadingSettings": "讀取中…",
diff --git a/packages/device-link/src/__tests__/remoteDesktop.test.ts b/packages/device-link/src/__tests__/remoteDesktop.test.ts
index 3225371650..4f0a276162 100644
--- a/packages/device-link/src/__tests__/remoteDesktop.test.ts
+++ b/packages/device-link/src/__tests__/remoteDesktop.test.ts
@@ -92,7 +92,7 @@ describe("remote desktop wire boundary", () => {
expect(
offer(remoteDesktopVideoSettingsWire({ fps: 60, quality, audio: true })),
).toMatchObject({
- settings: { fps: quality === "saver" ? 30 : 60, quality, audio: true },
+ settings: { fps: 60, quality, audio: true },
});
expect(
offer({ fps: 30, quality: "hd", bitrate: 20_000_000, audio: false }),
@@ -128,10 +128,10 @@ describe("remote desktop wire boundary", () => {
expect(
offer({ fps: 30, quality: "ultra", bitrate: 20_000_000, audio: false }),
).toMatchObject({ settings: { quality: "hd" } });
- // Older hosts ignore `quality`, so Saver's 30 fps cap travels in `fps`.
+ // Saver only lowers the bitrate; the viewer's frame rate is sent as chosen.
expect(
remoteDesktopVideoSettingsWire({ fps: 60, quality: "saver", audio: false }),
- ).toEqual({ fps: 30, quality: "saver", audio: false, bitrate: 2_000_000 });
+ ).toEqual({ fps: 60, quality: "saver", audio: false, bitrate: 2_000_000 });
expect(
remoteDesktopVideoSettingsWire({ fps: 60, quality: "auto", audio: false }).fps,
).toBe(60);
diff --git a/packages/device-link/src/__tests__/remoteDesktopViewerMedia.test.ts b/packages/device-link/src/__tests__/remoteDesktopViewerMedia.test.ts
index 081570f009..d475b69025 100644
--- a/packages/device-link/src/__tests__/remoteDesktopViewerMedia.test.ts
+++ b/packages/device-link/src/__tests__/remoteDesktopViewerMedia.test.ts
@@ -135,7 +135,7 @@ it("sends the tier with a legacy bitrate only to hosts that accept video setting
});
expect(request).toHaveBeenLastCalledWith(
expect.objectContaining({
- settings: { ...settings, fps: 30, bitrate: 2_000_000 },
+ settings: { ...settings, bitrate: 2_000_000 },
}),
expect.any(Function),
);
diff --git a/packages/device-link/src/remoteDesktop.ts b/packages/device-link/src/remoteDesktop.ts
index 0b78dde300..53921675d8 100644
--- a/packages/device-link/src/remoteDesktop.ts
+++ b/packages/device-link/src/remoteDesktop.ts
@@ -107,14 +107,17 @@ type LegacyVideoBitrate = 0 | 2_000_000 | 8_000_000 | 20_000_000;
const LEGACY_BITRATES: readonly number[] = [
0, 2_000_000, 8_000_000, 20_000_000,
];
-/** Older hosts only accept `bitrate` and ignore `quality`; send both. Saver
- * also caps the frame rate, which older hosts can only learn from `fps`. */
+/** Older hosts only accept `bitrate` and ignore `quality`; send both. */
export function remoteDesktopVideoSettingsWire(
settings: RemoteDesktopVideoSettings,
): RemoteDesktopVideoSettings & { bitrate: LegacyVideoBitrate } {
- if (settings.quality === "saver")
- return { ...settings, fps: 30, bitrate: 2_000_000 };
- return { ...settings, bitrate: settings.quality === "hd" ? 20_000_000 : 0 };
+ const bitrate =
+ settings.quality === "saver"
+ ? 2_000_000
+ : settings.quality === "hd"
+ ? 20_000_000
+ : 0;
+ return { ...settings, bitrate };
}
function legacyVideoQuality(bitrate: number): RemoteDesktopVideoQuality {
return bitrate === 0 ? "auto" : bitrate === 2_000_000 ? "saver" : "hd";