fix(agent): force clearing focus on a tap in the Agent conversation (#2769)

A tap on the conversation while the composer held focus could crash the app:
FocusManager.clearFocus() without force walks the focused chain for a custom
exit and throws IllegalArgumentException ("ActiveParent with no focused
child") when a parent is ActiveParent with no active child. The forced path
skips that walk and treats a missing child as cleared. Nothing in the Agent UI
sets a custom focus exit, so forcing changes no behaviour.

Co-authored-by: Jan Pokorny <4580066+JanPokorny@users.noreply.github.com>
This commit is contained in:
Jan PokornýandJan Pokorny authored and GitHub committed 2026-11-18 00:25:36 -05:00
1 parent c7cd2b55af
commit 8faaac3b89
1 file changed
+2 -1
@@ -292,7 +292,8 @@ private fun AgentPageContent(
awaitEachGesture {
awaitFirstDown(requireUnconsumed = false, pass = PointerEventPass.Initial)
if (panel == AgentPanel.MODEL || panel == AgentPanel.USAGE) panel = AgentPanel.NONE
if (composer.focused) focusManager.clearFocus()
// Forced: the unforced path walks the focus chain and throws ("ActiveParent with no focused child") when a tap lands while focus is moving.
if (composer.focused) focusManager.clearFocus(force = true)
}
},
list, following = !readingBack, onRevise = { composer.open() }, onSent = toLatest,