davila7/claude-code-templates · warning

Could not load conversation states:

Error message

Could not load conversation states:

What it means

The mobile chats analytics page fetches conversation states from a backend endpoint and, when the HTTP response is not ok (non-2xx status), logs this warning with the response status. The page still renders conversations, just without live state data (states stays an empty object).

Solutions

  1. Check the logged HTTP status: 401/403 means re-authenticate; 404 means the states endpoint isn't deployed at the expected URL
  2. Open the states endpoint URL directly in a browser/network tab to see the raw response
  3. Verify the backend/analytics server is running and serving the states route
  4. If the error is transient (502/503), retry or restart the backend service
Defensive patterns

Strategy: fallback

Validate before calling

const res = await fetch(statesUrl, { headers: { Authorization: `Bearer ${token}` } });
if (!res.ok) {
  // proceed with empty states rather than breaking rendering
  renderConversations(conversations, {});
  return;
}

Type guard

const isStatesPayload = (d) =>
  d !== null && typeof d === 'object' && typeof d.activeStates === 'object';

Try / catch

try {
  const r = await fetch(statesUrl);
  if (!r.ok) { console.warn('states unavailable', r.status); }
} catch (e) {
  console.warn('network error fetching states', e);
} finally {
  this.renderConversations(this.conversations, states); // always render
}

Prevention

When it happens

Trigger: A GET to the conversation-states endpoint returning 404 (endpoint not deployed), 401/403 (expired or missing auth token), 500 (server error), or the API being down/unreachable while the static page itself loads fine.

Common situations: Analytics dashboard opened with an expired session token; the states API route missing from the deployment; reverse proxy returning 502; CORS/network issues manifesting as non-ok responses; pointing the page at an environment where the endpoint is disabled.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/cd24050ebd0926d1. Report an issue: GitHub.

Appendix: source

Thrown at cli-tool/src/analytics-web/chats_mobile.html:2779

                        fetch('/api/conversations'),
                        fetch('/api/conversation-state') // Use singular like AgentsPage.js
                    ]);
                    
                    if (!conversationsResponse.ok) {
                        throw new Error(`HTTP error! status: ${conversationsResponse.status}`);
                    }
                    
                    const conversationsData = await conversationsResponse.json();
                    this.conversations = conversationsData.conversations || [];
                    
                    // Get conversation states (like AgentsPage.js)
                    let states = {};
                    if (statesResponse.ok) {
                        const statesData = await statesResponse.json();
                        states = statesData.activeStates || {};
                        console.log('📊 Loaded conversation states:', Object.keys(states).length, 'conversations');
                    } else {
                        console.warn('Could not load conversation states:', statesResponse.status);
                    }
                    
                    this.renderConversations(this.conversations, states);
                    
                } catch (error) {
                    console.error('Error loading conversations:', error);
                    conversationsList.innerHTML = `
                        <div class="no-conversations">
                            <div class="no-conversations-icon">⚠️</div>
                            <h3>Error loading conversations</h3>
                            <p>${escapeHtml(error.message)}</p>
                            <button onclick="location.reload()" style="margin-top: 12px; padding: 8px 16px; background: var(--text-accent); color: white; border: none; border-radius: 4px; cursor: pointer;">Retry</button>
                        </div>
                    `;
                }
            }

            renderConversations(conversations, states = {}) {

View on GitHub (pinned to a0851ed10c)