Skip to content

Add routing for shared sessions and admin pages#64

Merged
JoshuaAFerguson merged 3 commits into
mainfrom
claude/add-admin-routing-012Ss1zqFKbpDuwF28ndTT1Y
Nov 17, 2025
Merged

Add routing for shared sessions and admin pages#64
JoshuaAFerguson merged 3 commits into
mainfrom
claude/add-admin-routing-012Ss1zqFKbpDuwF28ndTT1Y

Conversation

@JoshuaAFerguson

Copy link
Copy Markdown
Member

No description provided.

…rashes

Fixed critical issue where WebSocket event handlers were causing infinite
re-render loops, resulting in crashes on multiple pages including:
- /shared-sessions
- /plugins/catalog
- /admin/quotas
- /admin/plugins
- /admin/scaling

Changes:
1. useEnterpriseWebSocket.ts:
   - Modified useWebSocketEvent hook to use refs for handler storage
   - Prevents effect re-execution when handler function reference changes
   - Maintains same pattern as parent useEnterpriseWebSocket hook

2. SharedSessions.tsx:
   - Changed setSessions to use callback form
   - Removed 'sessions' from useCallback dependency array
   - Prevents WebSocket reconnection loop

Root cause: Handler functions were recreated on every render, triggering
the useEffect dependency array, causing state updates and re-renders in
an infinite loop.

Fixes WebSocket connection stability and page navigation crashes.
… refresh impact

Replaced aggressive reconnection strategy with gradual backoff pattern to
prevent constant UI refreshes when WebSocket connections fail.

New backoff pattern:
- 1st retry: 30 seconds after initial connection failure
- 2nd retry: 15 seconds after 1st retry (45s total)
- 3rd retry: 15 seconds after 2nd retry (60s total)
- 4th+ retries: 60 seconds for all subsequent attempts

Changes:
1. useEnterpriseWebSocket.ts:
   - Added getReconnectDelay() function with custom backoff logic
   - Replaced fixed 3s interval with delay calculation
   - Removed reconnectInterval from connect() dependencies
   - Added console logging for better reconnection visibility

2. useWebSocket.ts:
   - Added same getReconnectDelay() function
   - Replaced exponential backoff with custom pattern
   - Removed reconnectInterval from connect() dependencies
   - Standardized console logging format

Benefits:
- Reduces UI churn from frequent reconnection attempts
- Gives backend/network time to recover before retrying
- Maintains connection resilience with eventual 60s steady-state
- Provides clear visibility into reconnection timing via console

This prevents the UI refresh issues caused by rapid reconnection attempts
while maintaining reliable WebSocket connectivity.
…ays across navigation

Fixed issue where users were re-prompted about WebSocket errors after navigating
between pages. The dismissed state now persists across page navigation using
localStorage.

Changes:
1. WebSocketErrorBoundary.tsx:
   - Added WS_ERROR_DISMISSED_KEY constant for localStorage key
   - Initialize dismissed state from localStorage in constructor
   - Persist dismissed state to localStorage when user clicks "Continue Without Live Updates"
   - Prevents re-prompting on every page navigation

2. EnhancedWebSocketStatus.tsx:
   - Updated getReconnectDelay() to match WebSocket hook pattern
   - Changed from exponential backoff (2^n) to custom pattern: 30s, 15s, 15s, 60s
   - Ensures UI countdown matches actual reconnection timing
   - Provides consistent UX across WebSocket status indicator and actual reconnections

Benefits:
- User only needs to dismiss WebSocket error dialog once per session
- Dismissed state persists across all page navigations
- UI countdown accurately reflects actual reconnection attempts
- Consistent reconnection timing throughout the application

This improves UX by not repeatedly interrupting the user with the same
error dialog as they navigate between pages.
@JoshuaAFerguson JoshuaAFerguson merged commit 357c766 into main Nov 17, 2025
8 of 23 checks passed
@JoshuaAFerguson JoshuaAFerguson deleted the claude/add-admin-routing-012Ss1zqFKbpDuwF28ndTT1Y branch November 17, 2025 18:08
onOpen,
autoReconnect = true,
reconnectInterval = 3000,
reconnectInterval = 3000, // Not used with custom backoff

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable reconnectInterval.

Copilot Autofix

AI 7 months ago

To fix the problem, remove the reconnectInterval variable from the destructured assignment in the useEnterpriseWebSocket options (lines 37-45). No other references or usages exist, so no other code changes are needed. The related comment ("// Not used with custom backoff") may also be safely removed, as it becomes irrelevant once the variable is gone. Ensure that surrounding commas and code remain syntactically correct after the removal.


Suggested changeset 1
ui/src/hooks/useEnterpriseWebSocket.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ui/src/hooks/useEnterpriseWebSocket.ts b/ui/src/hooks/useEnterpriseWebSocket.ts
--- a/ui/src/hooks/useEnterpriseWebSocket.ts
+++ b/ui/src/hooks/useEnterpriseWebSocket.ts
@@ -40,7 +40,6 @@
     onClose,
     onOpen,
     autoReconnect = true,
-    reconnectInterval = 3000, // Not used with custom backoff
     maxReconnectAttempts = 10,
   } = options;
 
EOF
@@ -40,7 +40,6 @@
onClose,
onOpen,
autoReconnect = true,
reconnectInterval = 3000, // Not used with custom backoff
maxReconnectAttempts = 10,
} = options;

Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants