Skip to content

Commit 639951b

Browse files
lsr911claude
andcommitted
fix(auto-reply): use truncateUtf16Safe in bash command and ACP steer output truncation
Replace naive .slice(0, N) with truncateUtf16Safe() in: - bash-command.ts: shell command name preview - lifecycle.ts: ACP steer output text Co-Authored-By: Claude <[email protected]>
1 parent 9269a27 commit 639951b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/auto-reply/reply/bash-command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** Handles /bash and ! shell command chat shortcuts. */
2+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
23
import {
34
normalizeLowercaseStringOrEmpty,
45
normalizeOptionalString,
@@ -54,7 +55,7 @@ function formatSessionSnippet(sessionId: string) {
5455
if (trimmed.length <= 12) {
5556
return trimmed;
5657
}
57-
return `${trimmed.slice(0, 8)}…`;
58+
return `${truncateUtf16Safe(trimmed, 8)}…`;
5859
}
5960

6061
function formatOutputBlock(text: string) {

src/auto-reply/reply/commands-acp/lifecycle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
resolveAcpThreadSessionDetailLines,
66
} from "@openclaw/acp-core/runtime/session-identifiers";
77
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
8+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
89
import { getAcpSessionManager } from "../../../acp/control-plane/manager.js";
910
import { resolveAcpSessionResolutionError } from "../../../acp/control-plane/manager.utils.js";
1011
import {
@@ -787,7 +788,7 @@ async function runAcpSteer(params: {
787788
if (event.text) {
788789
output += event.text;
789790
if (output.length > ACP_STEER_OUTPUT_LIMIT) {
790-
output = `${output.slice(0, ACP_STEER_OUTPUT_LIMIT)}…`;
791+
output = `${truncateUtf16Safe(output, ACP_STEER_OUTPUT_LIMIT)}…`;
791792
}
792793
}
793794
},

0 commit comments

Comments
 (0)