Commit ac81192b authored by David Black's avatar David Black Committed by Commit Bot

Handle Assistant interactions ending in error.

Already we are handling interactions that end in error if they contain
TTS. As it turns out, these interactions do not always include TTS
so we need to handle this case as well to show a message to the user.

Bug: b:116786185
Change-Id: Ic1b281c5d84f4cc2d955e01e31ffe3218cc82503
Reviewed-on: https://chromium-review.googlesource.com/1249077
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595640}
parent f0a4d384
...@@ -272,22 +272,43 @@ void AssistantInteractionController::OnInteractionFinished( ...@@ -272,22 +272,43 @@ void AssistantInteractionController::OnInteractionFinished(
// device hotword loss, for example, but can also occur if the interaction // device hotword loss, for example, but can also occur if the interaction
// errors out. In these cases we still need to commit the pending query as // errors out. In these cases we still need to commit the pending query as
// this is a prerequisite step to being able to finalize the pending response. // this is a prerequisite step to being able to finalize the pending response.
if (model_.pending_query().type() != AssistantQueryType::kNull) { if (model_.pending_query().type() != AssistantQueryType::kNull)
model_.CommitPendingQuery(); model_.CommitPendingQuery();
}
// If the interaction was finished due to multi-device hotword loss, we want // It's possible that the pending response has already been finalized. This
// to show an appropriate message to the user. // occurs if the response contained TTS, as we flush the response to the UI
if (resolution == AssistantInteractionResolution::kMultiDeviceHotwordLoss) { // when TTS is started to reduce latency.
model_.pending_response()->AddUiElement( if (!model_.pending_response())
std::make_unique<AssistantTextElement>(l10n_util::GetStringUTF8( return;
IDS_ASH_ASSISTANT_MULTI_DEVICE_HOTWORD_LOSS)));
// Some interaction resolutions require special handling.
switch (resolution) {
case AssistantInteractionResolution::kError:
// In the case of error, we show an appropriate message to the user.
model_.pending_response()->AddUiElement(
std::make_unique<AssistantTextElement>(
l10n_util::GetStringUTF8(IDS_ASH_ASSISTANT_ERROR_GENERIC)));
break;
case AssistantInteractionResolution::kMultiDeviceHotwordLoss:
// In the case of hotword loss to another device, we show an appropriate
// message to the user.
model_.pending_response()->AddUiElement(
std::make_unique<AssistantTextElement>(l10n_util::GetStringUTF8(
IDS_ASH_ASSISTANT_MULTI_DEVICE_HOTWORD_LOSS)));
break;
case AssistantInteractionResolution::kMicTimeout:
// Interactions resolving due to mic timeout are already handled above
// outside the switch.
NOTREACHED();
break;
case AssistantInteractionResolution::kInterruption: // fallthrough
case AssistantInteractionResolution::kNormal:
// No special handling required.
break;
} }
// The interaction has finished, so we finalize the pending response if it // Finalize the pending response to flush it to the UI.
// hasn't already been finalized. model_.FinalizePendingResponse();
if (model_.pending_response())
model_.FinalizePendingResponse();
} }
void AssistantInteractionController::OnHtmlResponse( void AssistantInteractionController::OnHtmlResponse(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment