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

Function upsertChatThread

desktop/chat-state-db.ts:110–128  ·  view source on GitHub ↗
(options: {
  sessionPath: string
  groupId?: string | undefined | null | undefined
  updateGroup?: boolean | undefined
})

Source from the content-addressed store, hash-verified

108}
109
110export 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
130function mapChatThreadRow(row: ChatThreadGroupRow): ChatThread {
131 return { ...mapThreadRow(row), groupId: row.groupId, projectId: row.projectId }

Callers 3

persistHostThreadUpdateFunction · 0.90
moveChatThreadFunction · 0.85

Calls 5

getThreadStateDatabaseFunction · 0.90
isChatSessionPathFunction · 0.85
ensureChatStateSchemaFunction · 0.85
runMethod · 0.80
prepareMethod · 0.80

Tested by

no test coverage detected