fix(admin-ui): keep sign and precision in CSV, YAML and context labels

CSV export prefixed negative numbers with an apostrophe, which corrupted the data. YAML emitted NaN and Infinity as plain strings. Context windows such as 1500 read as 2k. Numbers now skip the CSV formula guard, non-finite values use YAML float forms, and counts below 10k keep one decimal.
This commit is contained in:
2026-11-08 02:29:28 +00:00
parent e985fded45
commit 0a05dfc035
6 changed files with 42 additions and 4 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ const CSV_FORMULA_LEAD_CHARS = /^[=+\-@\t\r]/
*/
function csvField(value: unknown): string {
let s = value === null || value === undefined ? '' : String(value)
if (CSV_FORMULA_LEAD_CHARS.test(s)) s = `'${s}`
if (typeof value !== 'number' && CSV_FORMULA_LEAD_CHARS.test(s)) s = `'${s}`
if (!CSV_SPECIAL_CHARS.test(s)) return s
return `"${s.replace(/"/g, '""')}"`
}