Sync thread workspaces from Codex cwd
This commit is contained in:
@@ -445,6 +445,13 @@ func (s *Store) SyncThreadTitleByCodexID(ctx context.Context, codexThreadID, tit
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) SyncThreadWorkspace(ctx context.Context, telegramUserID, id, workspaceID int64) error {
|
||||
_, err := s.db.ExecContext(ctx, `
|
||||
UPDATE threads SET workspace_id = ?
|
||||
WHERE telegram_user_id = ? AND id = ?`, workspaceID, telegramUserID, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) UpsertPendingApproval(ctx context.Context, approval PendingApproval) (PendingApproval, error) {
|
||||
_, err := s.db.ExecContext(ctx, `
|
||||
INSERT INTO pending_approvals (
|
||||
|
||||
@@ -176,6 +176,20 @@ func TestRenameThread(t *testing.T) {
|
||||
if thread.Title != "synced codex title" {
|
||||
t.Fatalf("title = %q", thread.Title)
|
||||
}
|
||||
ws2, err := st.AddWorkspace(ctx, t.TempDir(), "repo2", false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.SyncThreadWorkspace(ctx, 42, thread.ID, ws2.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread, err = st.GetThreadByID(ctx, 42, thread.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if thread.WorkspaceID != ws2.ID {
|
||||
t.Fatalf("workspace id = %d, want %d", thread.WorkspaceID, ws2.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateWorkspacePath(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user