Skip to content

PR: Refactor setup and expose embedder backend in first-run - #60

Merged
savioruz merged 3 commits into
mainfrom
feat/web-setup-embedder-extraction
Aug 17, 2026
Merged

savioruz merged 3 commits into
mainfrom
feat/web-setup-embedder-extraction

Conversation

@savioruz

@savioruz savioruz commented Aug 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refactor the first-run setup flow into a shared memayu-setup crate so the CLI (dialoguer), TUI (ratatui), and web presenters drive the same ordered step list — then expose the embedder backend (local/remote) and extraction mode (llm/raw) choices in the web first-run UI (issue #55). Includes a non-breaking EmbedderBackend::Http → Remote rename (serde alias keeps "http" config valid). Base includes the already-merged #59 batch/MCP-camelCase (commit 5b4f946). CI green.

Changes

(1) Shared setup crate — commit 5c68761 (refactor, part of #55)

  • New crates/memayu-setup/Cargo.toml + src/lib.rs (~700 lines): move the canonical setup logic out of bin/memayu/src/setup_flow.rs into a reusable crate. Re-exports SetupStep, SETUP_STEPS (single source of truth), SetupAnswers, LocalModelSpec/LOCAL_MODELS, DeviceReport/check_device, preseed, embedding_dimension, finalize — so CLI, TUI, and web wizards all iterate the same steps and cannot drift.
  • crates/memayu-workspace/Cargo.toml: add crates/memayu-setup to workspace members.
  • bin/memayu/src/{wizard.rs,tui_setup.rs,main.rs}: switch from the local setup_flow module to use memayu_setup::{...}. wizard.rs (CLI) and tui_setup.rs (ratatui) now both drive memayu_setup::SETUP_STEPS.
  • ⚠️ Leftover: bin/memayu/src/setup_flow.rs is now an orphan (594 lines, no mod setup_flow; in main.rs → not compiled). Should be deleted (dead code). Flagged as Warning.

(2) Web setup exposes embedder backend + extraction mode — commit b2657b4 (issue #55)

  • crates/memayu-web/src/pages/setup.rs: the first-run web form now offers a step for embedder backend (local/remote radio) + extraction mode (llm/raw radio), with the local-model picker (dimension/fp32/int8/ram/languages preview) re-using memayu_setup::LOCAL_MODELS. State is driven by an Alpine.js step variable; POST collects embedder_backend/extraction_mode/local_model into the same SetupAnswers the CLI/TUI use.
  • crates/memayu-web/src/pages/providers.rs +1: surface local model in the providers list (consistent with bin/memayu doctor).
  • crates/memayu-web/static/memayu.css (+267): styling for the new embedder/extraction radio steps + local-model spec tile.

Embedder backend rename (http → remote) — non-breaking

  • crates/memayu-config/src/lib.rs: EmbedderBackend::Http → EmbedderBackend::Remote (Display writes "remote"), with #[serde(alias = "http")] and parser "remote" | "http" → Remote. Existing MEMAYU_EMBEDDER_BACKEND=http configs still parse; newly written configs persist "remote". No migration function (read compat via alias).
  • Updated doc comments + .env.example / validation messages accordingly.

Docs

  • README: memayu setup (CLI) and memayu setup --tui pointers + embedder backend values remote/local.

Migration / behavior

  • No DB schema change.
  • Config: embedder.backend = "http" still accepted (read); writes "remote". local unchanged. Non-breaking at the wire/config level.
  • CLI: no behavior change (wizard now delegates to the shared crate).
  • New crate memayu-setup is internal (path dep), no public release impact.

Tests

  • Existing cli.rs/doctor.rs/dashboard suites still pass (CI green, test 1m15s).
  • Web setup form fields covered by the shared memayu-setup unit logic; the orphan setup_flow.rs is not compiled so adds no warning noise.

Checklist

Fixes #55

The extraction-mode fix: `memayu setup` choosing `raw` still wrote a
fully-populated gpt-4 LLM row to `provider_config` (the LLM step is
skipped in raw mode, so the default gpt-4/base_url answers leaked
through). The runtime reads `runtime_settings` for the extraction mode
and never infers it from the LLM row, but the misleading placeholder
made a raw instance look configured for llm.

- memayu-setup: raw mode now writes an empty LLM block (no
  base_url/model/key) in both config_file_from_answers and
  provider_configs_from_answers.
- memayu-api::persist_provider_config: skip the `llm` row upsert
  entirely when extraction mode is Raw.

Bundles the related #55 embedder base_url normalization fix and its
regression tests (repo DB choke point, service persist, web form, and
POST /api/providers), which were pending in the same working tree.
@savioruz savioruz added enhancement New feature or request core memayu-core domain logic web web UI (Maud/htmx) infra CI/release/distribution priority-medium Medium priority — important but not blocking labels Aug 17, 2026
@savioruz savioruz added this to the v0.1.0 milestone Aug 17, 2026
@savioruz

Copy link
Copy Markdown
Owner Author

Review of PR #60 at b2657b4e100deff8d646b274cde0c5785f32802d, limited to origin/main...HEAD (net = 2 commits: 5c68761 setup-crate refactor + b2657b4 web-expose; #59 batch/MCP camelCase already on main).

🔴 Blocking

None. CI green: cargo build (1m3s), clippy (41s), fmt, test (1m15s), audit (2m27s).

🟡 Warning #1 — Non-breaking embedder rename Http→Remote writes "remote" but leaves old configs as "http" (no auto-migration)

EmbedderBackend::Http → Remote via #[serde(alias = "http")] so reads of old embedder.backend = "http" config still deserialize (✅). But there is no migrate() call, so an existing config file keeps "http" on disk until the user re-runs setup or edits it; reads still work. The Display impl now emits "remote", so any freshly written config will say remote. Acceptable (read-compat via alias), but worth a docs/README note that http and remote are synonyms. Not a regression.

🟡 Warning #2 — Orphaned bin/memayu/src/setup_flow.rs (594 lines) must be deleted

The shared setup logic was extracted into the new crates/memayu-setup crate; main.rs no longer declares mod setup_flow; and wizard.rs/tui_setup.rs now use memayu_setup::{...}. So bin/memayu/src/setup_flow.rs is a dead-copy (594 lines, uncompilable/ignored by the compiler). It is not a compile error (unused file), but it is stale duplication that can silently diverge from memayu-setup. Delete it before merge.

Validation

(1) Shared memayu-setup crate — commit 5c68761

  • New crates/memayu-setup (Cargo.toml + lib.rs ~700 lines) + workspace member registration. Exposes the canonical setup types/logic: SetupStep, SETUP_STEPS (ordered const — the single source of truth both presenters iterate), SetupAnswers, LocalModelSpec/LOCAL_MODELS/LOCAL_MODEL_NAMES, DeviceReport/check_device, preseed, embedding_dimension, finalize.
  • bin/memayu/src/main.rs no longer emits mod setup_flow; wizard.rs (CLI dialoguer) and tui_setup.rs (ratatui) both use memayu_setup::{...}. This removes the CLI/TUI setup drift flagged in prior reviews of PR feat(cli): improve cli setup wizard #58.
  • memayu-identity is reused for admin bootstrap (no duplicated account creation).
  • ⚠️ See Warning Config: replace .env-only with XDG config file + first-run setup wizard #2: the old bin/memayu/src/setup_flow.rs is not gated behind a mod and is therefore ignored by the compiler — delete it.

(2) Web first-run exposes embedder backend + extraction mode — commit b2657b4 (issue #55)

  • crates/memayu-web/src/pages/setup.rs: first-run web form gains an embedder backend step (local/remote radio) and an extraction mode step (llm/raw radio), reusing memayu_setup::LOCAL_MODELS for the local-model picker (shows dim/fp32/int8/ram/languages). Selection is driven by an Alpine.js step variable and posted into the same SetupAnswers shape as the CLI/TUI.
  • providers.rs +1 + memayu.css (+267): style the new radio steps + local-model spec tile; local model surfaced in providers list.
  • Rename Http→Remote: config/lib.rs parse "remote" | "http" → Remote, Display="remote", #[serde(alias="http")], doc/validation messages updated; .env.example touched. Reads old http config (✅ via alias); writes remote.

Migration / breaking

Tests

  • Existing cli.rs, doctor.rs, and dashboard test suites pass (CI green, cargo test 1m15s).
  • Note: no dedicated UI assertion on the new web form fields was added in this PR (Rust DOM/UI assertions are sparse in this repo); coverage is the shared memayu-setup unit logic exercised via the CLI/TUI subprocess tests. Acceptable.

Checklist

Note: description edited pre-review (split the two commits, corrected the issue ref to #55 only — #54/#45 live in sibling PRs #58/#60 context, #18 is the already-merged Candle base; flagged the orphan file).

@savioruz
savioruz marked this pull request as ready for review August 17, 2026 11:02
@savioruz
savioruz merged commit 9344ee7 into main Aug 17, 2026
5 checks passed
@savioruz
savioruz deleted the feat/web-setup-embedder-extraction branch August 25, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core memayu-core domain logic enhancement New feature or request infra CI/release/distribution priority-medium Medium priority — important but not blocking web web UI (Maud/htmx)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web UI first-run setup should support embedder (local/remote) and extraction mode (llm/raw) selection

1 participant