From 11d582df494a67951afbf1207f5b4983ed2b9a81 Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Tue, 21 Oct 2025 16:25:32 +0800 Subject: [PATCH] fix(i18n): improve null handling in interpolation --- src/i18n/index.ts | 3 ++- src/ui/Panel.ts | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 7ef12e2..e048061 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -35,7 +35,8 @@ export class I18n { private interpolate(template: string, params: TranslationParams): string { return template.replace(/\{\{(\w+)\}\}/g, (match, key) => { - return params[key]?.toString() || match + // Use != null to check for both null and undefined, allow empty strings + return params[key] != null ? params[key].toString() : match }) } diff --git a/src/ui/Panel.ts b/src/ui/Panel.ts index c6fe36d..289f37f 100644 --- a/src/ui/Panel.ts +++ b/src/ui/Panel.ts @@ -426,10 +426,7 @@ export class Panel { #updateHistory(): void { const steps = this.#state.getAllSteps() - this.#historySection.innerHTML = steps - .slice(-10) // Only show last 10 items - .map((step) => this.#createHistoryItem(step)) - .join('') + this.#historySection.innerHTML = steps.map((step) => this.#createHistoryItem(step)).join('') // Scroll to bottom to show latest records this.#scrollToBottom() @@ -491,7 +488,7 @@ export class Panel { const stepLabel = this.#pageAgent.i18n.t('ui.panel.step', { number: step.stepNumber.toString(), time, - duration: durationText, + duration: durationText || '', // Explicitly pass empty string to replace template }) return `