Spaces:
Running
Running
Vedika commited on
Update index.html
Browse files- index.html +11 -23
index.html
CHANGED
|
@@ -218,7 +218,7 @@
|
|
| 218 |
border: 1px solid var(--glass-border);
|
| 219 |
}
|
| 220 |
|
| 221 |
-
/* ----------
|
| 222 |
.bot-message {
|
| 223 |
align-self: flex-start;
|
| 224 |
max-width: 100%;
|
|
@@ -242,7 +242,8 @@
|
|
| 242 |
|
| 243 |
.bot-content-wrapper {
|
| 244 |
flex: 1 1 0%;
|
| 245 |
-
min-width: 0;
|
|
|
|
| 246 |
width: 100%;
|
| 247 |
overflow: hidden;
|
| 248 |
}
|
|
@@ -253,14 +254,14 @@
|
|
| 253 |
color: var(--text-primary);
|
| 254 |
word-wrap: break-word;
|
| 255 |
overflow-wrap: break-word;
|
| 256 |
-
word-break:
|
| 257 |
-
white-space:
|
| 258 |
width: 100%;
|
| 259 |
max-width: 100%;
|
| 260 |
}
|
| 261 |
|
| 262 |
.bot-content * { max-width: 100%; }
|
| 263 |
-
.bot-content p { margin-bottom: 16px; }
|
| 264 |
.bot-content p:last-child { margin-bottom: 0; }
|
| 265 |
.bot-content strong { font-weight: 600; color: #000; }
|
| 266 |
.bot-content code { font-family: var(--font-code); background: rgba(31,31,31,0.05); padding: 3px 6px; border-radius: 6px; font-size: 0.9em; color: #0284c7; white-space: pre-wrap; word-break: break-word; }
|
|
@@ -268,14 +269,14 @@
|
|
| 268 |
.bot-content pre {
|
| 269 |
background: #0d1117; padding: 40px 16px 16px; border-radius: var(--radius-md);
|
| 270 |
overflow-x: auto; margin: 16px 0; box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
| 271 |
-
position: relative; white-space: pre
|
| 272 |
}
|
| 273 |
.bot-content pre::before {
|
| 274 |
content: ''; position: absolute; top: 14px; left: 16px;
|
| 275 |
width: 12px; height: 12px; border-radius: 50%;
|
| 276 |
background: #ff5f56; box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
|
| 277 |
}
|
| 278 |
-
.bot-content pre code { background: none; padding: 0; color: #e2e8f0; font-size: 13.5px; text-shadow: none; white-space: pre
|
| 279 |
|
| 280 |
.chat-attachment-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
|
| 281 |
.chat-file-pill {
|
|
@@ -307,7 +308,7 @@
|
|
| 307 |
.qwen-think-box summary::-webkit-details-marker { display: none; }
|
| 308 |
.qwen-think-box summary svg.arrow { width: 14px; height: 14px; transition: transform var(--transition-default); }
|
| 309 |
.qwen-think-box[open] summary svg.arrow { transform: rotate(90deg); }
|
| 310 |
-
.qwen-think-content { padding: 16px; border-top: 1px solid var(--border-light); font-size: 13.5px; color: var(--text-secondary); font-style: italic; line-height: 1.6; opacity: 0.8; white-space:
|
| 311 |
|
| 312 |
.action-status {
|
| 313 |
display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px;
|
|
@@ -849,7 +850,6 @@
|
|
| 849 |
const blob = await response.blob();
|
| 850 |
return URL.createObjectURL(blob);
|
| 851 |
} catch(e) {
|
| 852 |
-
console.error(`TTS chunk ${chunkIndex} error:`, e);
|
| 853 |
return null;
|
| 854 |
}
|
| 855 |
},
|
|
@@ -1323,16 +1323,12 @@
|
|
| 1323 |
}
|
| 1324 |
}
|
| 1325 |
|
| 1326 |
-
// 🔧 FIX: Don't inject weather into payload sent to backend/history
|
| 1327 |
-
// Just use it for display context, not stored in history
|
| 1328 |
let systemInjectedPayload = payloadStr;
|
| 1329 |
if(State.weatherContext) {
|
| 1330 |
systemInjectedPayload = `${payloadStr}\n\n[SYSTEM REAL-TIME WEATHER: ${State.weatherContext}]`;
|
| 1331 |
}
|
| 1332 |
|
| 1333 |
Chat.renderUser(text, attachUI);
|
| 1334 |
-
// 🔧 FIX: Store clean user message in history (without weather injection)
|
| 1335 |
-
// This prevents confusion in next requests
|
| 1336 |
State.history.push({ role: 'user', content: payloadStr });
|
| 1337 |
FileSys.discard();
|
| 1338 |
|
|
@@ -1373,7 +1369,7 @@
|
|
| 1373 |
if(done) break;
|
| 1374 |
buffer += decoder.decode(value, {stream: true});
|
| 1375 |
const lines = buffer.split('\n');
|
| 1376 |
-
buffer = lines.pop();
|
| 1377 |
|
| 1378 |
for(let line of lines) {
|
| 1379 |
if(line.startsWith('data: ')) {
|
|
@@ -1382,9 +1378,7 @@
|
|
| 1382 |
try {
|
| 1383 |
const json = JSON.parse(dataStr);
|
| 1384 |
|
| 1385 |
-
// 🔧 FIX: Handle error responses from backend
|
| 1386 |
if (json.error) {
|
| 1387 |
-
console.error("Backend error:", json.error);
|
| 1388 |
botObj.contentDiv.innerHTML += `<br><span style="color:var(--brand-danger);">⚠️ ${UI.escape(json.error)}</span>`;
|
| 1389 |
return;
|
| 1390 |
}
|
|
@@ -1393,8 +1387,6 @@
|
|
| 1393 |
fullText += json.choices[0].delta.content;
|
| 1394 |
if (!firstChunkReceived) {
|
| 1395 |
firstChunkReceived = true;
|
| 1396 |
-
// 🔧 FIX: Start TTS preparation as soon as first chunk arrives
|
| 1397 |
-
// This overlaps TTS generation with streaming
|
| 1398 |
if(botObj.listenBtn) {
|
| 1399 |
setTimeout(() => {
|
| 1400 |
TTSManager.autoPrepare(msgId, fullText, botObj.listenBtn);
|
|
@@ -1403,9 +1395,7 @@
|
|
| 1403 |
}
|
| 1404 |
}
|
| 1405 |
}
|
| 1406 |
-
catch(e) {
|
| 1407 |
-
console.warn("JSON parse error:", e, "Line:", dataStr);
|
| 1408 |
-
}
|
| 1409 |
Chat.parseAndRender(fullText, false, true, botObj.contentDiv);
|
| 1410 |
UI.scrollToBottom();
|
| 1411 |
}
|
|
@@ -1415,7 +1405,6 @@
|
|
| 1415 |
State.history.push({ role: 'assistant', content: fullText });
|
| 1416 |
HistoryManager.saveCurrent();
|
| 1417 |
|
| 1418 |
-
// 🔧 FIX: Ensure TTS is fully prepared after streaming completes
|
| 1419 |
if(botObj.listenBtn && fullText.trim().length > 0) {
|
| 1420 |
TTSManager.autoPrepare(msgId, fullText, botObj.listenBtn);
|
| 1421 |
}
|
|
@@ -1427,7 +1416,6 @@
|
|
| 1427 |
HistoryManager.saveCurrent();
|
| 1428 |
}
|
| 1429 |
} else {
|
| 1430 |
-
console.error("Chat error:", e);
|
| 1431 |
botObj.contentDiv.innerHTML += `<br><span style="color:var(--brand-danger);">⚠️ ${UI.escape(e.message || 'Connection Offline.')}</span>`;
|
| 1432 |
}
|
| 1433 |
} finally {
|
|
|
|
| 218 |
border: 1px solid var(--glass-border);
|
| 219 |
}
|
| 220 |
|
| 221 |
+
/* ---------- BUG FIX: VERTICAL TEXT (FLEX + MIN-WIDTH: 0) ---------- */
|
| 222 |
.bot-message {
|
| 223 |
align-self: flex-start;
|
| 224 |
max-width: 100%;
|
|
|
|
| 242 |
|
| 243 |
.bot-content-wrapper {
|
| 244 |
flex: 1 1 0%;
|
| 245 |
+
min-width: 0; /* CRITICAL: Prevents flexbox from shrinking to character width */
|
| 246 |
+
max-width: calc(100% - 50px);
|
| 247 |
width: 100%;
|
| 248 |
overflow: hidden;
|
| 249 |
}
|
|
|
|
| 254 |
color: var(--text-primary);
|
| 255 |
word-wrap: break-word;
|
| 256 |
overflow-wrap: break-word;
|
| 257 |
+
word-break: normal;
|
| 258 |
+
white-space: pre-wrap; /* Restored to pre-wrap for Markdown formatting */
|
| 259 |
width: 100%;
|
| 260 |
max-width: 100%;
|
| 261 |
}
|
| 262 |
|
| 263 |
.bot-content * { max-width: 100%; }
|
| 264 |
+
.bot-content p { margin-bottom: 16px; white-space: pre-wrap; }
|
| 265 |
.bot-content p:last-child { margin-bottom: 0; }
|
| 266 |
.bot-content strong { font-weight: 600; color: #000; }
|
| 267 |
.bot-content code { font-family: var(--font-code); background: rgba(31,31,31,0.05); padding: 3px 6px; border-radius: 6px; font-size: 0.9em; color: #0284c7; white-space: pre-wrap; word-break: break-word; }
|
|
|
|
| 269 |
.bot-content pre {
|
| 270 |
background: #0d1117; padding: 40px 16px 16px; border-radius: var(--radius-md);
|
| 271 |
overflow-x: auto; margin: 16px 0; box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
| 272 |
+
position: relative; white-space: pre; word-break: normal;
|
| 273 |
}
|
| 274 |
.bot-content pre::before {
|
| 275 |
content: ''; position: absolute; top: 14px; left: 16px;
|
| 276 |
width: 12px; height: 12px; border-radius: 50%;
|
| 277 |
background: #ff5f56; box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
|
| 278 |
}
|
| 279 |
+
.bot-content pre code { background: none; padding: 0; color: #e2e8f0; font-size: 13.5px; text-shadow: none; white-space: pre; }
|
| 280 |
|
| 281 |
.chat-attachment-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
|
| 282 |
.chat-file-pill {
|
|
|
|
| 308 |
.qwen-think-box summary::-webkit-details-marker { display: none; }
|
| 309 |
.qwen-think-box summary svg.arrow { width: 14px; height: 14px; transition: transform var(--transition-default); }
|
| 310 |
.qwen-think-box[open] summary svg.arrow { transform: rotate(90deg); }
|
| 311 |
+
.qwen-think-content { padding: 16px; border-top: 1px solid var(--border-light); font-size: 13.5px; color: var(--text-secondary); font-style: italic; line-height: 1.6; opacity: 0.8; white-space: pre-wrap;}
|
| 312 |
|
| 313 |
.action-status {
|
| 314 |
display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px;
|
|
|
|
| 850 |
const blob = await response.blob();
|
| 851 |
return URL.createObjectURL(blob);
|
| 852 |
} catch(e) {
|
|
|
|
| 853 |
return null;
|
| 854 |
}
|
| 855 |
},
|
|
|
|
| 1323 |
}
|
| 1324 |
}
|
| 1325 |
|
|
|
|
|
|
|
| 1326 |
let systemInjectedPayload = payloadStr;
|
| 1327 |
if(State.weatherContext) {
|
| 1328 |
systemInjectedPayload = `${payloadStr}\n\n[SYSTEM REAL-TIME WEATHER: ${State.weatherContext}]`;
|
| 1329 |
}
|
| 1330 |
|
| 1331 |
Chat.renderUser(text, attachUI);
|
|
|
|
|
|
|
| 1332 |
State.history.push({ role: 'user', content: payloadStr });
|
| 1333 |
FileSys.discard();
|
| 1334 |
|
|
|
|
| 1369 |
if(done) break;
|
| 1370 |
buffer += decoder.decode(value, {stream: true});
|
| 1371 |
const lines = buffer.split('\n');
|
| 1372 |
+
buffer = lines.pop();
|
| 1373 |
|
| 1374 |
for(let line of lines) {
|
| 1375 |
if(line.startsWith('data: ')) {
|
|
|
|
| 1378 |
try {
|
| 1379 |
const json = JSON.parse(dataStr);
|
| 1380 |
|
|
|
|
| 1381 |
if (json.error) {
|
|
|
|
| 1382 |
botObj.contentDiv.innerHTML += `<br><span style="color:var(--brand-danger);">⚠️ ${UI.escape(json.error)}</span>`;
|
| 1383 |
return;
|
| 1384 |
}
|
|
|
|
| 1387 |
fullText += json.choices[0].delta.content;
|
| 1388 |
if (!firstChunkReceived) {
|
| 1389 |
firstChunkReceived = true;
|
|
|
|
|
|
|
| 1390 |
if(botObj.listenBtn) {
|
| 1391 |
setTimeout(() => {
|
| 1392 |
TTSManager.autoPrepare(msgId, fullText, botObj.listenBtn);
|
|
|
|
| 1395 |
}
|
| 1396 |
}
|
| 1397 |
}
|
| 1398 |
+
catch(e) {}
|
|
|
|
|
|
|
| 1399 |
Chat.parseAndRender(fullText, false, true, botObj.contentDiv);
|
| 1400 |
UI.scrollToBottom();
|
| 1401 |
}
|
|
|
|
| 1405 |
State.history.push({ role: 'assistant', content: fullText });
|
| 1406 |
HistoryManager.saveCurrent();
|
| 1407 |
|
|
|
|
| 1408 |
if(botObj.listenBtn && fullText.trim().length > 0) {
|
| 1409 |
TTSManager.autoPrepare(msgId, fullText, botObj.listenBtn);
|
| 1410 |
}
|
|
|
|
| 1416 |
HistoryManager.saveCurrent();
|
| 1417 |
}
|
| 1418 |
} else {
|
|
|
|
| 1419 |
botObj.contentDiv.innerHTML += `<br><span style="color:var(--brand-danger);">⚠️ ${UI.escape(e.message || 'Connection Offline.')}</span>`;
|
| 1420 |
}
|
| 1421 |
} finally {
|