[PR #1260] [MERGED] feat(magic-rewrite): port V1 to refactor #5010

Closed
opened 2026-10-22 04:12:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1260
Author: @cha1latte
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @cha1latte

Base: refactor ← Head: prep/pr-1238-magic-rewrite-refactor-v2


📝 Commits (5)

  • 991a4c2 Port Magic Rewrite to refactor
  • dea9415 Preserve expanded editor edits on Escape
  • 2850def Merge remote-tracking branch 'upstream/refactor' into prep/pr-1238-magic-rewrite-refactor-v2
  • 2f6f5d2 Add Magic Rewrite proof evidence
  • 8f08fcd Address Magic Rewrite review feedback

📊 Changes

6 files changed (+519 additions, -46 deletions)

View changed files

➕ docs/evidence/pr-1260-magic-rewrite/after.png (+0 -0)
➕ docs/evidence/pr-1260-magic-rewrite/provider-request.json (+18 -0)
📝 src/features/catalog/lorebooks/components/LorebookFormFields.tsx (+128 -28)
📝 src/shared/components/ui/ExpandedTextarea.tsx (+97 -18)
➕ src/shared/components/ui/MagicRewritePanel.tsx (+159 -0)
➕ src/shared/hooks/use-magic-rewrite.ts (+117 -0)

📄 Description

Linked issue

Refs #1183
Refs #1238

Why this change

PR #1238 contains the Magic Rewrite V1 feature, but its branch was not based on the active refactor branch.

This PR ports the Magic Rewrite V1 surface directly onto refactor and adapts the implementation to the refactor architecture, where editor UI calls the shared LLM gateway instead of adding the old package/server route path.

What changed

  • Added a shared Magic Rewrite hook that resolves the default text connection and calls llmApi.complete.
  • Added the shared MagicRewritePanel with instructions, Generate Rewrite, Before/After preview, and word-level diff highlighting.
  • Added Magic Rewrite access to the shared expanded textarea used by character/persona editor fields.
  • Added Magic Rewrite access to the lorebook entry expanded content editor.
  • Preserved V1 scope: no chat-context selectors, no history inclusion, and no extra provider controls.

Refactor impact

Primary owner:

  • Shared API / shared UI, with catalog editor entry points.

Impact areas reviewed:

  • Shared API boundary: UI uses src/shared/api/llm-api.ts and storageApi; no old package/server route was restored.
  • Feature boundary: character/persona expanded textareas and lorebook entry expanded content editor.
  • Remote runtime boundary: Magic Rewrite was smoke checked through llm_complete via the Rust remote runtime.

Boundary notes:

  • src/shared/hooks/use-magic-rewrite.ts stays in shared code and imports only shared API wrappers.
  • Feature editors import the shared panel/component instead of duplicating provider logic.
  • Engine code remains independent of shared API wrappers.

Pressure points touched:

  • Shared expanded textarea behavior.
  • Lorebook form expanded content modal.
  • No src-tauri/src/lib.rs command registration, mode surface, or import-module changes.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Codex ran pnpm check:architecture successfully in C:\tmp\marinara-pr-1238.
  • Codex ran pnpm check:frontend successfully.
  • Codex ran full pnpm check successfully after refreshing onto current upstream/refactor.
  • Codex ran git diff --check upstream/refactor...HEAD successfully.
  • Codex ran node scratch\verify-pr-1260-magic-rewrite.mjs successfully. The harness starts a disposable Rust remote runtime, seeds a default text connection and character, points the app at a fake OpenAI-compatible provider, opens the real character Description expanded editor, runs Magic Rewrite, receives the provider rewrite through llm_complete, applies it, and captures proof.
  • The provider request evidence shows the original source text and rewrite instruction were sent to the fake provider.
  • Bunny review pass completed after the refactor-base refresh and evidence commit.
  • GitHub CI passed on the refreshed head after the refactor-base update.
  • CodeRabbit reviewed the PR after the rate-limit retry and left three focused comments. Codex addressed them in commit 8f08fcd5 and reran local validation.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

Added scoped PR evidence under docs/evidence/pr-1260-magic-rewrite/; no user-facing docs or release metadata changed.

UI evidence

Runtime proof screenshot:

Magic Rewrite applied in the refactor character Description editor

Provider request proof:

github.com/cha1latte/Marinara-Engine@8f08fcd5de/docs/evidence/pr-1260-magic-rewrite/provider-request.json


🔄 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/1260 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `prep/pr-1238-magic-rewrite-refactor-v2` --- ### 📝 Commits (5) - [`991a4c2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/991a4c2516452ebc8fdbf5d4fd97b41084a17a7d) Port Magic Rewrite to refactor - [`dea9415`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dea94153f2f7c585995809d8858cc17e9a9312f8) Preserve expanded editor edits on Escape - [`2850def`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2850defb4aee178fdd52fb4c24f85780a36a568d) Merge remote-tracking branch 'upstream/refactor' into prep/pr-1238-magic-rewrite-refactor-v2 - [`2f6f5d2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2f6f5d28d1ec445eb6711371dc36b8bdf1f723c0) Add Magic Rewrite proof evidence - [`8f08fcd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f08fcd5de42cd273d4a9abf85a6bc81d83c2cd7) Address Magic Rewrite review feedback ### 📊 Changes **6 files changed** (+519 additions, -46 deletions) <details> <summary>View changed files</summary> ➕ `docs/evidence/pr-1260-magic-rewrite/after.png` (+0 -0) ➕ `docs/evidence/pr-1260-magic-rewrite/provider-request.json` (+18 -0) 📝 `src/features/catalog/lorebooks/components/LorebookFormFields.tsx` (+128 -28) 📝 `src/shared/components/ui/ExpandedTextarea.tsx` (+97 -18) ➕ `src/shared/components/ui/MagicRewritePanel.tsx` (+159 -0) ➕ `src/shared/hooks/use-magic-rewrite.ts` (+117 -0) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Refs #1183 Refs #1238 ## Why this change PR #1238 contains the Magic Rewrite V1 feature, but its branch was not based on the active `refactor` branch. This PR ports the Magic Rewrite V1 surface directly onto `refactor` and adapts the implementation to the refactor architecture, where editor UI calls the shared LLM gateway instead of adding the old package/server route path. ## What changed - Added a shared Magic Rewrite hook that resolves the default text connection and calls `llmApi.complete`. - Added the shared `MagicRewritePanel` with instructions, Generate Rewrite, Before/After preview, and word-level diff highlighting. - Added Magic Rewrite access to the shared expanded textarea used by character/persona editor fields. - Added Magic Rewrite access to the lorebook entry expanded content editor. - Preserved V1 scope: no chat-context selectors, no history inclusion, and no extra provider controls. ## Refactor impact Primary owner: - Shared API / shared UI, with catalog editor entry points. Impact areas reviewed: - Shared API boundary: UI uses `src/shared/api/llm-api.ts` and `storageApi`; no old package/server route was restored. - Feature boundary: character/persona expanded textareas and lorebook entry expanded content editor. - Remote runtime boundary: Magic Rewrite was smoke checked through `llm_complete` via the Rust remote runtime. Boundary notes: - `src/shared/hooks/use-magic-rewrite.ts` stays in shared code and imports only shared API wrappers. - Feature editors import the shared panel/component instead of duplicating provider logic. - Engine code remains independent of shared API wrappers. Pressure points touched: - Shared expanded textarea behavior. - Lorebook form expanded content modal. - No `src-tauri/src/lib.rs` command registration, mode surface, or import-module changes. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - Codex ran `pnpm check:architecture` successfully in `C:\tmp\marinara-pr-1238`. - Codex ran `pnpm check:frontend` successfully. - Codex ran full `pnpm check` successfully after refreshing onto current `upstream/refactor`. - Codex ran `git diff --check upstream/refactor...HEAD` successfully. - Codex ran `node scratch\verify-pr-1260-magic-rewrite.mjs` successfully. The harness starts a disposable Rust remote runtime, seeds a default text connection and character, points the app at a fake OpenAI-compatible provider, opens the real character Description expanded editor, runs Magic Rewrite, receives the provider rewrite through `llm_complete`, applies it, and captures proof. - The provider request evidence shows the original source text and rewrite instruction were sent to the fake provider. - Bunny review pass completed after the refactor-base refresh and evidence commit. - GitHub CI passed on the refreshed head after the refactor-base update. - CodeRabbit reviewed the PR after the rate-limit retry and left three focused comments. Codex addressed them in commit `8f08fcd5` and reran local validation. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims Added scoped PR evidence under `docs/evidence/pr-1260-magic-rewrite/`; no user-facing docs or release metadata changed. ## UI evidence Runtime proof screenshot: ![Magic Rewrite applied in the refactor character Description editor](https://raw.githubusercontent.com/cha1latte/Marinara-Engine/8f08fcd5de42cd273d4a9abf85a6bc81d83c2cd7/docs/evidence/pr-1260-magic-rewrite/after.png) Provider request proof: https://github.com/cha1latte/Marinara-Engine/blob/8f08fcd5de42cd273d4a9abf85a6bc81d83c2cd7/docs/evidence/pr-1260-magic-rewrite/provider-request.json --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:26 +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#5010
No description provided.