Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 剪贴板恢复后清除过期提示
Dashdf33876c664f
diff --git a/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.test.tsx b/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.test.tsxindex 79ac97f4fa..68dbf3a443 100644--- a/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.test.tsx+++ b/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.test.tsx@@ -219,6 +219,54 @@ it("foreground replacement never sends a stale cleanup disable", async () => {expect(h.tick).toHaveBeenCalledTimes(2);expect(h.update).not.toHaveBeenCalled();});+it.each([+ "phone-to-computer-complete",+ "computer-to-phone-complete",+ "unchanged-content",+ "content-empty",+])(+ "clears stale content notices only on accepted recovery: %s",+ async (stage) => {+ await act(async () => root.render(createElement(Probe)));+ for (const notice of ["clipboardSyncSkipped", "clipboardSyncConflict"]) {+ if (notice === "clipboardSyncSkipped")+ h.tick.mockImplementationOnce(async () => h.trace("content-skipped"));+ else h.tick.mockRejectedValueOnce(new Error("CLIPBOARD_CONFLICT"));+ await act(async () => vi.advanceTimersByTimeAsync(1500));+ expect(latest.safetyNotice).toBe(notice);+ // An idle tick accepts no new snapshot and must preserve its diagnosis.+ await act(async () => vi.advanceTimersByTimeAsync(1500));+ expect(latest.safetyNotice).toBe(notice);+ h.tick.mockImplementationOnce(async () => h.trace(stage));+ await act(async () => vi.advanceTimersByTimeAsync(1500));+ expect(latest.safetyNotice).toBeNull();+ }+ expect(h.update).not.toHaveBeenCalled();+ },+);+it("ignores recovery from a paused loop and keeps protection failures visible", async () => {+ caps.privacyScreen = true;+ h.request.mockImplementation(async (message) => {+ if (message.op === "privacyScreen" && message.enabled)+ throw new Error("PRIVACY_FAILED");+ return { enabled: message.enabled };+ });+ h.tick.mockImplementationOnce(async () => h.trace("content-skipped"));+ await act(async () => root.render(createElement(Probe)));+ const staleTrace = h.trace;+ await act(async () => root.render(createElement(Probe, { focused: false })));+ await act(async () => root.render(createElement(Probe)));+ await act(async () => staleTrace("unchanged-content"));+ expect(latest.safetyNotice).toBe("clipboardSyncSkipped");+ h.privacy = true;+ await act(async () => root.render(createElement(Probe)));+ h.tick.mockImplementationOnce(async () => h.trace("unchanged-content"));+ await act(async () => vi.advanceTimersByTimeAsync(1500));+ expect(latest.safetyNotice).toBe("privacyFailed");+ h.privacy = false;+ await act(async () => root.render(createElement(Probe)));+ expect(latest.safetyNotice).toBeNull();+});it("renews host opt-in after a delayed disable from an earlier client state", async () => {h.tick.mockRejectedValueOnce(new Error("DESKTOP_CLIPBOARD_UNAVAILABLE"));await act(async () => root.render(createElement(Probe)));diff --git a/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.ts b/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.tsindex ecd44eca8f..d0023259a6 100644--- a/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.ts+++ b/apps/mobile/src/remote-desktop/useRemoteDesktopSafety.ts@@ -227,7 +227,9 @@ export function useRemoteDesktopSafety(setClipboardNotice("clipboardSyncSkipped");if (stage === "phone-to-computer-complete" ||- stage === "computer-to-phone-complete"+ stage === "computer-to-phone-complete" ||+ stage === "unchanged-content" ||+ stage === "content-empty")setClipboardNotice(null);},diff --git a/docs/remote-desktop.md b/docs/remote-desktop.mdindex 4bf0d9ea70..c2348ad7c3 100644--- a/docs/remote-desktop.md+++ b/docs/remote-desktop.md@@ -1163,6 +1163,12 @@ disconnecting invalidates pending work. It does not poll in the background,maintain history or log clipboard contents. Private formats and arbitrary filesremain unsupported; only portable representations are synchronized.+Mobile clears stale skipped/conflict notices when the current sync loop accepts+an empty or unchanged-content snapshot, or completes a transfer in either+direction. Idle polls and callbacks from paused loops do not clear these notices;+clipboard recovery never hides a privacy-screen or host-mute failure. Regression+coverage lives in `apps/mobile/src/remote-desktop/useRemoteDesktopSafety.test.tsx`.+Only one viewer lease is active. A second viewer sees a busy state and canexplicitly take over when the host advertises `connectionTakeover`. Ordinarystarts never evict an existing viewer. Takeover stops the old lease and input;