fix(web): show completed label for think block after streaming ends (#17149)

This commit is contained in:
euvre
2026-07-22 19:30:09 +08:00
committed by GitHub
parent 5bc28d4d15
commit d757303fa4
4 changed files with 23 additions and 7 deletions

View File

@@ -78,10 +78,16 @@ export const preprocessLaTeX = (content: string) => {
return inlineProcessedContent;
};
export function replaceThinkToSection(text: string = '') {
export function replaceThinkToSection(
text: string = '',
summary: string = 'Thinking...',
) {
const pattern = /<think>([\s\S]*?)<\/think>/g;
const result = text.replace(pattern, '<details class="think"><summary>Thinking...</summary>$1</details>');
const result = text.replace(
pattern,
`<details class="think"><summary>${summary}</summary>$1</details>`,
);
return result;
}
@@ -89,7 +95,10 @@ export function replaceThinkToSection(text: string = '') {
export function replaceRetrievingToSection(text: string = '') {
const pattern = /<retrieving>([\s\S]*?)<\/retrieving>/g;
const result = text.replace(pattern, '<details class="retrieving"><summary>Retrieving...</summary>$1</details>');
const result = text.replace(
pattern,
'<details class="retrieving"><summary>Retrieving...</summary>$1</details>',
);
return result;
}