Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(file-browser): 按评审修复忽略目录开关的三处 P1
Zhang Yunjinb44580f1b93b
diff --git a/apps/desktop/src/main/file-browser/__tests__/watcher.test.ts b/apps/desktop/src/main/file-browser/__tests__/watcher.test.tsindex 980e5b1c16..64cfc3c9d7 100644--- a/apps/desktop/src/main/file-browser/__tests__/watcher.test.ts+++ b/apps/desktop/src/main/file-browser/__tests__/watcher.test.ts@@ -184,14 +184,10 @@ describe('WatcherManager stop 宽限期', () => {const workdir = path.join(path.sep, 'no-such-workdir-reveal');await manager.start(makeWindow(), workdir, { showIgnoredDirs: true }, vi.fn());expect(calls[0].ignore).toEqual(- expect.arrayContaining([- path.join(workdir, 'node_modules'),- path.join(workdir, 'Library'),- path.join(workdir, '.git'),- ]),+ expect.arrayContaining(['**/node_modules/**', '**/Library/**', '**/.git/**']),);// 开关打开时 REVEALABLE 不预过滤 —— 它们本来就该推事件。- expect(calls[0].ignore).not.toContain(path.join(workdir, 'dist'));+ expect(calls[0].ignore).not.toContain('**/dist/**');});it('开关关闭时同样无条件带上 ALWAYS(目录稍后才出现也不漏)', async () => {@@ -200,12 +196,30 @@ describe('WatcherManager stop 宽限期', () => {await manager.start(makeWindow(), workdir, { showIgnoredDirs: false }, vi.fn());expect(calls[0].ignore).toEqual(expect.arrayContaining([- path.join(workdir, 'node_modules'),- path.join(workdir, 'Library'),+ '**/node_modules/**',+ '**/Library/**',+ '**/dist/**',]),);});+ /**+ * 预过滤名单的「层级」回归:名单必须发 glob,不能发根级绝对路径。+ * @parcel/watcher 对非 glob 项走 `ignorePaths` 前缀比较 ——+ * `nested/node_modules/x` 不是 `/workdir/node_modules` 的后代,monorepo+ * (`packages/foo/node_modules`)与嵌套 Unity 工程(`client/Library`)会整目录+ * 漏过去,开关打开时每个生成文件都是一条事件推过 watcher-host + IPC。+ * glob 形态与层级无关,这里锁住这个形态(实测 2.5.6/win32:前缀形态零命中,+ * `**\/<name>/**` 全层级命中)。+ */+ it('预过滤用 glob 覆盖任意层级(不是根级绝对路径)', async () => {+ const { manager, calls } = setup();+ await manager.start(makeWindow(), 'D:/repo', { showIgnoredDirs: false }, vi.fn());+ expect(calls[0].ignore).toContain('**/node_modules/**');+ expect(calls[0].ignore).toContain('**/Library/**');+ expect(calls[0].ignore).not.toContain(path.join('D:/repo', 'node_modules'));+ });+it('不同 window 同 workdir 互不干扰(key 维度 window×workdir)', async () => {const { manager, subscribeFn, unsubscribe } = setup();await manager.start(makeWindow(1), 'D:/repo', {}, vi.fn());diff --git a/apps/desktop/src/main/file-browser/watcher.ts b/apps/desktop/src/main/file-browser/watcher.tsindex bbec05e9a0..3210927ad7 100644--- a/apps/desktop/src/main/file-browser/watcher.ts+++ b/apps/desktop/src/main/file-browser/watcher.ts@@ -40,7 +40,6 @@*/import path from 'node:path';-import * as fs from 'node:fs';import type { BrowserWindow } from 'electron';import {@@ -118,9 +117,8 @@ interface WatcherEntry {/*** 预过滤目录 — 这些目录名一旦出现在路径里, OS watcher 直接跳过,不再向- * callback 推任何事件。和 ignore.ts 的 BUILTIN_IGNORE 思路一致, 但 parcel- * 的 ignore 接受的是路径(不是 glob), 所以这里用绝对路径 + 工作区内常见命中- * 位置一次性穷举。比靠 callback 内过滤省一次 IPC + 一次 matcher 调用。+ * callback 推任何事件。和 ignore.ts 的 BUILTIN_IGNORE 思路一致。比靠+ * callback 内过滤省一次 IPC + 一次 matcher 调用。** 注意: 这里只剪"目录名命中" 的 case; *.log / build-* 这种 glob 仍由* callback 内的 matcher 兜底。@@ -149,27 +147,33 @@ const PREFILTER_REVEALABLE = [];/**- * 把预过滤名单展成"工作区根下直接命中"的绝对路径列表 (parcel 的- * ignore 选项要求路径而非 glob)。子目录里同名目录(e.g. nested- * node_modules) parcel 会自己沿父链判断 — 它内部用前缀匹配。+ * 名单 → parcel ignore glob。+ *+ * @parcel/watcher 的 ignore 数组吃两种形态:非 glob 走 `ignorePaths`(相对+ * workdir resolve 成绝对路径,**前缀**比较),glob 走 picomatch 正则。前缀形态+ * 只认“工作区根下直接命中”—— 实测(2.5.6, win32)`nested/node_modules/x` 不是+ * `/workdir/node_modules` 的后代,一条事件都拦不住,monorepo+ * (`packages/foo/node_modules`)与嵌套 Unity 工程(`client/Library`)全量漏过去。+ * 所以统一发 glob:`**\/<name>/**` 覆盖任意层级。+ *+ * 末尾的 `/**` 不能省:目录名要连内部条目一起匹配,`**\/<name>` 只匹配目录自身+ * (实测)。将来名单里若出现文件项(如 .DS_Store),要另用不带后缀的形态。*/-function buildIgnoreList(workdir: string, opts: { showIgnoredDirs: boolean }): string[] {- // ALWAYS 名单**无条件注册**,不做 existsSync 探测:parcel 的 ignore 只在+const ignoreGlobsForDirs = (names: readonly string[]): string[] =>+ names.map((name) => `**/${name}/**`);++function buildIgnoreList(opts: { showIgnoredDirs: boolean }): string[] {+ // ALWAYS 名单**无条件注册**,不做存在性探测:parcel 的 ignore 只在// subscribe 那一刻生效一次,而 node_modules / Library 常常在会话开始后才出现// (npm install / Unity 导入)。当时不存在就漏掉,就再也没有第二次机会 ——// 开关打开时这些目录被 matcher 放行,目录里每个生成路径都会一路推过- // watcher-host + IPC。不存在的路径传给 parcel 无害(它只做前缀比较)。- const out = PREFILTER_ALWAYS.map((dir) => path.join(workdir, dir));- // REVEALABLE 只在开关关闭时预过滤,且只挑当前存在的目录:开关打开后它们本- // 就该推事件;关闭时即使漏掉预过滤,parcel callback 里的 matcher 也会拦下- // (代价只是多一次 IPC)。- if (!opts.showIgnoredDirs) {- for (const dir of PREFILTER_REVEALABLE) {- const abs = path.join(workdir, dir);- if (fs.existsSync(abs)) out.push(abs);- }- }- return out;+ // watcher-host + IPC。glob 不存在的目录只是永不命中,无副作用。+ const always = ignoreGlobsForDirs(PREFILTER_ALWAYS);+ // REVEALABLE 只在开关关闭时预过滤:开关打开后它们本来就该推事件;关闭时+ // 即使漏掉预过滤,callback 里的 matcher 也会拦下(代价只是多一次 IPC)。+ return opts.showIgnoredDirs+ ? always+ : [...always, ...ignoreGlobsForDirs(PREFILTER_REVEALABLE)];}/**@@ -299,7 +303,7 @@ export class WatcherManager {honorVcsIgnore: false,showIgnoredDirs,});- const ignore = buildIgnoreList(workdir, { showIgnoredDirs });+ const ignore = buildIgnoreList({ showIgnoredDirs });const entry: WatcherEntry = {handle: null,diff --git a/apps/desktop/src/renderer/__tests__/fileBrowserTransportRevealCaps.test.ts b/apps/desktop/src/renderer/__tests__/fileBrowserTransportRevealCaps.test.tsindex 4c1c21eb1f..4a295612dd 100644--- a/apps/desktop/src/renderer/__tests__/fileBrowserTransportRevealCaps.test.ts+++ b/apps/desktop/src/renderer/__tests__/fileBrowserTransportRevealCaps.test.ts@@ -86,4 +86,25 @@ describe('deviceSupportsRevealIgnoredDirs', () => {await expect(transport.deviceSupportsRevealIgnoredDirs(deviceId, '/repo')).resolves.toBe(true);expect(invokeMock).toHaveBeenCalledTimes(2);});++ it('肯定结论按连接代次失效:重连后重探(被控端被回滚到老端也能纠正)', async () => {+ const deviceId = freshDevice();+ invokeMock.mockResolvedValue({ ok: true, showIgnoredDirs: true });++ await expect(transport.deviceSupportsRevealIgnoredDirs(deviceId, '/repo', 0)).resolves.toBe(+ true,+ );+ // 同代次命中缓存,不重复探测。+ await expect(transport.deviceSupportsRevealIgnoredDirs(deviceId, '/repo', 0)).resolves.toBe(+ true,+ );+ expect(invokeMock).toHaveBeenCalledTimes(1);++ // 重连(代次 +1):旧结论作废,重新问 —— 设备此时已被回滚成中间版本。+ invokeMock.mockResolvedValue({ ok: true, gzip: true });+ await expect(transport.deviceSupportsRevealIgnoredDirs(deviceId, '/repo', 1)).resolves.toBe(+ false,+ );+ expect(invokeMock).toHaveBeenCalledTimes(2);+ });});diff --git a/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/__tests__/useFileTree.test.tsx b/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/__tests__/useFileTree.test.tsxindex 1a59e7b3bc..09c549e3a7 100644--- a/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/__tests__/useFileTree.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/__tests__/useFileTree.test.tsx@@ -195,10 +195,10 @@ describe('useFileTree showIgnoredDirs option', () => {/*** 切开关会换一份 store。新 store 若从空快照 + initialLoading 起步,FileTreeView* 会把整树替换成空白占位(本地 <300ms 连 spinner 都没有),视觉上闪一下;- * 「刷新」按钮原地 refetch 所以不闪。新 store 必须继承兄弟 store 的快照,- * 等新 matcher 的数据回来再校正。+ * 「刷新」按钮原地 refetch 所以不闪。新 store 必须继承兄弟 store 的根列表,+ * 等新 matcher 的数据回来再校正(子树缓存与展开态不跨 scope 继承,见下一条)。*/- it('切开关继承旧树快照,不回到 initialLoading 空白', async () => {+ it('切开关继承根列表,不回到 initialLoading 空白', async () => {const hiddenEntries: readonly DirEntry[] = [{ name: 'src', relPath: 'src', type: 'directory', size: 0, mtimeMs: 1 },];@@ -237,27 +237,41 @@ describe('useFileTree showIgnoredDirs option', () => {});/**- * 展开态同样不能被切开关抹掉:新 scope 的 localStorage 可能没有记录,- * 但 seed 的 expanded 是当前可见的展开集合,应与之合并而非覆盖。+ * 关开关方向不继承旧 scope 的展开集合与子树缓存:reveal 态展开过的+ * node_modules 是 reveal-only 路径,带进 hidden store 会让它进入展开集合与+ * warm 列表(hidden 侧要为它发 listDir,SSH 上可达数百个 RPC),并在根列表+ * 回来前把被忽略的行显示出来。展开态按各自 scope 从 localStorage 恢复。*/- it('切开关保留已展开的目录,不折叠', async () => {+ it('关开关不把 reveal-only 路径带进 hidden store', async () => {+ const revealedRoot: readonly DirEntry[] = [+ { name: 'node_modules', relPath: 'node_modules', type: 'directory', size: 0, mtimeMs: 1 },+ ];+ mocks.listDir.mockImplementation((args: { relPath?: string; showIgnoredDirs?: boolean }) =>+ Promise.resolve(args.showIgnoredDirs ? revealedRoot : ([] as readonly DirEntry[])),+ );+const view = renderHook(({ reveal }: { reveal: boolean }) =>- useFileTree({ workdir: '/workdir-seed-expanded', showIgnoredDirs: reveal }),- { initialProps: { reveal: false } },+ useFileTree({ workdir: '/workdir-seed-filter', showIgnoredDirs: reveal }),+ { initialProps: { reveal: true } },);await waitFor(() => expect(view.result.current.initialLoading).toBe(false));-await act(async () => {- view.result.current.toggleFolder('src');+ view.result.current.toggleFolder('node_modules');});- expect(view.result.current.expanded.has('src')).toBe(true);+ expect(view.result.current.expanded.has('node_modules')).toBe(true);+ mocks.listDir.mockClear();await act(async () => {- view.rerender({ reveal: true });+ view.rerender({ reveal: false });});await waitFor(() => expect(view.result.current.initialLoading).toBe(false));- expect(view.result.current.expanded.has('src')).toBe(true);++ // hidden store 不该继承 reveal-only 的展开态,也不该为它发 listDir。+ expect(view.result.current.expanded.has('node_modules')).toBe(false);+ expect(mocks.listDir).not.toHaveBeenCalledWith(+ expect.objectContaining({ relPath: 'node_modules' }),+ );view.unmount();});@@ -288,6 +302,7 @@ describe('useFileTree device 的 showIgnoredDirs 能力探测', () => {expect(mocks.deviceSupportsRevealIgnoredDirs).toHaveBeenCalledWith('device-1','/workdir-old-device',+ 0,);await waitFor(() =>expect(mocks.listDir).toHaveBeenCalledWith(@@ -348,6 +363,12 @@ describe('useFileTree device 的 showIgnoredDirs 能力探测', () => {view.rerender();await waitFor(() => expect(view.result.current.showIgnoredDirsSupported).toBe(true));expect(mocks.deviceSupportsRevealIgnoredDirs).toHaveBeenCalledTimes(2);+ // 重连后那次探测带上新代次 —— 缓存按代次失效(设备被回滚到老端也能纠正)。+ expect(mocks.deviceSupportsRevealIgnoredDirs).toHaveBeenLastCalledWith(+ 'device-flaky',+ '/workdir-flaky',+ 1,+ );view.unmount();});diff --git a/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useFileTree.ts b/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useFileTree.tsindex 2e3b7282c9..85c6972c35 100644--- a/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useFileTree.ts+++ b/apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useFileTree.ts@@ -237,26 +237,37 @@ function emit(store: FileTreeStore): void {* 空快照 + initialLoading 起步,FileTreeView 会把整棵树替换成占位(本地* <300ms 连 spinner 都没有,就是空白),视觉上闪一下;同一 workdir 的另一半* reveal scope 的 store 此刻通常还在表里 —— 旧 store 的 refCount 归零发生在- * 本次 commit 的 effect cleanup,晚于 render 期间的 useMemo —— 借它的快照当- * 初始视图,新 matcher 的 listDir 回来后再原地校正(initStore 会把 seed 的- * 全部目录重拉一遍)。+ * 本次 commit 的 effect cleanup,晚于 render 期间的 useMemo —— 借它的+ * **根目录列表**当首帧内容,新 matcher 的 listDir 回来后再原地校正。+ *+ * 只借根列表,不借子树缓存与 expanded:那两者都带旧 matcher 的语义。reveal 态+ * 展开过 node_modules 时,把它们带进 hidden store 会让被忽略路径进入展开集合与+ * warm 列表(hidden 侧会给它们发 listDir,SSH 上可达数百个 RPC),并在根列表+ * 回来前把被忽略的行显示出来。展开态仍按各自 scope 从 localStorage 恢复+ * (expandedStore 的分片本意),不跨 scope 合并。** 「刷新」按钮没有这个问题:它在同一份 store 上原地 refetch,从不经过空态。*/-function findRevealSiblingSnapshot(- opts: Required<UseFileTreeOptions>,-): FileTreeStore['snapshot'] | null {+function findRevealSiblingSeed(opts: Required<UseFileTreeOptions>): {+ rootEntries: readonly DirEntry[] | null;+ loadError: FileTreeStore['snapshot']['loadError'];+} | null {const siblingKey = storeKey({ ...opts, showIgnoredDirs: !opts.showIgnoredDirs });- return stores.get(siblingKey)?.snapshot ?? null;+ const sibling = stores.get(siblingKey);+ if (!sibling) return null;+ return {+ rootEntries: sibling.snapshot.entries.get(ROOT_KEY) ?? null,+ loadError: sibling.snapshot.loadError,+ };}function getOrCreateStore(opts: Required<UseFileTreeOptions>): FileTreeStore {const key = storeKey(opts);const existing = stores.get(key);if (existing) return existing;- // 切开关路径:借另一半 reveal scope 的快照,第一帧就有树可渲染,不经过+ // 切开关路径:借另一半 reveal scope 的根列表,第一帧就有内容可渲染,不经过// initialLoading 空白;首次挂载(无兄弟 store)仍走原来的 loading 路径。- const seed = findRevealSiblingSnapshot(opts);+ const seed = findRevealSiblingSeed(opts);const store: FileTreeStore = {key,workdir: opts.workdir,@@ -267,8 +278,8 @@ function getOrCreateStore(opts: Required<UseFileTreeOptions>): FileTreeStore {showIgnoredDirs: opts.showIgnoredDirs,snapshot: seed? {- entries: seed.entries,- expanded: seed.expanded,+ entries: seed.rootEntries ? new Map([[ROOT_KEY, seed.rootEntries]]) : new Map(),+ expanded: new Set([ROOT_KEY]),// 新 store 自己还没有 in-flight 请求,seed 的 loadingPaths 不继承。loadingPaths: new Set(),initialLoading: false,@@ -438,10 +449,10 @@ function queueEventRefresh(store: FileTreeStore, eventRelPath: string): void {* 幂等:重复调用直接 no-op(refCount 已 >0)。 */async function initStore(store: FileTreeStore): Promise<void> {// 恢复 localStorage 持久化的 expanded 集合(workdir × 视图模式共享,见- // expandedStore 的 scope 说明)。seed(另一半 reveal scope 的 store)带着- // 当前可见的展开集合 —— 并集合并,切开关时不把已展开的目录折叠掉。+ // expandedStore 的 scope 说明)。分片是刻意的:两个 scope 各记自己的展开态,+ // 不跨 scope 合并 —— 合并会把 reveal 态展开过的 node_modules 带进 hidden 态。const restored = loadExpandedSet(store.workdir, { showIgnoredDirs: store.showIgnoredDirs });- const nextExpanded = new Set<string>([ROOT_KEY, ...restored, ...store.snapshot.expanded]);+ const nextExpanded = new Set<string>([ROOT_KEY, ...restored]);store.snapshot = { ...store.snapshot, expanded: nextExpanded };emit(store);@@ -465,13 +476,9 @@ async function initStore(store: FileTreeStore): Promise<void> {// Initial root fetch + 已 restore expanded 目录的并行 lazy fetch。每个 listDir// <12ms,即使 50 个 restored 也能在 <1s 内 warm 完。- // seed 路径再加一份:seed 的 entries 全是旧 matcher 拉的,全部重拉校正 ——- // 包括已收起但有缓存的目录,不然用户之后展开它会直接命中 stale 缓存。- const warmPaths = new Set<string>([...nextExpanded, ...store.snapshot.entries.keys()]);- warmPaths.delete(ROOT_KEY);await Promise.all([fetchDir(store, ROOT_KEY),- ...[...warmPaths].map((p) => fetchDir(store, p)),+ ...[...restored].map((p) => fetchDir(store, p)),]);store.snapshot = { ...store.snapshot, initialLoading: false };emit(store);@@ -586,13 +593,15 @@ export function useFileTree({setDeviceRevealSupported(null);}let cancelled = false;- void deviceSupportsRevealIgnoredDirs(deviceId, workdir).then((supported) => {- if (cancelled) return;- // null = 瞬态失败:保持现状(首帧仍是「未知」,已有结论也不推翻),- // 等下一次 reconnectEpoch 或重新挂载时再问一次。- if (supported === null) return;- setDeviceRevealSupported(supported);- });+ void deviceSupportsRevealIgnoredDirs(deviceId, workdir, revealReconnectEpoch).then(+ (supported) => {+ if (cancelled) return;+ // null = 瞬态失败:保持现状(首帧仍是「未知」,已有结论也不推翻),+ // 等下一次 reconnectEpoch 或重新挂载时再问一次。+ if (supported === null) return;+ setDeviceRevealSupported(supported);+ },+ );return () => {cancelled = true;};diff --git a/apps/desktop/src/renderer/lib/fileBrowserTransport.ts b/apps/desktop/src/renderer/lib/fileBrowserTransport.tsindex f51e651c46..711e9a29b1 100644--- a/apps/desktop/src/renderer/lib/fileBrowserTransport.ts+++ b/apps/desktop/src/renderer/lib/fileBrowserTransport.ts@@ -76,34 +76,51 @@ function deviceSupportsGzip(deviceId: string, workdir: string): Promise<boolean>* channel,invoke 会被快速拒回 `CHANNEL_NOT_ALLOWED`(确定性);隧道不可达 /* 重连中的 reject 与之不同,属于瞬态。*- * 缓存:**只缓存肯定结论 `true`**。`false`(老端)不留在缓存里 —— 被控端在一次- * 掉线期间升级是真实场景,缓存会把它钉在「不支持」直到重启;重探一次只是一个被- * 快速拒绝的 invoke,代价可忽略。瞬态 `null` 同样不缓存,由调用方在连接恢复后重探。+ * 缓存:**只缓存肯定结论 `true`**,且带**连接代次**(重连后失效重探 —— 设备被+ * 回滚到老 Desktop 时 deviceId 不变,不带代次会一直命中旧结论)。`false`(老端)+ * 不留在缓存里 —— 被控端在一次掉线期间升级是真实场景,缓存会把它钉在「不支持」+ * 直到重启;重探一次只是一个被快速拒绝的 invoke,代价可忽略。瞬态 `null` 同样+ * 不缓存,由调用方在连接恢复后重探。** 与 gzip 那份缓存分开:后者带着「用出空写就永久降级」的自愈语义,两件事互不牵连。*/-const deviceRevealCaps = new Map<string, Promise<boolean | null>>();+const deviceRevealCaps = new Map<+ string,+ { epoch: number; probe: Promise<boolean | null> }+>();++/** 只回收「本次探测装上的那条」:同 deviceId 可能已因更新的代次换上新的 probe。 */+function evictRevealCapsIfCurrent(deviceId: string, epoch: number): void {+ if (deviceRevealCaps.get(deviceId)?.epoch === epoch) deviceRevealCaps.delete(deviceId);+}export function deviceSupportsRevealIgnoredDirs(deviceId: string,workdir: string,+ /**+ * 连接代次(`useDeviceLinkReconnectEpoch`):重连 / 被控端恢复 online 时自增。+ * 肯定结论只在本代次内有效 —— 设备被回滚到老 Desktop 时 deviceId 不变,不带+ * 代次的缓存会让重连后的重探直接命中旧 promise,开关保持可按而 listDir 靜默+ * 忽略该字段,直到 controller 重启。+ */+ reconnectEpoch = 0,): Promise<boolean | null> {const cached = deviceRevealCaps.get(deviceId);- if (cached) return cached;+ if (cached && cached.epoch === reconnectEpoch) return cached.probe;const probe = Promise.resolve().then(() => invokeOp<{ ok: boolean; showIgnoredDirs?: boolean }>(deviceId, 'caps', { workdir })).then((r) => {const supported = r?.ok === true && r.showIgnoredDirs === true;// 只留肯定结论;「不支持」下次重新问(被控端可能已升级)。- if (!supported) deviceRevealCaps.delete(deviceId);+ if (!supported) evictRevealCapsIfCurrent(deviceId, reconnectEpoch);return supported;}).catch((err: unknown) => {- deviceRevealCaps.delete(deviceId);+ evictRevealCapsIfCurrent(deviceId, reconnectEpoch);if (isDeviceTooOldError(err)) return false; // 老端:确定性不支持return null; // 瞬态:不落定,等连接恢复重探});- deviceRevealCaps.set(deviceId, probe);+ deviceRevealCaps.set(deviceId, { epoch: reconnectEpoch, probe });return probe;}