1652
1653
toJSON(): Omit<ISerializableChatResponseData, 'timestamp'> {
1654
>
const modelState = this._modelState.get();
chatModel.ts
1655
>
const pendingConfirmation = this.isPendingConfirmation.get();
1656
>
1657
>
return {
1658
>
responseId: this.id,
1659
>
result: this.result,
1660
>
responseMarkdownInfo: this.codeBlockInfos?.map<ISerializableMarkdownInfo>(info => ({ suggestionId: info.suggestionId })),
1661
>
followups: this.followups,
1662
>
modelState: modelState.value === ResponseModelState.Pending || modelState.value === ResponseModelState.NeedsInput ? { value: ResponseModelState.Cancelled, completedAt: Date.now() } : modelState,
1663
>
vote: this.vote,
1664
>
slashCommand: this.slashCommand,
1665
>
usedContext: this.usedContext,
1666
>
contentReferences: this.contentReferences,
1667
>
codeCitations: this.codeCitations,
1668
>
responseTimestamp: this._timestamp,
1669
>
timeSpentWaiting: (pendingConfirmation ? Date.now() - pendingConfirmation.startedWaitingAt : 0) + this._timeSpentWaitingAccumulator,
1670
>
promptTokens: this.usage?.promptTokens,
1671
>
completionTokens: this.completionTokenCount,
1672
>
outputBuffer: this.usage?.outputBuffer,
1673
>
promptTokenDetails: this.usage?.promptTokenDetails,
1674
>
copilotCredits: this.usage?.copilotCredits,
1675
>
elapsedMs: this.elapsedMs ?? (this.completedAt ? Math.max(0, this.completedAt - this.confirmationAdjustedTimestamp.get()) : undefined),
1676
>
} satisfies WithDefinedProps<Omit<ISerializableChatResponseData, 'timestamp'>>;
1677
>
}
1678
}
1679