Use Telegram drafts for assistant streaming

This commit is contained in:
Codex
2026-06-04 08:59:18 +00:00
parent 372d5831fa
commit 739b6cd870
2 changed files with 176 additions and 21 deletions

View File

@@ -260,6 +260,29 @@ func TestInvalidPhotoDirectiveStaysVisible(t *testing.T) {
}
}
func TestAssistantStreamPreviewHidesDirectives(t *testing.T) {
text := "before\n<!-- telegram-photo {\"path\":\"/workspace/photo.jpg\"} -->\nafter\n<!-- codex-thread-rename "
got := assistantStreamPreview(text)
want := "before\nafter\n"
if got != want {
t.Fatalf("assistantStreamPreview() = %q, want %q", got, want)
}
}
func TestAssistantStreamTextFitsLimit(t *testing.T) {
text := strings.Repeat("<>&", TelegramMessageLimit)
got := assistantStreamText(text)
if got == "" {
t.Fatal("assistantStreamText returned empty text")
}
if len([]rune(got)) > TelegramMessageLimit {
t.Fatalf("stream text length = %d, want <= %d", len([]rune(got)), TelegramMessageLimit)
}
if strings.Contains(got, "&lt;") {
t.Fatalf("draft stream should use plain text, got %q", got[:20])
}
}
func TestSplitAssistantMessageSegmentsWithThreadDirectives(t *testing.T) {
cwd := filepath.Join(string(filepath.Separator), "workspace", "project")
text := fmt.Sprintf("<!-- codex-thread-rename {\"title\":\" A Better Thread Title \"} -->\n<!-- codex-thread-cwd {\"cwd\":%q} -->", cwd)