Skip to content

Commit 2e237f2

Browse files
authored
Merge pull request #886 from dgageot/simpler-code-3
Simpler code
2 parents 16517e8 + c20d164 commit 2e237f2

8 files changed

Lines changed: 32 additions & 53 deletions

File tree

pkg/acp/agent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,17 @@ func (a *Agent) handleToolCallConfirmation(ctx context.Context, acpSess *Session
278278
{
279279
Kind: acp.PermissionOptionKindAllowOnce,
280280
Name: "Allow this action",
281-
OptionId: acp.PermissionOptionId("allow"),
281+
OptionId: "allow",
282282
},
283283
{
284284
Kind: acp.PermissionOptionKindAllowAlways,
285285
Name: "Allow and remember my choice",
286-
OptionId: acp.PermissionOptionId("allow-always"),
286+
OptionId: "allow-always",
287287
},
288288
{
289289
Kind: acp.PermissionOptionKindRejectOnce,
290290
Name: "Skip this action",
291-
OptionId: acp.PermissionOptionId("reject"),
291+
OptionId: "reject",
292292
},
293293
},
294294
})

pkg/config/auto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var DefaultModels = map[string]string{
1616
}
1717

1818
func AvailableProviders(ctx context.Context, modelsGateway string, env environment.Provider) []string {
19-
providers := []string{}
19+
var providers []string
2020

2121
if modelsGateway == "" {
2222
switch {

pkg/rag/strategy/bm25.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/fsnotify/fsnotify"
1515

1616
v2 "github.com/docker/cagent/pkg/config/v2"
17-
chunk "github.com/docker/cagent/pkg/rag/chunk"
17+
"github.com/docker/cagent/pkg/rag/chunk"
1818
"github.com/docker/cagent/pkg/rag/database"
1919
)
2020

pkg/telemetry/telemetry_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -730,17 +730,6 @@ func TestHTTPRequestVerification(t *testing.T) {
730730
})
731731
}
732732

733-
// SlowMockHTTPClient creates artificial backpressure by adding delays
734-
type SlowMockHTTPClient struct {
735-
*MockHTTPClient
736-
delay time.Duration
737-
}
738-
739-
func (s *SlowMockHTTPClient) RoundTrip(req *http.Request) (*http.Response, error) {
740-
time.Sleep(s.delay) // Add artificial delay
741-
return s.MockHTTPClient.RoundTrip(req)
742-
}
743-
744733
// TestNon2xxHTTPResponseHandling ensures that 5xx responses are logged and handled gracefully
745734
func TestNon2xxHTTPResponseHandling(t *testing.T) {
746735
logger := slog.New(slog.NewTextHandler(os.Stderr, nil))

pkg/tools/builtin/api.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ import (
1515
"github.com/docker/cagent/pkg/tools"
1616
)
1717

18-
const (
19-
ToolNameAPI = "api"
20-
)
21-
2218
type APITool struct {
2319
tools.ElicitationTool
2420
handler *apiHandler

pkg/tui/components/spinner/spinner.go

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,38 +85,40 @@ func (s Spinner) Init() tea.Cmd {
8585
return s.Tick()
8686
}
8787

88-
func (s Spinner) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
89-
if msg, ok := msg.(tickMsg); ok {
90-
if msg.ID > 0 && msg.ID != s.id {
91-
return s, nil
92-
}
93-
if msg.tag > 0 && msg.tag != s.tag {
94-
return s, nil
95-
}
96-
s.tag++
88+
func (s Spinner) Update(message tea.Msg) (layout.Model, tea.Cmd) {
89+
msg, ok := message.(tickMsg)
90+
if !ok {
91+
return s, nil
92+
}
9793

98-
s.frame++
94+
if msg.ID > 0 && msg.ID != s.id {
95+
return s, nil
96+
}
97+
if msg.tag > 0 && msg.tag != s.tag {
98+
return s, nil
99+
}
99100

100-
if s.pauseFrames > 0 {
101-
s.pauseFrames--
102-
if s.pauseFrames == 0 {
103-
s.direction = -1
104-
}
105-
} else {
106-
s.lightPosition += s.direction
101+
s.tag++
102+
s.frame++
107103

108-
if s.direction == 1 && s.lightPosition > len(s.currentMessage)+2 {
109-
s.pauseFrames = 6
110-
}
104+
if s.pauseFrames > 0 {
105+
s.pauseFrames--
106+
if s.pauseFrames == 0 {
107+
s.direction = -1
108+
}
109+
} else {
110+
s.lightPosition += s.direction
111111

112-
if s.direction == -1 && s.lightPosition < -3 {
113-
s.direction = 1
114-
}
112+
if s.direction == 1 && s.lightPosition > len(s.currentMessage)+2 {
113+
s.pauseFrames = 6
115114
}
116115

117-
return s, s.Tick()
116+
if s.direction == -1 && s.lightPosition < -3 {
117+
s.direction = 1
118+
}
118119
}
119-
return s, nil
120+
121+
return s, s.Tick()
120122
}
121123

122124
func (s Spinner) View() string {

pkg/tui/components/statusbar/statusbar.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ func (s *StatusBar) formatHelpString(bindings []key.Binding) string {
4040
}
4141
}
4242

43-
if len(helpParts) == 0 {
44-
return ""
45-
}
46-
4743
// Join with proper spacing between key bindings
4844
return strings.Join(helpParts, " ")
4945
}

pkg/tui/styles/styles.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ const (
5050
ColorLineNumber = "#565F89" // Muted blue-grey (same as ColorMutedBlue)
5151
ColorSeparator = "#414868" // Dark blue-grey (same as ColorBorderSecondary)
5252

53-
// Word-level diff highlight colors (visible but not harsh)
54-
ColorDiffWordAddBg = "#2D4F3F" // Medium dark teal with green tint
55-
ColorDiffWordRemoveBg = "#4F2D3A" // Medium dark burgundy with red tint
56-
5753
// Interactive element colors
5854
ColorSelected = "#364A82" // Dark blue for selected items
5955
ColorHover = "#2D3F5F" // Slightly lighter than selected

0 commit comments

Comments
 (0)