From 4e6bb619f72af135298cbf0308a3cd0e6cfd7c50 Mon Sep 17 00:00:00 2001 From: Leon-SK668 <0668001470@xydigit.com> Date: Sun, 19 Jul 2026 06:19:33 +0800 Subject: [PATCH] fix(onboarding): preserve emoji in recommendation reasons (#110401) Co-authored-by: Peter Steinberger --- src/system-agent/setup-app-recommendations.test.ts | 3 ++- src/system-agent/setup-app-recommendations.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/system-agent/setup-app-recommendations.test.ts b/src/system-agent/setup-app-recommendations.test.ts index dcf88ff05e97..309d88805cb4 100644 --- a/src/system-agent/setup-app-recommendations.test.ts +++ b/src/system-agent/setup-app-recommendations.test.ts @@ -170,7 +170,7 @@ describe("setup app recommendation matcher", () => { }); it("tolerates fenced JSON with extra keys and long reasons", async () => { - const reason = `useful ${"very ".repeat(40)}integration`; + const reason = `${"a".repeat(118)}🤖suffix`; const result = await getSetupAppRecommendations({ inventorySource, runtime: defaultRuntime, @@ -200,6 +200,7 @@ describe("setup app recommendation matcher", () => { expect(result.status).toBe("ok"); if (result.status === "ok") { expect(result.matches[0]?.candidateId).toBe("notes-tools"); + expect(result.matches[0]?.reason).toBe(`${"a".repeat(118)}…`); expect(result.matches[0]?.reason.length).toBeLessThanOrEqual(120); } }); diff --git a/src/system-agent/setup-app-recommendations.ts b/src/system-agent/setup-app-recommendations.ts index 70873c71738b..efc4d36e7cce 100644 --- a/src/system-agent/setup-app-recommendations.ts +++ b/src/system-agent/setup-app-recommendations.ts @@ -1,3 +1,4 @@ +import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice"; import pLimit from "p-limit"; import { z } from "zod"; import { searchClawHubSkills } from "../infra/clawhub.js"; @@ -79,7 +80,7 @@ const MatcherOutputSchema = z.object({ .string() .trim() .min(1) - .transform((value) => (value.length > 120 ? `${value.slice(0, 119)}…` : value)), + .transform((value) => (value.length > 120 ? `${truncateUtf16Safe(value, 119)}…` : value)), }), ), });