fix(dashboard): disable SSE in demo mode and remove unused hooks

- Skip SSE connection in demo mode (MSW doesn't support SSE).
- Remove unused `useProjectEvents` and related real-time hooks from `Dashboard`.
- Temporarily disable activity feed SSE until a global endpoint is available.
This commit is contained in:
2026-01-06 02:29:00 +01:00
parent 192237e69b
commit 70009676a3
2 changed files with 13 additions and 11 deletions

View File

@@ -31,8 +31,6 @@ import { PendingApprovals } from './PendingApprovals';
import { EmptyState } from './EmptyState';
import { useDashboard, type PendingApproval } from '@/lib/api/hooks/useDashboard';
import { useAuth } from '@/lib/auth/AuthContext';
import { useProjectEvents } from '@/lib/hooks/useProjectEvents';
import { useProjectEventsFromStore } from '@/lib/stores/eventStore';
export interface DashboardProps {
/** Additional CSS classes */
@@ -43,13 +41,6 @@ export function Dashboard({ className }: DashboardProps) {
const { user } = useAuth();
const { data, isLoading, error } = useDashboard();
// Real-time events - using a generic project ID for dashboard-wide events
// In production, this would be a dedicated dashboard events endpoint
const { connectionState } = useProjectEvents('dashboard', {
autoConnect: true,
});
const events = useProjectEventsFromStore('dashboard');
// Get user's first name for empty state
const firstName = user?.first_name || user?.email?.split('@')[0] || 'there';
@@ -108,11 +99,13 @@ export function Dashboard({ className }: DashboardProps) {
</div>
{/* Activity Feed Sidebar */}
{/* TODO: Enable when global activity SSE endpoint is implemented */}
{/* Currently disabled - there's no dashboard-wide SSE endpoint */}
<div className="hidden lg:block">
<Card className="sticky top-4">
<ActivityFeed
events={events}
connectionState={connectionState}
events={[]}
connectionState="disconnected"
isLoading={isLoading}
maxHeight={600}
showHeader

View File

@@ -247,6 +247,15 @@ export function useProjectEvents(
* Connect to SSE endpoint
*/
const connect = useCallback(() => {
// In frontend demo mode (MSW), SSE is not supported - skip connection
if (config.demo.enabled) {
if (config.debug.api) {
console.log('[SSE] Demo mode enabled - SSE connections disabled');
}
updateConnectionState('disconnected');
return;
}
// Prevent connection if not authenticated or no project ID
/* istanbul ignore next -- early return guard, tested via connection state */
if (!isAuthenticated || !accessToken || !projectId) {