davila7/claude-code-templates · warning
Could not find message with ID
Error message
Could not find message with ID
What it means
scrollToMessageById retries finding a DOM element with the given message ID, waiting 500ms per attempt (e.g. for lazy-loaded messages to render). After exhausting attempts with no matching element and nothing left to load, it warns and breaks out of the loop — the scroll simply never happens.
Source
Thrown at cli-tool/src/analytics-web/chats_mobile.html:4118
if (messageElement) {
// Found the message!
this.scrollToMessage(messageElement);
this.highlightCurrentMatchById(messageId);
return;
}
// Try to load more messages
if (this.messagesPagination.hasMore && !this.messagesPagination.isLoading) {
console.log(`🔄 Loading more messages to find message ${messageId}...`);
await this.loadMoreMessages(this.selectedConversationId, false);
attempts++;
// Wait a bit for messages to render
await new Promise(resolve => setTimeout(resolve, 500));
} else {
// No more messages to load or already loading
console.warn('Could not find message with ID', messageId, 'after', attempts, 'attempts');
break;
}
}
}
scrollToMessage(messageElement) {
if (!messageElement) {
console.warn('No message element to scroll to');
return;
}
const messagesContainer = document.getElementById('chatMessages');
if (!messagesContainer) return;
// Get the absolute position of the message within the scrollable container
const containerTop = messagesContainer.getBoundingClientRect().top;
const messageTop = messageElement.getBoundingClientRect().top;
const containerHeight = messagesContainer.clientHeight;View on GitHub (pinned to a0851ed10c)
Solutions
- Verify the message ID actually exists in the conversation data returned by the API
- Check how message elements get their DOM id and confirm it matches the ID you pass (no prefix/suffix mismatch)
- Increase the attempts/timeout or trigger loading older messages before scrolling
- Handle the failure gracefully — show a 'message not found' notice instead of silently not scrolling
Example fix
// before
scrollToMessageById('msg_123'); // warns if never rendered
// after
const el = document.querySelector('[data-message-id="msg_123"]');
if (el) {
scrollToMessage(el);
} else {
showNotice('Message not found in this conversation');
} Defensive patterns
Strategy: retry
Validate before calling
const exists = this.conversations.some(c =>
c.messages?.some(m => m.id === messageId));
if (!exists) { showNotice('Message not found'); return; } Type guard
const isMessageElement = (el) => el instanceof HTMLElement && el.dataset.messageId != null;
Try / catch
try { await scrollToMessageById(id); } catch { showNotice('Could not locate that message'); } Prevention
- Validate the message ID against loaded data before attempting to scroll
- Use consistent ID formatting between API data and DOM element attributes
- Bound the retry loop and surface a user-visible message when it gives up
When it happens
Trigger: Calling scrollToMessageById with a message ID that doesn't exist in the loaded conversation (stale deep-link, deleted message), or when lazy loading finished but the target message was never rendered (filtered out, pagination limit, or DOM id mismatch between the API's message ID and the rendered element's id attribute).
Common situations: Deep links/URLs to old messages that were deleted; message IDs from an export that differ from runtime DOM ids; very long conversations where the target is beyond the lazy-load window; UI filters hiding the target message.
Related errors
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/3121a8b4047800fa.
Report an issue: GitHub.