Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions src/components/message/live-turn-stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ interface LiveEditStats extends LineChangeStats {
files: number
}

function formatCompactInt(n: number, formatter: Intl.NumberFormat): string {
if (n < 1000) return String(n)
return formatter.format(n)
}

function asObject(value: unknown): Record<string, unknown> | null {
if (!value || typeof value !== "object" || Array.isArray(value)) return null
return value as Record<string, unknown>
Expand Down Expand Up @@ -317,14 +312,11 @@ export function LiveTurnStats({
const [elapsed, setElapsed] = useState(() => Date.now() - message.startedAt)
const editStats = useMemo(() => extractLiveEditStats(message), [message])
const tps = useTokenOutputSpeed(message)
const compactNumberFormatter = useMemo(
() =>
new Intl.NumberFormat(locale, {
notation: "compact",
maximumFractionDigits: 1,
}),
[locale]
)

// Line counts are shown in full rather than compacted: `+2.8K/-2.7K` asks the
// reader to undo the rounding before they can compare the two sides, and
// "additions nearly equal deletions" is exactly the reading that matters here.
const lineFormatter = useMemo(() => new Intl.NumberFormat(locale), [locale])

useEffect(() => {
const timer = setInterval(() => {
Expand Down Expand Up @@ -367,11 +359,24 @@ export function LiveTurnStats({
<span className="hidden text-border leading-none @[24rem]/turnstats:inline">
|
</span>
<span className="hidden items-center gap-1 leading-none @[24rem]/turnstats:inline-flex">
<FilePenLine className="h-3 w-3 shrink-0" />
{editStats.files}F +
{formatCompactInt(editStats.additions, compactNumberFormatter)}/-
{formatCompactInt(editStats.deletions, compactNumberFormatter)}
<span
className="hidden items-center gap-1 leading-none @[24rem]/turnstats:inline-flex"
title={t("editStatsTooltip", {
files: editStats.files,
additions: lineFormatter.format(editStats.additions),
deletions: lineFormatter.format(editStats.deletions),
})}
>
<FilePenLine
aria-label={t("editStatsAria")}
className="h-3 w-3 shrink-0"
/>
{t("filesChanged", { count: editStats.files })}
<span className="text-border">·</span>
{t("linesChanged", {
additions: lineFormatter.format(editStats.additions),
deletions: lineFormatter.format(editStats.deletions),
})}
</span>
</>
)}
Expand All @@ -392,7 +397,7 @@ export function LiveTurnStats({
aria-label={t("outputSpeedAria")}
className="h-3 w-3 shrink-0"
/>
{tps.toFixed(1)} tok/s
{t("outputSpeedValue", { value: tps.toFixed(1) })}
</span>
</>
)}
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value}د",
"elapsedSeconds": "{value}ث",
"outputSpeedAria": "السرعة التقديرية للإخراج",
"outputSpeedTooltip": "السرعة التقديرية للإخراج (نص + تفكير)"
"outputSpeedTooltip": "السرعة التقديرية للإخراج (نص + تفكير)",
"filesChanged": "{count} ملف مُعدَّل",
"linesChanged": "إضافة {additions} سطر، حذف {deletions} سطر",
"editStatsAria": "تغييرات هذه الجولة",
"editStatsTooltip": "غيّرت هذه الجولة {files} ملف — إضافة {additions} سطر، حذف {deletions} سطر",
"outputSpeedValue": "{value} رمز/ثانية"
},
"jsonTree": {
"viewRaw": "عرض JSON الخام",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value} Min",
"elapsedSeconds": "{value} Sek",
"outputSpeedAria": "Geschätzte Ausgabegeschwindigkeit",
"outputSpeedTooltip": "Geschätzte Ausgabegeschwindigkeit (Text + Denken)"
"outputSpeedTooltip": "Geschätzte Ausgabegeschwindigkeit (Text + Denken)",
"filesChanged": "{count, plural, one {# Datei geändert} other {# Dateien geändert}}",
"linesChanged": "{additions} Zeilen ergänzt, {deletions} entfernt",
"editStatsAria": "Änderungen in diesem Durchlauf",
"editStatsTooltip": "{files, plural, one {# Datei} other {# Dateien}} in diesem Durchlauf geändert: {additions} Zeilen ergänzt, {deletions} entfernt",
"outputSpeedValue": "{value} Tokens/s"
},
"jsonTree": {
"viewRaw": "Rohes JSON anzeigen",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value}m",
"elapsedSeconds": "{value}s",
"outputSpeedAria": "Estimated output speed",
"outputSpeedTooltip": "Estimated output speed (text + thinking)"
"outputSpeedTooltip": "Estimated output speed (text + thinking)",
"filesChanged": "{count, plural, one {# file changed} other {# files changed}}",
"linesChanged": "{additions} lines added, {deletions} removed",
"editStatsAria": "This turn's edits",
"editStatsTooltip": "{files, plural, one {# file changed} other {# files changed}} this turn — {additions} lines added, {deletions} removed",
"outputSpeedValue": "{value} tokens/sec"
},
"jsonTree": {
"viewRaw": "Show raw JSON",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value} min",
"elapsedSeconds": "{value} s",
"outputSpeedAria": "Velocidad de salida estimada",
"outputSpeedTooltip": "Velocidad de salida estimada (texto + razonamiento)"
"outputSpeedTooltip": "Velocidad de salida estimada (texto + razonamiento)",
"filesChanged": "{count, plural, one {# archivo modificado} other {# archivos modificados}}",
"linesChanged": "{additions} líneas añadidas, {deletions} eliminadas",
"editStatsAria": "Cambios de este turno",
"editStatsTooltip": "{files, plural, one {# archivo} other {# archivos}} modificados en este turno: {additions} líneas añadidas, {deletions} eliminadas",
"outputSpeedValue": "{value} tokens/s"
},
"jsonTree": {
"viewRaw": "Ver JSON sin formato",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value} min",
"elapsedSeconds": "{value} s",
"outputSpeedAria": "Vitesse de sortie estimée",
"outputSpeedTooltip": "Vitesse de sortie estimée (texte + raisonnement)"
"outputSpeedTooltip": "Vitesse de sortie estimée (texte + raisonnement)",
"filesChanged": "{count, plural, one {# fichier modifié} other {# fichiers modifiés}}",
"linesChanged": "{additions} lignes ajoutées, {deletions} supprimées",
"editStatsAria": "Modifications de ce tour",
"editStatsTooltip": "{files, plural, one {# fichier} other {# fichiers}} modifiés ce tour : {additions} lignes ajoutées, {deletions} supprimées",
"outputSpeedValue": "{value} jetons/s"
},
"jsonTree": {
"viewRaw": "Afficher le JSON brut",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value}分",
"elapsedSeconds": "{value}秒",
"outputSpeedAria": "推定出力速度",
"outputSpeedTooltip": "推定出力速度(テキスト + 思考)"
"outputSpeedTooltip": "推定出力速度(テキスト + 思考)",
"filesChanged": "{count} 個のファイルを変更",
"linesChanged": "{additions} 行追加、{deletions} 行削除",
"editStatsAria": "このターンの変更",
"editStatsTooltip": "このターンは {files} 個のファイルを変更 — {additions} 行追加、{deletions} 行削除",
"outputSpeedValue": "{value} token/秒"
},
"jsonTree": {
"viewRaw": "生の JSON を表示",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value}분",
"elapsedSeconds": "{value}초",
"outputSpeedAria": "예상 출력 속도",
"outputSpeedTooltip": "예상 출력 속도(텍스트 + 추론)"
"outputSpeedTooltip": "예상 출력 속도(텍스트 + 추론)",
"filesChanged": "{count}개 파일 수정",
"linesChanged": "{additions}줄 추가, {deletions}줄 삭제",
"editStatsAria": "이번 턴 변경",
"editStatsTooltip": "이번 턴에 {files}개 파일 수정 — {additions}줄 추가, {deletions}줄 삭제",
"outputSpeedValue": "{value} token/초"
},
"jsonTree": {
"viewRaw": "원본 JSON 보기",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value} min",
"elapsedSeconds": "{value} s",
"outputSpeedAria": "Velocidade de saída estimada",
"outputSpeedTooltip": "Velocidade de saída estimada (texto + raciocínio)"
"outputSpeedTooltip": "Velocidade de saída estimada (texto + raciocínio)",
"filesChanged": "{count, plural, one {# arquivo alterado} other {# arquivos alterados}}",
"linesChanged": "{additions} linhas adicionadas, {deletions} removidas",
"editStatsAria": "Alterações desta rodada",
"editStatsTooltip": "{files, plural, one {# arquivo} other {# arquivos}} alterados nesta rodada: {additions} linhas adicionadas, {deletions} removidas",
"outputSpeedValue": "{value} tokens/s"
},
"jsonTree": {
"viewRaw": "Ver JSON bruto",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value} 分钟",
"elapsedSeconds": "{value} 秒",
"outputSpeedAria": "估算输出速度",
"outputSpeedTooltip": "估算输出速度(正文 + 思考)"
"outputSpeedTooltip": "估算输出速度(正文 + 思考)",
"filesChanged": "改了 {count} 个文件",
"linesChanged": "新增 {additions} 行、删除 {deletions} 行",
"editStatsAria": "本轮改动",
"editStatsTooltip": "本轮改了 {files} 个文件:新增 {additions} 行、删除 {deletions} 行",
"outputSpeedValue": "{value} token/秒"
},
"jsonTree": {
"viewRaw": "查看原始 JSON",
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/messages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,12 @@
"elapsedMinutes": "{value} 分鐘",
"elapsedSeconds": "{value} 秒",
"outputSpeedAria": "估算輸出速度",
"outputSpeedTooltip": "估算輸出速度(正文 + 思考)"
"outputSpeedTooltip": "估算輸出速度(正文 + 思考)",
"filesChanged": "改了 {count} 個檔案",
"linesChanged": "新增 {additions} 行、刪除 {deletions} 行",
"editStatsAria": "本輪改動",
"editStatsTooltip": "本輪改了 {files} 個檔案:新增 {additions} 行、刪除 {deletions} 行",
"outputSpeedValue": "{value} token/秒"
},
"jsonTree": {
"viewRaw": "檢視原始 JSON",
Expand Down