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

Function publishExternalThreadUpdate

desktop/runtime/thread-publisher.ts:344–396  ·  view source on GitHub ↗
({
  lastModifiedMs,
  projectId,
  sessionPath,
  thread,
  threadId,
}: {
  lastModifiedMs: number
  projectId: string
  sessionPath: string
  thread: ThreadData
  threadId: string
})

Source from the content-addressed store, hash-verified

342}
343
344export async function publishExternalThreadUpdate({
345 lastModifiedMs,
346 projectId,
347 sessionPath,
348 thread,
349 threadId,
350}: {
351 lastModifiedMs: number
352 projectId: string
353 sessionPath: string
354 thread: ThreadData
355 threadId: string
356}) {
357 thread = normalizeThreadDataForReason(thread, 'external')
358
359 rememberLiveThread(sessionPath, thread)
360 rememberSessionPath(sessionPath, projectId)
361 threadId = upsertThreadSummary({
362 id: threadId,
363 cwd: projectId,
364 sessionPath,
365 title: thread.title,
366 lastModifiedMs,
367 })
368 setThreadRunningState(sessionPath, false)
369
370 const latestUserPrompt = getLatestUserPrompt(thread)
371 const latestAssistantMessage = getLatestInboxAssistantMessage(thread.messages)
372
373 if (!latestAssistantMessage && (latestUserPrompt || hasInboxItem(sessionPath))) {
374 beginInboxThreadTurn(sessionPath, latestUserPrompt)
375 }
376
377 if (latestAssistantMessage && hasAssistantMessageChanged(sessionPath, latestAssistantMessage)) {
378 upsertInboxThreadMessage({
379 sessionPath,
380 userPrompt: latestUserPrompt,
381 content: latestAssistantMessage.content,
382 preview: latestAssistantMessage.preview,
383 lastAssistantAtMs: lastModifiedMs,
384 })
385 }
386
387 emitDesktopEvent({
388 type: 'thread-update',
389 reason: 'external',
390 projectId,
391 threadId,
392 sessionPath,
393 thread,
394 composer: null,
395 })
396}
397
398export function publishComposerUpdate(
399 composer: ComposerState,

Callers

nothing calls this directly

Calls 12

rememberLiveThreadFunction · 0.90
rememberSessionPathFunction · 0.90
upsertThreadSummaryFunction · 0.90
setThreadRunningStateFunction · 0.90
hasInboxItemFunction · 0.90
beginInboxThreadTurnFunction · 0.90
upsertInboxThreadMessageFunction · 0.90
emitDesktopEventFunction · 0.90
getLatestUserPromptFunction · 0.70

Tested by

no test coverage detected