0.1.6: GBrain brains — refreshed after sync, clashes never make a second page
- A vault has a kind on the hub: Obsidian (as before) or GBrain. Set it with
`lunesync vault kind`, the canvas panel or the window; Lune suggests it when
it finds gbrain.yml / .gbrain-source. Every change is in the access log.
- GBrain vaults: devices that have `gbrain` (looked for beyond PATH) are asked
once whether to refresh it after sync. Lune then runs
`gbrain sync --source <name> --no-pull` in the background after notes arrive
or are saved; it never holds up syncing. A failed refresh turns the vault
amber ("GBrain not refreshed") with Retry, also on the canvas.
- Clashes in GBrain vaults: lines both sides added are kept in the one note,
incoming first. Same lines changed: the incoming version stays, this
device's waits under Notes to tidy, stored in .git/lune/tidy (never a copy
file GBrain would index). Applies to syncing, undo, held notes and
handovers. Held notes moved aside stay red until decided.
- .gbrain-source is kept per device. Obsidian vaults are unchanged.
- SPEC: M8 section and decisions recorded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,8 @@ pub fn run(cfg: &VaultConfig, label: &str, poll: Duration, timing: Timing, log:
|
||||
let mut was_holding = false;
|
||||
let mut was_read_only = false;
|
||||
let mut announced: HashSet<String> = HashSet::new();
|
||||
// Set when notes changed here (this device's burst was saved, or others' arrived): GBrain vaults refresh.
|
||||
let mut brain_due = false;
|
||||
let leaving = state::lune_dir(&vault.git_dir).join("leaving");
|
||||
let nudge = state::lune_dir(&vault.git_dir).join("nudge");
|
||||
loop {
|
||||
@@ -138,6 +140,7 @@ pub fn run(cfg: &VaultConfig, label: &str, poll: Duration, timing: Timing, log:
|
||||
match vault.save_changes(None, &skip) {
|
||||
Ok(Some(saved)) => {
|
||||
say(&format!("saved: {}", saved.message));
|
||||
brain_due = true;
|
||||
if let Some(d) = saved.held {
|
||||
say(&format!(
|
||||
"HELD: this change removes or rewrites {} of {} notes, so it stays on this device. \
|
||||
@@ -196,6 +199,7 @@ pub fn run(cfg: &VaultConfig, label: &str, poll: Duration, timing: Timing, log:
|
||||
say("new changes are waiting until your current edits settle");
|
||||
}
|
||||
was_waiting = report.waiting_for_local_edits;
|
||||
brain_due |= !report.received.is_empty();
|
||||
print_report(&report, &say);
|
||||
backoff = poll;
|
||||
sync_at = Instant::now() + poll;
|
||||
@@ -214,6 +218,18 @@ pub fn run(cfg: &VaultConfig, label: &str, poll: Duration, timing: Timing, log:
|
||||
say(&format!("couldn't record sync status: {e:#}"));
|
||||
}
|
||||
}
|
||||
|
||||
if brain_due {
|
||||
brain_due = false;
|
||||
// The settings are read fresh: the hub can change a vault's kind, and the person can turn refreshing on, while we run.
|
||||
let current = crate::config::Config::load()
|
||||
.ok()
|
||||
.and_then(|c| c.vaults.into_iter().find(|v| v.path == cfg.path))
|
||||
.unwrap_or_else(|| cfg.clone());
|
||||
if crate::brain::after_changes(¤t) {
|
||||
say("refreshing GBrain in the background");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +254,15 @@ fn print_report(r: &SyncReport, say: &dyn Fn(&str)) {
|
||||
for (note, copy) in &r.kept_both {
|
||||
say(&format!("{note} was changed in two places — kept both, yours is in \"{copy}\""));
|
||||
}
|
||||
for note in &r.joined {
|
||||
say(&format!("{note} was added to in two places — both kept, the other device's lines first"));
|
||||
}
|
||||
for note in &r.to_tidy {
|
||||
say(&format!("{note} was changed in two places — the other version stays, yours waits under Notes to tidy"));
|
||||
}
|
||||
for note in &r.held_to_tidy {
|
||||
say(&format!("{note} changed elsewhere while held here — your held version waits under Notes to tidy"));
|
||||
}
|
||||
for (note, copy) in &r.set_aside {
|
||||
say(&format!("{note} changed elsewhere while held here — your held version is now \"{copy}\""));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user