@@ -1034,6 +1034,10 @@ class PhotoReasoningViewModel(
10341034 screenInfoForPrompt : String? = null,
10351035 imageUrisForChat : List <String >? = null
10361036 ) {
1037+ Log .d(
1038+ TAG ,
1039+ " reasonWithMistral: start, images=${selectedImages.size} , screenInfo=${! screenInfoForPrompt.isNullOrBlank()} , chatSize=${_chatState .getAllMessages().size} "
1040+ )
10371041 _uiState .value = PhotoReasoningUiState .Loading
10381042 _showStopNotificationFlow .value = true
10391043 val context = appContext
@@ -1062,6 +1066,7 @@ class PhotoReasoningViewModel(
10621066 currentReasoningJob?.cancel()
10631067 currentReasoningJob = viewModelScope.launch(Dispatchers .IO ) {
10641068 try {
1069+ Log .d(TAG , " reasonWithMistral: launched IO job" )
10651070 val currentModel = com.google.ai.sample.GenerativeAiViewModelFactory .getCurrentModel()
10661071 val genSettings = com.google.ai.sample.util.GenerationSettingsPreferences .loadSettings(context, currentModel.modelName)
10671072
@@ -1132,6 +1137,7 @@ class PhotoReasoningViewModel(
11321137 val availableKeys = apiKeyManager.getApiKeys(ApiProvider .MISTRAL )
11331138 .filter { it.isNotBlank() }
11341139 .distinct()
1140+ Log .d(TAG , " reasonWithMistral: availableKeys=${availableKeys.size} " )
11351141 if (availableKeys.isEmpty()) {
11361142 throw IOException (" Mistral API key not found." )
11371143 }
@@ -1149,6 +1155,7 @@ class PhotoReasoningViewModel(
11491155 client.newCall(buildRequest(selectedKey)).execute()
11501156 }
11511157 val finalResponse = coordinated.response
1158+ Log .d(TAG , " reasonWithMistral: coordinated response code=${finalResponse.code} " )
11521159
11531160 if (! finalResponse.isSuccessful) {
11541161 val errBody = finalResponse.body?.string()
@@ -1163,6 +1170,7 @@ class PhotoReasoningViewModel(
11631170 processCommandsIncrementally(accText)
11641171 }
11651172 }
1173+ Log .d(TAG , " reasonWithMistral: stream parse finished, responseLength=${aiResponseText.length} " )
11661174 finalResponse.close()
11671175
11681176 withContext(Dispatchers .Main ) {
@@ -1181,6 +1189,7 @@ class PhotoReasoningViewModel(
11811189 }
11821190 } finally {
11831191 withContext(Dispatchers .Main ) {
1192+ Log .d(TAG , " reasonWithMistral: finally, draining queued auto-screenshot requests" )
11841193 releaseAndDrainMistralAutoScreenshotQueue()
11851194 refreshStopButtonState()
11861195 }
@@ -2332,9 +2341,10 @@ private fun processCommands(text: String) {
23322341 synchronized(mistralAutoScreenshotQueueLock) {
23332342 if (mistralAutoScreenshotInFlight) {
23342343 queuedMistralScreenshotRequest = request
2335- Log .d(TAG , " Mistral auto screenshot request queued (latest wins)." )
2344+ Log .d(TAG , " Mistral auto screenshot request queued (latest wins). uri= $screenshotUri " )
23362345 } else {
23372346 mistralAutoScreenshotInFlight = true
2347+ Log .d(TAG , " Mistral auto screenshot request becomes in-flight. uri=$screenshotUri " )
23382348 shouldStartNow = true
23392349 }
23402350 }
@@ -2344,6 +2354,7 @@ private fun processCommands(text: String) {
23442354 }
23452355
23462356 private fun dispatchMistralAutoScreenshotRequest (request : QueuedMistralScreenshotRequest ) {
2357+ Log .d(TAG , " Dispatching Mistral auto screenshot request. uri=${request.screenshotUri} " )
23472358 reason(
23482359 userInput = createGenericScreenshotPrompt(),
23492360 selectedImages = listOf (request.bitmap),
@@ -2357,9 +2368,11 @@ private fun processCommands(text: String) {
23572368 val queued = queuedMistralScreenshotRequest
23582369 if (queued == null ) {
23592370 mistralAutoScreenshotInFlight = false
2371+ Log .d(TAG , " Mistral auto screenshot queue drained completely. inFlight=false" )
23602372 null
23612373 } else {
23622374 queuedMistralScreenshotRequest = null
2375+ Log .d(TAG , " Mistral auto screenshot queue has pending request to drain." )
23632376 queued
23642377 }
23652378 }
0 commit comments