Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(daemon): print a size that rounds to 1024 KB in MB (#10431)

kevind6e5921f8d04
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index d26a4abb78..faaf810287 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -7362,7 +7362,8 @@ func formatBytes(n int64) string {
return "unknown size"
case n < 1024:
return fmt.Sprintf("%d B", n)
- case n < 1024*1024:
+ case n < 1024*1024-512:
+ // Sizes from 1023.5 KB up round to "1024 KB", so they print in MB.
return fmt.Sprintf("%.0f KB", float64(n)/1024)
default:
return fmt.Sprintf("%.2f MB", float64(n)/(1024*1024))
diff --git a/server/internal/daemon/skill_bundle_resolve_test.go b/server/internal/daemon/skill_bundle_resolve_test.go
index 784e0f0aa8..9e2b1604ec 100644
--- a/server/internal/daemon/skill_bundle_resolve_test.go
+++ b/server/internal/daemon/skill_bundle_resolve_test.go
@@ -390,6 +390,9 @@ func TestFormatBytes(t *testing.T) {
{1024, "1 KB"},
{552960, "540 KB"},
{1101426, "1.05 MB"},
+ {1048063, "1023 KB"},
+ {1048064, "1.00 MB"},
+ {1048575, "1.00 MB"},
}
for _, tc := range cases {
if got := formatBytes(tc.n); got != tc.want {