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

Function beginInboxThreadTurn

desktop/thread-state-db/inbox-writes.ts:18–56  ·  view source on GitHub ↗
(sessionPath: string, prompt: string | null)

Source from the content-addressed store, hash-verified

16}
17
18export 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
58export function markInboxThreadRead(sessionPath: string) {
59 const db = getThreadStateDatabase()

Callers 4

persistHostThreadUpdateFunction · 0.90
updateInboxStartStateFunction · 0.90

Calls 4

getThreadStateDatabaseFunction · 0.90
runInTransactionFunction · 0.90
prepareMethod · 0.80
runMethod · 0.80

Tested by

no test coverage detected