Skip to content

Commit c2313e0

Browse files
committed
feat: update logic
1 parent fdfb178 commit c2313e0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/msgfmt/message_box.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func removeClaudeReportTaskToolCall(msg string) string {
106106
lines := strings.Split(msg, "\n")
107107

108108
toolCallStartIdx := -1
109+
newLineAfterToolCallIdx := -1
109110

110111
// Store all tool call start and end indices [[start, end], ...]
111112
var toolCallIdxs [][]int
@@ -121,7 +122,17 @@ func removeClaudeReportTaskToolCall(msg string) string {
121122

122123
// Reset to find the next tool call
123124
toolCallStartIdx = -1
125+
newLineAfterToolCallIdx = -1
124126
}
127+
if len(line) == 0 && toolCallStartIdx != -1 && newLineAfterToolCallIdx == -1 {
128+
newLineAfterToolCallIdx = i
129+
}
130+
}
131+
132+
// Handle the case where the last tool call goes till the end of the message
133+
// And a failsafe when the next message is not prefixed with ●
134+
if toolCallStartIdx != -1 && newLineAfterToolCallIdx != -1 {
135+
toolCallIdxs = append(toolCallIdxs, []int{toolCallStartIdx, newLineAfterToolCallIdx})
125136
}
126137

127138
// If no tool calls found, return original message

lib/msgfmt/testdata/format/claude/remove-task-tool-call/msg.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,19 @@
5454
How to play:
5555
Open the HTML file in your web browser and use the arrow keys
5656
to move the snake. Collect the red food to grow and increase
57-
your score!
57+
your score!
58+
59+
● coder - coder_report_task (MCP)(summary: "Snake game created
60+
successfully at snake-game.html",
61+
link: "file:///home/coder/snake-ga
62+
me.html", state: "working")
63+
⎿ {
64+
"message": "Thanks for reporting!"
65+
}
66+
67+
68+
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
69+
70+
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
71+
? for shortcuts ⧉ In message_box.go
72+

0 commit comments

Comments
 (0)