Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cyclops-cs): archive postgres conversations (#7171)

r33drichards1ebadd484352
diff --git a/libs/fleet/backend/chat/postgres_store.go b/libs/fleet/backend/chat/postgres_store.go
index e8a49bbc0d..94cdb5b4de 100644
--- a/libs/fleet/backend/chat/postgres_store.go
+++ b/libs/fleet/backend/chat/postgres_store.go
@@ -112,7 +112,7 @@ func (store *PostgresConversationStore) SetArchived(ctx context.Context, ownerID
now := store.now()
conversation, err := scanPostgresConversation(store.pool.QueryRow(ctx, `
UPDATE chat_conversations
- SET archived_at = CASE WHEN $3 THEN $4 ELSE NULL END, updated_at = $4
+ SET archived_at = CASE WHEN $3 THEN $4::timestamptz ELSE NULL::timestamptz END, updated_at = $4
WHERE id = $1 AND owner_sub = $2
RETURNING `+postgresConversationColumns, conversationID, ownerID, archived, now))
if errors.Is(err, pgx.ErrNoRows) {
diff --git a/libs/fleet/backend/database/migrator_pg_test.go b/libs/fleet/backend/database/migrator_pg_test.go
index cf013fcdfc..9444f7c995 100644
--- a/libs/fleet/backend/database/migrator_pg_test.go
+++ b/libs/fleet/backend/database/migrator_pg_test.go
@@ -164,6 +164,20 @@ func assertChatConversationStore(t *testing.T, ctx context.Context, applicationU
if len(loaded.Messages) != 2 || loaded.Messages[1].Content != "ready" {
t.Fatalf("first store did not observe second store append: %+v", loaded.Messages)
}
+ archived, err := second.SetArchived(ctx, "owner-1", conversation.ID, true)
+ if err != nil {
+ t.Fatalf("archive through second store: %v", err)
+ }
+ if archived.ArchivedAt == nil {
+ t.Fatal("archived conversation has nil ArchivedAt")
+ }
+ restored, err := first.SetArchived(ctx, "owner-1", conversation.ID, false)
+ if err != nil {
+ t.Fatalf("restore through first store: %v", err)
+ }
+ if restored.ArchivedAt != nil {
+ t.Fatalf("restored conversation ArchivedAt = %v, want nil", restored.ArchivedAt)
+ }
}
func TestRunUpgradesVersionOneAndThenNoOps(t *testing.T) {