Public Access
Free the terminal from the Hosts screen, and fill the room it left
The WebView sat inside the Hosts grid, so navigating to Files or the keychain hid every open terminal and the strip that named them. A connection you had opened was invisible from four of the five screens. The window now has two surfaces rather than one: a nav rail that says which page you are on, and a terminal strip that is always there and switches the whole content area to a shell. Screen keeps meaning "which page" and never becomes a sixth kind of page, which is why this is two properties instead of one enum with a terminal member in it. Every screen lives inside one wrapper panel that collapses when a terminal is showing. That is not tidiness — the WebView hosts a Win32 child window that composites above everything Avalonia draws, so a screen left visible over its rectangle is a screen sliced in half, and this window has shipped that defect once already. One decision point, IsTerminalShowing, and a nested panel rather than five compound bindings nobody would remember to extend. The focus choreography is the part no test in this repo can see. Every reveal path now focuses in the same turn the WebView appeared, so all three of them post at DispatcherPriority.Loaded and let the native control re-push its bounds first. Going the other way had a real bug: the screen-changed branch called a bare Focus() where it had to release the keyboard from the native child, so switching from a terminal to Files silently ate the first keystrokes. Rare before this commit and the primary gesture after it. The tab strip grew a cross inside each tab, a plus that opens the quick-connect palette, and middle-click close. Nested buttons are correct here: Avalonia handles a left press on the cross and deliberately does not handle other buttons, which is exactly what lets middle-click bubble up from the cross as well as the tab. The test is PointerUpdateKind rather than IsMiddleButtonPressed, because the latter reports button state and is also true for a left press made while the middle button happens to be held. The handler is on the tab and not the strip, so the background closes nothing by construction. Plus opens the palette rather than a flyout, since a menu dropping into the WebView's rectangle may or may not composite above a child HWND and this repo does not make rendering claims it has not photographed. Everything a user reads now says keychain. The wire, the database and the cryptographic spec still say vault, deliberately: renaming those is a migration and a protocol change for a word. That split is written down rather than left to be rediscovered as an inconsistency. Four things that were squeezed into the keychain's category rail, or into nothing at all, now have screens. Pinned host keys get one, with fingerprints never truncated and a filter that matches them, because comparing what you have against what the operator published is the whole workflow; the approved date is read out of the item's UUIDv7 rather than added as a column, and says so, since it means first approval and not last use. Keys can be generated in the client, which needed the openssh-key-v1 container written by hand — there is no BCL or NSec helper, and the PKCS#8 route is unverified in the SSH library this uses. The armour carries no passphrase: encrypting it needs bcrypt_pbkdf, which is Blowfish with a swizzle, in a project whose crypto is otherwise entirely libsodium, for a protection the key's own remarks argue is redundant inside a vault. Generation fills the existing editor and stops, so SAVE stays the one thing that writes. ~/.ssh/config can be imported behind a preview that is ticked per row and writes nothing until the button; IdentityFile records the path and imports the key material only on an explicit opt-in, because reading somebody's private key into a vault is precisely the act this product exists to make deliberate. Match blocks and ProxyJump are reported rather than obeyed — one cannot be evaluated statically and the other has nothing behind it to route with, and a preview that implied otherwise would be worse than one that admits it. Files can be dragged in all four directions that are honestly available. Remote to Explorer does not ship and is not pretended to: the shell wants the bytes during the drop, which needs a virtual file and a native COM data object, outside what Avalonia offers. Note for the next person that Avalonia 12 replaced the drag model outright — DataObject and DataFormats are no-op stubs and IDataObject is not in the reference assembly, so every tutorial written for 11 does not compile here. Hosts can be grouped, flat and never nested. A parent id merged as a scalar lets two offline clients each re-parent A under B and B under A, producing a cycle inside an encrypted payload that no server can police and every reader would have to detect for ever. Membership lives in that payload rather than in the one plaintext concession ADR 0001 allows, whose test is that the relay cannot function without it — nothing on the server reads a group, so what plaintext would hand over is a clustering of the estate for nothing. The plaintext column reserved for it is dropped, provably always null, and the server now refuses a client that sends one; it was never populated, was copied on apply, and was not cleared on delete, so a group id would have outlived the host it described. Snippets insert through xterm rather than through the pump, because xterm is the only thing that knows whether the remote has bracketed paste on, and that is what makes a shell treat embedded newlines as text instead of as execute. The host process moves opaque bytes and never parses output, so it would have to guess, and guessing wrong runs every line. Running is off by default and the copy says the text goes into whatever is there — the terminal has no notion of being at a prompt, and may be in vi or at a password prompt with echo off, so the Enter the user presses themselves is the entire safety property. Connections and keychain changes are recorded as synced encrypted items, which is what makes them auditable by a team later and costs the server knowledge of connection rate and timing from row counts alone. ADR 0001 already concedes it cannot hide that class of metadata; the trade is now written into it rather than left implicit. A connection entry is written once, at close, which is what makes a synced log tractable: nothing to merge, one outbox row, no chance of colliding with itself. Live sessions come from memory, not from the log. The write is void by contract and posts to a bounded channel, because putting an encrypt-and-write on the teardown path of every session is how closing the application comes to take four seconds. A ticket opened before a lock still closes afterwards, since a shell outlives the vault. The activity log hooks the one generic repository every kind writes through, so it cannot miss a caller — which is also why the log kinds themselves declare they are not audited, or the first entry would write an entry about writing an entry. It records the names of the fields that changed and never their values; a log with an old password in it would be a plaintext credential store with no vault around it. Retention is 90 days or 5,000 entries, whichever bites first, pruned on the sync loop rather than on a second timer. That log traffic then broke the status line, which is worth recording because the fix is a shape and not a patch: background sync counted its own log rows as pushed items, so the quiet rule stopped being quiet and every action's message was overwritten a second later by a sync report. The report now separates log rows from user items and the rule reads the latter. S3 buckets appear as a remote in the file browser, behind the same interface an SFTP session implements, so the queue and both panes did not have to learn what they are talking to. Uploads go through a pipe, because the queue wants to write and the SDK wants to read; memory is then bounded by the part size instead of buffering a file to disk twice. Finally, the Windows device key store moved out of the session project, which was the one thing keeping it from being portable — everything else in it is platform-neutral, and a Windows CNG dependency in the middle of the vault code meant a second head could not reference it without dragging Windows along. The seam that made the move free was already there. docs/android-port.md is the audit behind that: what ports, what does not, in order of cost, the four decisions taken, and an inventory of every screen and state the interface has to carry, written so a design can be made from it directly. dotnet build, dotnet test and dotnet format --verify-no-changes are all clean: 1240 tests at zero warnings, including the end-to-end suite against real containers. The manual checks that headless Avalonia cannot make — the drag from Explorer, a generated key against a real host, twelve tabs at the minimum window width — are listed in docs/manual-checks.md and are still outstanding.
This commit is contained in:
1 parent
1292084af9
commit
d07b336868
163 files changed
+24491
-647
No files matched your search
@@ -1,5 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using DodoSSH.Client.App.ViewModels;
|
||||
|
||||
namespace DodoSSH.Client.App.Views;
|
||||
@@ -8,12 +11,42 @@ namespace DodoSSH.Client.App.Views;
|
||||
/// The two-pane file browser and the transfer queue.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Its data context is the <c>TransfersViewModel</c>, which the shell owns for the life of the process — a
|
||||
/// transfer in flight has to survive a lock, the same policy that keeps shells running. See
|
||||
/// <c>MainWindowViewModel.LockAsync</c>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Everything about drag and drop is in this file and nothing about it is policy.</b> The handlers pull
|
||||
/// paths or rows out of a drop and hand them to <c>QueueUploads</c>/<c>QueueDownloads</c>; what may be
|
||||
/// queued, what is skipped and what is said about it all live in the view model, where they can be tested
|
||||
/// without a window. Nothing headless can synthesise a real platform drag, so the wiring below is verified
|
||||
/// by hand — see <c>docs/manual-checks.md</c>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal sealed partial class TransfersScreen : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// How remote rows travel while being dragged.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An in-process format, so the rows themselves cross rather than a list of path strings that would
|
||||
/// have to be looked up again on the other side. It also cannot be confused with a drop from the
|
||||
/// operating system: a file dragged out of the file manager arrives as <c>DataFormat.File</c> and never
|
||||
/// as this, so "did this come from our own remote pane" needs no guessing.
|
||||
/// </remarks>
|
||||
private static readonly DataFormat<RemoteDragPayload> RemoteEntries =
|
||||
DataFormat.CreateInProcessFormat<RemoteDragPayload>("dodossh/remote-entries");
|
||||
|
||||
/// <summary>How far the pointer moves before a press becomes a drag.</summary>
|
||||
/// <remarks>
|
||||
/// Without a threshold every click on a row starts a drag, which makes selecting one impossible.
|
||||
/// </remarks>
|
||||
private const double DragThreshold = 4;
|
||||
|
||||
private PointerPressedEventArgs? pressed;
|
||||
private Point pressedAt;
|
||||
|
||||
public TransfersScreen()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -23,11 +56,32 @@ internal sealed partial class TransfersScreen : UserControl
|
||||
// Enter on a keyboard-navigated row goes through the same commands from the buttons above them.
|
||||
LocalList.DoubleTapped += OnLocalActivated;
|
||||
RemoteList.DoubleTapped += OnRemoteActivated;
|
||||
|
||||
// On the pane rather than on the list. A directory with nothing in it lays its ListBox out at zero
|
||||
// height behind the empty-state sentence, and a drop handler on the list would have nothing to hit.
|
||||
LocalPane.AddHandler(DragDrop.DragOverEvent, OnLocalDragOver);
|
||||
LocalPane.AddHandler(DragDrop.DragLeaveEvent, OnLocalDragLeave);
|
||||
LocalPane.AddHandler(DragDrop.DropEvent, OnLocalDrop);
|
||||
|
||||
RemotePane.AddHandler(DragDrop.DragOverEvent, OnRemoteDragOver);
|
||||
RemotePane.AddHandler(DragDrop.DragLeaveEvent, OnRemoteDragLeave);
|
||||
RemotePane.AddHandler(DragDrop.DropEvent, OnRemoteDrop);
|
||||
|
||||
// Tunnelling, so noting where a press started does not take the press away from the ListBox — a row
|
||||
// still selects, and the drag only begins once the pointer has moved far enough.
|
||||
foreach (var list in new Control[] { LocalList, RemoteList })
|
||||
{
|
||||
list.AddHandler(PointerPressedEvent, OnPointerPressed, RoutingStrategies.Tunnel);
|
||||
list.AddHandler(PointerMovedEvent, OnPointerMoved, RoutingStrategies.Tunnel);
|
||||
list.AddHandler(PointerReleasedEvent, OnPointerReleased, RoutingStrategies.Tunnel);
|
||||
}
|
||||
}
|
||||
|
||||
private TransfersViewModel? Transfers => DataContext as TransfersViewModel;
|
||||
|
||||
private void OnLocalActivated(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is TransfersViewModel transfers)
|
||||
if (Transfers is { } transfers)
|
||||
{
|
||||
transfers.OpenLocalCommand.Execute(null);
|
||||
}
|
||||
@@ -40,9 +94,211 @@ internal sealed partial class TransfersScreen : UserControl
|
||||
/// </remarks>
|
||||
private void OnRemoteActivated(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is TransfersViewModel transfers)
|
||||
if (Transfers is { } transfers)
|
||||
{
|
||||
_ = transfers.OpenRemoteCommand.ExecuteAsync(null);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Starting a drag ----
|
||||
|
||||
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (e.GetCurrentPoint(this).Properties.PointerUpdateKind is PointerUpdateKind.LeftButtonPressed)
|
||||
{
|
||||
pressed = e;
|
||||
pressedAt = e.GetPosition(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPointerReleased(object? sender, PointerReleasedEventArgs e) => pressed = null;
|
||||
|
||||
/// <remarks>
|
||||
/// The drag starts here rather than on the press, because a press is also how a row is selected.
|
||||
/// <c>DoDragDropAsync</c> wants the original <c>PointerPressedEventArgs</c>, so it is held from the
|
||||
/// press until either the pointer moves far enough or the button comes back up.
|
||||
/// </remarks>
|
||||
private void OnPointerMoved(object? sender, PointerEventArgs e)
|
||||
{
|
||||
if (pressed is not { } origin || Transfers is not { } transfers)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
{
|
||||
pressed = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var moved = e.GetPosition(this) - pressedAt;
|
||||
|
||||
if (Math.Abs(moved.X) < DragThreshold && Math.Abs(moved.Y) < DragThreshold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pressed = null;
|
||||
|
||||
if (ReferenceEquals(sender, RemoteList))
|
||||
{
|
||||
StartRemoteDrag(origin, transfers);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = StartLocalDragAsync(origin, transfers);
|
||||
}
|
||||
}
|
||||
|
||||
private static void StartRemoteDrag(PointerPressedEventArgs origin, TransfersViewModel transfers)
|
||||
{
|
||||
if (transfers.SelectedRemoteEntry is not { } row)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var transfer = new DataTransfer();
|
||||
transfer.Add(DataTransferItem.Create(RemoteEntries, new RemoteDragPayload([row])));
|
||||
|
||||
_ = DragDrop.DoDragDropAsync(origin, transfer, DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Local files travel as the platform's own file format rather than as an in-process one, which is what
|
||||
/// makes a single drag work both onto the remote pane and out into the file manager. It needs a real
|
||||
/// <see cref="IStorageItem"/>, hence the asynchronous lookup — and hence a fire-and-forget call, because
|
||||
/// nothing on a pointer-moved path can await.
|
||||
/// </remarks>
|
||||
private async Task StartLocalDragAsync(PointerPressedEventArgs origin, TransfersViewModel transfers)
|
||||
{
|
||||
if (transfers.SelectedLocalEntry is not { IsFile: true } row
|
||||
|| TopLevel.GetTopLevel(this) is not { } top)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var file = await top.StorageProvider.TryGetFileFromPathAsync(row.FullPath).ConfigureAwait(true);
|
||||
|
||||
if (file is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var transfer = new DataTransfer();
|
||||
transfer.Add(DataTransferItem.CreateFile(file));
|
||||
|
||||
await DragDrop.DoDragDropAsync(origin, transfer, DragDropEffects.Copy).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
// ---- Accepting a drop ----
|
||||
|
||||
/// <remarks>
|
||||
/// The local pane takes remote rows and nothing else. A file dragged from the file manager onto it
|
||||
/// would be a copy from this machine to this machine, which is not what this screen is for.
|
||||
/// </remarks>
|
||||
private void OnLocalDragOver(object? sender, DragEventArgs e)
|
||||
{
|
||||
var accepted = e.DataTransfer.Contains(RemoteEntries);
|
||||
|
||||
e.DragEffects = accepted ? DragDropEffects.Copy : DragDropEffects.None;
|
||||
|
||||
if (Transfers is { } transfers)
|
||||
{
|
||||
transfers.IsLocalDropTarget = accepted;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnLocalDragLeave(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (Transfers is { } transfers)
|
||||
{
|
||||
transfers.IsLocalDropTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLocalDrop(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (Transfers is not { } transfers)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
transfers.IsLocalDropTarget = false;
|
||||
e.Handled = true;
|
||||
|
||||
if (e.DataTransfer.TryGetValue(RemoteEntries) is { } payload)
|
||||
{
|
||||
transfers.QueueDownloads(payload.Rows);
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// The remote pane takes files: from the file manager, and from the local pane, which offers the same
|
||||
/// platform format. A drop while disconnected is refused visibly rather than accepted and then
|
||||
/// explained, because a red pane under the pointer is the answer arriving before the drop rather than
|
||||
/// after it.
|
||||
/// </remarks>
|
||||
private void OnRemoteDragOver(object? sender, DragEventArgs e)
|
||||
{
|
||||
var files = e.DataTransfer.Contains(DataFormat.File);
|
||||
var connected = Transfers is { IsConnected: true };
|
||||
|
||||
e.DragEffects = files && connected ? DragDropEffects.Copy : DragDropEffects.None;
|
||||
|
||||
if (Transfers is { } transfers)
|
||||
{
|
||||
transfers.IsRemoteDropTarget = files && connected;
|
||||
transfers.IsRemoteDropRefused = files && !connected;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnRemoteDragLeave(object? sender, DragEventArgs e) => ClearRemoteHighlight();
|
||||
|
||||
private void OnRemoteDrop(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (Transfers is not { } transfers)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearRemoteHighlight();
|
||||
e.Handled = true;
|
||||
|
||||
if (e.DataTransfer.TryGetFiles() is not { } files)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TryGetLocalPath, because the queue reads bytes off a real path. A storage item that is not a
|
||||
// local file — one from a cloud provider's virtual folder — has none, and dropping it is a thing
|
||||
// this screen declines rather than a thing it half does.
|
||||
var paths = files
|
||||
.Select(file => file.TryGetLocalPath())
|
||||
.OfType<string>()
|
||||
.ToList();
|
||||
|
||||
transfers.QueueUploads(paths);
|
||||
}
|
||||
|
||||
private void ClearRemoteHighlight()
|
||||
{
|
||||
if (Transfers is { } transfers)
|
||||
{
|
||||
transfers.IsRemoteDropTarget = false;
|
||||
transfers.IsRemoteDropRefused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The remote rows carried by one drag.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A record wrapping the list rather than the list itself, because <c>DataFormat.CreateInProcessFormat</c>
|
||||
/// keys on the type and a bare <c>IReadOnlyList<T></c> is too general a key to be sure of.
|
||||
/// </remarks>
|
||||
internal sealed record RemoteDragPayload(IReadOnlyList<RemoteEntryRowViewModel> Rows);
|
||||
Reference in new issue
Block a user