Allow assistant photo directives

This commit is contained in:
Codex
2026-05-21 12:28:57 +00:00
parent e9425c6d9b
commit 1a74c02173
6 changed files with 272 additions and 5 deletions
+25
View File
@@ -77,6 +77,31 @@ func TestParseCommand(t *testing.T) {
}
}
func TestSplitAssistantMessageSegmentsWithPhotoDirective(t *testing.T) {
text := "before\n<!-- telegram-photo {\"path\":\"/tmp/photo.jpg\",\"caption\":\"hello\"} -->\nafter"
segments := splitAssistantMessageSegments(text)
if len(segments) != 3 {
t.Fatalf("segments = %d, want 3: %#v", len(segments), segments)
}
if segments[0].Text != "before\n" || segments[0].Photo != nil {
t.Fatalf("unexpected first segment: %#v", segments[0])
}
if segments[1].Photo == nil || segments[1].Photo.Path != "/tmp/photo.jpg" || segments[1].Photo.Caption != "hello" {
t.Fatalf("unexpected photo segment: %#v", segments[1])
}
if segments[2].Text != "after" || segments[2].Photo != nil {
t.Fatalf("unexpected final segment: %#v", segments[2])
}
}
func TestInvalidPhotoDirectiveStaysVisible(t *testing.T) {
text := "<!-- telegram-photo not-json -->"
segments := splitAssistantMessageSegments(text)
if len(segments) != 1 || segments[0].Text != text {
t.Fatalf("invalid directive should stay text: %#v", segments)
}
}
func TestRenderCodexCommandExecutionItem(t *testing.T) {
output := "line 1\nline 2"
exitCode := 0