File tree Expand file tree Collapse file tree 3 files changed +5
-15
lines changed
pkg/tui/components/tool/webtool Expand file tree Collapse file tree 3 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ require (
1818 github.com/charmbracelet/glamour/v2 v2.0.0-20251106195642-800eb8175930
1919 github.com/charmbracelet/x/ansi v0.11.2
2020 github.com/coder/acp-go-sdk v0.6.3
21+ github.com/docker/go-units v0.5.0
2122 github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9
2223 github.com/fatih/color v1.18.0
2324 github.com/fsnotify/fsnotify v1.9.0
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBi
9999github.com/docker/distribution v2.8.3+incompatible /go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w =
100100github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8 =
101101github.com/docker/docker-credential-helpers v0.9.3 /go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo =
102+ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 =
103+ github.com/docker/go-units v0.5.0 /go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk =
102104github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9 h1:3uSSOd6mVlwcX3k5OYOpiDqFgRmaE2dBfLvVIFWWHrw =
103105github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9 /go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4 =
104106github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY =
Original file line number Diff line number Diff line change 55 "fmt"
66
77 tea "charm.land/bubbletea/v2"
8+ "github.com/docker/go-units"
89
910 "github.com/docker/cagent/pkg/tui/components/spinner"
1011 "github.com/docker/cagent/pkg/tui/components/toolcommon"
@@ -152,19 +153,5 @@ func formatArgs(args map[string]any) string {
152153
153154// extractSummary tries to extract a meaningful summary from the API response
154155func extractSummary (content string ) string {
155- size := len (content )
156-
157- // Convert to KB if >= 1024 bytes
158- if size >= 1024 * 1024 {
159- // Show in MB
160- mb := float64 (size ) / (1024 * 1024 )
161- return fmt .Sprintf ("Received %.1f MB" , mb )
162- } else if size >= 1024 {
163- // Show in KB
164- kb := float64 (size ) / 1024
165- return fmt .Sprintf ("Received %.1f KB" , kb )
166- }
167-
168- // Show in bytes for small responses
169- return fmt .Sprintf ("Received %d bytes" , size )
156+ return fmt .Sprintf ("Received %s" , units .HumanSize (float64 (len (content ))))
170157}
You can’t perform that action at this time.
0 commit comments