feat(tools): stream shell_run output live into the TUI
This commit is contained in:
+15
-3
@@ -683,15 +683,27 @@ func (m *model) mergeToolLog(text string) bool {
|
||||
if incoming.output == "" {
|
||||
return false
|
||||
}
|
||||
incomingHeader, _, ok := strings.Cut(text, "\n[output]\n")
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
for i := len(m.messages) - 1; i >= 0; i-- {
|
||||
if m.messages[i].role != roleTool {
|
||||
continue
|
||||
}
|
||||
existing := parseToolLog(m.messages[i].content)
|
||||
if existing.name == incoming.name && existing.args == incoming.args && existing.output == "" {
|
||||
m.messages[i].content = text
|
||||
return true
|
||||
if existing.name != incoming.name || existing.args != incoming.args {
|
||||
continue
|
||||
}
|
||||
if !strings.Contains(m.messages[i].content, "\n[output]\n") {
|
||||
// Placeholder card from the tool-start log; first chunk fills it.
|
||||
m.messages[i].content = text
|
||||
} else {
|
||||
// Streaming tools send incremental chunks; append the raw delta
|
||||
// so line boundaries are preserved inside the same card.
|
||||
m.messages[i].content += strings.TrimPrefix(text, incomingHeader+"\n[output]\n")
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user