feat(webui): localize agent activity
Localize frontend-owned activity presentation while preserving raw tool data and current controls. Include locale-aware model memoization and integration with current main. Co-authored-by: Xubin Ren <52506698+Re-bin@users.noreply.github.com>
This commit is contained in:
1 parent
f57cc3aad2
commit
796e1cb0e6
23 files changed
+1704
-128
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import type { TFunction } from "i18next";
|
||||
|
||||
export function redactActivityText(value: string): string {
|
||||
return value
|
||||
.replace(/(https?:\/\/)[^/@\s]+@/gi, "$1<redacted>@")
|
||||
@@ -48,16 +50,22 @@ export function safeActivityDetail(value: string, maxLength = 96): string {
|
||||
);
|
||||
}
|
||||
|
||||
export function summarizeShellCommand(command: string): string {
|
||||
export function formatActivityTarget(t: TFunction, action: string, target: string): string {
|
||||
return target
|
||||
? t("message.agentActivity.actionTarget", { action, target })
|
||||
: action;
|
||||
}
|
||||
|
||||
export function summarizeShellCommand(command: string, t: TFunction): string {
|
||||
const lines = redactShellCommand(command.replace(/\r\n/g, "\n"))
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean);
|
||||
const firstLine = compactActivityPath(lines[0] || "command");
|
||||
const firstLine = compactActivityPath(lines[0] || t("message.agentActivity.command"));
|
||||
const firstPreview = truncateMiddle(firstLine, 92);
|
||||
return lines.length <= 1
|
||||
? firstPreview
|
||||
: `${firstPreview} · script, ${lines.length} lines`;
|
||||
: `${firstPreview} · ${t("message.agentActivity.scriptLines", { count: lines.length })}`;
|
||||
}
|
||||
|
||||
function truncateMiddle(value: string, maxLength: number): string {
|
||||
|
||||
Reference in new issue
Block a user