fix(auto-reply): truncate user-facing text on UTF-16 boundary (#97299) · openclaw/openclaw@1b8b850
zenglingbiao
·
2026-06-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -87,6 +87,7 @@ import { CommandLaneClearedError, GatewayDrainingError } from "../../process/com
|
87 | 87 | import { CommandLane } from "../../process/lanes.js"; |
88 | 88 | import { defaultRuntime } from "../../runtime.js"; |
89 | 89 | import { shouldPreserveUserFacingSessionStateForInputProvenance } from "../../sessions/input-provenance.js"; |
| 90 | +import { truncateUtf16Safe } from "../../shared/utf16-slice.js"; |
90 | 91 | import { |
91 | 92 | isMarkdownCapableMessageChannel, |
92 | 93 | resolveMessageChannel, |
@@ -753,7 +754,7 @@ function extractCodexUsageLimitMessage(text: string): string | undefined {
|
753 | 754 | if (!message) { |
754 | 755 | return undefined; |
755 | 756 | } |
756 | | -return message.length > 500 ? `${message.slice(0, 497)}...` : message; |
| 757 | +return message.length > 500 ? `${truncateUtf16Safe(message, 497)}...` : message; |
757 | 758 | } |
758 | 759 | |
759 | 760 | function isPureTransientRateLimitSummary(err: unknown): boolean { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -95,6 +95,7 @@ import { isAcpSessionKey } from "../../routing/session-key.js";
|
95 | 95 | import { resolveSendPolicy } from "../../sessions/send-policy.js"; |
96 | 96 | import { createLazyImportLoader } from "../../shared/lazy-promise.js"; |
97 | 97 | import { resolveSilentReplyPolicyFromPolicies } from "../../shared/silent-reply-policy.js"; |
| 98 | +import { truncateUtf16Safe } from "../../shared/utf16-slice.js"; |
98 | 99 | import { createTtsDirectiveTextStreamCleaner } from "../../tts/directives.js"; |
99 | 100 | import { |
100 | 101 | normalizeTtsAutoMode, |
@@ -2565,7 +2566,7 @@ export async function dispatchReplyFromConfig(
|
2565 | 2566 | if (collapsed.length <= 80) { |
2566 | 2567 | return collapsed; |
2567 | 2568 | } |
2568 | | -return `${collapsed.slice(0, 77).trimEnd()}...`; |
| 2569 | +return `${truncateUtf16Safe(collapsed, 77).trimEnd()}...`; |
2569 | 2570 | }; |
2570 | 2571 | const formatPlanUpdateText = (payload: { explanation?: string; steps?: string[] }) => { |
2571 | 2572 | const explanation = payload.explanation?.replace(/\s+/g, " ").trim(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。