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, 04:45 UTC
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as SqlClient from "effect/sql/SqlClient"; |
| 3 | |
| 4 | export default Effect.gen(function* () { |
| 5 | const sql = yield* SqlClient.SqlClient; |
| 6 | |
| 7 | // Creation exposed no model choice; later metadata proves the user set or reset one. |
| 8 | yield* sql` |
| 9 | WITH automatically_seeded_projects AS ( |
| 10 | SELECT created.stream_id AS project_id |
| 11 | FROM orchestration_events AS created |
| 12 | WHERE created.aggregate_kind = 'project' |
| 13 | AND created.event_type = 'project.created' |
| 14 | AND json_type(created.payload_json, '$.defaultModelSelection') IS NOT NULL |
| 15 | AND json_type(created.payload_json, '$.defaultModelSelection') <> 'null' |
| 16 | AND NOT EXISTS ( |
| 17 | SELECT 1 |
| 18 | FROM orchestration_events AS configured |
| 19 | WHERE configured.aggregate_kind = 'project' |
| 20 | AND configured.stream_id = created.stream_id |
| 21 | AND configured.event_type = 'project.meta-updated' |
| 22 | AND json_type(configured.payload_json, '$.defaultModelSelection') IS NOT NULL |
| 23 | ) |
| 24 | ) |
| 25 | UPDATE projection_projects |
| 26 | SET default_model_selection_json = NULL |
| 27 | WHERE project_id IN (SELECT project_id FROM automatically_seeded_projects) |
| 28 | `; |
| 29 | |
| 30 | yield* sql` |
| 31 | UPDATE orchestration_events AS created |
| 32 | SET payload_json = json_set( |
| 33 | created.payload_json, |
| 34 | '$.defaultModelSelection', |
| 35 | json('null') |
| 36 | ) |
| 37 | WHERE created.aggregate_kind = 'project' |
| 38 | AND created.event_type = 'project.created' |
| 39 | AND json_type(created.payload_json, '$.defaultModelSelection') IS NOT NULL |
| 40 | AND json_type(created.payload_json, '$.defaultModelSelection') <> 'null' |
| 41 | AND NOT EXISTS ( |
| 42 | SELECT 1 |
| 43 | FROM orchestration_events AS configured |
| 44 | WHERE configured.aggregate_kind = 'project' |
| 45 | AND configured.stream_id = created.stream_id |
| 46 | AND configured.event_type = 'project.meta-updated' |
| 47 | AND json_type(configured.payload_json, '$.defaultModelSelection') IS NOT NULL |
| 48 | ) |
| 49 | `; |
| 50 | }); |