From cc56b8fadf33c73e08eb58eb90eb6e633f37ee43 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 1 Jan 2026 08:51:49 -0800 Subject: [PATCH] fix(android): fetch session status after creation to show all participants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add getPartyId() method to TssRepository - Call getSessionStatus after createKeygenSession to fetch all participants including server-party-co-managed that have already auto-joined - This matches Electron's behavior of calling getSessionStatus on session page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../tssparty/data/repository/TssRepository.kt | 5 ++++ .../presentation/viewmodel/MainViewModel.kt | 28 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt index 47ab8fe7..7ca2fb0c 100644 --- a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt +++ b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt @@ -46,6 +46,11 @@ class TssRepository @Inject constructor( private var messageCollectionJob: Job? = null private var sessionEventJob: Job? = null + /** + * Get the current party ID + */ + fun getPartyId(): String = partyId + // Track current message routing params for reconnection recovery private var currentMessageRoutingSessionId: String? = null private var currentMessageRoutingPartyIndex: Int? = null diff --git a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt index d8beb014..189cce95 100644 --- a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt +++ b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt @@ -235,13 +235,35 @@ class MainViewModel @Inject constructor( onSuccess = { sessionResult -> _createdInviteCode.value = sessionResult.inviteCode _currentSessionId.value = sessionResult.sessionId - // Add self as first participant - _sessionParticipants.value = listOf(participantName) // Store party index for later use _currentRound.value = 0 - _uiState.update { it.copy(isLoading = false) } android.util.Log.d("MainViewModel", "Keygen session created: sessionId=${sessionResult.sessionId}, partyIndex=${sessionResult.partyIndex}") + + // Fetch current session status to get all participants (including server-party-co-managed) + // This matches Electron's behavior of calling getSessionStatus after session creation + val statusResult = repository.getSessionStatus(sessionResult.sessionId) + statusResult.fold( + onSuccess = { status -> + val participantNames = status.participants.mapIndexed { index, p -> + if (p.partyId == repository.getPartyId()) { + participantName // Use the name provided by user for self + } else { + "参与方 ${index + 1}" // Generic name for others + } + } + _sessionParticipants.value = participantNames + android.util.Log.d("MainViewModel", "Session status fetched: ${status.participants.size} participants already joined") + android.util.Log.d("MainViewModel", " Participants: ${status.participants.map { it.partyId }}") + }, + onFailure = { e -> + // Fallback to just self if status fetch fails + _sessionParticipants.value = listOf(participantName) + android.util.Log.w("MainViewModel", "Failed to fetch session status: ${e.message}, using self only") + } + ) + + _uiState.update { it.copy(isLoading = false) } }, onFailure = { e -> _uiState.update { it.copy(isLoading = false, error = e.message) }