(sessionPath: string, prompt: string | null)
| 16 | } |
| 17 | |
| 18 | export function beginInboxThreadTurn(sessionPath: string, prompt: string | null) { |
| 19 | const db = getThreadStateDatabase() |
| 20 | const resetInboxItem = db.prepare( |
| 21 | ` |
| 22 | INSERT INTO inbox_items ( |
| 23 | session_path, |
| 24 | unread, |
| 25 | last_user_prompt, |
| 26 | last_assistant_message_json, |
| 27 | last_assistant_preview, |
| 28 | last_assistant_at_ms |
| 29 | ) |
| 30 | VALUES (?, 0, ?, NULL, NULL, NULL) |
| 31 | ON CONFLICT(session_path) DO UPDATE SET |
| 32 | unread = 0, |
| 33 | last_user_prompt = excluded.last_user_prompt, |
| 34 | last_assistant_message_json = NULL, |
| 35 | last_assistant_preview = NULL, |
| 36 | last_assistant_at_ms = NULL, |
| 37 | updated_at = CURRENT_TIMESTAMP |
| 38 | `, |
| 39 | ) |
| 40 | const resetThreadAssistantSnapshot = db.prepare( |
| 41 | ` |
| 42 | UPDATE threads |
| 43 | SET |
| 44 | last_assistant_message_json = NULL, |
| 45 | last_assistant_preview = NULL, |
| 46 | last_assistant_at_ms = NULL, |
| 47 | updated_at = CURRENT_TIMESTAMP |
| 48 | WHERE session_path = ? |
| 49 | `, |
| 50 | ) |
| 51 | |
| 52 | runInTransaction(db, () => { |
| 53 | resetInboxItem.run(sessionPath, prompt) |
| 54 | resetThreadAssistantSnapshot.run(sessionPath) |
| 55 | }) |
| 56 | } |
| 57 | |
| 58 | export function markInboxThreadRead(sessionPath: string) { |
| 59 | const db = getThreadStateDatabase() |
no test coverage detected