MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / upsertInboxThreadMessage

Function upsertInboxThreadMessage

desktop/thread-state-db/inbox-writes.ts:79–121  ·  view source on GitHub ↗
(record: ThreadInboxMessageRecord)

Source from the content-addressed store, hash-verified

77}
78
79export 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}

Callers 4

persistHostThreadUpdateFunction · 0.90
updateInboxEndStateFunction · 0.90

Calls 3

getThreadStateDatabaseFunction · 0.90
runMethod · 0.80
prepareMethod · 0.80

Tested by

no test coverage detected