(options: {
sessionPath: string
groupId?: string | undefined | null | undefined
updateGroup?: boolean | undefined
})
| 108 | } |
| 109 | |
| 110 | export function upsertChatThread(options: { |
| 111 | sessionPath: string |
| 112 | groupId?: string | undefined | null | undefined |
| 113 | updateGroup?: boolean | undefined |
| 114 | }) { |
| 115 | if (!isChatSessionPath(options.sessionPath)) return |
| 116 | ensureChatStateSchema() |
| 117 | getThreadStateDatabase() |
| 118 | .prepare( |
| 119 | ` |
| 120 | INSERT INTO chat_threads (session_path, group_id) |
| 121 | VALUES (?, ?) |
| 122 | ON CONFLICT(session_path) DO UPDATE SET |
| 123 | group_id = CASE WHEN ? THEN excluded.group_id ELSE chat_threads.group_id END, |
| 124 | updated_at = CURRENT_TIMESTAMP |
| 125 | `, |
| 126 | ) |
| 127 | .run(options.sessionPath, options.groupId ?? null, options.updateGroup ? 1 : 0) |
| 128 | } |
| 129 | |
| 130 | function mapChatThreadRow(row: ChatThreadGroupRow): ChatThread { |
| 131 | return { ...mapThreadRow(row), groupId: row.groupId, projectId: row.projectId } |
no test coverage detected