feat(gui): show snapshot policy, withheld snapshots and not-migrated clones; raise visible window

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5.5 committed 2026-11-16 17:36:06 +01:00
1 parent 23b7970644
commit e3a16a494c
3 files changed
+84 -3

No files matched your search

+18
View File
@@ -199,6 +199,17 @@ fn render(ui: &MainWindow) {
ui.set_wt_count(agg.worktrees as i32);
ui.set_attention_count(agg.attention as i32);
ui.set_has_config(snap.config.is_some());
let nm: Vec<SharedString> = snap
.status
.as_ref()
.and_then(|s| s["not_migrated"].as_array())
.map(|a| {
a.iter()
.filter_map(|p| p.as_str().map(SharedString::from))
.collect()
})
.unwrap_or_default();
ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm))));
let empty = Vec::new();
let repos: Vec<Repo> = snap
@@ -243,6 +254,7 @@ fn render(ui: &MainWindow) {
phase: s(r, "phase").into(),
last_sync: model::ago(r["last_sync"].as_u64().unwrap_or(0), now).into(),
error: r["last_error"].as_str().unwrap_or("").into(),
withheld: r["snapshots_withheld"].as_str().unwrap_or("").into(),
path: path.into(),
wts: ModelRc::from(Rc::new(VecModel::from(wts))),
}
@@ -286,6 +298,7 @@ fn render(ui: &MainWindow) {
time: model::clock(e["ts"].as_u64().unwrap_or(0), off).into(),
kind: s(e, "kind").into(),
repo: e["repo"].as_str().unwrap_or("–").into(),
tone: model::log_tone(&s(e, "kind")).into(),
msg: s(e, "msg").lines().next().unwrap_or("").into(),
})
.collect();
@@ -350,6 +363,11 @@ fn toast(ui: &MainWindow, msg: &str, bad: bool) {
}
fn show_window(ui: &MainWindow, core: &Core) {
// Slint exposes no xdg-activation, so an already visible window is raised by re-mapping it:
// a fresh toplevel is what the compositor focuses.
if core.visible.load(Ordering::SeqCst) && ui.window().is_visible() {
let _ = ui.hide();
}
let _ = ui.show();
// On Wayland a window shown from an idle (hidden) loop is not mapped until another event
// arrives; a one-shot redraw request provides it.
+34 -2
View File
@@ -112,6 +112,15 @@ pub fn aggregate(status: Option<&Value>) -> Aggregate {
}
}
/// Colour key of an activity event kind.
pub fn log_tone(kind: &str) -> &'static str {
match kind {
"error" | "watch_error" => "error",
"state" | "snapshots_withheld" | "snapshots_purged" | "declined" => "warn",
_ => "ok",
}
}
/// Last two path components, e.g. `work/api`.
pub fn short(path: &str) -> String {
let parts: Vec<&str> = path.split('/').filter(|p| !p.is_empty()).collect();
@@ -172,7 +181,7 @@ fn names(v: Option<&Value>) -> Vec<String> {
.unwrap_or_default()
}
/// One line per group: routes (private + public), owners and layout.
/// One line per group: routes (private + public), snapshot policy, owners and layout.
pub fn group_summary(g: &Value) -> String {
let mut s = format!("primary {}", str_of(g, "primary"));
let mirrors = names(g.get("mirror_to"));
@@ -186,6 +195,9 @@ pub fn group_summary(g: &Value) -> String {
s += &format!(" → {}", pm.join(", "));
}
}
if let Some(p) = g.get("snapshots").and_then(Value::as_str) {
s += &format!(" · snapshots: {p}");
}
if let Some(o) = g
.get("owners")
.and_then(Value::as_object)
@@ -231,6 +243,13 @@ pub fn settings_sections(cfg: &Value) -> Vec<Section> {
"Largest synced file".into(),
format!("{} MiB", num("max_file_mb", 50)),
),
(
"Snapshots (default)".into(),
sync.and_then(|s| s.get("snapshots"))
.and_then(Value::as_str)
.unwrap_or("private-only")
.to_string(),
),
];
let providers = cfg
.get("providers")
@@ -361,6 +380,14 @@ mod tests {
assert!(parse_import_listing("nothing to import").is_empty());
}
#[test]
fn log_tones() {
assert_eq!(log_tone("snapshots_withheld"), "warn");
assert_eq!(log_tone("snapshots_purged"), "warn");
assert_eq!(log_tone("snapshots_enabled"), "ok");
assert_eq!(log_tone("watch_error"), "error");
}
#[test]
fn formatting() {
assert_eq!(short("/home/u/Workspace/work/api"), "work/api");
@@ -383,18 +410,23 @@ mod tests {
"providers": {"gitea": {"kind": "gitea", "url": "https://g.example"}, "gh": {"kind": "github"}},
"groups": [{"name": "work", "primary": "gitea", "mirror_to": ["gh"],
"owners": {"gitea": "Org", "gh": "org-gh"},
"snapshots": "none",
"public": {"primary": "gh", "mirror_to": ["gitea"]}}],
"config_repo": {"name": "grove-config", "provider": "gitea"}
});
let s = settings_sections(&cfg);
assert_eq!(s[0].1[0], ("Name".into(), "pca".into()));
assert_eq!(s[0].1[2].1, "60 s");
assert_eq!(
s[0].1[4],
("Snapshots (default)".into(), "private-only".into())
);
// Providers come out sorted by id.
assert_eq!(s[1].1[0].1, "github");
assert_eq!(s[1].1[1].1, "gitea · https://g.example");
assert_eq!(
s[2].1[0].1,
"primary gitea · mirrors: gh · public: gh → gitea · owners: gh=org-gh, gitea=Org · bare-worktrees"
"primary gitea · mirrors: gh · public: gh → gitea · snapshots: none · owners: gh=org-gh, gitea=Org · bare-worktrees"
);
assert_eq!(s[3].1[0].1, "grove-config on gitea");
assert_eq!(group_name("work → gitea"), "work");
+32 -1
View File
@@ -16,6 +16,7 @@ export struct Repo {
phase: string,
last-sync: string,
error: string,
withheld: string,
wts: [Wt],
}
@@ -24,6 +25,7 @@ export struct LogRow {
kind: string,
repo: string,
msg: string,
tone: string,
}
export struct Kv {
@@ -176,6 +178,7 @@ export component MainWindow inherits Window {
in property <int> wt-count;
in property <int> attention-count;
in property <[Repo]> repos;
in property <[string]> not-migrated;
in property <[LogRow]> log;
in property <[string]> groups;
in property <[string]> providers;
@@ -355,6 +358,22 @@ export component MainWindow inherits Window {
text: "Start it with `systemctl --user start groved` (or run `groved` in a terminal).";
}
}
if !root.offline && root.not-migrated.length > 0: Card {
Text {
text: "Not migrated clones";
font-weight: 700;
}
Muted {
text: "These clones are in your workspace but not managed by grove yet: run `grove add` for each one to bring it into a group.";
}
for p in root.not-migrated: Muted {
text: p;
font-size: 12px;
overflow: elide;
}
}
if !root.offline && root.loading: Muted {
text: "Loading…";
}
@@ -403,6 +422,13 @@ export component MainWindow inherits Window {
font-size: 11px;
}
if r.withheld != "": Text {
text: "snapshots withheld: " + r.withheld;
color: #d98e1f;
font-size: 12px;
overflow: elide;
}
if r.error != "": Text {
text: r.error;
color: #d9483b;
@@ -496,6 +522,11 @@ export component MainWindow inherits Window {
}
}
if root.detail.withheld != "": Text {
text: "snapshots withheld: " + root.detail.withheld;
color: #d98e1f;
wrap: word-wrap;
}
if root.detail.error != "": Text {
text: root.detail.error;
color: #d9483b;
@@ -646,7 +677,7 @@ export component MainWindow inherits Window {
Text {
width: 90px;
text: e.kind;
color: Tone.of(e.kind == "error" || e.kind == "watch_error" ? "error" : e.kind == "state" ? "warn" : "ok");
color: Tone.of(e.tone);
font-size: 12px;
font-weight: 700;
}