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

Function getLatestUserPrompt

desktop/pi-desktop-runtime.ts:59–75  ·  view source on GitHub ↗
(thread: ThreadData)

Source from the content-addressed store, hash-verified

57}
58
59function getLatestUserPrompt(thread: ThreadData) {
60 let latestUserMessage: ProseMessage | undefined
61 for (let index = thread.messages.length - 1; index >= 0; index -= 1) {
62 const message = thread.messages[index]
63 if (message?.role === 'user') {
64 latestUserMessage = message as ProseMessage
65 break
66 }
67 }
68
69 if (!latestUserMessage) {
70 return null
71 }
72
73 const prompt = latestUserMessage.content.join('\n\n').trim()
74 return prompt.length > 0 ? prompt : null
75}
76
77async function persistHostThreadUpdate(event: Extract<DesktopEvent, { type: 'thread-update' }>) {
78 try {

Callers 1

persistHostThreadUpdateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected