feat: AI auto-fix bug tracker with real-time error monitoring
- Real-time error monitoring system with WebSocket - Auto-fix agent that triggers on browser errors - Bug tracker dashboard with floating button (🐛) - Live activity stream showing AI thought process - Fixed 4 JavaScript errors (SyntaxError, TypeError) - Fixed SessionPicker API endpoint error - Enhanced chat input with Monaco editor - Session picker component for project management Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,9 +46,8 @@ function enhanceChatInput() {
|
||||
// Chat History & Session Management
|
||||
// ============================================
|
||||
|
||||
// Load chat history with sessions
|
||||
// loadChatHistory is now in chat-functions.js to avoid conflicts
|
||||
// This file only provides the enhanced features (animations, quick actions, etc.)
|
||||
// Auto-load chat history when page loads
|
||||
(async function loadChatHistoryOnLoad() {
|
||||
try {
|
||||
const res = await fetch('/claude/api/claude/sessions');
|
||||
const data = await res.json();
|
||||
@@ -63,7 +62,7 @@ function enhanceChatInput() {
|
||||
];
|
||||
|
||||
// Sort by creation date (newest first)
|
||||
allSessions.sort((a, b) => new Date(b.createdAt || b.created_at) - new Date(a.createdAt || b.created_at));
|
||||
allSessions.sort((a, b) => new Date(b.createdAt || b.created_at) - new Date(a.createdAt || a.created_at));
|
||||
|
||||
if (allSessions.length === 0) {
|
||||
historyList.innerHTML = '<div class="chat-history-empty">No chat history yet</div>';
|
||||
@@ -75,7 +74,7 @@ function enhanceChatInput() {
|
||||
session.project ||
|
||||
session.id.substring(0, 12) + '...';
|
||||
const date = new Date(session.createdAt || session.created_at).toLocaleDateString();
|
||||
const isActive = session.id === attachedSessionId;
|
||||
const isActive = session.id === (window.attachedSessionId || null);
|
||||
|
||||
return `
|
||||
<div class="chat-history-item ${isActive ? 'active' : ''} ${session.status === 'historical' ? 'historical' : ''}"
|
||||
@@ -98,16 +97,18 @@ function enhanceChatInput() {
|
||||
}).join('');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading chat history:', error);
|
||||
console.error('[loadChatHistoryOnLoad] Error loading chat history:', error);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
// Resume historical session
|
||||
async function resumeSession(sessionId) {
|
||||
console.log('Resuming historical session:', sessionId);
|
||||
|
||||
// Show loading message
|
||||
appendSystemMessage('📂 Loading historical session...');
|
||||
if (typeof appendSystemMessage === 'function') {
|
||||
appendSystemMessage('📂 Loading historical session...');
|
||||
}
|
||||
|
||||
try {
|
||||
// Load the historical session
|
||||
@@ -120,7 +121,9 @@ async function resumeSession(sessionId) {
|
||||
|
||||
// Handle 404 - session not found
|
||||
if (res.status === 404) {
|
||||
appendSystemMessage('❌ Session not found. It may have been deleted or the ID is incorrect.');
|
||||
if (typeof appendSystemMessage === 'function') {
|
||||
appendSystemMessage('❌ Session not found. It may have been deleted or the ID is incorrect.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,48 +142,63 @@ async function resumeSession(sessionId) {
|
||||
}
|
||||
|
||||
if (data.session) {
|
||||
attachedSessionId = sessionId;
|
||||
chatSessionId = sessionId;
|
||||
if (typeof attachToSession === 'function') {
|
||||
attachToSession(sessionId);
|
||||
}
|
||||
|
||||
// Update UI
|
||||
document.getElementById('current-session-id').textContent = sessionId;
|
||||
const sessionIdEl = document.getElementById('current-session-id');
|
||||
if (sessionIdEl) sessionIdEl.textContent = sessionId;
|
||||
|
||||
// Load session messages
|
||||
clearChatDisplay();
|
||||
if (typeof clearChatDisplay === 'function') {
|
||||
clearChatDisplay();
|
||||
}
|
||||
|
||||
// Add historical messages
|
||||
if (data.session.outputBuffer && data.session.outputBuffer.length > 0) {
|
||||
data.session.outputBuffer.forEach(entry => {
|
||||
appendMessage('assistant', entry.content, false);
|
||||
if (typeof appendMessage === 'function') {
|
||||
appendMessage('assistant', entry.content, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Show resume message
|
||||
const sessionDate = new Date(data.session.createdAt || data.session.created_at);
|
||||
appendSystemMessage('✅ Resumed historical session from ' + sessionDate.toLocaleString());
|
||||
|
||||
appendSystemMessage('ℹ️ This is a read-only historical session. Start a new chat to continue working.');
|
||||
if (typeof appendSystemMessage === 'function') {
|
||||
appendSystemMessage('✅ Resumed historical session from ' + sessionDate.toLocaleString());
|
||||
appendSystemMessage('ℹ️ This is a read-only historical session. Start a new chat to continue working.');
|
||||
}
|
||||
|
||||
// Update active state in sidebar
|
||||
loadChatHistory();
|
||||
if (typeof loadChatHistory === 'function') {
|
||||
loadChatHistory();
|
||||
}
|
||||
|
||||
// Subscribe to session (for any future updates)
|
||||
subscribeToSession(sessionId);
|
||||
if (typeof subscribeToSession === 'function') {
|
||||
subscribeToSession(sessionId);
|
||||
}
|
||||
} else {
|
||||
throw new Error('No session data in response');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error resuming session:', error);
|
||||
appendSystemMessage('❌ Failed to resume session: ' + error.message);
|
||||
if (typeof appendSystemMessage === 'function') {
|
||||
appendSystemMessage('❌ Failed to resume session: ' + error.message);
|
||||
|
||||
// Remove the loading message
|
||||
const messagesContainer = document.getElementById('chat-messages');
|
||||
const loadingMessages = messagesContainer.querySelectorAll('.chat-system');
|
||||
loadingMessages.forEach(msg => {
|
||||
if (msg.textContent.includes('Loading historical session')) {
|
||||
msg.remove();
|
||||
// Remove the loading message
|
||||
const messagesContainer = document.getElementById('chat-messages');
|
||||
if (messagesContainer) {
|
||||
const loadingMessages = messagesContainer.querySelectorAll('.chat-system');
|
||||
loadingMessages.forEach(msg => {
|
||||
if (msg.textContent.includes('Loading historical session')) {
|
||||
msg.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +237,9 @@ function appendMessageWithAnimation(role, content, animate = true) {
|
||||
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
||||
|
||||
// Update token usage
|
||||
updateTokenUsage(content.length);
|
||||
if (typeof updateTokenUsage === 'function') {
|
||||
updateTokenUsage(content.length);
|
||||
}
|
||||
}
|
||||
|
||||
// Strip dyad tags from message for display
|
||||
@@ -348,7 +368,11 @@ function executeQuickAction(action) {
|
||||
input.value = prompt;
|
||||
input.focus();
|
||||
// Auto-send after short delay
|
||||
setTimeout(() => sendChatMessage(), 300);
|
||||
setTimeout(() => {
|
||||
if (typeof sendChatMessage === 'function') {
|
||||
sendChatMessage();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,7 +395,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// Add our enhancements
|
||||
setTimeout(() => {
|
||||
enhanceChatInput();
|
||||
loadChatHistory();
|
||||
focusChatInput();
|
||||
|
||||
// Show quick actions on first load
|
||||
@@ -390,7 +413,6 @@ const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.target.id === 'chat-view' && mutation.target.classList.contains('active')) {
|
||||
enhanceChatInput();
|
||||
loadChatHistory();
|
||||
focusChatInput();
|
||||
}
|
||||
});
|
||||
@@ -414,9 +436,9 @@ if (document.readyState === 'loading') {
|
||||
// Export functions
|
||||
if (typeof window !== 'undefined') {
|
||||
window.resumeSession = resumeSession;
|
||||
window.loadChatHistory = loadChatHistory;
|
||||
window.executeQuickAction = executeQuickAction;
|
||||
window.showQuickActions = showQuickActions;
|
||||
window.enhanceChatInput = enhanceChatInput;
|
||||
window.focusChatInput = focusChatInput;
|
||||
window.appendMessageWithAnimation = appendMessageWithAnimation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user