Reduce Telegram tool message noise
This commit is contained in:
@@ -101,6 +101,37 @@ func TestRenderCodexStartedItems(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolMessageAddsEditedAtBeforeDetails(t *testing.T) {
|
||||
tool := toolMessageState{
|
||||
toolHTML: SummaryDetailsHTML("Tool call: command finished\nCommand: go test ./...", "full output"),
|
||||
editedAt: "2026-05-21 12:34:56 UTC",
|
||||
}
|
||||
text := tool.html()
|
||||
want := "Command: go test ./...\nEdited at: 2026-05-21 12:34:56 UTC\n<blockquote expandable>"
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("edited timestamp not placed before details: %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolMessageFitsCombinedApprovalDetails(t *testing.T) {
|
||||
largeToolDetails := strings.Repeat("tool output line\n", 600)
|
||||
largeApprovalDetails := strings.Repeat("approval payload line\n", 600)
|
||||
tool := toolMessageState{
|
||||
toolHTML: SummaryDetailsHTML("Tool call: command finished", largeToolDetails),
|
||||
approvalHTML: SummaryDetailsHTML("Codex requests command approval", largeApprovalDetails),
|
||||
editedAt: "2026-05-21 12:34:56 UTC",
|
||||
}
|
||||
text := tool.html()
|
||||
if len([]rune(text)) > TelegramHTMLMessageLimit {
|
||||
t.Fatalf("tool message exceeds Telegram limit: %d", len([]rune(text)))
|
||||
}
|
||||
for _, want := range []string{"Tool call: command finished", "Codex requests command approval", "Edited at: 2026-05-21 12:34:56 UTC", "...[truncated]"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("fitted tool message missing %q in %q", want, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResumeCallbackData(t *testing.T) {
|
||||
threadID, ok := ParseResumeThreadCallbackData(ResumeThreadCallbackData(123))
|
||||
if !ok || threadID != 123 {
|
||||
|
||||
Reference in New Issue
Block a user