Sync thread names from Codex
This commit is contained in:
@@ -433,6 +433,18 @@ func (s *Store) RenameThreadByCodexID(ctx context.Context, codexThreadID, title
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) SyncThreadTitle(ctx context.Context, telegramUserID, id int64, title string) error {
|
||||
_, err := s.db.ExecContext(ctx, `
|
||||
UPDATE threads SET title = ?
|
||||
WHERE telegram_user_id = ? AND id = ?`, title, telegramUserID, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) SyncThreadTitleByCodexID(ctx context.Context, codexThreadID, title string) error {
|
||||
_, err := s.db.ExecContext(ctx, "UPDATE threads SET title = ? WHERE codex_thread_id = ?", title, codexThreadID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) UpsertPendingApproval(ctx context.Context, approval PendingApproval) (PendingApproval, error) {
|
||||
_, err := s.db.ExecContext(ctx, `
|
||||
INSERT INTO pending_approvals (
|
||||
|
||||
@@ -156,6 +156,26 @@ func TestRenameThread(t *testing.T) {
|
||||
if thread.Title != "codex title" {
|
||||
t.Fatalf("title = %q", thread.Title)
|
||||
}
|
||||
if err := st.SyncThreadTitle(ctx, 42, thread.ID, "synced title"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread, err = st.GetThreadByID(ctx, 42, thread.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if thread.Title != "synced title" {
|
||||
t.Fatalf("title = %q", thread.Title)
|
||||
}
|
||||
if err := st.SyncThreadTitleByCodexID(ctx, "codex-thread", "synced codex title"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread, err = st.GetThreadByID(ctx, 42, thread.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if thread.Title != "synced codex title" {
|
||||
t.Fatalf("title = %q", thread.Title)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateWorkspacePath(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user