Skip to content
Merged
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/charmbracelet/glamour/v2 v2.0.0-20251106195642-800eb8175930
github.com/charmbracelet/x/ansi v0.11.2
github.com/coder/acp-go-sdk v0.6.3
github.com/docker/go-units v0.5.0
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9
github.com/fatih/color v1.18.0
github.com/fsnotify/fsnotify v1.9.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBi
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9 h1:3uSSOd6mVlwcX3k5OYOpiDqFgRmaE2dBfLvVIFWWHrw=
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
Expand Down
17 changes: 2 additions & 15 deletions pkg/tui/components/tool/webtool/webtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

tea "charm.land/bubbletea/v2"
"github.com/docker/go-units"

"github.com/docker/cagent/pkg/tui/components/spinner"
"github.com/docker/cagent/pkg/tui/components/toolcommon"
Expand Down Expand Up @@ -152,19 +153,5 @@ func formatArgs(args map[string]any) string {

// extractSummary tries to extract a meaningful summary from the API response
func extractSummary(content string) string {
size := len(content)

// Convert to KB if >= 1024 bytes
if size >= 1024*1024 {
// Show in MB
mb := float64(size) / (1024 * 1024)
return fmt.Sprintf("Received %.1f MB", mb)
} else if size >= 1024 {
// Show in KB
kb := float64(size) / 1024
return fmt.Sprintf("Received %.1f KB", kb)
}

// Show in bytes for small responses
return fmt.Sprintf("Received %d bytes", size)
return fmt.Sprintf("Received %s", units.HumanSize(float64(len(content))))
}