Stop the terminal's accessory keys taking the keyboard off it
ci / build and test (push) Canceled after 0s
ci / android head (push) Canceled after 0s
ci / api image (push) Canceled after 0s

Ctrl, Esc, Tab, the arrows and the two text-size keys were ordinary Avalonia
buttons sitting over a NativeWebView. An ordinary button takes focus on tap,
which takes it off the WebView — and the package's own OnLostFocus then calls the
adapter's ResignFocus(). So pressing Tab handed the terminal one byte and took
the keyboard away from it, and everything typed afterwards went nowhere.

What makes it worth more than a one-line fix is the symptom. The row goes on
working, because its keys are pressed rather than typed into, so what you see is
a terminal that answers the buttons and ignores the keyboard — which reads as the
session having died rather than as anything to do with focus.

Focusable = false is what a toolbar button is: these keys are an extension of the
keyboard, not a place it should go. The focused element then never changes, so
nothing resigns and nothing has to be handed back — which matters, because the
hand-back is the direction platform-flags already records as the hard one.

The flags file gains the phone's half of that entry, and check 11.10 is the
measurement: this needs a paired hardware keyboard and there is no test on this
head that could stand in for one.
This commit is contained in:
2026-08-05 12:45:17 +02:00
parent 1bcf422bbe
commit 23f1db9dc8
4 changed files with 50 additions and 2 deletions
+17
View File
@@ -1334,6 +1334,23 @@ by gesture or by the arrow, returns to Settings and not to HOSTS; a second back
**Failure means:** `ShellScreen.Vault` is missing from `IsMoreSurface` or from the back gesture's first **Failure means:** `ShellScreen.Vault` is missing from `IsMoreSurface` or from the back gesture's first
case, and those two have to move together — the switch mirrors that property by construction. case, and those two have to move together — the switch mirrors that property by construction.
### 11.10 The accessory keys do not cost the terminal its keyboard · **needs a hardware keyboard**
With a shell open and a Bluetooth or USB keyboard paired, type into the terminal and confirm it arrives.
Now tap **Tab** on the accessory row, or **A+**, and type again.
**Pass:** the byte the key sent arrives, and so does everything typed after it. The terminal still has the
keyboard.
**Failure means:** the buttons on that row have become focusable again. An ordinary Avalonia button takes
focus on tap, which takes it off the `NativeWebView` — and the package's own `OnLostFocus` then resigns the
page's focus. The row goes on working, because its keys are pressed rather than typed into, so the symptom
is a terminal that answers the buttons and ignores the keyboard: it reads as the session having died. See
`Focusable = false` in `TerminalScreen.axaml.cs` and the focus entry in `docs/platform-flags.md`.
Worth doing on the software keyboard too, where the same fault shows as the keyboard closing on the first
tap of an arrow key.
--- ---
## Phase 12 — Shared vaults: the operations that span two accounts ## Phase 12 — Shared vaults: the operations that span two accounts
+12
View File
@@ -168,6 +168,18 @@ that reports `GetFocus()`, the class name of the window holding it, and the page
could fire. Not Escape, and not a bare F6: both are keys a TUI legitimately binds, and Ctrl+Shift is the could fire. Not Escape, and not a bare F6: both are keys a TUI legitimately binds, and Ctrl+Shift is the
range terminal emulators conventionally keep for themselves. range terminal emulators conventionally keep for themselves.
**On the phone the same asymmetry arrives through a button, and the fix is one property.** The terminal's
accessory row — Ctrl, Esc, Tab, the arrows, and the two text-size keys — is a set of ordinary Avalonia
buttons over a `NativeWebView`. An ordinary button takes focus on tap, which takes it off the WebView, and
`OnLostFocus` then calls the adapter's `ResignFocus()`. So pressing Tab handed the terminal one byte and
took the keyboard away from it: everything typed afterwards on a hardware keyboard went nowhere.
The symptom is what makes it worth an entry. The row goes on working — its keys are *pressed* rather than
typed into — so what a user sees is a terminal that answers the buttons and ignores the keyboard, which
reads as the session having died rather than as a focus problem. `Focusable = false` is what a toolbar
button is, and it means the focused element never changes, so nothing resigns and nothing has to be handed
back. Every button on that row carries it; check 11.10 is the measurement.
None of this is covered by a test, and cannot be here: headless Avalonia has no native window, so a None of this is covered by a test, and cannot be here: headless Avalonia has no native window, so a
headless test renders and focuses correctly and would confirm the wrong belief. What the suite covers is headless test renders and focuses correctly and would confirm the wrong belief. What the suite covers is
the plumbing that drives it — that connecting asks for focus once per session, that a failed connect does the plumbing that drives it — that connecting asks for focus once per session, that a failed connect does
@@ -347,6 +347,11 @@
Disabled at the ends rather than clamping silently. A button that keeps accepting taps and does Disabled at the ends rather than clamping silently. A button that keeps accepting taps and does
nothing reads as the terminal having stopped responding, which is the one thing this screen must nothing reads as the terminal having stopped responding, which is the one thing this screen must
never look like. never look like.
◆ Focusable="False", for the reason the accessory keys carry in code — see
TerminalScreen.axaml.cs. Every button on this row sits over a terminal somebody is typing into,
and an ordinary one takes Avalonia's focus off the NativeWebView on tap, which makes the package
resign the page's focus. Making the text smaller must not cost the keyboard.
--> -->
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="5" Margin="8,0,12,0" <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="5" Margin="8,0,12,0"
VerticalAlignment="Center"> VerticalAlignment="Center">
@@ -356,7 +361,7 @@
<Button Classes="row" MinHeight="30" Height="30" MinWidth="40" Padding="0" CornerRadius="9" <Button Classes="row" MinHeight="30" Height="30" MinWidth="40" Padding="0" CornerRadius="9"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Background="{StaticResource Panel}" BorderBrush="{StaticResource BorderMid}" Background="{StaticResource Panel}" BorderBrush="{StaticResource BorderMid}"
BorderThickness="1" BorderThickness="1" Focusable="False"
Command="{Binding ShrinkTerminalFontCommand}" Command="{Binding ShrinkTerminalFontCommand}"
IsEnabled="{Binding CanShrinkTerminalFont}"> IsEnabled="{Binding CanShrinkTerminalFont}">
<TextBlock Classes="mono" FontSize="13" Text="A" /> <TextBlock Classes="mono" FontSize="13" Text="A" />
@@ -365,7 +370,7 @@
<Button Classes="row" MinHeight="30" Height="30" MinWidth="40" Padding="0" CornerRadius="9" <Button Classes="row" MinHeight="30" Height="30" MinWidth="40" Padding="0" CornerRadius="9"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Background="{StaticResource Panel}" BorderBrush="{StaticResource BorderMid}" Background="{StaticResource Panel}" BorderBrush="{StaticResource BorderMid}"
BorderThickness="1" BorderThickness="1" Focusable="False"
Command="{Binding EnlargeTerminalFontCommand}" Command="{Binding EnlargeTerminalFontCommand}"
IsEnabled="{Binding CanEnlargeTerminalFont}"> IsEnabled="{Binding CanEnlargeTerminalFont}">
<TextBlock Classes="mono" FontSize="15" Text="A+" /> <TextBlock Classes="mono" FontSize="15" Text="A+" />
@@ -166,6 +166,20 @@ internal sealed partial class TerminalScreen : UserControl
BorderThickness = new Thickness(1), BorderThickness = new Thickness(1),
Foreground = Palette("TextDim"), Foreground = Palette("TextDim"),
HorizontalContentAlignment = HorizontalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center,
// ◆ NOT FOCUSABLE, AND THAT IS THE WHOLE CONTROL RATHER THAN A DETAIL.
//
// These keys are an extension of the keyboard, not a place the keyboard should go. As
// ordinary buttons they took Avalonia's focus on tap, which takes it off the NativeWebView
// — and the package's own OnLostFocus then calls the adapter's ResignFocus(). So pressing
// Tab or an arrow handed the terminal one byte and took the keyboard away from it: the next
// thing typed on a hardware keyboard went nowhere, and the row went on working because its
// buttons are pressed rather than typed into, which is what makes it look like the terminal
// had died instead.
//
// Focusable=false is what a toolbar button is, and it means the focused element never
// changes: the WebView is still it, so nothing resigns and nothing has to be handed back.
Focusable = false,
}; };
if (latches) if (latches)