Milestone 6: canvas for health and leaving

Devices report freshness per vault every 30 s (counts only); the canvas
shows current / behind / offline, held secrets in red, and a Nudge that
reaches the device at its next check-in. Notes kept in two versions can
be compared side by side and tidied on the hub's copy. Handovers are
reviewed in the vault panel; people can be removed from the team and
restored with a one-time link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 09:47:28 +07:00
parent 193cb06f85
commit 8be559817c
15 changed files with 744 additions and 57 deletions

View File

@@ -34,6 +34,16 @@ pub fn arrive(config: &mut Config) -> Result<Vec<String>> {
for d in &me.leaving {
said.push(leave(config, &h, d)?);
}
if me.nudge {
// Each vault's runner sees this and shares at once.
for vc in config.vaults.iter().filter(|v| v.hub_vault.is_some()) {
let dir = state::lune_dir(&vc.path.join(".git"));
if dir.exists() {
std::fs::write(dir.join("nudge"), "")?;
}
}
said.push("Someone asked this device to share now — sharing".into());
}
for hv in me.vaults {
if let Some(vc) = config.vaults.iter().find(|v| v.hub_vault == Some(hv.id)) {
@@ -72,6 +82,24 @@ pub fn arrive(config: &mut Config) -> Result<Vec<String>> {
Ok(said)
}
/// Tells the hub how each of this device's hub vaults is doing (M6 freshness).
pub fn report(config: &Config) -> Result<()> {
let Some(h) = &config.hub else { return Ok(()) };
let label = config.device_label();
let mut out = vec![];
for vc in config.vaults.iter().filter(|v| v.hub_vault.is_some()) {
let Ok(v) = Vault::open(vc, &label) else { continue };
out.push(hub::VaultHealth {
vault_id: vc.hub_vault.unwrap(),
last_synced: state::SyncState::load(&v.git_dir).last_synced,
waiting: v.waiting_files().unwrap_or(0),
held_secrets: v.secret_holds().map(|n| n.len()).unwrap_or(0),
holding: !crate::guard::load(&v.git_dir).is_empty(),
});
}
h.report(&out)
}
/// Leaves one vault: stop syncing, save, make read-only, hand over what wasn't shared, and once the
/// hub has it, delete the folder if the app created it.
pub fn leave(config: &mut Config, link: &HubLink, d: &Departure) -> Result<String> {