Use Telegram drafts for assistant streaming
This commit is contained in:
@@ -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, "<") {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user