Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 第十一轮 review 修复——Bash 行定位锚点/补读重连清空/auth 刷新假活跃
Kafeifei3e90b3a18813
diff --git a/apps/desktop/src/renderer/__tests__/tapdbConsentGate.test.ts b/apps/desktop/src/renderer/__tests__/tapdbConsentGate.test.tsindex b6bd8dac08..0dd08b5971 100644--- a/apps/desktop/src/renderer/__tests__/tapdbConsentGate.test.ts+++ b/apps/desktop/src/renderer/__tests__/tapdbConsentGate.test.ts@@ -470,6 +470,19 @@ describe('engagement-driven activity reporting', () => {expect(tapdb.setUser).toHaveBeenCalledTimes(2);});+ it('a token-refresh auth broadcast on a new day does not emit setUser (no interaction)', async () => {+ // auth:state-change 也由定时 token 刷新广播:挂机过夜的机器不得凭空产生+ // 当日账号活跃 —— 跨天重绑只走交互路径(reportActive)。+ await initAllowed();+ authListener?.({ isAuthenticated: true, user: { id: 'user-1' } });+ expect(tapdb.setUser).toHaveBeenCalledTimes(1);++ vi.setSystemTime(new Date(2026, 6, 29, 3, 0, 0));+ authListener?.({ isAuthenticated: true, user: { id: 'user-1' } });++ expect(tapdb.setUser).toHaveBeenCalledTimes(1);+ });+it('a window opened before midnight does not swallow the next day’s first interaction', async () => {// 23:55 上报后窗口本该到 00:05 —— 但已换日,00:03 的交互必须放行并补当日 setUser,// 否则「只在次日凌晨窗口内用了一下」的用户从第二天的活跃里整个消失。diff --git a/apps/desktop/src/renderer/analytics/tapdbClient.ts b/apps/desktop/src/renderer/analytics/tapdbClient.tsindex 2a27d5c798..483d52cb16 100644--- a/apps/desktop/src/renderer/analytics/tapdbClient.ts+++ b/apps/desktop/src/renderer/analytics/tapdbClient.ts@@ -167,11 +167,12 @@ export function initTapdb(): void {TapDBAPI.logout();log.info('logout');lastSetUserDate = null;- } else {- const today = getLocalDateKey();- if (nextUserId !== previousUserId || lastSetUserDate !== today) {- reportSetUser(nextUserId, 'auth_state', today);- }+ } else if (nextUserId !== previousUserId) {+ // 仅在身份真正变化时绑定。auth:state-change 也会由**定时 token 刷新**+ // 广播 —— 若这里按「跨天」补 setUser,挂机过夜的机器会在无人交互时+ // 凭空产生当日账号活跃,正是本次「活跃改交互驱动」要消灭的假 DAU;+ // 跨天重绑由交互路径(reportActive)负责,只在真实交互时发生。+ reportSetUser(nextUserId, 'auth_state');}} catch (err) {log.error('auth state binding failed (non-fatal)', err);diff --git a/apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsx b/apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsxindex 482b474681..23b6c22a91 100644--- a/apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsx+++ b/apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsx@@ -100,7 +100,13 @@ export function AgentActionsBlock({if (toolCalls.length === 0) return null;return (- <div className="flex w-full justify-start">+ // data-message-client-ids(空格分隔):后台任务面板「点行跳聊天」的定位锚点。+ // 聚合块内的工具行折叠时不在可视 DOM,精确 clientId 锚点(message wrapper /+ // 任务卡)查不到时,MessageStream 的 focus 用 ~= 属性选择器落到本块容器。+ <div+ className="flex w-full justify-start"+ data-message-client-ids={toolCalls.map((c) => c.clientId).join(' ')}+ ><div className="w-full"><buttontype="button"diff --git a/apps/desktop/src/renderer/components/chat/MessageStream.tsx b/apps/desktop/src/renderer/components/chat/MessageStream.tsxindex 7579516899..52626a19e5 100644--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx@@ -2369,9 +2369,15 @@ export function MessageStream({}const root = scrollRef.current;if (!root) return;- const el = root.querySelector(+ // 精确锚点(message wrapper / 带 toolCall 的任务卡)优先;查不到时退回+ // 聚合动作块的容器锚点(data-message-client-ids 空格分隔多 clientId)——+ // 后台 Bash 等工具行渲染在折叠块内,没有独立的行级 DOM 锚点。+ const el = (root.querySelector(`[data-message-client-id="${CSS.escape(focusMessageClientId)}"]`,- ) as HTMLElement | null;+ ) ??+ root.querySelector(+ `[data-message-client-ids~="${CSS.escape(focusMessageClientId)}"]`,+ )) as HTMLElement | null;if (!el) return;restoringRef.current = false;isNearBottomRef.current = false;diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsxindex b5e3fceb37..33ed02b7e8 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx@@ -572,10 +572,12 @@ export function BackgroundTasksBody({ReadonlyMap<string, AgentTaskUpdate['status']>>(() => new Map());const fileStatusRequestedRef = useRef<Set<string>>(new Set());+ // deviceConnectivity 参与依赖:断连窗口内的补读全部 miss 且被记忆短路,重连+ // 翻转时清空重来(本机恒 'local' 不触发;已成功的重读幂等,set 同值短路)。useEffect(() => {fileStatusRequestedRef.current = new Set();setFileStatusByTaskId(new Map());- }, [sessionId]);+ }, [sessionId, deviceConnectivity]);useEffect(() => {if (!sessionId) return;const pending: string[] = [];