fix(android): clear pendingSessionId in resetSessionStatus to fix stale session matching

The resetSessionStatus() function was not clearing pendingSessionId,
causing events from new sessions to be ignored because pendingSessionId
still held the old session ID.

Added:
- Clear pendingSessionId = null in resetSessionStatus()
- Clear _currentSession.value = null in resetSessionStatus()
- Added debug logging for session state clearing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-01 21:11:24 -08:00
parent e865153e8e
commit ecd7a2a2dc
2 changed files with 11 additions and 1 deletions

View File

@ -555,7 +555,8 @@
"Bash(adb devices:*)",
"Bash(adb logcat:*)",
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat\\(android\\): add 5-minute polling timeout mechanism for keygen/sign\n\nImplements Electron''s checkAndTriggerKeygen\\(\\) polling fallback:\n- Adds polling every 2 seconds with 5-minute timeout\n- Triggers keygen/sign via synthetic session_started event on in_progress status\n- Handles gRPC stream disconnection when app goes to background\n- Shows timeout error in UI via existing error mechanism\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
"Bash(go list:*)"
"Bash(go list:*)",
"Bash(adb install:*)"
],
"deny": [],
"ask": []

View File

@ -1832,8 +1832,17 @@ class TssRepository @Inject constructor(
* Called when navigating away from session screens to ensure fresh state
*/
fun resetSessionStatus() {
android.util.Log.d("TssRepository", "resetSessionStatus called - clearing session state")
_sessionStatus.value = SessionStatus.WAITING
stopSessionStatusPolling() // Stop polling when resetting session state
// CRITICAL: Clear pending session ID to avoid stale session matching
// Without this, events from new sessions would be ignored because
// pendingSessionId still holds the old session ID
pendingSessionId = null
_currentSession.value = null
android.util.Log.d("TssRepository", "Session state cleared: pendingSessionId=null, currentSession=null")
}
/**