Skip to content

Commit abf2094

Browse files
felixlagaclaude
andcommitted
fix(grok): long command titles no longer end in a broken character
Grok tool calls with a generic title fall back to the command, cut to 77 characters. When that cut lands inside an emoji, the row title keeps half of a surrogate pair and shows a replacement character before the "...". The cut now moves back one unit when it would split a pair, like the other title truncations in the repo. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0f4a130 commit abf2094

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎packages/provider-grok/src/server/xaiAcpExtension.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,18 @@ describe("XAiAcpExtension", () => {
458458
const normalized = normalizeXAiAcpToolCallState(toolCall);
459459
expect(normalized.status).toBe("completed");
460460
expect(normalized.title).toBe("for i in 1 2; do echo STREAM_$i; done; echo STREAM_DONE");
461+
expect(
462+
normalizeXAiAcpToolCallState({
463+
...toolCall,
464+
data: {
465+
...toolCall.data,
466+
rawOutput: {
467+
...toolCall.data.rawOutput,
468+
command: `git commit -m "${"x".repeat(61)}🎉 ship it"`,
469+
},
470+
},
471+
}).title,
472+
).toBe(`git commit -m "${"x".repeat(61)}...`);
461473
expect(
462474
normalizeXAiAcpToolCallState({
463475
...toolCall,

‎packages/provider-grok/src/server/xaiAcpExtension.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,10 @@ function resolveXAiAcpToolTitle(toolCall: AcpToolCallState): string | undefined
549549
nonEmptyString(rawInput?.command) ??
550550
nonEmptyString(unknownRecord(toolCall.data.rawOutput)?.command);
551551
if (command !== undefined) {
552-
return command.length > 80 ? `${command.slice(0, 77)}...` : command;
552+
if (command.length <= 80) return command;
553+
const splitsPair =
554+
/[\uD800-\uDBFF]/.test(command.charAt(76)) && /[\uDC00-\uDFFF]/.test(command.charAt(77));
555+
return `${command.slice(0, splitsPair ? 76 : 77)}...`;
553556
}
554557
return nonEmptyString(toolCall.title);
555558
}

0 commit comments

Comments
 (0)