[PR #4921] [MERGED] feat(client): Easy Viewer for Professor Mari's edit review cards #6542

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

📋 Pull Request Information

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

Base: staging ← Head: feat/mari-edit-easy-viewer


📝 Commits (4)

  • dd16b3e feat(client): add an Easy Viewer for Professor Mari's edit review cards (#4919)
  • a75f58c fix(client): render all changed lorebook fields + unique preview-row keys (#4919)
  • fb0db65 feat(client): per-card Easy/Raw toggle + prominent deletes/disables in the Mari Easy Viewer (#4919)
  • 100b504 fix(client): persist the Easy/Raw choice + show Disabled for all entry states (#4919)

📊 Changes

9 files changed (+889 additions, -9 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 package.json (+2 -1)
📝 packages/client/src/components/chat/HomeProfessorMariChat.tsx (+89 -8)
➕ packages/client/src/components/chat/MariEditEasyViewer.tsx (+399 -0)
➕ packages/client/src/lib/mari-edit-diff.ts (+174 -0)
➕ packages/client/src/lib/word-diff.ts (+74 -0)
📝 packages/client/src/localization/locales/en.json (+30 -0)
📝 packages/client/src/stores/ui.store.ts (+7 -0)
➕ scripts/regressions/mari-edit-diff.regression.ts (+113 -0)

📄 Description

Linked issue

Closes #4919

Why this change

When Professor Mari edits something, her Keep/Restore review card showed the change as a raw app_data … {JSON} command — a character rewrite, a lorebook entry edit, and a preset change all looked like the same opaque one-line blob. The card already renders created and deleted rows in a friendly way, but it had no rendering for update/replace rows, so every edit fell through to the raw command string.

The before/after data is already on the card: approval.diffPreview carries full before/after row snapshots per change. So this is almost entirely a client-side rendering improvement.

What changed (phases 1–3 of #4919)

  • Update field diff — update/replace rows now render as a per-field before/after diff with inline word-level highlighting (removed in red, added in green). New self-contained word-level diff util (word-diff.ts, no new dependency) and field-change extraction that recurses the nested data/JSON columns so you see "Personality changed", not "data changed" (mari-edit-diff.ts).
  • Lorebook Easy Viewer — lorebook_entries changes lay out like the entry editor (name, primary/secondary key chips with add/remove coloring, content diff, changed-toggle badges) via a dedicated read-only view.
  • Per-entry Dismiss + declutter — each change has a Dismiss control that hides a reviewed row so a multi-row change isn't cluttered. The card's Keep/Restore still governs the whole batch.
  • Easy / Raw toggle on the card, persisted per browser (ui.store mariEditViewMode, default Easy). Raw keeps the JSON command and the existing insert/delete previews.

Deferred to a phase-4 follow-up (agreed with the requester)

  • Peek-Prompt-fidelity rendering of character/preset edits. The prompt assembly is server-side (assemblePrompt reads persisted rows by ID) and apply:false returns before/after row objects, not a rendered prompt, so a faithful Peek-Prompt view needs a new server endpoint. The field diff already makes these edits readable.
  • True per-entry reject (reverting one row). Reverting a single row of a pending approval touches the audited durable-undo path (#4813/#4828/#4852) and referential ordering. In this PR, per-entry action is Dismiss (hide-from-review, since Mari's edits are already applied).

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, done by me:

  • pnpm check passes (TypeScript + ESLint + build, exit 0) and check-locales passes (26 new keys, sorted).
  • New mari-edit-diff.regression.ts (registered in the suite) passes: the word diff reconstructs both sides exactly, field extraction recurses nested data and skips noise/unchanged keys, and boolean-ish integer fields render as on/off.
  • Adversarial review (15 agents) found 10 issues; all fixed before this PR, notably two that a live pass would have caught: long field values were uncapped (a big character rewrite pushed Keep/Restore below the fold → added max-h-40 overflow-auto), and the added-green used a hardcoded emerald-300 that was ~1.3:1 contrast on the built-in light theme (→ theme-aware tint + text-[var(--foreground)], matching CharacterCardUpdateModal).

Still needs a human — I could not run a dev server (it collides with the maintainer's live install ports), so please verify in a real browser (don't trust the boxes above):

  • Have Mari edit a character, a lorebook entry, and a preset; confirm each renders a readable before/after diff in Easy mode, and toggle to Raw.
  • Check the light theme specifically (added-green legibility) and a narrow/mobile width.
  • Confirm Dismiss hides a row, and Keep / Restore / Keep&Enable still work in both Easy and Raw modes.

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)

CHANGELOG.md updated. No docs/ change (this is UI). New user-facing strings are in the canonical en.json; community locales fall back to English per .instructions.md, so no docs-i18n follow-up. No version bump.

UI evidence (if applicable)

Screenshots pending the manual browser pass (I can't run a dev server here). Happy to attach once verified.

Summary by CodeRabbit

  • New Features

    • Added an Easy Viewer for Professor Mari’s review cards with readable before-and-after changes.
    • Added structured lorebook and field-level diff displays with clear added and removed indicators.
    • Added Easy/Raw view toggling with a remembered preference.
    • Added per-change dismissal controls and prominent warnings for deletions or disabled items.
  • Bug Fixes

    • Improved visibility and formatting of database approval changes.
  • Tests

    • Added regression coverage for edit diffs and related workflows.
  • Documentation

    • Added an Unreleased changelog entry.

🔄 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/4921 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/11/2026 **Status:** ✅ Merged **Merged:** 8/11/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/mari-edit-easy-viewer` --- ### 📝 Commits (4) - [`dd16b3e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dd16b3ea35385aeb5c4a2a75fb1ad447c69a8fb4) feat(client): add an Easy Viewer for Professor Mari's edit review cards (#4919) - [`a75f58c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a75f58ca66306f44ac766c2289a780e5aabd30cf) fix(client): render all changed lorebook fields + unique preview-row keys (#4919) - [`fb0db65`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fb0db65b012de93d4bfe95f96d476378f4d75c3d) feat(client): per-card Easy/Raw toggle + prominent deletes/disables in the Mari Easy Viewer (#4919) - [`100b504`](https://github.com/Pasta-Devs/Marinara-Engine/commit/100b5046829637e5b15448778b6a868f6469ad2e) fix(client): persist the Easy/Raw choice + show Disabled for all entry states (#4919) ### 📊 Changes **9 files changed** (+889 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `package.json` (+2 -1) 📝 `packages/client/src/components/chat/HomeProfessorMariChat.tsx` (+89 -8) ➕ `packages/client/src/components/chat/MariEditEasyViewer.tsx` (+399 -0) ➕ `packages/client/src/lib/mari-edit-diff.ts` (+174 -0) ➕ `packages/client/src/lib/word-diff.ts` (+74 -0) 📝 `packages/client/src/localization/locales/en.json` (+30 -0) 📝 `packages/client/src/stores/ui.store.ts` (+7 -0) ➕ `scripts/regressions/mari-edit-diff.regression.ts` (+113 -0) </details> ### 📄 Description ## Linked issue Closes #4919 ## Why this change When Professor Mari edits something, her Keep/Restore review card showed the change as a raw `app_data … {JSON}` command — a character rewrite, a lorebook entry edit, and a preset change all looked like the same opaque one-line blob. The card already renders *created* and *deleted* rows in a friendly way, but it had **no rendering for `update`/`replace` rows**, so every edit fell through to the raw command string. The before/after data is already on the card: `approval.diffPreview` carries full `before`/`after` row snapshots per change. So this is almost entirely a client-side rendering improvement. ## What changed (phases 1–3 of #4919) - **Update field diff** — `update`/`replace` rows now render as a per-field before/after diff with inline word-level highlighting (removed in red, added in green). New self-contained word-level diff util (`word-diff.ts`, **no new dependency**) and field-change extraction that recurses the nested `data`/JSON columns so you see "Personality changed", not "data changed" (`mari-edit-diff.ts`). - **Lorebook Easy Viewer** — `lorebook_entries` changes lay out like the entry editor (name, primary/secondary key chips with add/remove coloring, content diff, changed-toggle badges) via a dedicated read-only view. - **Per-entry Dismiss + declutter** — each change has a Dismiss control that hides a reviewed row so a multi-row change isn't cluttered. The card's Keep/Restore still governs the whole batch. - **Easy / Raw toggle** on the card, persisted per browser (`ui.store` `mariEditViewMode`, default Easy). Raw keeps the JSON command and the existing insert/delete previews. ### Deferred to a phase-4 follow-up (agreed with the requester) - **Peek-Prompt-fidelity** rendering of character/preset edits. The prompt assembly is server-side (`assemblePrompt` reads persisted rows by ID) and `apply:false` returns before/after row objects, not a rendered prompt, so a faithful Peek-Prompt view needs a new server endpoint. The field diff already makes these edits readable. - **True per-entry reject** (reverting one row). Reverting a single row of a pending approval touches the audited durable-undo path (#4813/#4828/#4852) and referential ordering. In this PR, per-entry action is Dismiss (hide-from-review, since Mari's edits are already applied). ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated, done by me: - `pnpm check` passes (TypeScript + ESLint + build, exit 0) and `check-locales` passes (26 new keys, sorted). - New `mari-edit-diff.regression.ts` (registered in the suite) passes: the word diff reconstructs both sides exactly, field extraction recurses nested `data` and skips noise/unchanged keys, and boolean-ish integer fields render as on/off. - Adversarial review (15 agents) found 10 issues; all fixed before this PR, notably two that a live pass would have caught: **long field values were uncapped** (a big character rewrite pushed Keep/Restore below the fold → added `max-h-40 overflow-auto`), and the **added-green used a hardcoded `emerald-300`** that was ~1.3:1 contrast on the built-in light theme (→ theme-aware tint + `text-[var(--foreground)]`, matching `CharacterCardUpdateModal`). Still needs a human — I could **not** run a dev server (it collides with the maintainer's live install ports), so please verify in a real browser (don't trust the boxes above): - Have Mari edit a character, a lorebook entry, and a preset; confirm each renders a readable before/after diff in Easy mode, and toggle to Raw. - Check the **light theme** specifically (added-green legibility) and a **narrow/mobile** width. - Confirm Dismiss hides a row, and Keep / Restore / Keep&Enable still work in both Easy and Raw modes. ## Docs and release impact - [ ] No docs changes needed - [x] 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) `CHANGELOG.md` updated. No `docs/` change (this is UI). New user-facing strings are in the canonical `en.json`; community locales fall back to English per `.instructions.md`, so no `docs-i18n` follow-up. No version bump. ## UI evidence (if applicable) Screenshots pending the manual browser pass (I can't run a dev server here). Happy to attach once verified. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added an Easy Viewer for Professor Mari’s review cards with readable before-and-after changes. * Added structured lorebook and field-level diff displays with clear added and removed indicators. * Added Easy/Raw view toggling with a remembered preference. * Added per-change dismissal controls and prominent warnings for deletions or disabled items. * **Bug Fixes** * Improved visibility and formatting of database approval changes. * **Tests** * Added regression coverage for edit diffs and related workflows. * **Documentation** * Added an Unreleased changelog entry. <!-- 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:24 +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#6542
No description provided.