davila7/claude-code-templates · warning
Error calculating state for conversation ${conversation.id}:
Error message
Error calculating state for conversation ${conversation.id}: What it means
An HTTP route handler in chats-mobile.js computes a per-conversation active state and caught an error for one conversation, defaulting it to 'Inactive'. Caused by a per-item helper (getState-like function taking lastModified/process info) throwing.
Source
Thrown at cli-tool/src/chats-mobile.js:165
try {
// Calculate states for ALL conversations using StateCalculator
const activeStates = {};
for (const conversation of this.data.conversations) {
try {
// Get parsed messages for state calculation
const parsedMessages = await this.conversationAnalyzer.getParsedConversation(conversation.filePath);
// Use StateCalculator to determine current state
const state = this.stateCalculator.determineConversationState(
parsedMessages,
conversation.lastModified,
null // No running process detection for now
);
activeStates[conversation.id] = state;
} catch (error) {
console.warn(`Error calculating state for conversation ${conversation.id}:`, error.message);
activeStates[conversation.id] = 'Inactive';
}
}
res.json({
activeStates,
timestamp: new Date().toISOString(),
totalConversations: this.data.conversations.length
});
} catch (error) {
console.error('Error calculating conversation states:', error);
res.status(500).json({ error: 'Internal server error' });
}
});
// API to get unique working directories from conversations
this.app.get('/api/directories', (req, res) => {
try {View on GitHub (pinned to a0851ed10c)
Solutions
- Ignore — that conversation shows as Inactive; others are correct
- Check the conversation file named by its id for missing/odd mtime
- Update the CLI where mtime handling was hardened
- If persistent for all conversations, inspect the server console for the underlying message
Defensive patterns
Strategy: try-catch
Validate before calling
// Sanitize inputs to the state computation const lm = Number.isFinite(conversation.lastModified) ? conversation.lastModified : 0; const state = computeState(lm, null);
Type guard
function hasValidTimestamp(c) {
return !!c && Number.isFinite(c.lastModified) && c.lastModified > 0;
} Try / catch
try { activeStates[id] = computeState(c.lastModified, null); }
catch (error) {
console.warn(`Error calculating state for ${c.id}:`, error.message);
activeStates[id] = 'Inactive'; // safe default per conversation
} Prevention
- Default missing timestamps to 0/epoch before date math
- Never let one bad conversation fail the whole active-states response
- Log conversation ids so bad files are traceable
When it happens
Trigger: GET on the mobile chats active-states endpoint where computing state for one conversation throws — e.g. invalid lastModified (NaN/undefined date) passed into date math.
Common situations: A conversation file with missing/zero mtime; mixed data where lastModified is undefined; schema drift after CLI update.
Related errors
- Internal server error
- Conversation not found
- Failed to export session
- Warning: Could not extract project from conversation ${fileP
- Warning: Could not read settings.json for project ${projectD
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/a1ca53068d5482db.
Report an issue: GitHub.