diff --git a/CLAUDE.md b/CLAUDE.md index 806b95d..736fb30 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,8 +4,7 @@ Linux tool that keeps chosen git repos continuously in sync across machines, including uncommitted work, via snapshot refs (`refs/sync//`) on a primary remote. Rust workspace: `grove-core`, `grove` (CLI), `grove-daemon` (`groved`), `grove-providers` (Gitea/Forgejo/GitHub), -`grove-bridge` (localhost HTTP bridge for the GUI), plus `gui/ui` (plain HTML/JS) and `gui/src-tauri` (Tauri shell, -outside the workspace, never compiled yet). Phases 0-5 are implemented; the real two-PC run is still pending. +`grove-gui` (native Slint desktop app with a ksni tray, `docs/phase7.md`). Phases 0-7 are implemented; the real two-PC run is still pending. Do not start new work before the previous results are written to `docs/`. ## Commands @@ -13,17 +12,17 @@ Do not start new work before the previous results are written to `docs/`. - Throwaway Forgejo (dev only, Podman): `spikes/forgejo-up.sh`, then `spikes/phase0.sh` - Rust: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo test` - Daemon: `cargo run -p grove-daemon --bin groved -- --config PATH`; client `grove daemon status` -- GUI in a browser: `cargo run -p grove-bridge -- --ui gui/ui`; Tauri shell: see `docs/phase3.md` +- GUI: `cargo run -p grove-gui` (`--hidden` starts in the tray; needs a Wayland/X11 session and a StatusNotifier host) - Package: `cargo build --release --workspace && cargo deb -p grove --no-build` - Throwaway e2e on a local Forgejo: `spikes/phase4-e2e.sh` ## Architecture -See `docs/` (`phase0-spike.md` ... `phase6.md`, `DECISIONS.md`). Git is the storage layer; shell out to +See `docs/` (`phase0-spike.md` ... `phase7.md`, `DECISIONS.md`). Git is the storage layer; shell out to system `git`; snapshots use a temp `GIT_INDEX_FILE` + `commit-tree`, never touching the user's branch or index. ## Conventions -- Dependencies: serde+toml, clap+anyhow, notify+serde_json, ureq, keyring, age, tauri v2 (GUI shell), approved. Ask before adding more. +- Dependencies: serde+toml, clap+anyhow, notify+serde_json, ureq, keyring, age, slint (GUI, `winit` + software renderer) and ksni (tray), approved. Ask before adding more. - Everything in the repo is English. Open questions go to `docs/DECISIONS.md`. - Never destroy local work; divergence is surfaced, never auto-merged. @@ -39,3 +38,4 @@ Native Linux app (systemd user service). Never Docker for deployment. ## Gotchas - Forgejo push mirrors to localhost need `migrations.ALLOW_LOCALNETWORKS` (test instances only). - Push-mirror exclusion of `refs/sync/*` is verified on Forgejo 11 only, not yet on the real Gitea. +- Slint on Wayland: a window shown from an idle (hidden) event loop is not mapped until another event arrives; `show_window` schedules a one-shot redraw. Keep it. diff --git a/LESSONS.md b/LESSONS.md index dadba6a..cb0811b 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -8,3 +8,5 @@ - Bare-layout clones must set upstream tracking per branch, or `status` silently reports Synced for Behind/Diverged. Assert tracking in tests of any clone path. - Unix socket paths are limited to ~100 bytes: use a short `XDG_RUNTIME_DIR` (e.g. `/tmp/gd`) when running a daemon from deep scratch dirs. - Mock-server tests must parse the JSON request body; pretty-printed JSON breaks string asserts. +- Slint (winit/Wayland): `show()` from an idle event loop leaves the window unmapped until another event arrives; follow it with a one-shot `request_redraw` timer. +- Slint has no top-level `function`; use a `global`. A wrapped `Text` under-reports its preferred height inside layouts, so elide long log/error text instead of wrapping it. diff --git a/docs/phase3.md b/docs/phase3.md index 6f66e75..f8d9bfe 100644 --- a/docs/phase3.md +++ b/docs/phase3.md @@ -1,4 +1,8 @@ -# Phase 3: GUI +# Phase 3: GUI (superseded) + +> **Superseded by [Phase 7](phase7.md).** The HTML/JS frontend, the localhost bridge and the Tauri +> shell described below were removed; the native `grove-gui` replaces them. Kept for history. + ## Layout diff --git a/docs/phase7.md b/docs/phase7.md new file mode 100644 index 0000000..6a485cd --- /dev/null +++ b/docs/phase7.md @@ -0,0 +1,77 @@ +# Phase 7: native GUI + +`grove-gui` (crate `crates/grove-gui`) replaces the web UI of Phase 3. It is a native desktop app +(Slint UI, StatusNotifierItem tray) that lives in the system tray. It contains no sync logic: state +comes from the daemon over its Unix socket and every action runs an allow-listed `grove` subcommand, +exactly as before. + +## Architecture + +| Part | Where | +|---|---| +| Daemon IPC + allow-listed CLI calls + config (formerly `grove-bridge`) | `src/bridge.rs` | +| Pure logic: status -> aggregate/tray state, formatting, `grove import` listing parser, settings summary | `src/model.rs` | +| Tray (ksni), icons drawn in code per state | `src/tray.rs` | +| Single instance (Unix socket) | `src/instance.rs` | +| Window, callbacks, worker threads | `src/main.rs`, `ui/app.slint` | + +Threads: the Slint event loop; a worker that fetches `status` (and `log`/config only while the window +is visible); a subscriber that holds a `subscribe` connection to the daemon and wakes the worker on +every event (reconnects every 5 s while the daemon is down); the tray service; the single-instance +listener; short-lived threads for CLI calls so the UI never blocks. Fallback poll: 5 s with the +window open, 30 s hidden. No Slint timers run while idle. + +Tray states: ok, syncing, attention (also sets the item to `NeedsAttention`), paused, daemon offline. +Menu: Open, Sync now, Pause/Resume, Quit; left click opens the window. Closing the window hides it; +Quit exits. If no StatusNotifier host exists, closing the window quits. A transition into +`Diverged`/`Error` shows a toast when the window is open and calls `notify-send` (best effort) when hidden. + +Single instance: `$XDG_RUNTIME_DIR/grove/gui.sock`. A second `grove-gui` asks the first to show +its window and exits; `grove-gui --hidden` (autostart) only checks and never raises the window. + +Screens (parity with Phase 3): repositories with per-worktree state, repository detail with the +resolve panel (confirmation first), activity with filter, new repository, import (scan, pick, +import), settings (machine, providers, groups incl. public route and `owners`, config repo, token +login, secrets), onboarding when there is no config, offline state with a hint. + +## Run + +```bash +cargo run --release -p grove-gui # window + tray +grove-gui --hidden # tray only +grove-gui --config PATH --socket PATH --grove-bin PATH # test against another daemon/config +grove-gui --view settings # start on a view (activity, new, import, repo:) +``` + +`grove` is looked up next to the `grove-gui` binary, then in `PATH`. Packaging: `.deb` installs +`grove-gui`, `contrib/grove.desktop`, `contrib/grove-autostart.desktop` (`/etc/xdg/autostart`) and +`assets/grove.png`. Dev builds need no system Qt: Slint is built with the `winit` backend (Wayland and +X11 loaded at runtime) and the software renderer. + +## Dependencies + +- `slint` / `slint-build` 1.18.1 (`std`, `backend-winit`, `renderer-software`, `compat-1-2`; no Qt, + no femtovg, no system-tray feature). Style `fluent` (pure Slint). Slint is licensed GPL-3.0 or its + royalty-free license (attribution required) or a commercial one; pick one before distributing. +- `ksni` 0.3.7 (`async-io` + `blocking`, no tokio). + +## Memory (release build, KDE Plasma 6 / Wayland, `ps -o rss`) + +| State | Software renderer (used) | femtovg (GL) | +|---|---|---| +| Started with `--hidden` | 24-25 MB | 94 MB | +| Window open | 33.5 MB | 105 MB | +| After closing the window (hidden again) | 28 MB | not measured | + +Idle CPU hidden: 0 ticks in 20 s. 9 threads. + +## Limits + +- Showing an already visible window does not raise it (no xdg-activation token is passed). +- Activity timestamps use the local UTC offset read via `date +%z` (no timezone crate). +- The activity list shows the first line of each message, repository errors are cut at 160 characters + in the list (full text in the detail view). +- Slint's wrapped text under-reports its height in layouts, so long text is elided, not wrapped. +- Side-by-side compare for `Diverged` stays in the CLI (`grove resolve --compare`). +- Only the layout and read-only views were checked visually; forms and CLI-driven flows were not + clicked through (no input injection available), only their parsing and logic are unit-tested.