Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 群任务卡标题不再切开 emoji
Chris245e1ff82b3c
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex bb81ee8689..6b17f1d229 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -4290,6 +4290,22 @@ describe('Bot Session task end-to-end runtime', () => {} finally { release(); runtime.dispose(); }});+ it('clips a long group task title without splitting an emoji', async () => {+ await seedPair(); seedGroupLane();+ const release = registerGroupToolAuthority('group-lane', { botId: 'bot-a', mode: 'owner', isCurrent: () => true, validate: async () => {} });+ const postGroupTaskMessage = vi.fn(async (input: { clientId: string }) => ({ ok: true as const, messageId: `posted:${input.clientId}` }));+ const runtime = createDelegationRuntime({ postGroupTaskMessage });+ try {+ const task = await runtime.delegation.startSessionTask({ callerSessionId: 'group-lane', objective: `${'a'.repeat(59)}😀 and more\nDetails` });+ if (!task.ok) throw new Error(task.message);+ await vi.waitFor(() => expect(postGroupTaskMessage).toHaveBeenCalled());+ const card = (postGroupTaskMessage.mock.calls[0]![0] as unknown as { card: { fallback: string; data: { title: string } } }).card;+ // The task's own title is cut at 60 units, before the emoji rather than through it.+ expect(card.data.title).toBe('a'.repeat(59));+ expect(card.fallback).not.toMatch(/[\ud800-\udbff](?![\udc00-\udfff])/);+ } finally { release(); runtime.dispose(); }+ });+it('tells the teammate a task from an old local-only group reports to the owner privately', async () => {await seedPair(); seedGroupLane();const release = registerGroupToolAuthority('group-lane', { botId: 'bot-a', mode: 'owner', isCurrent: () => true, validate: async () => {} });diff --git a/apps/desktop/src/main/maker-ipc/botDelegationService.ts b/apps/desktop/src/main/maker-ipc/botDelegationService.tsindex fb2fdc5043..f906785176 100644--- a/apps/desktop/src/main/maker-ipc/botDelegationService.ts+++ b/apps/desktop/src/main/maker-ipc/botDelegationService.ts@@ -73,6 +73,13 @@ const MAX_ARTIFACTS = 64;const messageRowid = sql<number>`"messages"."rowid"`;const log = createLogger('bot-delegation');+/** First `max` UTF-16 units, stepping back rather than splitting an emoji (a stored half becomes "\ufffd"). */+function sliceWhole(text: string, max: number): string {+ if (text.length <= max) return text;+ const high = text.charCodeAt(max - 1);+ return text.slice(0, high >= 0xd800 && high <= 0xdbff ? max - 1 : max);+}+type DelegationStatus = BotDelegationStatus;type DelegationRow = typeof botDelegations.$inferSelect;@@ -847,7 +854,8 @@ export function createBotDelegationService(deps: BotDelegationServiceDeps) {const card = buildBotGroupTaskCard({meta,state: event.state,- title: child?.title?.trim() || row.objective.split('\n')[0]!.slice(0, 120),+ // The card builder clips the title on a character boundary; clipping here could split an emoji.+ title: child?.title?.trim() || row.objective.split('\n')[0]!,...(event.summary ? { summary: event.summary } : {}),}, groupTaskCardLabels());return deps.postGroupTaskMessage({@@ -2703,7 +2711,7 @@ export function createBotDelegationService(deps: BotDelegationServiceDeps) {: {}),...(taskRuntime.providerId ? { providerId: taskRuntime.providerId } : {}),agentKind: taskRuntime.agentKind as 'cc' | 'codex' | 'pi',- title: input.title?.trim() || objective.split('\n')[0]!.slice(0, 60),+ title: input.title?.trim() || sliceWhole(objective.split('\n')[0]!, 60),source: 'desktop',},});