feat: improve thinking state management for better UX in reasoning display

Previously, the "thinking" indicator and loading icon would only disappear
after the entire message generation was complete, which created a poor user
experience where users had to wait for the full response to see that the
reasoning phase had finished.

Changes made:
- Add `isThinkingComplete` field to independently track reasoning state
- Update streaming logic to mark thinking complete when content starts flowing
- Detect closed `<think>` tags to mark reasoning completion
- Modify MessageContent component to use independent thinking state
- Update "思考中..." text and loading icon display conditions
- Ensure thinking state is properly set in all completion scenarios
  (non-stream, errors, manual stop)

Now the thinking section immediately shows as complete when reasoning ends,
rather than waiting for the entire message to finish, providing much better
real-time feedback to users.

Files modified:
- web/src/hooks/useApiRequest.js
- web/src/components/playground/MessageContent.js
- web/src/utils/messageUtils.js
This commit is contained in:
Apple\Apple
2025-05-31 01:12:45 +08:00
parent f7a16c6ca5
commit 02bc3cde53
3 changed files with 17 additions and 3 deletions

View File

@@ -106,6 +106,7 @@ export const createLoadingAssistantMessage = () => createMessage(
{
reasoningContent: '',
isReasoningExpanded: true,
isThinkingComplete: false,
status: 'loading'
}
);