(ix: IInstantiationService, sid: string)
| 130 | } |
| 131 | |
| 132 | async function readViaLegacyAssembly(ix: IInstantiationService, sid: string) { |
| 133 | return ix.invokeFunction(async (a) => { |
| 134 | const broadcast = a.get(IWSBroadcastService); |
| 135 | const sessionService = a.get(ISessionService); |
| 136 | const messageService = a.get(IMessageService); |
| 137 | const promptService = a.get(IPromptService); |
| 138 | const approvals = a.get(IApprovalService) as ApprovalService; |
| 139 | const questions = a.get(IQuestionService) as QuestionService; |
| 140 | |
| 141 | let snapState = await broadcast.getSnapshotState(sid); |
| 142 | let session: Session | undefined; |
| 143 | let items: Message[] = []; |
| 144 | let hasMore = false; |
| 145 | |
| 146 | for (let attempt = 0; attempt < MAX_ASSEMBLY_ATTEMPTS; attempt++) { |
| 147 | session = await sessionService.get(sid); |
| 148 | const page = await messageService.list(sid, { |
| 149 | page_size: SNAPSHOT_MESSAGE_PAGE_SIZE, |
| 150 | }); |
| 151 | items = [...page.items].reverse(); |
| 152 | hasMore = page.has_more; |
| 153 | |
| 154 | const post = await broadcast.getSnapshotState(sid); |
| 155 | const stable = post.seq === snapState.seq && post.epoch === snapState.epoch; |
| 156 | snapState = post; |
| 157 | if (stable) break; |
| 158 | } |
| 159 | |
| 160 | const currentPromptId = promptService.getCurrentPromptId(sid); |
| 161 | const inFlightTurn = snapState.inFlightTurn; |
| 162 | if (inFlightTurn !== null && currentPromptId !== undefined) { |
| 163 | inFlightTurn.current_prompt_id = currentPromptId; |
| 164 | } |
| 165 | |
| 166 | return { |
| 167 | as_of_seq: snapState.seq, |
| 168 | epoch: snapState.epoch, |
| 169 | session: session!, |
| 170 | messages: { items, has_more: hasMore }, |
| 171 | in_flight_turn: inFlightTurn, |
| 172 | pending_approvals: approvals.listPending(sid), |
| 173 | pending_questions: questions.listPending(sid), |
| 174 | }; |
| 175 | }); |
| 176 | } |
no test coverage detected