-
Notifications
You must be signed in to change notification settings - Fork 1.9k
WIP: fix(tarko): prevent frequent session status API calls #1433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ulivz
wants to merge
9
commits into
main
Choose a base branch
from
fix/session-status-frequent-calls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−62
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for agent-tars-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Remove function dependencies from useEffect arrays that were causing infinite re-renders when creating/switching sessions: - Remove checkSessionStatus from useSession hook dependencies - Remove setActiveSession from SessionRouter dependencies - Fix memoization in useSession to prevent unnecessary re-renders
748f56a to
d75b74b
Compare
Previous commit incorrectly removed checkSessionStatus from the returned object, which would break API consumers. This commit restores it while keeping the dependency array fix.
Fixed frequent session status API calls by preventing multiple connection monitoring timers from being started. Used useRef to ensure initConnectionMonitoring is only called once, and separated session loading logic into its own effect.
…gistration Moved handleSessionStatusUpdate logic into useEffect to prevent frequent socket re-registration. The callback was recreated on every activeSessionId change, causing joinSession to be called repeatedly and triggering excessive session status API calls.
Only update connectionStatusAtom when connection status actually changes. The 30-second health check was updating the atom every time, causing all dependent useEffects to re-run and trigger frequent session status API calls.
Removed all manual session status API calls and rely entirely on socket events for status updates. This eliminates the root cause of frequent status API calls: - Removed checkSessionStatusAction - Removed manual status check in setActiveSessionAction - Removed periodic status check in useSession - Removed socket request-status emission Session status is now managed purely through real-time socket events.
Enhanced error handling when server goes down: - Added error state display in ChatInput with dismiss button - Improved session status error handling with connection updates - Restore user input on network errors for better UX - Clear error messages when user types or reconnects Now when server crashes during message sending: 1. User sees clear error message 2. Input content is restored automatically 3. Connection status updates appropriately 4. User can dismiss error and retry
Fixed critical bug where aborted sessions would show as processing after page refresh: - Restored checkSessionStatusAction for manual status checking - Added real status check in setActiveSessionAction on session switch - Removed forced isProcessing: false that overwrote real status - Keep socket events as primary status updates, manual check as fallback Now page refresh correctly shows real session status instead of wrong cached state.
Fixed critical issues in session status management: 1. Type Safety: - Fixed API response type mismatch in checkSessionStatusAction - Only use fields that API actually returns (isProcessing, state) - Preserve existing status fields when updating from API 2. Duplicate Event Handling: - Removed redundant global agent-status listener in useSession - Fixed socket listener cleanup in joinSession method - Added proper handler reference tracking for cleanup These fixes prevent runtime errors and ensure status updates are processed exactly once without conflicts.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Complete rewrite of session status management - eliminated all manual session status API calls and rely entirely on real-time socket events.
Root Cause
Multiple redundant session status checking mechanisms caused ~318 frequent API calls:
setActiveSessionActionuseSessionhookrequest-statusemission onjoinSessionconnectionStatusAtomupdates triggering re-rendersSolution
Simplified to socket-only status management:
checkSessionStatusActionentirelyuseSessionrequest-statusemissionResult: Session status API calls reduced from ~318 to zero manual calls - status updates only via socket events as intended.
Checklist