Sync thread workspaces from Codex cwd

This commit is contained in:
Codex
2026-05-21 09:56:47 +00:00
parent 1d433038ab
commit a73f88fe5e
5 changed files with 120 additions and 29 deletions

View File

@@ -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 (

View File

@@ -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) {