Skip to content

Commit 042de6a

Browse files
committed
refactor(ui): reuse canonical text truncation
1 parent 0dc8202 commit 042de6a

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

ui/src/lib/presenter.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
21
import type { CronJob, GatewaySessionRow, PresenceEntry } from "../api/types.ts";
32
// Control UI module implements presenter behavior.
43
import { t } from "../i18n/index.ts";
@@ -47,10 +46,6 @@ export function formatEventPayload(payload: unknown): string {
4746
}
4847
}
4948

50-
export function formatEventPayloadPreview(payload: unknown, maxLength = 120): string {
51-
return truncateUtf16Safe(formatEventPayload(payload), maxLength);
52-
}
53-
5449
export function formatCronState(job: CronJob) {
5550
const state = job.state ?? {};
5651
const next = state.nextRunAtMs ? formatMs(state.nextRunAtMs) : t("common.na");

ui/src/pages/overview/event-log.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { html, nothing } from "lit";
33
import type { EventLogEntry } from "../../api/event-log.ts";
44
import { icons } from "../../components/icons.ts";
55
import { t } from "../../i18n/index.ts";
6-
import { formatTimeMs } from "../../lib/format.ts";
7-
import { formatEventPayloadPreview } from "../../lib/presenter.ts";
6+
import { formatTimeMs, truncateText } from "../../lib/format.ts";
7+
import { formatEventPayload } from "../../lib/presenter.ts";
88

99
type OverviewEventLogProps = {
1010
events: readonly EventLogEntry[];
@@ -32,7 +32,7 @@ export function renderOverviewEventLog(props: OverviewEventLogProps) {
3232
<span class="ov-event-log-name">${entry.event}</span>
3333
${entry.payload
3434
? html`<span class="ov-event-log-payload muted"
35-
>${formatEventPayloadPreview(entry.payload)}</span
35+
>${truncateText(formatEventPayload(entry.payload), 120).text}</span
3636
>`
3737
: nothing}
3838
</div>

0 commit comments

Comments
 (0)