875
this._contentChanged(quiet);
876
} else if (progress.kind === 'thinking') {
878
>
// tries to split thinking chunks if it is an array. only while certain models give us array chunks.
879
>
const lastResponsePart = this._responseParts
880
>
.filter(p => p.kind !== 'textEditGroup')
881
>
.at(-1);
882
>
883
>
const lastText = lastResponsePart && lastResponsePart.kind === 'thinking'
884
? (Array.isArray(lastResponsePart.value) ? lastResponsePart.value.join('') : (lastResponsePart.value || ''))
886
>
const currText = Array.isArray(progress.value) ? progress.value.join('') : (progress.value || '');
887
>
const isEmpty = (s: string) => s.length === 0;
888
>
if (isEmpty(currText)) {
889
this.finalizeReasoningDuration();
891
>
this._activeReasoning = { part: progress, startedAt: Date.now() };
892
>
}
893
>
894
>
// Do not merge if either the current or last thinking chunk is empty; empty chunks separate thinking
895
>
if (!lastResponsePart
896
|| lastResponsePart.kind !== 'thinking'
897
|| isEmpty(currText)
898
|| isEmpty(lastText)
899
>
|| !canMergeMarkdownStrings(new MarkdownString(lastText), new MarkdownString(currText))) {
chatModel.ts
900
>
this._responseParts.push(progress);
901
>
} else {
902
const idx = this._responseParts.indexOf(lastResponsePart);
903
const mergedPart: IChatThinkingPart = {