mirror of
https://github.com/sst/opencode.git
synced 2025-07-08 00:25:00 +00:00
fix(tui): include orphaned tool calls
This commit is contained in:
parent
0eadc50a33
commit
6b73ffd1c1
1 changed files with 17 additions and 2 deletions
|
@ -125,6 +125,8 @@ func (m *messagesComponent) renderView(width int) {
|
||||||
m.partCount = 0
|
m.partCount = 0
|
||||||
m.lineCount = 0
|
m.lineCount = 0
|
||||||
|
|
||||||
|
orphanedToolCalls := make([]opencode.ToolInvocationPart, 0)
|
||||||
|
|
||||||
for _, message := range m.app.Messages {
|
for _, message := range m.app.Messages {
|
||||||
var content string
|
var content string
|
||||||
var cached bool
|
var cached bool
|
||||||
|
@ -156,12 +158,22 @@ func (m *messagesComponent) renderView(width int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case opencode.MessageRoleAssistant:
|
case opencode.MessageRoleAssistant:
|
||||||
for i, p := range message.Parts {
|
hasTextPart := false
|
||||||
|
for partIndex, p := range message.Parts {
|
||||||
switch part := p.AsUnion().(type) {
|
switch part := p.AsUnion().(type) {
|
||||||
case opencode.TextPart:
|
case opencode.TextPart:
|
||||||
|
hasTextPart = true
|
||||||
finished := message.Metadata.Time.Completed > 0
|
finished := message.Metadata.Time.Completed > 0
|
||||||
remainingParts := message.Parts[i+1:]
|
remainingParts := message.Parts[partIndex+1:]
|
||||||
toolCallParts := make([]opencode.ToolInvocationPart, 0)
|
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 {
|
for _, part := range remainingParts {
|
||||||
switch part := part.AsUnion().(type) {
|
switch part := part.AsUnion().(type) {
|
||||||
case opencode.TextPart:
|
case opencode.TextPart:
|
||||||
|
@ -212,6 +224,9 @@ func (m *messagesComponent) renderView(width int) {
|
||||||
}
|
}
|
||||||
case opencode.ToolInvocationPart:
|
case opencode.ToolInvocationPart:
|
||||||
if !m.showToolDetails {
|
if !m.showToolDetails {
|
||||||
|
if !hasTextPart {
|
||||||
|
orphanedToolCalls = append(orphanedToolCalls, part)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue