Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): erase invitation digests before deleting history
DavidShenb8f79142ef75
diff --git a/apps/mobile/src/__tests__/clipboardInvitationHistory.test.ts b/apps/mobile/src/__tests__/clipboardInvitationHistory.test.tsindex bec2721c21..3a8cb33ac4 100644--- a/apps/mobile/src/__tests__/clipboardInvitationHistory.test.ts+++ b/apps/mobile/src/__tests__/clipboardInvitationHistory.test.ts@@ -193,3 +193,38 @@ it('clears an account that was never loaded and permits a failed removal to be rawait rememberClipboardInvitation(account, digest);expect(await hasSeenClipboardInvitation(account, digest)).toBe(true);});++it('does not reload erased digests after removal fails and all process memory is lost', async () => {+ await rememberClipboardInvitation(account, digest);+ storage.removeItem.mockRejectedValueOnce(new Error('remove unavailable'));+ await expect(clearClipboardInvitationHistory(account)).rejects.toThrow('remove unavailable');+ expect(JSON.parse(storage.values.get(key)!)).toEqual({ version: 1, entries: [] });+ __testing.reset(); // Cold start: retain disk only, losing the retired flag and queues.+ expect(await hasSeenClipboardInvitation(account, digest)).toBe(false);+ expect(storage.values.has(key)).toBe(false);+ expect(storage.removeItem).toHaveBeenCalledTimes(2);+});++it('preserves durable erasure across repeated failed removal attempts and restarts', async () => {+ await rememberClipboardInvitation(account, digest);+ storage.removeItem.mockRejectedValue(new Error('remove unavailable'));+ await expect(clearClipboardInvitationHistory(account)).rejects.toThrow('remove unavailable');+ for (let i = 0; i < 2; i++) {+ __testing.reset();+ expect(await hasSeenClipboardInvitation(account, digest)).toBe(false);+ expect(JSON.parse(storage.values.get(key)!)).toEqual({ version: 1, entries: [] });+ }+ storage.removeItem.mockImplementation(async (k: string) => { storage.values.delete(k); });+ __testing.reset();+ expect(await hasSeenClipboardInvitation(account, digest)).toBe(false);+ expect(storage.values.has(key)).toBe(false);+});++it('still deletes the history when writing the empty record fails', async () => {+ await rememberClipboardInvitation(account, digest);+ storage.setItem.mockRejectedValueOnce(new Error('write unavailable'));+ await clearClipboardInvitationHistory(account);+ expect(storage.values.has(key)).toBe(false);+ __testing.reset();+ expect(await hasSeenClipboardInvitation(account, digest)).toBe(false);+});diff --git a/apps/mobile/src/device-link/clipboardInvitationHistory.ts b/apps/mobile/src/device-link/clipboardInvitationHistory.tsindex 8827acf4fb..8357797163 100644--- a/apps/mobile/src/device-link/clipboardInvitationHistory.ts+++ b/apps/mobile/src/device-link/clipboardInvitationHistory.ts@@ -122,6 +122,11 @@ export function clearClipboardInvitationHistory(accountKey: string): Promise<voihistory.entries = [];const clearing = history.writes.then(async () => {await history.hydrating;+ // Erase digests durably before removing the key. If removal fails and the+ // process exits, hydration sees an empty record and retries its removal.+ // Still attempt removal if overwriting fails (e.g. storage is full).+ await AsyncStorage.setItem(PREFIX + accountKey, JSON.stringify({ version: 1, entries: [] }))+ .catch(() => undefined);await AsyncStorage.removeItem(PREFIX + accountKey);if (histories.get(accountKey) === history) histories.delete(accountKey);}).finally(() => { history.clearing = null; });diff --git a/docs/product-rules/shared-task-mode.md b/docs/product-rules/shared-task-mode.mdindex 45e3bb25f3..79756d8c0c 100644--- a/docs/product-rules/shared-task-mode.md+++ b/docs/product-rules/shared-task-mode.md@@ -27,7 +27,7 @@- 客户端只向当前配置的服务提交邀请。链接中的 `server` 仅用于比较,不能覆盖请求目标;不同服务的邀请显示对应提示。仍接受旧的裸邀请码,REST 和 device-link 既有入参保持兼容。- 访客加入时直接使用已登录用户的账号昵称,不再要求填写自定义昵称。昵称只作为展示信息,成员身份仍由服务端的账号与成员关系决定。- 移动端登录后在启动或从后台回到前台时自动读取剪贴板,只识别当前服务的有效邀请链接,普通内容与裸邀请码不触发跳转。已提示过的邀请按账号持久化摘要去重,点“暂不加入”或加入后,冷启动与前后台切换均不重放仍在记录内的邀请;剪贴板结果不覆盖已打开的加入页面或更新的链接唤起,异步读取完成后须重新核验账号代次。系统粘贴权限提示引起的短暂失焦不重复读取。菜单不暴露“加入共享任务”入口,页面也不提供独立粘贴按钮。自动识别只打开加入页面,由用户点击加入;显式点击邀请链接继续直接加入并进入任务。-- 待处理邀请仍只在内存中暂存;去重仅持久化解析后邀请 token 的 SHA-256 摘要与提示时间,每个账号保留最近 16 条、有效期 30 天,内存缓存与落盘采用相同隔离、容量和时效。自动识别仅在确认弹框的原生 onShow 回调中记录摘要,并核验邀请 ID、账号代次与组件仍挂载;启动遮罩期间尚未展示的邀请不记为已提示,不等待加入成功;显式链接在账号归属确定后也记录摘要,但显式链接与设置页手动加入不受去重拦截。此规则是历史邀请去重,不承诺检测复制动作:A→B→A 或重新复制 A,在 A 记录有效时仍不自动提示;过期或容量淘汰后可再次提示。分享标题变化不算新邀请,不清空或改写剪贴板,不落盘剪贴板原文或明文邀请码。查询时淘汰的过期记录同步从磁盘清除,与新增记录共用串行写入队列;应用未运行时不承诺后台定时删除,清理失败在后续访问时重试。退出登录或终止会话清理当前账号历史,账号注销清理该身份在当前区域下的各成员历史,清理先失效内存并等待旧读写完成,避免旧写入恢复记录;普通账号切换不清除去重历史。存储读取失败不阻断邀请提示,也不覆盖未读出的历史;写入失败保留本次运行的摘要去重,下次冷启动可能再次提示。链接邀请支持首次登录后继续,切换账号、关闭页面或过期后不自动沿用待处理邀请。系统拒绝剪贴板访问时保持当前页面可用,邀请链接唤起仍可使用。+- 待处理邀请仍只在内存中暂存;去重仅持久化解析后邀请 token 的 SHA-256 摘要与提示时间,每个账号保留最近 16 条、有效期 30 天,内存缓存与落盘采用相同隔离、容量和时效。自动识别仅在确认弹框的原生 onShow 回调中记录摘要,并核验邀请 ID、账号代次与组件仍挂载;启动遮罩期间尚未展示的邀请不记为已提示,不等待加入成功;显式链接在账号归属确定后也记录摘要,但显式链接与设置页手动加入不受去重拦截。此规则是历史邀请去重,不承诺检测复制动作:A→B→A 或重新复制 A,在 A 记录有效时仍不自动提示;过期或容量淘汰后可再次提示。分享标题变化不算新邀请,不清空或改写剪贴板,不落盘剪贴板原文或明文邀请码。查询时淘汰的过期记录同步从磁盘清除,与新增记录共用串行写入队列;应用未运行时不承诺后台定时删除,清理失败在后续访问时重试。退出登录或终止会话清理当前账号历史,账号注销清理该身份在当前区域下的各成员历史,清理先失效内存并等待旧读写完成,再以空记录覆写后删除存储键,避免旧写入恢复记录;删除失败但覆写成功时,重启也不会恢复旧摘要,后续访问会重试移除空记录。覆写和删除均失败时只能尽力清理,不保证跨重启擦除;普通账号切换不清除去重历史。存储读取失败不阻断邀请提示,也不覆盖未读出的历史;写入失败保留本次运行的摘要去重,下次冷启动可能再次提示。链接邀请支持首次登录后继续,切换账号、关闭页面或过期后不自动沿用待处理邀请。系统拒绝剪贴板访问时保持当前页面可用,邀请链接唤起仍可使用。- 两端“设置 → 共享任务”提供独立管理页,分为“我发起的 / 我加入的”,有共享和空状态均保留“加入共享任务”次要按钮。手动加入使用紧凑弹框,接受邀请链接和旧裸邀请码;旧裸邀请码不进入自动识别。2026-09-28 用户已确认交互 HTML 并授权实现:Desktop 设置项位于远程控制之后;Mobile 沿用实际设置分组,在语音词典与外观之间增加“共享任务 → 共享管理”。顶部、主菜单和移动端首页共享分组不提供加入入口;桌面端侧栏“共享任务”分组右侧保留“+”加入入口(2026-09-28 用户确认)。- 自动识别邀请展示账号与加入确认,不暴露长链接或邀请输入框;手动加入和显式链接成功后进入任务。共享结束提示返回任务列表,并说明重新加入需要房主的新邀请。管理页的移除、退出、关闭当前、关闭全部使用紧凑确认;取消保留原页面、页签和滚动位置。加载失败提供重试,不当作空列表;关闭或退出成功回到对应管理列表。- 本阶段不修改移动端原生配置或 runtime fingerprint;Universal Links / Android App Links 另行实施。先部署服务端页面,再发布客户端;旧客户端尚不能解析新链接,需更新。