(
session: CopilotSession,
{ alreadyIdle = false }: { alreadyIdle?: boolean } = {}
)
| 5 | import { AssistantMessageEvent, CopilotSession, SessionEvent } from "../../../src"; |
| 6 | |
| 7 | export async function getFinalAssistantMessage( |
| 8 | session: CopilotSession, |
| 9 | { alreadyIdle = false }: { alreadyIdle?: boolean } = {} |
| 10 | ): Promise<AssistantMessageEvent> { |
| 11 | // Install the live subscription (via getFutureFinalResponse) before issuing the |
| 12 | // existing-messages RPC so we don't miss events that arrive while that RPC is in flight. |
| 13 | const futurePromise = getFutureFinalResponse(session); |
| 14 | // We may end up returning from the existing-messages path; attach a noop handler so |
| 15 | // the unawaited future-response rejection doesn't surface as an unhandled rejection. |
| 16 | futurePromise.catch(() => {}); |
| 17 | |
| 18 | const existing = await getExistingFinalResponse(session, alreadyIdle); |
| 19 | if (existing) { |
| 20 | return existing; |
| 21 | } |
| 22 | return futurePromise; |
| 23 | } |
| 24 | |
| 25 | async function getExistingFinalResponse( |
| 26 | session: CopilotSession, |
no test coverage detected
searching dependent graphs…