Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 重启确认的中文改为完整宾语,并限制姓名查询时间
shenjiachengb76d25f0e942
diff --git a/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts b/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.tsindex 09863f66c7..aeb0cdfbd4 100644--- a/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts+++ b/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts@@ -19,6 +19,7 @@ const h = vi.hoisted(() => ({selects: 0,dbRows: [] as unknown[],dbError: null as Error | null,+ dbHang: false,removed: [] as string[],log: {warn: vi.fn(),@@ -58,7 +59,7 @@ vi.mock('../localDb/client/current', () => ({const chain = {from: () => chain,leftJoin: () => chain,- where: () => Promise.resolve(h.dbRows),+ where: () => (h.dbHang ? new Promise(() => {}) : Promise.resolve(h.dbRows)),};return { drizzle: { select: () => { h.selects += 1; return chain; } } };},@@ -71,7 +72,7 @@ import {readRelaunchBlockingActivity,registerRelaunchBusyActivityIpc,} from '../relaunchBusyActivityIpc.js';-import { readRelaunchTurnFacts } from '../relaunchTurnFacts.js';+import { RELAUNCH_TURN_FACTS_BUDGET_MS, readRelaunchTurnFacts } from '../relaunchTurnFacts.js';/** 每个来源都记一次读取,用来证明拒绝路径下一个都没被碰。 */function countingSources(busy: boolean) {@@ -97,6 +98,7 @@ beforeEach(() => {h.selects = 0;h.dbRows = [];h.dbError = null;+ h.dbHang = false;h.removed = [];h.log.info.mockClear();});@@ -361,6 +363,19 @@ describe('readRelaunchTurnFacts', () => {expect(h.selects).toBe(1);});+ it('falls back when the teammate name query exceeds its short budget', async () => {+ vi.useFakeTimers();+ h.dbHang = true;+ try {+ const pending = readRelaunchTurnFacts(['bot-session']);+ await vi.advanceTimersByTimeAsync(RELAUNCH_TURN_FACTS_BUDGET_MS);+ await expect(pending).resolves.toBeNull();+ expect(h.selects).toBe(1);+ } finally {+ vi.useRealTimers();+ }+ });+it('does not call a delegated background task a teammate reply', async () => {h.dbRows = [{diff --git a/apps/desktop/src/main/relaunchTurnFacts.ts b/apps/desktop/src/main/relaunchTurnFacts.tsindex 450ba25ef0..26229a6c59 100644--- a/apps/desktop/src/main/relaunchTurnFacts.ts+++ b/apps/desktop/src/main/relaunchTurnFacts.ts@@ -15,6 +15,8 @@ import { getDbClient } from './localDb/client/current.js';import { botProfiles, botSessionLinks, sessions } from './localDb/schema.js';const MAX_TURN_FACTS = 32;+/** 姓名查询只为确认文案。数据库拥塞时不能把「立即重启」卡住几十秒。 */+export const RELAUNCH_TURN_FACTS_BUDGET_MS = 300;export async function readRelaunchTurnFacts(sessionIds: readonly string[],@@ -28,8 +30,9 @@ export async function readRelaunchTurnFacts(}if (ids.length === 0) return { companions: [], conversation: false };if (ids.length > MAX_TURN_FACTS) return null;+ let timer: ReturnType<typeof setTimeout> | undefined;try {- const rows = await getDbClient().drizzle+ const query = getDbClient().drizzle.select({id: sessions.id,source: sessions.source,@@ -44,7 +47,16 @@ export async function readRelaunchTurnFacts(and(eq(botSessionLinks.sessionId, sessions.id), isNull(botSessionLinks.archivedAt)),).leftJoin(botProfiles, eq(botProfiles.id, botSessionLinks.botId))- .where(inArray(sessions.id, ids));+ .where(inArray(sessions.id, ids))+ .then((rows) => rows)+ .catch(() => null);+ const rows = await Promise.race([+ query,+ new Promise<null>((resolve) => {+ timer = setTimeout(() => resolve(null), RELAUNCH_TURN_FACTS_BUDGET_MS);+ }),+ ]);+ if (!rows) return null;const facts: RelaunchTurnRow[] = rows.map((row) => ({id: row.id,source: row.source ?? null,@@ -56,6 +68,8 @@ export async function readRelaunchTurnFacts(return classifyRelaunchTurnRows(ids, facts);} catch {return null;+ } finally {+ if (timer) clearTimeout(timer);}}diff --git a/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx b/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsxindex f1457f7043..967b07ca2e 100644--- a/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx+++ b/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx@@ -611,13 +611,14 @@ describe('formatRelaunchActivityHint builds a complete sentence', () => {'update.banner.activityNameJoiner': '、','update.banner.activityNameJoinerPair': '、','update.banner.activityNameJoinerLast': '、',- 'update.banner.activity.companionOne': '伙伴 {{names}} 正在回复',- 'update.banner.activity.companionOther': '伙伴 {{names}} 正在回复',+ 'update.banner.activity.companionOne': '伙伴 {{names}} 的回复',+ 'update.banner.activity.companionOther': '伙伴 {{names}} 的回复',+ 'update.banner.activity.conversation': '正在进行的对话','update.banner.activity.backgroundCommand': '后台命令',});expect(formatRelaunchActivityHint(t, {- categories: ['companion', 'background-command'],+ categories: ['companion', 'conversation', 'background-command'],companionNames: ['Cindy', 'Mika'],- })).toBe('重启会中断伙伴 Cindy、Mika 正在回复、后台命令。');+ })).toBe('重启会中断伙伴 Cindy、Mika 的回复、正在进行的对话、后台命令。');});});diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 0be172a9cd..4c0693fc91 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -8829,10 +8829,10 @@"activityNameJoinerPair": "、","activityNameJoinerLast": "、","activity": {- "companion": "伙伴正在回复",- "companionOne": "伙伴 {{names}} 正在回复",- "companionOther": "伙伴 {{names}} 正在回复",- "conversation": "对话进行中",+ "companion": "伙伴的回复",+ "companionOne": "伙伴 {{names}} 的回复",+ "companionOther": "伙伴 {{names}} 的回复",+ "conversation": "正在进行的对话","backgroundCommand": "后台命令","scheduledTask": "定时任务","generation": "生成任务",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 224c80ae49..164873abf3 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -8829,10 +8829,10 @@"activityNameJoinerPair": "、","activityNameJoinerLast": "、","activity": {- "companion": "夥伴正在回覆",- "companionOne": "夥伴 {{names}} 正在回覆",- "companionOther": "夥伴 {{names}} 正在回覆",- "conversation": "對話進行中",+ "companion": "夥伴的回覆",+ "companionOne": "夥伴 {{names}} 的回覆",+ "companionOther": "夥伴 {{names}} 的回覆",+ "conversation": "正在進行的對話","backgroundCommand": "背景命令","scheduledTask": "定時任務","generation": "生成任務",