[PR #4963] [MERGED] feat(mari): Easy Viewer phase 4 — entry status, per-entry reject, prompt preview (#4931) #6557

Closed
opened 2026-10-23 04:11:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4963
Author: @kolacheee
Created: 8/13/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/mari-easy-viewer-entry-status


📝 Commits (10+)

  • 5ff9c5e feat(mari): show lorebook entry activation + vectorization in the Easy Viewer (#4931)
  • d0b3661 docs(changelog): note Easy Viewer entry activation + vectorization status (#4931)
  • cd2a157 feat(mari): server-side per-entry reject for pending reviews (#4931)
  • e5335b8 feat(mari): per-entry Reject control in the Easy Viewer (#4931)
  • b58ca75 feat(mari): synthetic Peek-Prompt render endpoint for reviewed edits (#4931)
  • 502e025 feat(mari): View as prompt preview for character/preset edits in the Easy Viewer (#4931)
  • 5f38569 docs(changelog): note Easy Viewer per-entry reject + prompt preview (#4931)
  • 85cfb8b fix(mari): address adversarial review of the Easy Viewer phase-4 (#4931)
  • 6479dff Merge remote-tracking branch 'origin/staging' into feat/mari-easy-viewer-entry-status
  • 8610911 fix(mari): address CodeRabbit review of the prompt preview + reject (#4931)

📊 Changes

10 files changed (+1535 additions, -105 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 packages/client/src/components/chat/HomeProfessorMariChat.tsx (+165 -3)
📝 packages/client/src/components/chat/MariEditEasyViewer.tsx (+263 -43)
➕ packages/client/src/components/chat/MariPromptPreviewModal.tsx (+159 -0)
📝 packages/client/src/lib/mari-edit-diff.ts (+3 -0)
📝 packages/client/src/localization/locales/en.json (+25 -3)
📝 packages/server/src/routes/professor-mari-workspace.routes.ts (+50 -0)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+306 -56)
➕ packages/server/src/services/professor-mari/workspace-edit-render.ts (+236 -0)
📝 scripts/regressions/open-issues.regression.ts (+325 -0)

📄 Description

Linked issue

Closes #4931

Covers all three Easy Viewer phase-4 items in one PR (per the issue): the activation/vectorization visibility, the true per-entry reject, and the Peek-Prompt-fidelity render. Builds on the Easy Viewer from #4919 / #4921.

Why this change

Three gaps in Professor Mari's "Easy Viewer" review cards:

  1. A lorebook entry's kind was not obvious. constant only showed as a chip when it changed, enabled as a Disabled badge, and vectorization not at all unless it changed — so a reviewer couldn't tell at a glance whether Mari made a Constant, Selective, or Normal entry, or whether it was vectorized.
  2. No true per-entry reject. The per-row control was Dismiss (a client-only hide); the only real revert was Restore, which reverts the whole batch. You couldn't revert one entry of a multi-entry change while keeping the rest.
  3. Character/preset edits showed only a field diff, not how they read in the prompt. The request was to see them the way they appear in Peek Prompt.

What changed

1. Always-visible activation + vectorization status (client-only). Each lorebook-entry card shows an activation pill (Constant / Selective / Normal, using the lorebook editor's own dot colors) and a vectorization pill (Vectorized / Vector excluded), rendered as from → to when Mari's edit changes them. The prominent Disabled badge is kept (enabled is orthogonal). A selective flip on a constant entry stays in the generic diff so it is never dropped; a derived embedding vector can never render as a giant diff.

2. True per-entry reject (server + client), scoped to lorebook entries. A destructive-styled Reject button reverts one entry while keeping the rest applied. Server: restoreChanges/validateAndFlushRestored extracted from restorePlan (behavior-preserving), and a new rejectRows(id, selections) reverts a dependency-closed subset through the same audited transaction, refuses anything that could dangle a reference (a cascade child, a non-entry row, a stale selection), then shrinks the pending record (recompute summary + mirrored fields + atomically rewrite the durable sidecar) or resolves it when empty. Preserves the audited undo contract: the #4852 in-tx supersede guard, apply/restore asymmetry, #4927 character-book sync, #4813 sidecar durability, the pending map's insertion order, and operationHash. The client sends the row's diffPreview index + a {table,id,action} tuple the server re-checks; the state_changed / invalid_selection paths return 200 ok:false so the reason shows inline.

3. Synthetic "View as prompt" preview (server + client) for character and preset edits (not deletes — the field diff covers those). A new render-prompt endpoint assembles the edited entity on its own — no persona, no chat history, previewOnly — before and after: a character edit uses a read-only DB proxy that substitutes the before/after snapshot for the live character row against the default preset; a preset/section/group/choice edit loads the edited row's own preset and splices the snapshot into the assembler arrays. The client shows a before/after diff of the assembled prompt (additions green, removals red), reusing the word-diff and the neutral panel chrome, labeled a preview. It is best-effort — any assembly failure renders as unavailable, never a 500.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated (already run locally; boxes above left for the human to confirm per repo policy):

  • pnpm check passes (TypeScript + ESLint + check-locales + client build), exit 0, after merging latest staging.
  • scripts/regressions/open-issues.regression.ts passes, including new cases: per-entry reject (partial reject reverts one entry and shrinks the card; a stale tuple and a non-entry row are refused; rejecting every entry leaves the shell), and the character render DB proxy (substitution, pass-through of other characters, null-drop) exercised through the storage getById path.
  • An adversarial review pass ran on the reject (audited undo path — no findings) and the render; four render/client findings were fixed (delete rows no longer offer the preview; the modal can't reopen after close; dismissals are kept on a no-op reject).

Still to verify in a real browser (not yet done — I do not run the shared dev server, to avoid a port collision with a running install):

  • Have Mari create/edit lorebook entries of each kind and confirm the activation + vectorization pills and the from → to transitions read correctly (light and dark theme, mobile wrapping).
  • Reject one entry of a multi-entry change: the entry reverts and disappears from other panels while the rest stay; try rejecting a superseded entry and confirm the state_changed message.
  • Open "View as prompt" on a character and a preset edit: the before/after prompt preview reads correctly and is clearly a preview; the button is absent on deletes; loading / unavailable states behave.
  • Confirm Keep / Restore / Dismiss and the Easy/Raw toggle still behave as before.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Notes: adds three CHANGELOG.md entries under ### Added. No user-facing docs under docs/ changed, so no docs-i18n update is required. No version bump.

UI evidence (if applicable)

Screenshots to be added from the manual browser pass. A design mockup of the activation/vectorization pills (including a from → to transition and the Disabled/Removed treatments) was shared with the maintainer during development.

Summary by CodeRabbit

  • New Features

    • Lorebook entries now show persistent activation and vectorization status.
    • Reviewers can expand change details and reject individual lorebook changes while protecting related references.
    • Added before-and-after prompt previews for character and preset edits.
    • Added clearer loading, error, and success feedback for review actions.
  • Bug Fixes

    • Derived vector data no longer appears as a field change.
    • Improved safeguards for partially rejecting multi-entry edits.
    • Prompt previews handle unavailable or empty results gracefully.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4963 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/13/2026 **Status:** ✅ Merged **Merged:** 8/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/mari-easy-viewer-entry-status` --- ### 📝 Commits (10+) - [`5ff9c5e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5ff9c5e5be88f06728997552c82af10f5e74d98c) feat(mari): show lorebook entry activation + vectorization in the Easy Viewer (#4931) - [`d0b3661`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d0b3661a3a7c33b9eae2a33e8ddf717c8e4a87cf) docs(changelog): note Easy Viewer entry activation + vectorization status (#4931) - [`cd2a157`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cd2a15726c1c7b294a0cfb3c8797a2542a97cc4a) feat(mari): server-side per-entry reject for pending reviews (#4931) - [`e5335b8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e5335b8599f301ec1899ef43e2a969bdc62ad099) feat(mari): per-entry Reject control in the Easy Viewer (#4931) - [`b58ca75`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b58ca75807d46a30715c2fc59af1404480528b0e) feat(mari): synthetic Peek-Prompt render endpoint for reviewed edits (#4931) - [`502e025`](https://github.com/Pasta-Devs/Marinara-Engine/commit/502e02580ad31c7f7aa1d4946a734f0174688b33) feat(mari): View as prompt preview for character/preset edits in the Easy Viewer (#4931) - [`5f38569`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5f38569f57c820e5858322bd742e930eafcb56cb) docs(changelog): note Easy Viewer per-entry reject + prompt preview (#4931) - [`85cfb8b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/85cfb8b4b7c5ef9cec902c6d2e5c477092c1d5b0) fix(mari): address adversarial review of the Easy Viewer phase-4 (#4931) - [`6479dff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6479dff9838dcc26844dd8d7e3bd4ef6eac3797a) Merge remote-tracking branch 'origin/staging' into feat/mari-easy-viewer-entry-status - [`8610911`](https://github.com/Pasta-Devs/Marinara-Engine/commit/86109110c4744aed76a72f2da7a99144ebe8b434) fix(mari): address CodeRabbit review of the prompt preview + reject (#4931) ### 📊 Changes **10 files changed** (+1535 additions, -105 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `packages/client/src/components/chat/HomeProfessorMariChat.tsx` (+165 -3) 📝 `packages/client/src/components/chat/MariEditEasyViewer.tsx` (+263 -43) ➕ `packages/client/src/components/chat/MariPromptPreviewModal.tsx` (+159 -0) 📝 `packages/client/src/lib/mari-edit-diff.ts` (+3 -0) 📝 `packages/client/src/localization/locales/en.json` (+25 -3) 📝 `packages/server/src/routes/professor-mari-workspace.routes.ts` (+50 -0) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+306 -56) ➕ `packages/server/src/services/professor-mari/workspace-edit-render.ts` (+236 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+325 -0) </details> ### 📄 Description ## Linked issue Closes #4931 Covers all three Easy Viewer phase-4 items in one PR (per the issue): the activation/vectorization visibility, the true per-entry reject, and the Peek-Prompt-fidelity render. Builds on the Easy Viewer from #4919 / #4921. ## Why this change Three gaps in Professor Mari's "Easy Viewer" review cards: 1. **A lorebook entry's kind was not obvious.** `constant` only showed as a chip when it changed, `enabled` as a Disabled badge, and vectorization not at all unless it changed — so a reviewer couldn't tell at a glance whether Mari made a Constant, Selective, or Normal entry, or whether it was vectorized. 2. **No true per-entry reject.** The per-row control was Dismiss (a client-only hide); the only real revert was Restore, which reverts the whole batch. You couldn't revert one entry of a multi-entry change while keeping the rest. 3. **Character/preset edits showed only a field diff, not how they read in the prompt.** The request was to see them the way they appear in Peek Prompt. ## What changed **1. Always-visible activation + vectorization status** (client-only). Each lorebook-entry card shows an activation pill (Constant / Selective / Normal, using the lorebook editor's own dot colors) and a vectorization pill (Vectorized / Vector excluded), rendered as `from → to` when Mari's edit changes them. The prominent Disabled badge is kept (`enabled` is orthogonal). A `selective` flip on a constant entry stays in the generic diff so it is never dropped; a derived `embedding` vector can never render as a giant diff. **2. True per-entry reject** (server + client), scoped to lorebook entries. A destructive-styled Reject button reverts one entry while keeping the rest applied. Server: `restoreChanges`/`validateAndFlushRestored` extracted from `restorePlan` (behavior-preserving), and a new `rejectRows(id, selections)` reverts a dependency-closed subset through the same audited transaction, refuses anything that could dangle a reference (a cascade child, a non-entry row, a stale selection), then shrinks the pending record (recompute summary + mirrored fields + atomically rewrite the durable sidecar) or resolves it when empty. Preserves the audited undo contract: the `#4852` in-tx supersede guard, apply/restore asymmetry, `#4927` character-book sync, `#4813` sidecar durability, the pending map's insertion order, and `operationHash`. The client sends the row's `diffPreview` index + a `{table,id,action}` tuple the server re-checks; the state_changed / invalid_selection paths return 200 `ok:false` so the reason shows inline. **3. Synthetic "View as prompt" preview** (server + client) for character and preset edits (not deletes — the field diff covers those). A new `render-prompt` endpoint assembles the edited entity **on its own** — no persona, no chat history, `previewOnly` — before and after: a character edit uses a read-only DB proxy that substitutes the before/after snapshot for the live character row against the default preset; a preset/section/group/choice edit loads the edited row's own preset and splices the snapshot into the assembler arrays. The client shows a before/after diff of the assembled prompt (additions green, removals red), reusing the word-diff and the neutral panel chrome, labeled a preview. It is best-effort — any assembly failure renders as unavailable, never a 500. ## Validation <!-- Boxes left unchecked intentionally: AI-assisted PR, so the manual/browser items are a TO-DO list for the human contributor, not proof of completion. See notes below. --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated (already run locally; boxes above left for the human to confirm per repo policy): - `pnpm check` passes (TypeScript + ESLint + `check-locales` + client build), exit 0, after merging latest `staging`. - `scripts/regressions/open-issues.regression.ts` passes, including new cases: per-entry reject (partial reject reverts one entry and shrinks the card; a stale tuple and a non-entry row are refused; rejecting every entry leaves the shell), and the character render DB proxy (substitution, pass-through of other characters, null-drop) exercised through the storage `getById` path. - An adversarial review pass ran on the reject (audited undo path — no findings) and the render; four render/client findings were fixed (delete rows no longer offer the preview; the modal can't reopen after close; dismissals are kept on a no-op reject). Still to verify in a real browser (not yet done — I do not run the shared dev server, to avoid a port collision with a running install): - Have Mari create/edit lorebook entries of each kind and confirm the activation + vectorization pills and the `from → to` transitions read correctly (light and dark theme, mobile wrapping). - Reject one entry of a multi-entry change: the entry reverts and disappears from other panels while the rest stay; try rejecting a superseded entry and confirm the state_changed message. - Open "View as prompt" on a character and a preset edit: the before/after prompt preview reads correctly and is clearly a preview; the button is absent on deletes; loading / unavailable states behave. - Confirm Keep / Restore / Dismiss and the Easy/Raw toggle still behave as before. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Notes: adds three `CHANGELOG.md` entries under `### Added`. No user-facing docs under `docs/` changed, so no `docs-i18n` update is required. No version bump. ## UI evidence (if applicable) Screenshots to be added from the manual browser pass. A design mockup of the activation/vectorization pills (including a `from → to` transition and the Disabled/Removed treatments) was shared with the maintainer during development. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Lorebook entries now show persistent activation and vectorization status. - Reviewers can expand change details and reject individual lorebook changes while protecting related references. - Added before-and-after prompt previews for character and preset edits. - Added clearer loading, error, and success feedback for review actions. - **Bug Fixes** - Derived vector data no longer appears as a field change. - Improved safeguards for partially rejecting multi-entry edits. - Prompt previews handle unavailable or empty results gracefully. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:11:34 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6557
No description provided.