Skip to content

Commit 6aa76a8

Browse files
committed
Remove useless comments
Signed-off-by: Djordje Lukic <[email protected]>
1 parent c2110a7 commit 6aa76a8

File tree

14 files changed

+1
-71
lines changed

14 files changed

+1
-71
lines changed

pkg/tui/components/tool/defaulttool/defaulttool.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,20 @@ func New(
4040
}
4141
}
4242

43-
// SetSize implements layout.Model.
4443
func (c *Component) SetSize(width, height int) tea.Cmd {
4544
c.width = width
4645
c.height = height
4746
return nil
4847
}
4948

50-
// Init implements layout.Model.
5149
func (c *Component) Init() tea.Cmd {
5250
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
5351
return c.spinner.Tick
5452
}
5553
return nil
5654
}
5755

58-
// Update implements layout.Model.
5956
func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
60-
// Handle spinner updates
6157
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
6258
var cmd tea.Cmd
6359
c.spinner, cmd = c.spinner.Update(msg)
@@ -67,7 +63,6 @@ func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
6763
return c, nil
6864
}
6965

70-
// View implements layout.Model.
7166
func (c *Component) View() string {
7267
msg := c.message
7368
displayName := msg.ToolDefinition.DisplayName()

pkg/tui/components/tool/defaulttool/render.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/docker/cagent/pkg/tui/styles"
1010
)
1111

12-
// renderToolArgs renders tool arguments
1312
func renderToolArgs(toolCall tools.ToolCall, width int) string {
1413
decoder := json.NewDecoder(strings.NewReader(toolCall.Function.Arguments))
1514

pkg/tui/components/tool/editfile/editfile.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,20 @@ func New(
4343
}
4444
}
4545

46-
// SetSize implements [layout.Model].
4746
func (c *Component) SetSize(width, height int) tea.Cmd {
4847
c.width = width
4948
c.height = height
5049
return nil
5150
}
5251

53-
// Init implements [layout.Model].
5452
func (c *Component) Init() tea.Cmd {
5553
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
5654
return c.spinner.Tick
5755
}
5856
return nil
5957
}
6058

61-
// Update implements [layout.Model].
6259
func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
63-
// Handle spinner updates
6460
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
6561
var cmd tea.Cmd
6662
c.spinner, cmd = c.spinner.Update(msg)
@@ -70,7 +66,6 @@ func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
7066
return c, nil
7167
}
7268

73-
// View implements [layout.Model].
7469
func (c *Component) View() string {
7570
msg := c.message
7671
var args builtin.EditFileArgs

pkg/tui/components/tool/editfile/render.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type linePair struct {
3737
newLineNum int
3838
}
3939

40-
// renderEditFile renders edit_file tool arguments
4140
func renderEditFile(toolCall tools.ToolCall, width int, splitView bool, toolStatus types.ToolStatus) string {
4241
var args builtin.EditFileArgs
4342
if err := json.Unmarshal([]byte(toolCall.Function.Arguments), &args); err != nil {
@@ -65,9 +64,6 @@ func renderEditFile(toolCall tools.ToolCall, width int, splitView bool, toolStat
6564
return output.String()
6665
}
6766

68-
// computeDiff computes a diff between old and new text
69-
// For confirmation status: reads current file (old) and applies edit to get new content
70-
// For result status: reads current file (new) and reconstructs old content by reversing the edit
7167
func computeDiff(path, oldText, newText string, toolStatus types.ToolStatus) []*udiff.Hunk {
7268
currentContent, err := os.ReadFile(path)
7369
if err != nil {
@@ -130,7 +126,6 @@ func normalizeDiff(diff []*udiff.Hunk) []*udiff.Hunk {
130126
return diff
131127
}
132128

133-
// syntaxHighlight applies syntax highlighting to code and returns styled text
134129
func syntaxHighlight(code, filePath string) []chromaToken {
135130
lexer := lexers.Match(filePath)
136131
if lexer == nil {
@@ -178,7 +173,6 @@ func chromaToLipgloss(tokenType chroma.TokenType, style *chroma.Style) lipgloss.
178173
return lipStyle
179174
}
180175

181-
// renderDiffWithSyntaxHighlight renders a unified diff view
182176
func renderDiffWithSyntaxHighlight(diff []*udiff.Hunk, filePath string, width int) string {
183177
var output strings.Builder
184178
contentWidth := width - lineNumWidth
@@ -201,7 +195,6 @@ func renderDiffWithSyntaxHighlight(diff []*udiff.Hunk, filePath string, width in
201195
return strings.TrimSuffix(output.String(), "\n")
202196
}
203197

204-
// renderSplitDiffWithSyntaxHighlight renders a split diff view with old/new side-by-side
205198
func renderSplitDiffWithSyntaxHighlight(diff []*udiff.Hunk, filePath string, width int) string {
206199
// Fall back to unified diff if terminal is too narrow
207200
separator := styles.SeparatorStyle.Render(" │ ")
@@ -229,7 +222,6 @@ func renderSplitDiffWithSyntaxHighlight(diff []*udiff.Hunk, filePath string, wid
229222
return strings.TrimSuffix(output.String(), "\n")
230223
}
231224

232-
// getDisplayLineNumber returns the appropriate line number and updates counters
233225
func getDisplayLineNumber(line *udiff.Line, oldLineNum, newLineNum *int) int {
234226
switch line.Kind {
235227
case udiff.Delete:
@@ -249,7 +241,6 @@ func getDisplayLineNumber(line *udiff.Line, oldLineNum, newLineNum *int) int {
249241
return 0
250242
}
251243

252-
// prepareContent normalizes content for display
253244
func prepareContent(content string, maxWidth int) string {
254245
content = strings.ReplaceAll(content, "\t", strings.Repeat(" ", tabWidth))
255246
content = strings.TrimRight(content, "\n")
@@ -259,7 +250,6 @@ func prepareContent(content string, maxWidth int) string {
259250
return content
260251
}
261252

262-
// renderLine renders a line with syntax highlighting and appropriate styling
263253
func renderLine(content string, kind udiff.OpKind, filePath string, width int) string {
264254
tokens := syntaxHighlight(content, filePath)
265255
lineStyle := getLineStyle(kind)
@@ -269,7 +259,6 @@ func renderLine(content string, kind udiff.OpKind, filePath string, width int) s
269259
return padToWidth(rendered, width, lineStyle)
270260
}
271261

272-
// renderSplitSide renders one side of a split diff
273262
func renderSplitSide(line *udiff.Line, lineNum int, filePath string, width int) string {
274263
lineNumStr := formatLineNum(line, lineNum)
275264

@@ -284,7 +273,6 @@ func renderSplitSide(line *udiff.Line, lineNum int, filePath string, width int)
284273
return styles.LineNumberStyle.Render(lineNumStr) + styledContent
285274
}
286275

287-
// renderTokensWithStyle applies consistent styling to tokens
288276
func renderTokensWithStyle(tokens []chromaToken, lineStyle lipgloss.Style) string {
289277
var output strings.Builder
290278

@@ -296,7 +284,6 @@ func renderTokensWithStyle(tokens []chromaToken, lineStyle lipgloss.Style) strin
296284
return output.String()
297285
}
298286

299-
// padToWidth adds padding to reach the desired width
300287
func padToWidth(content string, width int, style lipgloss.Style) string {
301288
currentWidth := ansi.StringWidth(content)
302289
if paddingNeeded := width - currentWidth; paddingNeeded > 0 {
@@ -306,7 +293,6 @@ func padToWidth(content string, width int, style lipgloss.Style) string {
306293
return content
307294
}
308295

309-
// ensureWidth ensures a line has consistent width
310296
func ensureWidth(line string, width int) string {
311297
if lineWidth := ansi.StringWidth(line); lineWidth < width {
312298
padding := styles.DiffUnchangedStyle.Render(strings.Repeat(" ", width-lineWidth))
@@ -315,7 +301,6 @@ func ensureWidth(line string, width int) string {
315301
return line
316302
}
317303

318-
// getLineStyle returns the style for a diff line type
319304
func getLineStyle(kind udiff.OpKind) lipgloss.Style {
320305
switch kind {
321306
case udiff.Delete:
@@ -327,15 +312,13 @@ func getLineStyle(kind udiff.OpKind) lipgloss.Style {
327312
}
328313
}
329314

330-
// formatLineNum formats a line number or returns empty space
331315
func formatLineNum(line *udiff.Line, lineNum int) string {
332316
if line == nil {
333317
return strings.Repeat(" ", lineNumWidth)
334318
}
335319
return fmt.Sprintf("%4d ", lineNum)
336320
}
337321

338-
// pairDiffLines pairs old and new lines for split view rendering
339322
func pairDiffLines(lines []udiff.Line, fromLine, toLine int) []linePair {
340323
var pairs []linePair
341324
oldLineNum, newLineNum := fromLine, toLine

pkg/tui/components/tool/factory.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ type Factory struct {
2222
registry *Registry
2323
}
2424

25-
// NewFactory creates a new component factory with the given registry.
2625
func NewFactory(registry *Registry) *Factory {
2726
return &Factory{
2827
registry: registry,
2928
}
3029
}
3130

32-
// Create creates a tool component for the given message.
3331
func (f *Factory) Create(
3432
msg *types.Message,
3533
renderer *glamour.TermRenderer,

pkg/tui/components/tool/readfile/readfile.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,20 @@ func New(
4040
}
4141
}
4242

43-
// SetSize implements layout.Model.
4443
func (c *Component) SetSize(width, height int) tea.Cmd {
4544
c.width = width
4645
c.height = height
4746
return nil
4847
}
4948

50-
// Init implements layout.Model.
5149
func (c *Component) Init() tea.Cmd {
5250
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
5351
return c.spinner.Tick
5452
}
5553
return nil
5654
}
5755

58-
// Update implements layout.Model.
5956
func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
60-
// Handle spinner updates
6157
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
6258
var cmd tea.Cmd
6359
c.spinner, cmd = c.spinner.Update(msg)
@@ -67,7 +63,6 @@ func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
6763
return c, nil
6864
}
6965

70-
// View implements layout.Model.
7166
func (c *Component) View() string {
7267
msg := c.message
7368
var args builtin.ReadFileArgs

pkg/tui/components/tool/registry.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,18 @@ type Registry struct {
2323
builders map[string]ComponentBuilder
2424
}
2525

26-
// NewRegistry creates a new component registry.
2726
func NewRegistry() *Registry {
2827
return &Registry{
2928
builders: make(map[string]ComponentBuilder),
3029
}
3130
}
3231

33-
// Register adds a component builder for a tool name.
34-
// If a builder already exists for this tool name, it will be replaced.
3532
func (r *Registry) Register(toolName string, builder ComponentBuilder) {
3633
r.mu.Lock()
3734
defer r.mu.Unlock()
3835
r.builders[toolName] = builder
3936
}
4037

41-
// Get retrieves a component builder for a tool name.
42-
// Returns the builder and true if found, nil and false otherwise.
4338
func (r *Registry) Get(toolName string) (ComponentBuilder, bool) {
4439
r.mu.RLock()
4540
defer r.mu.RUnlock()

pkg/tui/components/tool/todotool/component.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,19 @@ func New(
4242
}
4343
}
4444

45-
// SetSize implements [layout.Model].
4645
func (c *Component) SetSize(width, height int) tea.Cmd {
4746
c.width = width
4847
c.height = height
4948
return nil
5049
}
5150

52-
// Init implements [layout.Model].
5351
func (c *Component) Init() tea.Cmd {
5452
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
5553
return c.spinner.Tick
5654
}
5755
return nil
5856
}
5957

60-
// Update implements [layout.Model].
6158
func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
6259
if c.message.ToolStatus == types.ToolStatusPending || c.message.ToolStatus == types.ToolStatusRunning {
6360
var cmd tea.Cmd
@@ -68,7 +65,6 @@ func (c *Component) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
6865
return c, nil
6966
}
7067

71-
// View implements [layout.Model].
7268
func (c *Component) View() string {
7369
msg := c.message
7470
toolName := msg.ToolCall.Function.Name
@@ -88,7 +84,6 @@ func (c *Component) View() string {
8884
}
8985
}
9086

91-
// renderCreate renders the create_todo operation
9287
func (c *Component) renderCreate() string {
9388
msg := c.message
9489
displayName := msg.ToolDefinition.DisplayName()
@@ -117,7 +112,6 @@ func (c *Component) renderCreate() string {
117112
return styles.BaseStyle.PaddingLeft(2).PaddingTop(1).Render(content + resultContent)
118113
}
119114

120-
// renderCreateMultiple renders the create_todos operation
121115
func (c *Component) renderCreateMultiple() string {
122116
msg := c.message
123117
displayName := msg.ToolDefinition.DisplayName()
@@ -148,7 +142,6 @@ func (c *Component) renderCreateMultiple() string {
148142
return styles.BaseStyle.PaddingLeft(2).PaddingTop(1).Render(content + resultContent)
149143
}
150144

151-
// renderList renders the list_todos operation
152145
func (c *Component) renderList() string {
153146
msg := c.message
154147
displayName := msg.ToolDefinition.DisplayName()
@@ -186,7 +179,6 @@ func (c *Component) renderList() string {
186179
return styles.BaseStyle.PaddingLeft(2).PaddingTop(1).Render(content)
187180
}
188181

189-
// renderUpdate renders the update_todo operation
190182
func (c *Component) renderUpdate() string {
191183
msg := c.message
192184
displayName := msg.ToolDefinition.DisplayName()
@@ -218,7 +210,6 @@ func (c *Component) renderUpdate() string {
218210
return styles.BaseStyle.PaddingLeft(2).PaddingTop(1).Render(content + resultContent)
219211
}
220212

221-
// renderDefault provides a fallback rendering for unknown tool types
222213
func (c *Component) renderDefault() string {
223214
msg := c.message
224215
displayName := msg.ToolDefinition.DisplayName()

pkg/tui/components/tool/todotool/sidebar.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ func NewSidebarComponent(manager *service.TodoManager) *SidebarComponent {
2525
}
2626
}
2727

28-
// SetSize sets the component width
2928
func (c *SidebarComponent) SetSize(width int) {
3029
c.width = width
3130
}
3231

33-
// SetTodos sets the todo from a tool call, handles create_todo, create_todos, update_todo
3432
func (c *SidebarComponent) SetTodos(toolCall tools.ToolCall) error {
3533
params, err := parseTodoArgs(toolCall)
3634
if err != nil {

pkg/tui/components/tool/todotool/todotool.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/docker/cagent/pkg/tui/styles"
77
)
88

9-
// renderTodoIcon returns the icon and style for a todo status
109
func renderTodoIcon(status string) (string, lipgloss.Style) {
1110
switch status {
1211
case "pending":

0 commit comments

Comments
 (0)