(record: ThreadInboxMessageRecord)
| 77 | } |
| 78 | |
| 79 | export function upsertInboxThreadMessage(record: ThreadInboxMessageRecord) { |
| 80 | const db = getThreadStateDatabase() |
| 81 | const serializedContent = JSON.stringify(record.content) |
| 82 | |
| 83 | db.prepare( |
| 84 | ` |
| 85 | INSERT INTO inbox_items ( |
| 86 | session_path, |
| 87 | unread, |
| 88 | last_user_prompt, |
| 89 | last_assistant_message_json, |
| 90 | last_assistant_preview, |
| 91 | last_assistant_at_ms |
| 92 | ) |
| 93 | VALUES (?, 1, ?, ?, ?, ?) |
| 94 | ON CONFLICT(session_path) DO UPDATE SET |
| 95 | unread = 1, |
| 96 | last_user_prompt = excluded.last_user_prompt, |
| 97 | last_assistant_message_json = excluded.last_assistant_message_json, |
| 98 | last_assistant_preview = excluded.last_assistant_preview, |
| 99 | last_assistant_at_ms = excluded.last_assistant_at_ms, |
| 100 | updated_at = CURRENT_TIMESTAMP |
| 101 | `, |
| 102 | ).run( |
| 103 | record.sessionPath, |
| 104 | record.userPrompt, |
| 105 | serializedContent, |
| 106 | record.preview, |
| 107 | record.lastAssistantAtMs, |
| 108 | ) |
| 109 | |
| 110 | db.prepare( |
| 111 | ` |
| 112 | UPDATE threads |
| 113 | SET |
| 114 | last_assistant_message_json = ?, |
| 115 | last_assistant_preview = ?, |
| 116 | last_assistant_at_ms = ?, |
| 117 | updated_at = CURRENT_TIMESTAMP |
| 118 | WHERE session_path = ? |
| 119 | `, |
| 120 | ).run(serializedContent, record.preview, record.lastAssistantAtMs, record.sessionPath) |
| 121 | } |
no test coverage detected