Skip to content

feat(web): add memory detail modal showing full content (#56) - #63

Merged
savioruz merged 1 commit into
mainfrom
feat/web-memory-detail
Aug 25, 2026
Merged

savioruz merged 1 commit into
mainfrom
feat/web-memory-detail

Conversation

@savioruz

Copy link
Copy Markdown
Owner

The /home list and search results render each memory with a truncate class, so long content was clipped with no way to read it in full.

Add GET /home/memory/{id} returning an HTMX modal fragment with the complete content in a scrollable, wrap-safe region plus created_at / updated_at and metadata badges. List rows and search result rows are now clickable (hx-get into a #memory-detail-target container) to open the modal.

Regression test seeds a 20KB-content memory and asserts the detail endpoint returns the full untruncated content and metadata.

The /home list and search results render each memory with a
truncate class, so long content was clipped with no way to read it
in full.

Add GET /home/memory/{id} returning an HTMX modal fragment with the
complete content in a scrollable, wrap-safe region plus created_at /
updated_at and metadata badges. List rows and search result rows are
now clickable (hx-get into a #memory-detail-target container) to open
the modal.

Regression test seeds a 20KB-content memory and asserts the detail
endpoint returns the full untruncated content and metadata.
@savioruz savioruz added enhancement New feature or request web web UI (Maud/htmx) self-hosted Relates to self-hosted / local-first usage priority-medium Medium priority — important but not blocking labels Aug 25, 2026
@savioruz savioruz added this to the v0.1.0 milestone Aug 25, 2026
@savioruz

Copy link
Copy Markdown
Owner Author

Review of PR #63 at 9a44e415ccc3604633e183102dac89ec964c8638 (base main), net change = 5 files (+214/-2): pages/memory.rs (new), lib.rs (mod), pages/mod.rs (mod), home.rs, tests/dashboard.rs. Implements #56 (full, untruncated memory content on demand).

🔴 Blocking

None. CI: build pending / clippy / test pending at review time (fmt pass). Logic review is source-based (PR description + diff sufficient); will re-check CI on re-review.

🟡 Warning #1 — inline <script> triggers showModal() on every HTMX swap

detail_modal ends with an inline script if (m && typeof m.showModal==='function') m.showModal();. It runs once when the fragment is swapped in (guarded by getElementById), and the only other htmx:afterSwap listener wires #memory-list pagination — no overlap — so there is no double-open today. It is fine, but it is inline script-per-modal; if modal is opened multiple times without a fresh swap, getElementById + guard prevent errors. Acceptable; consider moving to a delegated htmx:afterOnLoad handler later for cleanliness. Minor.

Validation

Memory detail modal (#56)

  • crates/memayu-web/src/pages/memory.rs (new, 100 lines): GET /home/memory/{id} returns an HTMX modal fragment (dialog.modal + modal-box) with the full, untruncated content in a scrollable region (overflow-y-auto, max-height:50vh, white-space:pre-wrap, word-break:break-word, pre-wrap), plus created/updated timestamps and a metadata badge list.
  • Content + layout never clipped (list rows still truncate a snippet — by design); full content only in the modal.
  • Authorization: service.get_memory(&id) + mem.user_id == user.id check — cross-user access returns 404 (privacy-preserving, no existence leak). ✅
  • Metadata sorted via BTreeMap<&String,_> (stable tag order). Close button, ESC/dialog-backdrop, and showModal() deferred via inline script guarded by a null/type check.

List integration (home.rs)

  • Row click: hx-get=/home/memory/{id} → hx-target=#memory-detail-target, hx-swap=innerHTML; list keeps the truncated snippet. Modal lazy-loaded fragment swapped into the reserved target div. Reverse-pagination + htmx.ajax wiring unchanged.

Route registration (lib.rs / pages/mod.rs)

  • pub mod memory; added and mounted under /home auth group (share CurrentUser extractor).

Tests (crates/memayu-web/tests/dashboard.rs)

  • memory_detail_shows_full_long_content_and_metadata: seeds a long memory (content truncated in list), opens GET /home/memory/<id> fragment, asserts the full content is present (not truncated) and metadata rendered. Full HTTP round-trip via build_test_app (StubEmbedder with deterministic FNV-1a 3-dim vectors).
  • Existing dashboard suite (login_rejects_bad_password, search, setup-key-modal, pagination) still compiles/pass against the new lib.rs/home.rs/memory.rs.

Migration / breaking

  • No DB schema change.
  • Only additive: new route + new module + new test; list/search/pagination paths unchanged.
  • GET /home/memory/{id} is under the existing /home authenticated router — no new public surface.

Checklist

Note: PR title is clean (no redundant prefix); description adequate. CI not green at review time (build/test/audit pending) — logic review is complete and source-based; the source-based checks (auth guard, untruncated-region, additive-only) are satisfied independent of CI, and CI must go green before merge. Comment updated in place per ZeroClaw convention.

@savioruz
savioruz marked this pull request as ready for review August 25, 2026 12:09
@savioruz
savioruz merged commit 4132e82 into main Aug 25, 2026
5 checks passed
@savioruz
savioruz deleted the feat/web-memory-detail 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

enhancement New feature or request priority-medium Medium priority — important but not blocking self-hosted Relates to self-hosted / local-first usage web web UI (Maud/htmx)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant