Skip to content

Commit 3668ea4

Browse files
committed
Show the tool arguments as they come in
Fixes #50 Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent 3f3b56e commit 3668ea4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

internal/tui/components/tool/tool.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
"github.com/charmbracelet/bubbles/v2/spinner"
8+
"github.com/charmbracelet/bubbles/v2/viewport"
89
tea "github.com/charmbracelet/bubbletea/v2"
910
"github.com/charmbracelet/glamour/v2"
1011

@@ -158,6 +159,14 @@ func (mv *toolModel) Render(width int) string {
158159

159160
content := fmt.Sprintf("│ %s %s%s", icon, styles.HighlightStyle.Render(msg.ToolName), spinnerText)
160161

162+
if msg.Arguments != "" {
163+
lines := wrapLines(msg.Arguments, mv.width-2)
164+
argsViewport := viewport.New(viewport.WithWidth(mv.width), viewport.WithHeight(len(lines)))
165+
argsViewport.SetContent(styles.MutedStyle.Render(strings.Join(lines, "\n")))
166+
argsViewport.GotoBottom()
167+
content += "\n" + argsViewport.View()
168+
}
169+
161170
// Add tool result content if available (for completed tools with content)
162171
var resultContent string
163172
if (msg.ToolStatus == types.ToolStatusCompleted || msg.ToolStatus == types.ToolStatusError) && msg.Content != "" {

pkg/runtime/runtime.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ func (r *Runtime) handleStream(stream chat.MessageStream, a *agent.Agent, sess *
373373
} else {
374374
toolCalls[idx].Function.Arguments += deltaToolCall.Function.Arguments
375375
}
376+
shouldEmitPartial = true
376377
}
377378

378379
// Emit PartialToolCallEvent when we first get the function name

0 commit comments

Comments
 (0)