@hivegpt/hiveai-angular 0.0.611 → 0.0.612

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3426,7 +3426,8 @@ class ChatDrawerComponent {
3426
3426
  var _a, _b, _c, _d;
3427
3427
  const lastItem = this.chatLog[this.chatLog.length - 1];
3428
3428
  if (done) {
3429
- lastItem.message = this.processMessageForDisplay(lastItem.message);
3429
+ // Final pass with the complete raw text (aiResponse) for a clean render
3430
+ lastItem.message = this.processMessageForDisplay(this.aiResponse);
3430
3431
  this.chatLog.pop();
3431
3432
  this.chatLog.push(lastItem);
3432
3433
  if (allSuggestions === null || allSuggestions === void 0 ? void 0 : allSuggestions.length) {
@@ -3455,7 +3456,7 @@ class ChatDrawerComponent {
3455
3456
  allSuggestions.push(match === null || match === void 0 ? void 0 : match.replace(/<\/?sug>/g, ''));
3456
3457
  });
3457
3458
  }
3458
- lastItem.message = this.aiResponse;
3459
+ lastItem.message = this.processMessageForDisplay(this.aiResponse);
3459
3460
  this.cdr.markForCheck();
3460
3461
  }
3461
3462
  else {
@@ -4650,7 +4651,7 @@ class ChatDrawerComponent {
4650
4651
  return false;
4651
4652
  }
4652
4653
  handleAskWebSocketMessage(rawMessage) {
4653
- var _a, _b, _c, _d, _e;
4654
+ var _a, _b, _c, _d, _e, _f;
4654
4655
  if (!rawMessage)
4655
4656
  return;
4656
4657
  let parsed = null;
@@ -4672,7 +4673,9 @@ class ChatDrawerComponent {
4672
4673
  return;
4673
4674
  const isNewAiMessage = !this.chatLog.find((p) => p._id == messageId);
4674
4675
  const currentChatMessage = this.upsertAiChatMessage(messageId);
4675
- currentChatMessage.message = `${currentChatMessage.message || ''}${(payload === null || payload === void 0 ? void 0 : payload.text) || ''}`;
4676
+ // Accumulate raw text and render markdown in real-time
4677
+ currentChatMessage.rawMessage = `${currentChatMessage.rawMessage || ''}${(payload === null || payload === void 0 ? void 0 : payload.text) || ''}`;
4678
+ currentChatMessage.message = this.processMessageForDisplay(currentChatMessage.rawMessage);
4676
4679
  if (isNewAiMessage) {
4677
4680
  // First chunk: hide Thinking indicator and scroll to the message start
4678
4681
  this.isChatingWithAi = false;
@@ -4692,19 +4695,21 @@ class ChatDrawerComponent {
4692
4695
  break;
4693
4696
  }
4694
4697
  const currentChatMessage = this.upsertAiChatMessage(messageId);
4695
- const finalAnswer = (_c = (_b = payload === null || payload === void 0 ? void 0 : payload.text) !== null && _b !== void 0 ? _b : currentChatMessage.message) !== null && _c !== void 0 ? _c : '';
4698
+ const finalAnswer = (_d = (_c = (_b = payload === null || payload === void 0 ? void 0 : payload.text) !== null && _b !== void 0 ? _b : currentChatMessage.rawMessage) !== null && _c !== void 0 ? _c : currentChatMessage.message) !== null && _d !== void 0 ? _d : '';
4696
4699
  const hasCardResponse = this.applyToolResultCardMessage(currentChatMessage, messageId, finalAnswer, payload === null || payload === void 0 ? void 0 : payload.tool_results);
4697
4700
  if (!hasCardResponse) {
4698
4701
  currentChatMessage.type = 'ai';
4699
4702
  currentChatMessage.message = this.processMessageForDisplay(finalAnswer);
4700
4703
  }
4704
+ // Clean up raw accumulator
4705
+ delete currentChatMessage.rawMessage;
4701
4706
  if (Array.isArray(payload === null || payload === void 0 ? void 0 : payload.suggestions)) {
4702
4707
  currentChatMessage.relatedListItems = payload.suggestions;
4703
4708
  }
4704
4709
  if (Array.isArray(payload === null || payload === void 0 ? void 0 : payload.web_results)) {
4705
4710
  currentChatMessage.sourcesList = payload.web_results;
4706
- currentChatMessage.displayedSources = (_d = payload.web_results) === null || _d === void 0 ? void 0 : _d.slice(0, 3);
4707
- currentChatMessage.remainingSources = (_e = payload.web_results) === null || _e === void 0 ? void 0 : _e.slice(3);
4711
+ currentChatMessage.displayedSources = (_e = payload.web_results) === null || _e === void 0 ? void 0 : _e.slice(0, 3);
4712
+ currentChatMessage.remainingSources = (_f = payload.web_results) === null || _f === void 0 ? void 0 : _f.slice(3);
4708
4713
  }
4709
4714
  if (payload === null || payload === void 0 ? void 0 : payload.tool_results) {
4710
4715
  currentChatMessage.toolResults = payload.tool_results;
@@ -4712,13 +4717,10 @@ class ChatDrawerComponent {
4712
4717
  this.showFeedBackIconsIndex = this.chatLog.length - 1;
4713
4718
  this.activeAskMessageId = '';
4714
4719
  this.isChatingWithAi = false;
4715
- // For card responses (tool results), scroll to the message text bubble
4716
- // instead of the very bottom avoids cards pushing the view too far down
4717
- if (hasCardResponse && messageId) {
4718
- this.cdr.markForCheck();
4719
- setTimeout(() => this.scrollToAiMessage(messageId), 30);
4720
- }
4721
- else {
4720
+ // For card responses (tool results), don't scroll at all
4721
+ // user is already viewing the AI text from the streaming phase,
4722
+ // cards render below and the user can scroll down to see them.
4723
+ if (!hasCardResponse) {
4722
4724
  this.scrollToBottom();
4723
4725
  }
4724
4726
  this.focusOnTextarea();