Skip to content

Commit 0cc5235

Browse files
cpcloudcursoragent
andcommitted
fix(ui): exclude cellText from mag transform
cellText covers phone numbers, serial numbers, model numbers, and other identifiers that happen to look numeric. Previously magFormat would attempt to parse them and convert e.g. "5551234567" into magnitude notation. Now only cellMoney and cellDrilldown are transformed. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4bfcd5e commit 0cc5235

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

internal/app/mag.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ func magFormat(c cell, includeUnit bool) string {
2424
}
2525

2626
// Only transform kinds that carry meaningful numeric data.
27-
// Skip cellReadonly (IDs, ages, counts) and non-numeric kinds.
27+
// cellText is excluded because it covers phone numbers, serial numbers,
28+
// model numbers, and other identifiers that happen to look numeric.
2829
switch c.Kind {
29-
case cellText, cellMoney, cellDrilldown:
30-
// Potentially numeric; continue to parsing below.
31-
case cellReadonly, cellDate, cellWarranty, cellUrgency, cellNotes, cellStatus:
30+
case cellMoney, cellDrilldown:
31+
// Definitely numeric; continue to parsing below.
32+
default:
3233
return value
3334
}
3435

internal/app/mag_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,30 @@ func TestMagFormatSkipsReadonly(t *testing.T) {
7979
assert.Equal(t, "42", magFormat(c, false))
8080
}
8181

82-
func TestMagFormatSkipsNonNumeric(t *testing.T) {
82+
func TestMagFormatSkipsNonNumericKinds(t *testing.T) {
8383
tests := []struct {
8484
name string
8585
value string
8686
kind cellKind
8787
}{
88-
{"text", "Kitchen Remodel", cellText},
88+
{"text name", "Kitchen Remodel", cellText},
8989
{"status", "underway", cellStatus},
9090
{"date", "2026-02-12", cellDate},
9191
{"warranty date", "2027-06-15", cellWarranty},
9292
{"urgency date", "2026-03-01", cellUrgency},
9393
{"notes", "Some long note", cellNotes},
94-
{"empty", "", cellText},
95-
{"dash", "\u2014", cellMoney},
94+
{"empty text", "", cellText},
95+
{"dash money", "\u2014", cellMoney},
9696
{"readonly id", "7", cellReadonly},
97+
98+
// Numeric-looking cellText values that must NOT be transformed:
99+
// phone numbers, serial numbers, model numbers, zip codes.
100+
{"phone number", "5551234567", cellText},
101+
{"formatted phone", "(555) 123-4567", cellText},
102+
{"serial number", "123456789", cellText},
103+
{"model number", "12345", cellText},
104+
{"zip code", "90210", cellText},
105+
{"interval", "3m", cellText},
97106
}
98107
for _, tt := range tests {
99108
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)