fix phantom tool call failed messages and empty text parts with some models
This commit is contained in:
@@ -882,7 +882,7 @@ export namespace Session {
|
|||||||
|
|
||||||
case "tool-input-start":
|
case "tool-input-start":
|
||||||
const part = await updatePart({
|
const part = await updatePart({
|
||||||
id: Identifier.ascending("part"),
|
id: toolCalls[value.id]?.id ?? Identifier.ascending("part"),
|
||||||
messageID: assistantMsg.id,
|
messageID: assistantMsg.id,
|
||||||
sessionID: assistantMsg.sessionID,
|
sessionID: assistantMsg.sessionID,
|
||||||
type: "tool",
|
type: "tool",
|
||||||
@@ -1029,17 +1029,17 @@ export namespace Session {
|
|||||||
case "text":
|
case "text":
|
||||||
if (currentText) {
|
if (currentText) {
|
||||||
currentText.text += value.text
|
currentText.text += value.text
|
||||||
await updatePart(currentText)
|
if (currentText.text) await updatePart(currentText)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
case "text-end":
|
case "text-end":
|
||||||
if (currentText && currentText.text) {
|
if (currentText) {
|
||||||
|
currentText.text = currentText.text.trimEnd()
|
||||||
currentText.time = {
|
currentText.time = {
|
||||||
start: Date.now(),
|
start: Date.now(),
|
||||||
end: Date.now(),
|
end: Date.now(),
|
||||||
}
|
}
|
||||||
currentText.text = currentText.text.trimEnd()
|
|
||||||
await updatePart(currentText)
|
await updatePart(currentText)
|
||||||
}
|
}
|
||||||
currentText = undefined
|
currentText = undefined
|
||||||
|
|||||||
@@ -281,6 +281,9 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
|||||||
if part.Synthetic {
|
if part.Synthetic {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if part.Text == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
remainingParts := message.Parts[partIndex+1:]
|
remainingParts := message.Parts[partIndex+1:]
|
||||||
fileParts := make([]opencode.FilePart, 0)
|
fileParts := make([]opencode.FilePart, 0)
|
||||||
for _, part := range remainingParts {
|
for _, part := range remainingParts {
|
||||||
@@ -365,6 +368,9 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
|||||||
if reverted {
|
if reverted {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if part.Text == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
hasTextPart = true
|
hasTextPart = true
|
||||||
finished := part.Time.End > 0
|
finished := part.Time.End > 0
|
||||||
remainingParts := message.Parts[partIndex+1:]
|
remainingParts := message.Parts[partIndex+1:]
|
||||||
|
|||||||
Reference in New Issue
Block a user