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

Function loadInboxThreadList

desktop/pi-threads/thread-loader.ts:46–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44}
45
46export async function loadInboxThreadList(): Promise<InboxThread[]> {
47 const threads = listInboxThreads()
48
49 return mapWithConcurrency(threads, INBOX_PROMPT_BACKFILL_CONCURRENCY, async (thread) => {
50 try {
51 if (thread.prompt?.trim()) {
52 return thread
53 }
54
55 const loadedThread = await loadThread(thread.sessionPath)
56 let prompt: string | null = null
57
58 for (let index = loadedThread.messages.length - 1; index >= 0; index -= 1) {
59 const message = loadedThread.messages[index]
60 if (message?.role === 'user') {
61 const nextPrompt = message.content.join('\n\n').trim()
62 prompt = nextPrompt.length > 0 ? nextPrompt : null
63 break
64 }
65 }
66
67 if (!prompt) {
68 return thread
69 }
70
71 upsertInboxThreadPrompt(thread.sessionPath, prompt)
72 return { ...thread, prompt }
73 } catch (error) {
74 console.warn(`Failed to backfill inbox prompt for ${thread.sessionPath}.`, error)
75 return thread
76 }
77 })
78}
79
80export async function loadThreadSnapshot(
81 sessionPath: string,

Callers

nothing calls this directly

Calls 4

listInboxThreadsFunction · 0.90
mapWithConcurrencyFunction · 0.90
upsertInboxThreadPromptFunction · 0.90
loadThreadFunction · 0.85

Tested by

no test coverage detected