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

Function listProjectThreads

desktop/thread-state-db/queries.ts:192–227  ·  view source on GitHub ↗
(
  projectId: string,
  options: { chat?: boolean | undefined } = {},
)

Source from the content-addressed store, hash-verified

190}
191
192export function listProjectThreads(
193 projectId: string,
194 options: { chat?: boolean | undefined } = {},
195): Thread[] {
196 const db = getThreadStateDatabase()
197 const rows = db
198 .prepare(
199 `
200 SELECT
201 threads.id AS id,
202 threads.title AS title,
203 threads.session_path AS sessionPath,
204 COALESCE(inbox_items.last_assistant_preview, threads.last_assistant_preview) AS summary,
205 threads.running AS running,
206 COALESCE(inbox_items.unread, 0) AS unread,
207 threads.pinned AS pinned,
208 threads.last_modified_ms AS lastModifiedMs
209 FROM threads
210 LEFT JOIN inbox_items ON inbox_items.session_path = threads.session_path
211 WHERE threads.cwd = ? AND threads.archived = 0
212 ORDER BY threads.pinned DESC, threads.last_modified_ms DESC, threads.title COLLATE NOCASE ASC
213 `,
214 )
215 .all(projectId) as ThreadRow[]
216
217 return rows
218 .filter((row) => matchesThreadScope(row.sessionPath, options))
219 .map((row) =>
220 mapThreadRow({
221 ...row,
222 running: getEffectiveThreadRunningState(row.running, getLiveThread(row.sessionPath))
223 ? 1
224 : 0,
225 }),
226 )
227}
228
229export function listInboxThreads(): InboxThread[] {
230 const db = getThreadStateDatabase()

Callers 1

loadProjectThreadsFunction · 0.90

Calls 7

getThreadStateDatabaseFunction · 0.90
mapThreadRowFunction · 0.90
getLiveThreadFunction · 0.90
matchesThreadScopeFunction · 0.85
allMethod · 0.80
prepareMethod · 0.80

Tested by

no test coverage detected