onUserInteraction method
A real person touched the app (RN / Android onUserInteraction): the
running mission or highlight is aborted and reports cancelled with
failure_reason: "user_interrupted", and — when something was
interrupted or the agent's UI was on screen (agentUiVisible) — the
backend gets a user_interaction frame, at most one per
kUserInteractionThrottle. A touch while the agent is idle and nothing
is on screen does nothing. Returns true when the touch interrupted
something or found the agent's UI on screen.
Implementation
bool onUserInteraction(bool agentUiVisible, {DateTime? now}) {
final loop = _voiceLoop;
final interrupted = loop?.interruptActive(kUserInterruptedReason);
if (interrupted == null && !agentUiVisible) return false;
if (loop != null) {
final at = now ?? DateTime.now();
final last = _lastInteractionSentAt;
if (last == null || at.difference(last) >= kUserInteractionThrottle) {
_lastInteractionSentAt = at;
loop.sendWire(userInteractionMessage(interrupted ?? loop.lastMissionId));
}
}
return true;
}