fix: smaller suggestion buttons and fix message ordering - add user msg before processing
All checks were successful
BotUI CI/CD / build (push) Successful in 43s
All checks were successful
BotUI CI/CD / build (push) Successful in 43s
This commit is contained in:
parent
5fa187fd97
commit
d2ea78cdbd
2 changed files with 39 additions and 35 deletions
|
|
@ -607,21 +607,21 @@ footer {
|
|||
|
||||
.suggestion-chip,
|
||||
.suggestion-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 14px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border, var(--border-color, #d0d0d0));
|
||||
border-radius: 20px;
|
||||
color: #333;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 5px 10px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border, var(--border-color, #d0d0d0));
|
||||
border-radius: 16px;
|
||||
color: #333;
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Dark theme suggestion buttons */
|
||||
|
|
|
|||
|
|
@ -1047,20 +1047,24 @@ function sendMessage(messageContent) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Reset streaming state for new user message
|
||||
// This ensures bot responses create new message elements
|
||||
if (isStreaming) {
|
||||
finalizeStreaming();
|
||||
}
|
||||
isStreaming = false;
|
||||
streamingMessageId = null;
|
||||
currentStreamingContent = "";
|
||||
// Also reset thinking state when user sends a new message
|
||||
isThinking = false;
|
||||
// Reset suggestions cache so tool buttons are re-rendered after conversation
|
||||
lastRenderedSuggestions = null;
|
||||
// Finalize any ongoing streaming BEFORE adding user message
|
||||
// This ensures previous bot response is complete before new exchange starts
|
||||
if (isStreaming && streamingMessageId) {
|
||||
finalizeStreaming();
|
||||
}
|
||||
isStreaming = false;
|
||||
streamingMessageId = null;
|
||||
currentStreamingContent = "";
|
||||
// Also reset thinking state when user sends a new message
|
||||
isThinking = false;
|
||||
// Reset suggestions cache so tool buttons are re-rendered after conversation
|
||||
lastRenderedSuggestions = null;
|
||||
|
||||
// Inject active switchers into content
|
||||
// Add user message to chat BEFORE sending to server
|
||||
// This ensures user message appears immediately and streaming responses go to new div
|
||||
addMessage("user", content);
|
||||
|
||||
// Inject active switchers into content
|
||||
var activeKeys = Object.keys(activeSwitchers).filter(function(k) { return activeSwitchers[k]; });
|
||||
|
||||
var enhancedContent = content;
|
||||
|
|
@ -1087,15 +1091,15 @@ function sendMessage(messageContent) {
|
|||
}
|
||||
|
||||
// Clear input if called from input field
|
||||
if (!messageContent) {
|
||||
hideMentionDropdown();
|
||||
input.value = "";
|
||||
input.focus();
|
||||
}
|
||||
if (!messageContent) {
|
||||
hideMentionDropdown();
|
||||
input.value = "";
|
||||
input.focus();
|
||||
}
|
||||
|
||||
addMessage("user", content); // Original clean content for the UI
|
||||
// User message was already added above before sending to server
|
||||
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
bot_id: currentBotId,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue