Share the shelf as well as what is on it, and ask a group which vault

A group is where hosts are filed and what lends them a port, a username and a key,
and until now it could only ever be made in the vault this machine files new items
into. So sharing a vault shared the machines and not the arrangement: a colleague
opened four hosts filed under a group they could read the name of and nothing else,
and the group a teammate made had no card, no heading and no way to be corrected
from the screen looking straight at the hosts inside it. Recorded as half shipped in
docs/design-import-gaps.md, and this is the other half.

The list stopped being the active vault's. It was narrow for two stated reasons —
a row shown across vaults has to carry which vault it lives in, because rename and
delete both need it, and two vaults may hold a "production" each, which a layout
with one heading per group cannot tell apart — and both are now paid for rather than
avoided. Every row carries its vault, the badge beside the name says which, and the
two cards sit side by side saying what they are.

The three shapes of the group read are now deliberately different sizes. The list is
what a person looks at, so a hidden vault's groups leave it: a card that cannot be
opened onto anything is worse than no card. The per-vault lists are what a picker
offers, because a picker is always asking about one vault. The map is what a host's
GroupId resolves through, and it stays widest of all — including over hidden vaults,
since a group lends a port and hiding a vault must never change what one of its
hosts dials. RebuildGroups is the one place hiding is applied, which is what keeps
those answers apart.

The editor asks which vault on the terms the host editor's picker set: while adding
only, hidden where there is one writable vault, and never offered afterwards, because
the two are encrypted under different keys and moving an item is a delete and a
retype. Its parent picker is that vault's alone, for the reason the host editor's
group picker is one level down — a parent in another vault is a level half the key
holders cannot resolve, and their hosts would inherit from nothing. + NEW GROUP
inside an open group departs from NewHost and takes that group's vault rather than
the standing preference: a group made inside another is in its parent's vault by
construction, and answering "inside PLATFORM" with a group elsewhere and no parent
would drop the one thing the button said.

Two smaller things follow from the cards spanning vaults. Dragging a host onto a
group card in another vault is refused with both names, because the write it would
make is exactly the id-nobody-can-resolve the host editor's picker was fixed to
prevent, and treating it as "no group" would unfile a host somebody was plainly
filing. And a group being renamed says its vault in the drawer's header, since the
picker is not drawn for an existing one and renaming a colleague's shelf without
being told whose it is is the edit most worth naming.

The save target is a nullable field behind a property that falls back to the standing
preference. The group name box is bound whether or not anything raised an editor over
it — that is what the desktop's group bar was, and typing a name into it and pressing
ADD is still a way to make a group, which would otherwise have written to no vault
at all.

1575 tests pass, five more than before: a group filed into a shared vault is listed
and renamed there, the editor's picker does not move the keychain screen's, the
parent picker offers only its own vault, a cross-vault drop is refused, and hiding a
vault takes the cards without changing what its hosts dial.
This commit is contained in:
2026-08-04 16:27:16 +02:00
parent 176df67861
commit c39df3f51e
8 changed files with 762 additions and 108 deletions
@@ -612,12 +612,216 @@ public sealed class VaultSharingTests : IAsyncLifetime
vault.ShowsEditorVaultChoice.ShouldBeFalse("an item cannot be moved between vaults");
}
/// <remarks>
/// <para>
/// A group is a shelf, and a shared vault is what makes it everybody's shelf. The assertions are the
/// three things that were missing while the group list was the active vault's alone: it is listed at
/// all, the row says which vault it is in, and a rename typed into it goes back to that vault rather
/// than forking a second group of the new name into the personal one.
/// </para>
/// <para>
/// Reloaded between the write and the read, so what is asserted is what came back out of the vault
/// rather than the row the save left behind.
/// </para>
/// </remarks>
[Fact]
public async Task AGroupFiledIntoASharedVault_IsListedThereAndRenamedThere()
{
await UnlockedAsync();
var vaults = shell.Vaults;
await CreateVaultAsync(vaults, "Platform secrets");
var vault = shell.Vault!;
var sharedVaultId = vaults.SelectedVault!.VaultId;
await vault.LoadAsync(Token);
vault.NewGroupCommand.Execute(null);
vault.ShowsGroupEditorVaultChoice.ShouldBeTrue("there are two vaults to choose between");
vault.GroupEditorSelectedVault =
vault.GroupEditorVaultChoices.Single(choice => choice.VaultId == sharedVaultId);
vault.GroupEditorLabel = "production";
await vault.SaveGroupCommand.ExecuteAsync(null);
await vault.LoadAsync(Token);
var group = vault.Groups.ShouldHaveSingleItem();
group.VaultId.ShouldBe(sharedVaultId, vault.Status);
group.VaultBadge.ShouldBe("PLATFORM SECRETS", "a card in a session holding two vaults says which");
vault.SelectedGroup = group;
vault.EditGroupCommand.Execute(null);
vault.ShowsGroupEditorVaultChoice.ShouldBeFalse("an item cannot be moved between vaults");
vault.DrawerSubtitle.ShouldBe(
"Platform secrets", "with no picker drawn, the header is what says whose shelf this is");
vault.GroupEditorLabel = "live";
await vault.SaveGroupCommand.ExecuteAsync(null);
await vault.LoadAsync(Token);
var renamed = vault.Groups.ShouldHaveSingleItem();
renamed.Label.ShouldBe("live");
renamed.VaultId.ShouldBe(sharedVaultId, "a rename must not fork a copy into the personal vault");
}
/// <remarks>
/// <para>
/// The group editor's picker is the group's, exactly as the host editor's is the host's: moving it must
/// not move the keychain screen's standing preference, and moving that one must not move a group
/// half-typed here.
/// </para>
/// <para>
/// The second half is the one worth the test. The picker is read when the form opens and the vault is
/// captured there, so a click on the other screen between typing the name and pressing ADD cannot
/// redirect the group somebody was making.
/// </para>
/// </remarks>
[Fact]
public async Task TheGroupEditorChoosesItsOwnVault_WithoutMovingTheKeychainScreensPicker()
{
await UnlockedAsync();
var vaults = shell.Vaults;
await CreateVaultAsync(vaults, "Platform secrets");
var vault = shell.Vault!;
var sharedVaultId = vaults.SelectedVault!.VaultId;
await vault.LoadAsync(Token);
var personal = vault.SelectedTargetVault!;
vault.NewGroupCommand.Execute(null);
vault.GroupEditorSelectedVault =
vault.GroupEditorVaultChoices.Single(choice => choice.VaultId == sharedVaultId);
vault.GroupEditorLabel = "production";
// Moved back after the editor opened, the way a click on the keychain screen would. The group must
// still land in the shared vault.
vault.SelectedTargetVault = personal;
await vault.SaveGroupCommand.ExecuteAsync(null);
vault.Groups.ShouldHaveSingleItem().VaultId.ShouldBe(sharedVaultId, vault.Status);
vault.SelectedTargetVault.ShouldBe(
personal, "the editor's picker is the group's, not the screen's standing preference");
}
/// <remarks>
/// A parent belongs to one vault, and a group filed under one in another vault would be a level half
/// the people holding the key cannot resolve — their hosts would inherit a port and a username from
/// nothing. The same rule the host editor's group picker follows, one level up the same tree.
/// </remarks>
[Fact]
public async Task AGroupsParentPicker_OffersOnlyTheVaultItIsGoingInto()
{
await UnlockedAsync();
var vaults = shell.Vaults;
await CreateVaultAsync(vaults, "Platform secrets");
var vault = shell.Vault!;
var sharedVaultId = vaults.SelectedVault!.VaultId;
await vault.LoadAsync(Token);
// In the personal vault, which is where the standing preference points.
vault.NewGroupCommand.Execute(null);
vault.GroupEditorLabel = "estate";
await vault.SaveGroupCommand.ExecuteAsync(null);
vault.Groups.ShouldHaveSingleItem().Label.ShouldBe("estate", vault.Status);
vault.NewGroupCommand.Execute(null);
vault.GroupEditorParentChoices
.Any(choice => string.Equals(choice.Label, "estate", StringComparison.Ordinal))
.ShouldBeTrue("a group in the personal vault may be filed under a personal group");
vault.GroupEditorSelectedVault =
vault.GroupEditorVaultChoices.Single(choice => choice.VaultId == sharedVaultId);
vault.GroupEditorParentChoices.ShouldHaveSingleItem()
.EntityId.ShouldBeNull("only 'no parent' is left once the group is going somewhere else");
}
/// <remarks>
/// <para>
/// Dragging a host card onto a group card is the one gesture that files a host without opening its
/// editor, and it can now be aimed across a vault boundary, because both grids draw every readable
/// vault. The write it would make is the exact thing the host editor's group picker was fixed to
/// prevent: an id only the other vault's holders can resolve.
/// </para>
/// <para>
/// Refused and said so, rather than quietly treated as "no group" — the user is plainly filing
/// something, and unfiling it instead would be the wrong answer delivered silently.
/// </para>
/// </remarks>
[Fact]
public async Task AHostDraggedOntoAnotherVaultsGroup_IsRefusedRatherThanFiledUnderIt()
{
await UnlockedAsync();
var vaults = shell.Vaults;
await CreateVaultAsync(vaults, "Platform secrets");
var vault = shell.Vault!;
var sharedVaultId = vaults.SelectedVault!.VaultId;
await vault.LoadAsync(Token);
vault.NewGroupCommand.Execute(null);
vault.GroupEditorSelectedVault =
vault.GroupEditorVaultChoices.Single(choice => choice.VaultId == sharedVaultId);
vault.GroupEditorLabel = "production";
await vault.SaveGroupCommand.ExecuteAsync(null);
// The host stays in the personal vault, which is where a new one goes without being told otherwise.
vault.NewHostCommand.Execute(null);
vault.EditorLabel = "prod-db";
vault.EditorHostname = "db.internal";
await vault.SaveHostCommand.ExecuteAsync(null);
var host = vault.Hosts.Single(row => string.Equals(row.Label, "prod-db", StringComparison.Ordinal));
var group = vault.Groups.Single(row => row.VaultId == sharedVaultId);
host.VaultId.ShouldNotBe(sharedVaultId, "this test is meaningless with both in one vault");
await vault.MoveHostToGroupCommand.ExecuteAsync(new HostGroupMove(host, group.EntityId));
vault.Status.ShouldContain("its own vault");
vault.Hosts
.Single(row => string.Equals(row.Label, "prod-db", StringComparison.Ordinal))
.Host.GroupId
.ShouldBeNull("the host is left where it was rather than filed under an unresolvable group");
}
/// <remarks>
/// The mirror image of the host test above, and it goes the other way on purpose. A host filed into a
/// shared vault has to stay there, because hosts are read across every readable vault and so come back.
/// Tags are not — the editable list is the active vault's alone, like groups and buckets — so a tag
/// filed anywhere else would be created, pushed, reported as added and then invisible, with nothing on
/// the keychain screen able to rename or delete it and no active-vault switcher to go and find it with.
/// shared vault has to stay there, because hosts are read across every readable vault and so come back;
/// so does a group, since its list spans them too. Tags are not — the editable list is the active
/// vault's alone, like buckets — so a tag filed anywhere else would be created, pushed, reported as
/// added and then invisible, with nothing on the keychain screen able to rename or delete it and no
/// active-vault switcher to go and find it with.
/// </remarks>
[Fact]
public async Task ATagIgnoresTheTargetPicker_BecauseItsListOnlyEverShowsOneVault()