fix: Prevent undefined rendering in reasoning translations
Fixed React error #306 (text content mismatch) caused by undefined values in reasoning translations. Root cause: Translation functions could return undefined when: - Translation key doesn't exist - reasoning_data has unexpected structure - parameters are missing Changes: - Added defaultValue to all translation calls - Added || fallback operators to ensure strings are always returned - Added proper null/undefined checks with empty string fallbacks - Enhanced getInsightDescription with multiple fallback levels This ensures all translation functions return valid strings, preventing React hydration mismatches and rendering errors on the dashboard.
This commit is contained in:
@@ -137,13 +137,18 @@ const AIInsightsPage: React.FC = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
return t(`${category}.${insight.reasoning_data.type}`, insight.reasoning_data.parameters);
|
||||
const params = {
|
||||
...insight.reasoning_data.parameters,
|
||||
defaultValue: insight.description || `${category}: ${insight.reasoning_data.type}`
|
||||
};
|
||||
const translated = t(`${category}.${insight.reasoning_data.type}`, params);
|
||||
return translated || insight.description || `AI Insight: ${insight.reasoning_data.type}`;
|
||||
} catch (e) {
|
||||
// Fall back to description if translation key not found
|
||||
return insight.description;
|
||||
return insight.description || 'AI Insight';
|
||||
}
|
||||
}
|
||||
return insight.description;
|
||||
return insight.description || 'AI Insight';
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user