Forward recorded Codex turn timestamps to chat history
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package codex
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHistoryCarriesRecordedTurnTimes(t *testing.T) {
|
||||
c := modelTestChat(t, func(method string, _ json.RawMessage) any {
|
||||
if method != "thread/turns/list" {
|
||||
t.Fatalf("unexpected method %s", method)
|
||||
}
|
||||
return json.RawMessage(`{"data":[{"id":"new","startedAt":1793916000,"status":"inProgress","items":[{"id":"u","clientId":"client-u","type":"userMessage","content":[{"type":"text","text":"question"}]},{"id":"a","type":"agentMessage","text":"reply"}]},{"id":"old","items":[{"id":"legacy","type":"agentMessage","text":"old reply"}]}],"nextCursor":null}`)
|
||||
})
|
||||
for range 2 {
|
||||
page, err := c.Messages(context.Background(), fixtureThread, 50, "")
|
||||
if err != nil || len(page.Messages) != 3 {
|
||||
t.Fatalf("page=%+v err=%v", page, err)
|
||||
}
|
||||
if page.Messages[0].CreatedAt != 0 {
|
||||
t.Fatal("invented legacy timestamp")
|
||||
}
|
||||
for _, msg := range page.Messages[1:] {
|
||||
if msg.CreatedAt != 1793916000000 {
|
||||
t.Fatalf("missing recorded time: %+v", msg)
|
||||
}
|
||||
}
|
||||
if page.Messages[1].ID != "client-u" {
|
||||
t.Fatal("lost user identity")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidCodexTurnTimesStayUnknown(t *testing.T) {
|
||||
for _, stamp := range []int64{0, -1, 8640000000001, 9223372036854775807} {
|
||||
if (turn{StartedAt: stamp}).createdAtMillis() != 0 {
|
||||
t.Fatalf("accepted %d", stamp)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user