The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 18:30 UTC
fix(server): dev database seed no longer runs settle scripts in real worktrees (#33908)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Lenori committed
Nov 12, 2026 at 21:07 UTC
0951791089b4f296d84bb47bf73eb402c335239e
2 files changed
+45
-4
apps/server/scripts/migrate-dev-db.test.ts
+35
-2
@@ -34,10 +34,21 @@ const createFixtureSource = Effect.fn("createMigrateDevDbFixtureSource")(functio
34
const sql = yield* SqlClient.SqlClient;
35
yield* runMigrations({ toMigrationInclusive });
36
37
+ const scripts = JSON.stringify([
38
+ { id: "lint", name: "Lint", command: "vp lint", icon: "lint", runOnWorktreeCreate: false },
39
+ {
40
+ id: "teardown",
41
+ name: "Teardown",
42
+ command: "./teardown",
43
+ icon: "configure",
44
+ runOnWorktreeCreate: false,
45
+ runOnSettle: true,
46
+ },
47
+ ]);
48
yield* sql`INSERT INTO projection_projects
49
(project_id, title, workspace_root, scripts_json, created_at, updated_at, deleted_at)
50
VALUES
40
- ('project-kept', 'Kept', '/tmp/kept', '[]', '2026-08-01', '2026-08-01', NULL),
51
+ ('project-kept', 'Kept', '/tmp/kept', ${scripts}, '2026-08-01', '2026-08-01', NULL),
52
('project-deleted', 'Deleted', '/tmp/deleted', '[]', '2026-08-01', '2026-08-02', '2026-08-02')`;
53
54
const forkPayload =
@@ -162,6 +173,8 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
173
json_extract(payload_json, '$.pullRequests[0].url') AS url,
174
json_extract(payload_json, '$.pullRequests[0].watch') AS watch
175
FROM orchestration_v2_projection_threads WHERE thread_id = 'stopped-thread'`;
176
+ const [project] = yield* sql<{ scripts_json: string }>`
177
+ SELECT scripts_json FROM projection_projects WHERE project_id = 'project-kept'`;
178
const [leftovers] = yield* sql<{
179
auth: number;
180
tasks: number;
@@ -176,7 +189,7 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
189
(SELECT COUNT(*) FROM scheduled_task_webhook_pending) AS webhooks,
190
(SELECT COUNT(*) FROM orchestration_v2_projection_context_transfers) AS transfers,
191
(SELECT COUNT(*) FROM peer_environment_links) AS links`;
179
- return { threads, events, sessions, pullRequest, leftovers };
192
+ return { threads, events, sessions, pullRequest, project, leftovers };
193
}),
194
);
195
assert.deepStrictEqual(
@@ -196,6 +209,26 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
209
{ url: "https://github.com/owner/repo/pull/7", watch: null },
210
"copied pull request links keep their history but stop being watched",
211
);
212
+ assert.deepStrictEqual(
213
+ JSON.parse(kept.project?.scripts_json ?? "[]"),
214
+ [
215
+ {
216
+ id: "lint",
217
+ name: "Lint",
218
+ command: "vp lint",
219
+ icon: "lint",
220
+ runOnWorktreeCreate: false,
221
+ },
222
+ {
223
+ id: "teardown",
224
+ name: "Teardown",
225
+ command: "./teardown",
226
+ icon: "configure",
227
+ runOnWorktreeCreate: false,
228
+ },
229
+ ],
230
+ "copied project scripts stay listed but never run on settle in the original checkout",
231
+ );
232
assert.deepStrictEqual(kept.leftovers, {
233
auth: 0,
234
tasks: 0,
apps/server/scripts/migrate-dev-db.ts
+10
-2
@@ -382,12 +382,20 @@ const pruneSnapshot = Effect.fn("pruneDevDbSnapshot")(function* (input: RunMigra
382
OR (aggregate_kind = 'project'
383
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', (
385
+ SET payload_json = json_set(payload_json, '$.pullRequests', json((
386
SELECT json_group_array(json_remove(link.value, '$.watch') ORDER BY link.key)
387
- FROM json_each(payload_json, '$.pullRequests') AS link))
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)`;
391
+ // Copied threads keep their real worktree paths, where a settle script would run.
392
+ yield* sql`UPDATE projection_projects
393
+ SET scripts_json = (
394
+ SELECT json_group_array(json_remove(script.value, '$.runOnSettle') ORDER BY script.key)
395
+ FROM json_each(scripts_json) AS script)
396
+ WHERE EXISTS (
397
+ SELECT 1 FROM json_each(scripts_json) AS script
398
+ WHERE json_extract(script.value, '$.runOnSettle') IS NOT NULL)`;
399
for (const table of CLEARED_TABLES) {
400
yield* sql`DELETE FROM ${sql(table)}`;
401
}