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

Function dequeueComposerPrompt

desktop/runtime-host/live-runtime-service.ts:566–617  ·  view source on GitHub ↗
(
  request: ComposerStateRequest & {
    queueId: string
    queueSnapshotKey: string
    queueMode: Exclude<ComposerStreamingBehavior, 'stop'>
  },
)

Source from the content-addressed store, hash-verified

564}
565
566export async function dequeueComposerPrompt(
567 request: ComposerStateRequest & {
568 queueId: string
569 queueSnapshotKey: string
570 queueMode: Exclude<ComposerStreamingBehavior, 'stop'>
571 },
572) {
573 const persistedSessionPath = getPersistedSessionPath(request.sessionPath)
574 if (!persistedSessionPath) return null
575 return await withRuntimeMutationLock(persistedSessionPath, async () => {
576 await reloadRuntimeSettingsIfSafe(persistedSessionPath, { useMutationLock: false })
577 const runtime = await getOrCreateRuntimeForSessionPath(persistedSessionPath, {
578 suspendDisposal: true,
579 settingsCwd: request.composerSessionDir ?? null,
580 chatGroupId: request.chatGroupId ?? null,
581 })
582 try {
583 const currentQueueSnapshot = {
584 steering: [...runtime.session.getSteeringMessages()],
585 followUp: [...runtime.session.getFollowUpMessages()],
586 }
587 if (buildComposerQueueSnapshotKey(currentQueueSnapshot) !== request.queueSnapshotKey) {
588 await emitComposerUpdate({ ...request, sessionPath: persistedSessionPath })
589 return null
590 }
591 const currentQueue =
592 request.queueMode === 'steer'
593 ? currentQueueSnapshot.steering
594 : currentQueueSnapshot.followUp
595 if (findQueuedPromptIndexById(request.queueMode, currentQueue, request.queueId) === null) {
596 await emitComposerUpdate({ ...request, sessionPath: persistedSessionPath })
597 return null
598 }
599 const clearedQueue = runtime.session.clearQueue()
600 const dequeueResult = removeQueuedPromptById(clearedQueue, request.queueMode, request.queueId)
601 if (!dequeueResult) {
602 await replayComposerQueue(runtime.session, clearedQueue)
603 await emitComposerUpdate({ ...request, sessionPath: persistedSessionPath })
604 return null
605 }
606 return await replayDequeuedComposerQueue({
607 clearedQueue,
608 dequeueResult,
609 request,
610 runtime,
611 sessionPath: persistedSessionPath,
612 })
613 } finally {
614 scheduleRuntimeDisposal(persistedSessionPath)
615 }
616 })
617}
618
619export async function answerNativeAskQuestions(
620 request: ComposerStateRequest & { requestId: string; answers: string[][] | null },

Callers 1

handleRequestFunction · 0.90

Calls 11

getPersistedSessionPathFunction · 0.90
withRuntimeMutationLockFunction · 0.90
removeQueuedPromptByIdFunction · 0.90
replayComposerQueueFunction · 0.90
scheduleRuntimeDisposalFunction · 0.90
emitComposerUpdateFunction · 0.70

Tested by

no test coverage detected