Fix chat UI to show helpful message when text-router logs don't contain chat data
This commit is contained in:
1 parent
79d9abef34
commit
341e9a3213
2 files changed
+17
-4
No files matched your search
+5
-1
@@ -302,7 +302,11 @@ def register_api_routes(app, services, settings):
|
||||
'is_admin': row.get('is_admin', False),
|
||||
})
|
||||
|
||||
return jsonify({'success': True, 'messages': messages, 'count': len(messages)})
|
||||
note = None
|
||||
if not messages:
|
||||
note = "Chat messages are not available in this server version. The text-router pod does not expose chat logs via kubectl."
|
||||
|
||||
return jsonify({'success': True, 'messages': messages, 'count': len(messages), 'note': note})
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'error': str(e)})
|
||||
|
||||
|
||||
+12
-3
@@ -60,14 +60,23 @@ function formatTimestamp(ts) {
|
||||
return ts;
|
||||
}
|
||||
|
||||
function renderMessages(messages) {
|
||||
function renderMessages(messages, note) {
|
||||
const container = document.getElementById('chat-messages');
|
||||
const filter = document.getElementById('filter-channel').value;
|
||||
|
||||
const filtered = filter === 'all' ? messages : messages.filter(m => m.channel === filter);
|
||||
|
||||
if (filtered.length === 0) {
|
||||
container.innerHTML = '<div style="text-align:center;padding:40px;color:var(--text-muted);">No chat messages found</div>';
|
||||
let msg = 'No chat messages found.';
|
||||
if (note) {
|
||||
msg = `<div style="text-align:center;padding:40px;color:var(--text-muted);max-width:500px;margin:0 auto;">
|
||||
<p style="font-size:14px;margin-bottom:8px;">${note}</p>
|
||||
<p style="font-size:12px;color:var(--text-muted);">Chat parsing relies on text-router pod logs, which may not include chat in all server versions.</p>
|
||||
</div>`;
|
||||
} else {
|
||||
msg = '<div style="text-align:center;padding:40px;color:var(--text-muted);">No chat messages found</div>';
|
||||
}
|
||||
container.innerHTML = msg;
|
||||
container.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
@@ -107,7 +116,7 @@ async function loadChat() {
|
||||
const resp = await fetch('/api/chat_logs');
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
renderMessages(data.messages);
|
||||
renderMessages(data.messages, data.note);
|
||||
document.getElementById('last-updated').textContent = `Updated ${new Date().toLocaleTimeString()}`;
|
||||
} else {
|
||||
loading.textContent = 'Error: ' + (data.error || 'Failed to load chat logs');
|
||||
|
||||
Reference in new issue
Block a user