The best way to control Claude Code, Codex and more from any computer or phone

main
ts 22 lines 1.01 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as SqlClient from "effect/sql/SqlClient";
3
4 // Subagents and forks once copied their source's title marker without a title job of their own,
5 // so only a pending or running job for the thread's current request can still clear it.
6 export default Effect.gen(function* () {
7 const sql = yield* SqlClient.SqlClient;
8 yield* sql`
9 UPDATE orchestration_v2_projection_threads
10 SET payload_json = json_set(payload_json, '$.titleRegeneration', json('null'))
11 WHERE json_valid(payload_json)
12 AND json_type(payload_json, '$.titleRegeneration') = 'object'
13 AND NOT EXISTS (
14 SELECT 1 FROM orchestration_v2_effect_outbox AS job
15 WHERE job.effect_type = 'thread-title.generate'
16 AND job.thread_id = orchestration_v2_projection_threads.thread_id
17 AND job.command_id =
18 json_extract(orchestration_v2_projection_threads.payload_json, '$.titleRegeneration.requestId')
19 AND job.status IN ('pending', 'running')
20 )
21 `;
22 });