summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/components
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-07-03 09:32:44 -0500
committeradamdottv <[email protected]>2025-07-03 09:32:44 -0500
commit6b73ffd1c1527dcc1b961318375f7eb638a3b4af (patch)
tree4e32c14cb11c2e739b1c2d14e7268b3d8a05b8fe /packages/tui/internal/components
parent0eadc50a3302d6916383f60203233aae754d27b0 (diff)
downloadopencode-6b73ffd1c1527dcc1b961318375f7eb638a3b4af.tar.gz
opencode-6b73ffd1c1527dcc1b961318375f7eb638a3b4af.zip
fix(tui): include orphaned tool calls
Diffstat (limited to 'packages/tui/internal/components')
-rw-r--r--packages/tui/internal/components/chat/messages.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go
index ac001cd7f..1b2389926 100644
--- a/packages/tui/internal/components/chat/messages.go
+++ b/packages/tui/internal/components/chat/messages.go
@@ -125,6 +125,8 @@ func (m *messagesComponent) renderView(width int) {
m.partCount = 0
m.lineCount = 0
+ orphanedToolCalls := make([]opencode.ToolInvocationPart, 0)
+
for _, message := range m.app.Messages {
var content string
var cached bool
@@ -156,12 +158,22 @@ func (m *messagesComponent) renderView(width int) {
}
case opencode.MessageRoleAssistant:
- for i, p := range message.Parts {
+ hasTextPart := false
+ for partIndex, p := range message.Parts {
switch part := p.AsUnion().(type) {
case opencode.TextPart:
+ hasTextPart = true
finished := message.Metadata.Time.Completed > 0
- remainingParts := message.Parts[i+1:]
+ remainingParts := message.Parts[partIndex+1:]
toolCallParts := make([]opencode.ToolInvocationPart, 0)
+
+ // sometimes tool calls happen without an assistant message
+ // these should be included in this assistant message as well
+ if len(orphanedToolCalls) > 0 {
+ toolCallParts = append(toolCallParts, orphanedToolCalls...)
+ orphanedToolCalls = make([]opencode.ToolInvocationPart, 0)
+ }
+
for _, part := range remainingParts {
switch part := part.AsUnion().(type) {
case opencode.TextPart:
@@ -212,6 +224,9 @@ func (m *messagesComponent) renderView(width int) {
}
case opencode.ToolInvocationPart:
if !m.showToolDetails {
+ if !hasTextPart {
+ orphanedToolCalls = append(orphanedToolCalls, part)
+ }
continue
}