mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 15:26:09 +00:00
feat(gui): stalled repos, runtime not-migrated rows, safer import cleanup
- daemon status reports stalled repos; GUI shows them with the backup hint - activity: repo_stalled is a warning; repo_added/removed shown - migrate rows keep their result only until the next status refresh - import removes a failed clone's directory only if it created it Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
01c4974c07
commit
b875a41b4d
8 files changed
+63
-6
No files matched your search
@@ -86,6 +86,8 @@ pub struct Shared {
|
|||||||
pub repos: BTreeMap<PathBuf, RepoStatus>,
|
pub repos: BTreeMap<PathBuf, RepoStatus>,
|
||||||
/// Plain clones in configured groups: ignored until migrated with `grove add`.
|
/// Plain clones in configured groups: ignored until migrated with `grove add`.
|
||||||
pub not_migrated: Vec<PathBuf>,
|
pub not_migrated: Vec<PathBuf>,
|
||||||
|
/// Repos left alone because an interrupted `grove add`/clone left a marker behind.
|
||||||
|
pub stalled: Vec<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Msg {
|
pub enum Msg {
|
||||||
@@ -365,6 +367,7 @@ fn rescan(
|
|||||||
{
|
{
|
||||||
let mut shared = ctx.shared.lock().unwrap();
|
let mut shared = ctx.shared.lock().unwrap();
|
||||||
shared.not_migrated = d.not_migrated;
|
shared.not_migrated = d.not_migrated;
|
||||||
|
shared.stalled = d.stalled.clone();
|
||||||
shared.repos.retain(|p, _| {
|
shared.repos.retain(|p, _| {
|
||||||
let keep = found.contains(p);
|
let keep = found.contains(p);
|
||||||
if !keep {
|
if !keep {
|
||||||
|
|||||||
@@ -169,7 +169,8 @@ fn handle(req: &Request, ctx: &Ctx) -> Value {
|
|||||||
.collect();
|
.collect();
|
||||||
ok(
|
ok(
|
||||||
json!({"machine": ctx.machine, "paused": s.paused, "now": now_secs(), "repos": repos,
|
json!({"machine": ctx.machine, "paused": s.paused, "now": now_secs(), "repos": repos,
|
||||||
"not_migrated": s.not_migrated.iter().map(|p| p.display().to_string()).collect::<Vec<_>>()}),
|
"not_migrated": s.not_migrated.iter().map(|p| p.display().to_string()).collect::<Vec<_>>(),
|
||||||
|
"stalled": s.stalled.iter().map(|p| p.display().to_string()).collect::<Vec<_>>()}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"pause" | "resume" => {
|
"pause" | "resume" => {
|
||||||
|
|||||||
@@ -712,6 +712,10 @@ fn stale_busy_marker_keeps_the_repo_out_and_warns_once() {
|
|||||||
assert_eq!(events(&sock, "repo_stalled").len(), 1);
|
assert_eq!(events(&sock, "repo_stalled").len(), 1);
|
||||||
assert_eq!(repo_paths(&sock).len(), 1);
|
assert_eq!(repo_paths(&sock).len(), 1);
|
||||||
assert!(stale.join(".grove-busy").exists());
|
assert!(stale.join(".grove-busy").exists());
|
||||||
|
assert_eq!(
|
||||||
|
status(&sock)["stalled"],
|
||||||
|
json!([stale.display().to_string()])
|
||||||
|
);
|
||||||
d.shutdown();
|
d.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,27 @@ fn render(ui: &MainWindow) {
|
|||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
// A result is shown until the daemon's list moves on, then it goes.
|
||||||
|
let listed: HashSet<&str> = snap
|
||||||
|
.status
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|s| s["not_migrated"].as_array())
|
||||||
|
.map(|a| a.iter().filter_map(Value::as_str).collect())
|
||||||
|
.unwrap_or_default();
|
||||||
|
if !st.migrating {
|
||||||
|
st.mig.retain(|p, _| listed.contains(p.as_str()));
|
||||||
|
}
|
||||||
|
let stalled: Vec<SharedString> = snap
|
||||||
|
.status
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|s| s["stalled"].as_array())
|
||||||
|
.map(|a| {
|
||||||
|
a.iter()
|
||||||
|
.filter_map(|p| p.as_str().map(SharedString::from))
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
ui.set_stalled(ModelRc::from(Rc::new(VecModel::from(stalled))));
|
||||||
ui.set_migrating(st.migrating);
|
ui.set_migrating(st.migrating);
|
||||||
ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm))));
|
ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm))));
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ pub fn reconcile_outputs(outputs: &mut HashMap<String, OutRec>, states: &HashMap
|
|||||||
pub fn log_tone(kind: &str) -> &'static str {
|
pub fn log_tone(kind: &str) -> &'static str {
|
||||||
match kind {
|
match kind {
|
||||||
"error" | "watch_error" => "error",
|
"error" | "watch_error" => "error",
|
||||||
"state" | "snapshots_withheld" | "snapshots_purged" | "declined" => "warn",
|
"state" | "snapshots_withheld" | "snapshots_purged" | "declined" | "repo_stalled" => "warn",
|
||||||
_ => "ok",
|
_ => "ok",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,6 +453,9 @@ mod tests {
|
|||||||
assert_eq!(log_tone("snapshots_purged"), "warn");
|
assert_eq!(log_tone("snapshots_purged"), "warn");
|
||||||
assert_eq!(log_tone("snapshots_enabled"), "ok");
|
assert_eq!(log_tone("snapshots_enabled"), "ok");
|
||||||
assert_eq!(log_tone("watch_error"), "error");
|
assert_eq!(log_tone("watch_error"), "error");
|
||||||
|
assert_eq!(log_tone("repo_stalled"), "warn");
|
||||||
|
assert_eq!(log_tone("repo_added"), "ok");
|
||||||
|
assert_eq!(log_tone("repo_removed"), "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ export component MainWindow inherits Window {
|
|||||||
in property <[Repo]> repos;
|
in property <[Repo]> repos;
|
||||||
in property <[MigRow]> not-migrated;
|
in property <[MigRow]> not-migrated;
|
||||||
in property <bool> migrating;
|
in property <bool> migrating;
|
||||||
|
in property <[string]> stalled;
|
||||||
in property <string> migrate-confirm-text;
|
in property <string> migrate-confirm-text;
|
||||||
in property <[LogRow]> log;
|
in property <[LogRow]> log;
|
||||||
in property <[string]> groups;
|
in property <[string]> groups;
|
||||||
@@ -379,6 +380,22 @@ export component MainWindow inherits Window {
|
|||||||
text: "Start it with `systemctl --user start groved` (or run `groved` in a terminal).";
|
text: "Start it with `systemctl --user start groved` (or run `groved` in a terminal).";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !root.offline && root.stalled.length > 0: Card {
|
||||||
|
Text {
|
||||||
|
text: "Stalled repositories";
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
Muted {
|
||||||
|
text: "An interrupted `grove add` or clone left a marker in these repositories, so grove leaves them alone. Check the repository and restore from the backups (see the Activity log), then remove the `.grove-busy` / `.grove-stage` marker by hand.";
|
||||||
|
}
|
||||||
|
|
||||||
|
for p in root.stalled: Muted {
|
||||||
|
text: p;
|
||||||
|
font-size: 12px;
|
||||||
|
overflow: elide;
|
||||||
|
}
|
||||||
|
}
|
||||||
if !root.offline && root.not-migrated.length > 0: Card {
|
if !root.offline && root.not-migrated.length > 0: Card {
|
||||||
Text {
|
Text {
|
||||||
text: "Not migrated clones";
|
text: "Not migrated clones";
|
||||||
|
|||||||
@@ -412,9 +412,13 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> {
|
|||||||
let res = (|| -> Result<()> {
|
let res = (|| -> Result<()> {
|
||||||
let url = r.git_url(forge.protocol)?.to_string();
|
let url = r.git_url(forge.protocol)?.to_string();
|
||||||
let dir = gdir.join(&r.name);
|
let dir = gdir.join(&r.name);
|
||||||
|
let existed = dir.exists();
|
||||||
if let Err(e) = clone_bare_layout(&url, &dir, &forge.git_env) {
|
if let Err(e) = clone_bare_layout(&url, &dir, &forge.git_env) {
|
||||||
// Leave no empty directory behind (it only goes away when nothing was cloned).
|
// The busy marker is released by now. Remove only a directory this import
|
||||||
let _ = fs::remove_dir(&dir);
|
// created, and only while it is empty (`remove_dir` refuses anything else).
|
||||||
|
if !existed {
|
||||||
|
let _ = fs::remove_dir(&dir);
|
||||||
|
}
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
}
|
}
|
||||||
println!("imported {} -> {}", r.name, dir.display());
|
println!("imported {} -> {}", r.name, dir.display());
|
||||||
|
|||||||
+6
-2
@@ -122,8 +122,12 @@ for confirmation first (the dialog names the backup directory, `<state dir>/back
|
|||||||
path or the refusal message (linked worktrees, submodules, detached HEAD...). The bridge only runs
|
path or the refusal message (linked worktrees, submodules, detached HEAD...). The bridge only runs
|
||||||
`add` for an existing, non-symlink directory directly under `<root>/<group>/` and passes no flags
|
`add` for an existing, non-symlink directory directly under `<root>/<group>/` and passes no flags
|
||||||
(so no custom backup directory). Afterwards the status is refreshed; the daemon computes its
|
(so no custom backup directory). Afterwards the status is refreshed; the daemon computes its
|
||||||
not-migrated list at start (a daemon-side fix is separate), so finished rows stay on screen with
|
not-migrated list at runtime, so after a migration the row keeps its result on screen until the
|
||||||
their result until the daemon list changes.
|
next status refresh drops it. A second `grove add` is refused while a `.grove-busy` marker is held;
|
||||||
|
Migrate all runs strictly one clone at a time and shows that refusal text on the row. Repos the
|
||||||
|
daemon reports as `stalled` (interrupted operation, marker left behind) get their own card with
|
||||||
|
the hint to check the backups; `repo_added`, `repo_removed` and `repo_stalled` (warning) appear in
|
||||||
|
Activity.
|
||||||
|
|
||||||
## Diagnostics log
|
## Diagnostics log
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user