Give the phone a selection instead of a card under the list

A long press on a host raised a connect card over the bottom of the list: a
password box, CONNECT, EDIT, MOVE and DELETE. It was the right idea in the wrong
place. It covered rows, it had room for five things and never a sixth, and every
one of them was about exactly one machine — so filing eleven imported hosts under
a group was eleven trips through a form, and there was nowhere to put a sixth
action if anybody wanted one.

A long press now chooses the host it landed on, and the actions move into a bar
across the top of the screen, in the vault header's place rather than beside it.
That is where Android has put them since contextual action bars existed, and it
is the one strip a list can never grow into — but the real reason for it is that
while it is up the screen is unambiguously about the ticked hosts and nothing
else, which is what lets the count in the middle of it mean something. Left to
right: the cross that leaves the mode, the count, the pencil, and a ⋯ holding
Connect, Connect via SFTP, Move to vault, Copy to vault, Change group, Duplicate
and Remove.

A tap still connects and still raises nothing. Once anything is ticked it ticks
and unticks instead, which is what every Android list does and is not merely a
convention worth following: a tap that connected while five machines sat ticked
would open a terminal on top of a selection somebody was halfway through
building. Unticking the last host leaves the mode, so there are two ways out of
it and the cross is only one of them.

Both gestures now read the row from the element under the finger rather than from
the list's selection, and that is a correctness change rather than tidying. A tap
on a group heading moves the selection and the view model bounces it straight back
to whichever host was chosen before — which answered "a host, or nothing" for free
while a tap only ever connected. It stops answering it the moment a tap can tick
one: the heading would tick a machine the user was not pointing at, into a set
they are about to delete.

Three of the seven entries are about one machine and are drawn only for one. A
terminal, a file-transfer session and a form each have no reading over six, so
they are collapsed rather than refused. The other four read better for a count
than without one — it is the reason the set exists — and each of them says
afterwards how many hosts it wrote and how many it left alone. Skipping beats
refusing the whole run: a selection of eleven with one read-only row would
otherwise do nothing at all and then report about the wrong ten.

Copy to vault and Duplicate are new, and the difference between them is what each
can safely carry. A copy crosses a key boundary, so it drops the group and the
tags exactly as a move does — both are items of the vault being left, and a host
arriving with either would point at something the destination does not contain,
resolvable on the machine that sent it and dangling for everybody else. A
duplicate stays in the same keychain, so everything it points at is still there
and it keeps both. Change group is the write dragging a card onto a group already
makes on the desktop, run over a selection; it refuses one spanning two keychains
rather than half-filing it, which is the refusal a drop across that boundary
already makes one host at a time.

Connect via SFTP is the one action that leaves the vault. Which machine is a
decrypted item and so is this object's business; the screen it leads to and the
transfers view model behind it are the shell's — so it is an event, on the same
division SessionOpened already draws for a shell. The host is re-found in that
screen's own copy of the list, because the picker binds to rows in that copy and
handing it the vault's object would select nothing.

What is left of the card is the password box, and only because it had nowhere
else to go: a host that authenticates with a typed password cannot be reached by
a tap alone. That tap now raises a sheet rather than the bar, and the difference
is that a sheet is up only while a question is on screen — the bar was raised by
a long press and stayed, so it was a password box sitting over the list whether or
not anything was being asked. Dismissing it empties the box, which is not tidiness
either: a secret left behind would satisfy the emptiness check that decides
whether to raise the sheet at all, so the next tap would dial with somebody else's
password.

The pencil moving into that bar takes the host editor with it. It was a card in
the list's own row, under the search box and the sync line — twenty controls
sharing a screen with two rows of chrome about the list it had replaced. It is a
page now, and PhoneShell stands all four of its rows down for it, which is what
"opens with all the options" means at 360dp. That needed a second subscription in
that control: two of its flags are questions about the vault rather than about the
shell, and the shell does not forward the vault's notifications.

The ticks are held as entity ids rather than as rows, and written back onto the
rows after every reload. Every row object in the list is replaced on every filter
keystroke and every synchronisation pass, so a set of rows would empty itself once
a minute under somebody choosing what to do with eleven machines. Ids that no
longer resolve are dropped, so a colleague's deletion arriving mid-selection
leaves a count that matches what is on screen.

One caller had to change with it. ConnectToRecent opened the pane about a host,
which was the desktop's drawer and the phone's card; the phone's answer is now a
tick, and nothing on that list means "selected" any more — so arriving with the
host merely selected would be arriving at a screen with nothing to press. Both are
raised together, and the one the head in front of the user does not draw is inert.
This commit is contained in:
2026-08-06 09:15:37 +02:00
parent 174ef7c420
commit c882fa0cd3
11 changed files with 2669 additions and 722 deletions
@@ -17,6 +17,18 @@ internal sealed partial class PhoneShell : UserControl
{
private MainWindowViewModel? shell;
/// <summary>
/// The open vault, while there is one, so that this control hears about the hosts screen's own state.
/// </summary>
/// <remarks>
/// ◆ <b>A second subscription, and it is the price of the header being swappable.</b> Two of the flags
/// below are questions about the vault rather than about the shell — whether hosts are ticked, and
/// whether the host editor is filling the screen — and the shell does not forward the vault's
/// notifications. Kept in step from <see cref="OnShellChanged"/>, because <c>Vault</c> is replaced on
/// every unlock and nulled on every lock; a handler left on a disposed vault would keep it alive.
/// </remarks>
private VaultViewModel? vault;
/// <summary>
/// Everything the phone draws, which is the element the software keyboard is kept off.
/// </summary>
@@ -90,10 +102,40 @@ internal sealed partial class PhoneShell : UserControl
TryOfferDeviceUnlock();
}
FollowTheVault();
RefreshChrome();
};
}
/// <summary>Moves this control's second subscription onto whichever vault is open now.</summary>
/// <remarks>
/// Compared before being swapped, so that the ordinary case — a shell notification about something else
/// entirely — costs one reference comparison rather than an unsubscribe and a resubscribe per property
/// change on the shell.
/// </remarks>
private void FollowTheVault()
{
if (ReferenceEquals(vault, shell?.Vault))
{
return;
}
if (vault is not null)
{
vault.PropertyChanged -= OnVaultChanged;
}
vault = shell?.Vault;
if (vault is not null)
{
vault.PropertyChanged += OnVaultChanged;
}
}
private void OnVaultChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
=> RefreshChrome();
/// <summary>Whether this surface is wide enough to be laid out like the desktop.</summary>
/// <remarks>
/// A property of the control rather than of the view model, because it is a fact about the surface and
@@ -115,6 +157,14 @@ internal sealed partial class PhoneShell : UserControl
public static readonly StyledProperty<bool> ShowsVaultHeaderProperty =
AvaloniaProperty.Register<PhoneShell, bool>(nameof(ShowsVaultHeader));
/// <summary>Whether the bar about the chosen hosts is drawn in the header's place.</summary>
public static readonly StyledProperty<bool> ShowsHostSelectionBarProperty =
AvaloniaProperty.Register<PhoneShell, bool>(nameof(ShowsHostSelectionBar));
/// <summary>Whether the strip of open shells above the bottom bar is drawn.</summary>
public static readonly StyledProperty<bool> ShowsShellStripProperty =
AvaloniaProperty.Register<PhoneShell, bool>(nameof(ShowsShellStrip));
/// <inheritdoc cref="IsWideProperty" />
public bool IsWide
{
@@ -143,6 +193,20 @@ internal sealed partial class PhoneShell : UserControl
private set => SetValue(ShowsVaultHeaderProperty, value);
}
/// <inheritdoc cref="ShowsHostSelectionBarProperty" />
public bool ShowsHostSelectionBar
{
get => GetValue(ShowsHostSelectionBarProperty);
private set => SetValue(ShowsHostSelectionBarProperty, value);
}
/// <inheritdoc cref="ShowsShellStripProperty" />
public bool ShowsShellStrip
{
get => GetValue(ShowsShellStripProperty);
private set => SetValue(ShowsShellStripProperty, value);
}
/// <summary>
/// Works out which chrome this surface should be wearing.
/// </summary>
@@ -161,7 +225,16 @@ internal sealed partial class PhoneShell : UserControl
/// Losing them on the keychain would be losing the only LOCK button on the surface.
/// </para>
/// <para>
/// Recomputed on every shell notification rather than on a named list of them. Three boolean
/// ◆ <b>The header is now a swap rather than a switch, and the editor takes the whole screen.</b> Two
/// more flags and two more inputs, both of them the vault's rather than the shell's — see
/// <see cref="vault"/>. While hosts are ticked the header stands down and
/// <see cref="ShowsHostSelectionBar"/> puts the action bar in its place, which is what makes that bar
/// unambiguous: the screen is about the ticked hosts and nothing else. While the host editor is open it
/// is a page rather than a card, so all four rows of chrome stand down and the form has the display —
/// which is what "opens in a separate page" means on a 360dp screen.
/// </para>
/// <para>
/// Recomputed on every notification from either object rather than on a named list of them. Five boolean
/// comparisons and no allocation is cheaper than being wrong: the properties this reads are computed
/// ones, and which of them raise a change is a fact about a file in another project that nothing here
/// would notice going stale.
@@ -172,6 +245,16 @@ internal sealed partial class PhoneShell : UserControl
var wide = body.Bounds.Width >= WideAt;
var pages = shell?.IsShowingPages == true;
// The editor is a page of its own now, so nothing else is drawn around it — not the vault header,
// not the shells strip, and not the way off the screen. Its own header carries the back arrow, which
// is the one control it needs and the one the system gesture already maps to.
var editing = vault?.IsEditing == true;
// Only on the hosts screen. The ticks survive a trip to the keychain — the set is not cleared by
// navigating — and a bar counting hosts over the transfers screen would be chrome about a list that
// is not on the display.
var choosing = vault?.IsChoosingHosts == true && shell?.IsHostsShowing == true;
// Before the flags, because it changes what one of them reads. Nothing else on this head navigates
// in response to a resize, and this is not navigation for its own sake: the hub is a list of the
// destinations the rail now carries, so an unfolded device would otherwise sit on a menu of things
@@ -183,9 +266,11 @@ internal sealed partial class PhoneShell : UserControl
}
IsWide = wide;
ShowsRail = wide && pages;
ShowsBottomBar = !wide && pages;
ShowsVaultHeader = pages && (wide || shell?.IsMoreSurface != true);
ShowsRail = wide && pages && !editing;
ShowsBottomBar = !wide && pages && !editing;
ShowsShellStrip = pages && !editing;
ShowsHostSelectionBar = pages && choosing && !editing;
ShowsVaultHeader = pages && !editing && !choosing && (wide || shell?.IsMoreSurface != true);
}
private void OnShellChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -195,6 +280,7 @@ internal sealed partial class PhoneShell : UserControl
return;
}
FollowTheVault();
RefreshChrome();
if (e.PropertyName is nameof(MainWindowViewModel.State))
@@ -500,16 +586,23 @@ internal sealed partial class PhoneShell : UserControl
/// <returns>Whether anything was closed, and so whether back has been spent.</returns>
/// <remarks>
/// <para>
/// Order is the whole of it. The two sheets sit over the list and the two editors sit in place of it, so
/// a sheet has to go first — closing an editor while a sheet was open would leave the sheet floating
/// over a list nobody asked to see, and the second back would then close the sheet rather than the
/// editor the user was looking at.
/// Order is the whole of it. The sheets sit over the list, the panels sit above it and the editors sit
/// in place of it, so a sheet has to go first — closing an editor while a sheet was open would leave the
/// sheet floating over a list nobody asked to see, and the second back would then close the sheet rather
/// than the editor the user was looking at.
/// </para>
/// <para>
/// The editors are cancelled rather than merely hidden. Cancelling is what clears the boxes, and the
/// host editor's boxes are the ones worth clearing: leaving a half-typed hostname behind would have the
/// next NEW HOST open on somebody else's abandoned draft.
/// </para>
/// <para>
/// ◆ <b>Selection mode is last and is still a thing back has to spend itself on.</b> It is a mode rather
/// than a surface — the list underneath is fully drawn and the only sign of it is the bar across the top
/// — and a gesture that left the application from it would take somebody out of the app because they had
/// held a row down. Its panels go before it, in the order they are stacked: the picker or the question is
/// what the user is looking at, and the ticks underneath are what it is about.
/// </para>
/// </remarks>
private static bool TryCloseAnOpenEditor(MainWindowViewModel current)
{
@@ -518,22 +611,71 @@ internal sealed partial class PhoneShell : UserControl
return false;
}
return TryLowerASheet(vault) || TryCloseSomethingBehindTheSheets(vault);
}
/// <summary>Lowers the nearest of the four sheets, which are what sits over everything else.</summary>
/// <remarks>
/// The four cannot be open at once — each is raised from a control the others hide — so their order
/// between themselves decides nothing. What matters is that all of them come before the panels and the
/// editors underneath: closing an editor while a sheet was open would leave the sheet floating over a
/// list nobody asked to see.
/// </remarks>
private static bool TryLowerASheet(VaultViewModel vault)
{
// ◆ The action bar's own menu, first of the four because it is raised from chrome that is already
// over everything else.
if (vault.IsHostActionSheetOpen)
{
vault.CloseHostActionSheetCommand.Execute(null);
return true;
}
// The password sheet, which is what a tap on a machine that wants one raises. Cancelled rather than
// hidden, because cancelling is what empties the box — see VaultViewModel.CancelConnectPassword.
if (vault.IsAskingForConnectPassword)
{
vault.CancelConnectPasswordCommand.Execute(null);
return true;
}
if (vault.IsAddSheetOpen)
{
vault.CloseAddSheetCommand.Execute(null);
return true;
}
// The other sheet, and it is checked beside the first rather than after the editors for the same
// reason: it is raised over the list, so it is the nearest thing on screen. The two cannot be open
// at once — one is raised by the +, the other by a heading, and each hides the list the other's
// control is on — so their order between themselves decides nothing.
if (vault.GroupSheet is not null)
{
vault.CloseGroupSheetCommand.Execute(null);
return true;
}
return false;
}
/// <summary>Closes the nearest of the panels, the editors and selection mode itself.</summary>
/// <inheritdoc cref="TryCloseAnOpenEditor" path="/remarks" />
private static bool TryCloseSomethingBehindTheSheets(VaultViewModel vault)
{
if (vault.IsSendingChosenHostsToAVault)
{
vault.CancelSendChosenHostsToAVaultCommand.Execute(null);
return true;
}
if (vault.IsRegroupingChosenHosts)
{
vault.CancelRegroupChosenHostsCommand.Execute(null);
return true;
}
if (vault.IsConfirmingChosenHostDeletion)
{
vault.CancelDeleteCommand.Execute(null);
return true;
}
if (vault.IsEditing)
{
vault.CancelEditCommand.Execute(null);
@@ -546,6 +688,12 @@ internal sealed partial class PhoneShell : UserControl
return true;
}
if (vault.IsChoosingHosts)
{
vault.ClearHostChoiceCommand.Execute(null);
return true;
}
return false;
}