Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): drop unreachable binary tail boundary guard

Zhao Dengfeng95eaf1f35d2a
diff --git a/apps/mobile/src/__tests__/sessionReferences.test.ts b/apps/mobile/src/__tests__/sessionReferences.test.ts
index 9f349bf484..fd756047cf 100644
--- a/apps/mobile/src/__tests__/sessionReferences.test.ts
+++ b/apps/mobile/src/__tests__/sessionReferences.test.ts
@@ -690,9 +690,9 @@ describe('resolveMobileSessionReferences', () => {
});
it.each([
- { cutPoint: 'binary tail', payloadBody: '😀"' },
- { cutPoint: 'serialized payload', payloadBody: '"😀' },
- ])('keeps emoji whole at the $cutPoint multi-reference budget cut', async ({ payloadBody }) => {
+ { layout: 'emoji before quote', payloadBody: '😀"' },
+ { layout: 'quote before emoji', payloadBody: '"😀' },
+ ])('keeps emoji whole when the serialized payload cut trims $layout content', async ({ payloadBody }) => {
const invoke = asInvoke(async (_deviceId, channel, args) => {
if (channel === 'local-db:sessions:get') return { id: args[0] };
const request = args[0] as { sessionId: string };
diff --git a/apps/mobile/src/session/sessionReferences.ts b/apps/mobile/src/session/sessionReferences.ts
index 6da0db685e..ae12e53fd3 100644
--- a/apps/mobile/src/session/sessionReferences.ts
+++ b/apps/mobile/src/session/sessionReferences.ts
@@ -284,7 +284,9 @@ function sliceTailToTokenBudget(text: string, budget: number): string {
if (estimateMobileReferenceTokens(text.slice(text.length - middle)) <= payloadBudget) low = middle;
else high = middle - 1;
}
- return `…${sliceFromCodePointBoundary(text, text.length - low)}`;
+ // 估算按 code point 计数,补上低代理项前的高代理项不增加 token,
+ // 二分得到的最长后缀因此不会从代理对中间开始。
+ return `…${text.slice(text.length - low)}`;
}
function fitMessagesToTokenBudget(