Files
Marcos Paulo 181aad91e6 feat: sync, accounts, live editing, vault launcher, compact layout
Sync and the server
- crates/sync: revision ledger (stale writers conflict, edit beats delete), client planner, three-way merge, conflict names, path and hash gates
- apps/notescraft-sync-server: pairing, device tokens, change log with long poll, blobs, accounts with many vaults, roles, invites, audit log, quota, GC, readiness, request ids
- server history (revisions, restore, retention), chunked resumable uploads, live editing endpoints (SSE rooms, presence, flush through the ledger)
- engine: HttpRemote, sync_once, SyncWorker, sync.* commands, share.* and server.* commands, live session client, note.capture, vault catalog and vaults.* commands

Editing together
- crates/collab: operational transformation core (TextOp, transform, client state machine, room, presence)
- ui-egui: Settings > Sync, sync pill, conflicts, Share dialog, live pill and remote carets, launcher Connect and Join flows

App shell
- vault launcher (desktop and phone layouts) wired into the app host (--launcher, File > Vaults...)
- compact (phone) layout with a bottom tab bar

Verified with cargo xtask ci (fmt, clippy -D warnings, workspace tests, layers, tree, i18n). Android and iOS shells are not built: the build machine has no NDK or Xcode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 07:46:24 -03:00

74 lines
3.0 KiB
Rust

//! Renders the vault launcher with sample rows, offscreen: `--size 1280x800 --out file.png`
//! (below 600 pt wide it draws the phone layout).
use notescraft_engine::{SyncBadge, VaultRow};
use notescraft_ui_egui::{launcher::Launcher, theme::Tokens};
/// A sample row; `role` marks a shared vault.
fn row(name: &str, path: &str, pinned: bool, ago_hours: u64, sync: SyncBadge, role: Option<&str>) -> VaultRow {
VaultRow {
path: path.to_owned(),
name: name.to_owned(),
pinned,
last_opened_ms: NOW.saturating_sub(ago_hours * 3_600_000),
exists: !path.contains("USB"),
sync,
server: role.map(|_| String::from("sync.example.net")),
role: role.map(str::to_owned),
}
}
/// A fixed "now" (noon, 2026-10-20) so the render does not change between runs.
const NOW: u64 = 1_792_454_400_000 + 43_200_000;
struct Preview {
tokens: Tokens,
launcher: Launcher,
ready: bool,
}
fn main() {
let Some(theme) = notescraft_themes::builtin("catppuccin-mocha") else { return };
let args: Vec<String> = std::env::args().collect();
let arg = |name: &str| args.iter().position(|a| a == name).and_then(|i| args.get(i + 1).cloned());
let size = arg("--size")
.and_then(|s| s.split_once('x').and_then(|(w, h)| Some(egui::vec2(w.parse().ok()?, h.parse().ok()?))))
.unwrap_or(egui::vec2(1280.0, 800.0));
let out = arg("--out").unwrap_or_else(|| "/tmp/notescraft-launcher.png".to_owned());
let rows = vec![
row("Journal", "~/Notes/Journal", true, 2, SyncBadge::Synced, None),
row("Project Atlas", "~/Notes/Atlas", false, 26, SyncBadge::Waiting(2), Some("Editor")),
row("Work", "/Volumes/Storage/Work", false, 72, SyncBadge::Synced, None),
row("Obsidian archive", "~/Documents/Obsidian", false, 400, SyncBadge::NotSynced, None),
row("Old course notes", "/Volumes/USB/Course", false, 900, SyncBadge::NotSynced, None),
];
let mut harness = egui_kittest::Harness::builder()
.with_size(size)
.with_pixels_per_point(if size.x < 600.0 { 2.0 } else { 1.0 })
.with_max_steps(32)
.wgpu()
.build_ui_state(
|ui, state: &mut Preview| {
if !state.ready {
egui_extras::install_image_loaders(ui.ctx());
notescraft_ui_egui::fonts::install(ui.ctx());
notescraft_ui_egui::style::apply(ui.ctx(), &state.tokens);
state.ready = true;
ui.ctx().request_repaint();
return;
}
let _ = state.launcher.show(ui.ctx(), &state.tokens);
},
Preview { tokens: Tokens::new(theme), launcher: Launcher::new(rows, NOW), ready: false },
);
harness.run();
match harness.render() {
Ok(image) => {
if let Err(error) = image.save(&out) {
eprintln!("could not save screenshot: {error}");
}
}
Err(error) => eprintln!("could not render screenshot: {error}"),
}
}