Skip to content

Commit 9f04b77

Browse files
fix(server): dev database seed drops active pull request watches
The dev seed copied kept threads' projection payloads verbatim, so a stopped thread's pull request watch survived and the dev server's PullRequestWatchReactor could wake the developer's real agent. The prune transaction now rebuilds each affected `pullRequests` array without its `watch`, keeping the links, their order, and `endedWatch` history. Fixes #32736 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b9cd183 commit 9f04b77

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎apps/server/scripts/migrate-dev-db.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,13 @@ const pruneSnapshot = Effect.fn("pruneDevDbSnapshot")(function* (input: RunMigra
381381
AND stream_id NOT IN (SELECT thread_id FROM kept_threads))
382382
OR (aggregate_kind = 'project'
383383
AND stream_id NOT IN (SELECT project_id FROM kept_projects))`;
384+
yield* sql`UPDATE orchestration_v2_projection_threads
385+
SET payload_json = json_set(payload_json, '$.pullRequests', (
386+
SELECT json_group_array(json_remove(link.value, '$.watch') ORDER BY link.key)
387+
FROM json_each(payload_json, '$.pullRequests') AS link))
388+
WHERE EXISTS (
389+
SELECT 1 FROM json_each(payload_json, '$.pullRequests') AS link
390+
WHERE json_extract(link.value, '$.watch') IS NOT NULL)`;
384391
for (const table of CLEARED_TABLES) {
385392
yield* sql`DELETE FROM ${sql(table)}`;
386393
}

0 commit comments

Comments
 (0)