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。

merge(main): sync remote desktop viewer

MagicLizi6f9884cdf348
diff --cc apps/desktop/native/remote-desktop/windows-input/src/desktop.rs
index 8217a313a9,27c9969cee..81a4cadeb4
--- a/apps/desktop/native/remote-desktop/windows-input/src/desktop.rs
+++ b/apps/desktop/native/remote-desktop/windows-input/src/desktop.rs
@@@ -29,17 -32,10 +32,17 @@@ impl InputDesktop
let next = OpenInputDesktop(
0,
0,
- DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS | DESKTOP_SWITCHDESKTOP,
+ // An explicitly attached desktop needs JOURNALPLAYBACK access
+ // for SendInput, even though we do not install journaling hooks.
+ // Without it binding succeeds, then the first input fails with
+ // ERROR_ACCESS_DENIED. The desktop ACL and UIPI still apply.
+ DESKTOP_READOBJECTS
+ | DESKTOP_WRITEOBJECTS
+ | DESKTOP_SWITCHDESKTOP
+ | DESKTOP_JOURNALPLAYBACK,
);
if next.is_null() {
- return Err(());
+ return Err(GetLastError());
}
let mut name = vec![0u16; 256];
let mut needed = 0;
diff --cc apps/desktop/src/main/remote-desktop/__tests__/captureBoundary.test.ts
index 5662612c85,11cf442ce1..5a85a2516f
--- a/apps/desktop/src/main/remote-desktop/__tests__/captureBoundary.test.ts
+++ b/apps/desktop/src/main/remote-desktop/__tests__/captureBoundary.test.ts
@@@ -18,6 -16,9 +18,7 @@@ const h = vi.hoisted(() => (
nativeFrame: vi.fn(async () => 'frame'),
input: vi.fn(),
viewHeartbeat: vi.fn(),
- inputFailure: null as null | (() => void),
- releaseControl: vi.fn(),
+ hostInput: vi.fn(),
iceConfig: vi.fn(async (): Promise<any[]> => [
{ urls: ['turn:relay.example.test:3478'], username: 'temporary', credential: 'test-only' },
]),
diff --cc apps/desktop/src/main/remote-desktop/controller.ts
index 7e07a7a4b1,48579c6a9a..8416de46b7
--- a/apps/desktop/src/main/remote-desktop/controller.ts
+++ b/apps/desktop/src/main/remote-desktop/controller.ts
@@@ -133,12 -133,16 +133,17 @@@ export class RemoteDesktopController
this.deps.stopVideo();
this.deps.changed();
}
-
- /** A refused native input revokes control, while preserving viewing and the
- * peer-bound lease. Pending grants must not turn a failed helper back on. */
+ /**
+ * Input injection failed while the lease is still valid. Input belongs to the
+ * control bit, so release control and keep everything else: ending the lease
+ * here would tear down capture and media, and every phone tap would surface as
+ * a reconnect even though the desktop session itself is healthy. The viewer
- * observes the new state on its next heartbeat or input attempt.
++ * observes the new state on its next heartbeat or input attempt. A pending
++ * start is also cancelled so a failed helper cannot restore control later.
+ */
releaseControl(): void {
const active = this.active;
- if (!active?.controlling) return;
+ if (!active || (!active.controlling && !this.inputStarting)) return;
active.controlling = false;
this.controlGeneration++;
this.clipboardTransfer.reset();
diff --cc apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
index 6c8dfc9ce8,1c9d267079..4137c630fc
--- a/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
+++ b/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
@@@ -525,20 -471,28 +526,12 @@@ export default function RemoteDesktopSc
(cause: unknown) => {
if (!alive.current) return;
const message = cause instanceof Error ? cause.message : String(cause);
- const code =
- cause &&
- typeof cause === "object" &&
- "code" in cause &&
- typeof cause.code === "string"
- ? cause.code
- : message.match(
- /\b(?:DESKTOP|CHANNEL|DEVICE|INVOKE|REMOTE|ACCESS)_[A-Z_]+\b/,
- )?.[0];
+ const code = remoteDesktopErrorCode(cause);
// Keep diagnostics free of device names, input and signaling payloads.
console.debug("[remote-desktop] connection failed", {
- code: code && /^[A-Z_]+$/.test(code) ? code : "UNKNOWN",
+ code: code ?? "UNKNOWN",
});
- const blocked =
- code === "ACCESS_REVOKED"
- ? "accessRevoked"
- : code === "REMOTE_DISABLED"
- ? "remoteDisabled"
- : code === "DESKTOP_BUSY"
- ? "connectionBusy"
- : code === "CHANNEL_NOT_ALLOWED"
- ? "upgrade"
- : message.includes("DESKTOP_DISABLED")
- ? "disabled"
- : message.includes("PERMISSION") ||
- message.includes("ACCESSIBILITY")
- ? "permissionHint"
- : message.includes("DESKTOP_STOPPED")
- ? "disconnected"
- : null;
+ const blocked = remoteDesktopFailureKey(code ?? message);
stop(!blocked);
setError(blocked);
if (blocked) recovery.current.enabled = false;
@@@ -646,12 -698,16 +720,16 @@@
// Entering remote desktop is the user's intent to control. The existing
// host permission and ownership gates still decide whether it is allowed.
if (result.canControl && wantsControl.current) {
- const control = await viewerSession.current!.control(true);
- const control = await request<{ controlling: boolean }>({
- op: "control",
- lease: next.lease,
- enabled: true,
- });
-- if (current !== generation.current) return;
-- // Control changes keep the same session identity for in-flight replies.
-- next.controlling = control.controlling;
-- setLease({ ...next });
-- send({ type: "control", enabled: control.controlling });
++ try {
++ const control = await viewerSession.current!.control(true);
++ if (current !== generation.current) return;
++ // Control changes keep the same session identity for in-flight replies.
++ next.controlling = control.controlling;
++ setLease({ ...next });
++ send({ type: "control", enabled: control.controlling });
++ } catch (cause) {
++ if (current === generation.current) resolveControlFailure(cause);
++ }
}
mark("control-ready");
setControlReady(true);
@@@ -660,18 -716,18 +738,20 @@@
} finally {
if (current === generation.current) connecting.current = false;
}
-- },
-- [
-- deviceId,
-- fail,
-- landscape,
-- mode,
-- request,
-- send,
-- stop,
-- t,
-- videoPreferencesLoaded,
-- ],
++ },
++ [
++ deviceId,
++ fail,
++ landscape,
++ mode,
++ request,
++ resolveControlFailure,
++ send,
++ stop,
++ t,
++ videoPreferencesLoaded,
++ viewerSession,
++ ],
);
const connectRef = useRef(connect);
connectRef.current = connect;