Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/helpers/types/conversationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ IRichContent.prototype.language;
* @property {boolean} is_dummy
* @property {boolean} is_appended
* @property {string} [indication]
* @property {any} [thought]
* @property {any} [meta_data]
*/

Expand Down
24 changes: 12 additions & 12 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,9 @@
...message,
is_chat_message: false,
is_dummy: true,
meta_data: {
...(message.meta_data || {}),
thinking_text: message.meta_data?.thinking_text || ''
thought: {
...(message.thought || {}),
thinking_text: message.thought?.thinking_text || ''
}
});
}
Expand All @@ -602,12 +602,12 @@
&& lastMsg?.is_dummy
) {
setTimeout(() => {
const thinkingText = message.meta_data?.thinking_text || '';
const thinkingText = message.thought?.thinking_text || '';
if (thinkingText) {
if (!dialogs[dialogs.length - 1].meta_data) {
dialogs[dialogs.length - 1].meta_data = { thinking_text: '' };
if (!dialogs[dialogs.length - 1].thought) {
dialogs[dialogs.length - 1].thought = { thinking_text: '' };
}
dialogs[dialogs.length - 1].meta_data.thinking_text += thinkingText;
dialogs[dialogs.length - 1].thought.thinking_text += thinkingText;
Comment on lines +605 to +610
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. No legacy thinking-text fallback 🐞 Bug ≡ Correctness

The UI now reads thinking text only from message.thought.thinking_text, but message ingestion paths
(dialogs history + SignalR stream) pass payloads through without normalizing legacy
meta_data.thinking_text into thought. This causes thinking text (and avatar visibility during
thinking-only) to disappear for existing conversations or any producers still populating meta_data.
Agent Prompt
### Issue description
The UI now relies on `message.thought.thinking_text`, but inbound messages are not normalized from legacy `meta_data.thinking_text`. This breaks display of thinking text for persisted/history messages and any stream events still using `meta_data`.

### Issue Context
Messages come from two main ingress paths:
- Dialog history: `getDialogs()` returns `response.data` directly.
- Realtime stream: SignalR handlers do `JSON.parse()` and forward `obj` directly.

### Fix Focus Areas
Implement one of these (prefer normalization once at ingress):
1) **Ingress normalization**: when loading dialogs and when receiving SignalR messages, map legacy fields:
   - If `msg.thought` is missing, set `msg.thought = { thinking_text: msg.meta_data?.thinking_text ?? '' }`.
   - Optionally also keep `meta_data` for compatibility.
2) **UI fallback** (if you can’t normalize everywhere): change reads to `message?.thought?.thinking_text ?? message?.meta_data?.thinking_text ?? ''`.

Focus edits here:
- src/routes/chat/[agentId]/[conversationId]/chat-box.svelte[575-613]
- src/routes/chat/[agentId]/[conversationId]/chat-box.svelte[2013-2023]
- src/routes/chat/[agentId]/[conversationId]/rich-content/rc-message.svelte[27-31]
- src/lib/services/conversation-service.js[87-95]
- src/lib/services/signalr-service.js[173-185]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
dialogs[dialogs.length - 1].text += message.text;
refreshDialogs();
Expand Down Expand Up @@ -638,13 +638,13 @@
}

try {
const thinkingText = item.meta_data?.thinking_text || '';
const thinkingText = item.thought?.thinking_text || '';
if (thinkingText) {
if (!dialogs[dialogs.length - 1].meta_data) {
dialogs[dialogs.length - 1].meta_data = { thinking_text: '' };
if (!dialogs[dialogs.length - 1].thought) {
dialogs[dialogs.length - 1].thought = { thinking_text: '' };
}
for (const tt of thinkingText) {
dialogs[dialogs.length - 1].meta_data.thinking_text += tt;
dialogs[dialogs.length - 1].thought.thinking_text += tt;
refreshDialogs();
await delay(10);
}
Expand Down Expand Up @@ -2014,7 +2014,7 @@
{#if message.sender.role == UserRole.Client}
<img src="images/users/user-dummy.jpg" class="rounded-circle avatar-sm" style="margin-bottom: -15px;" alt="avatar">
{:else}
{@const isShowIcon = (message?.rich_content?.message?.text || message?.text || message?.meta_data?.thinking_text) || message?.uuid !== lastBotMsg?.uuid}
{@const isShowIcon = (message?.rich_content?.message?.text || message?.text || message?.thought?.thinking_text) || message?.uuid !== lastBotMsg?.uuid}
<img
class="rounded-circle avatar-sm"
style={`display: ${isShowIcon ? 'block' : 'none'}; margin-bottom: -15px;`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
} = $props();

let text = $derived(message?.rich_content?.message?.text || message?.text || '');
let thinkingText = $derived(message?.meta_data?.thinking_text || '');
let thinkingText = $derived(message?.thought?.thinking_text || '');
let isThinking = $derived(thinkingText && !text && isStreaming);
let isStoppedThinking = $derived(thinkingText && !text && !isStreaming);

Expand Down
Loading