Skip to content

feat(magic-rewrite): V1 — AI-assisted text rewriting for editors#1238

Closed
kevin-ho wants to merge 3 commits into
Pasta-Devs:stagingfrom
kevin-ho:feat/magic-rewrite-v1
Closed

feat(magic-rewrite): V1 — AI-assisted text rewriting for editors#1238
kevin-ho wants to merge 3 commits into
Pasta-Devs:stagingfrom
kevin-ho:feat/magic-rewrite-v1

Conversation

@kevin-ho
Copy link
Copy Markdown
Contributor

@kevin-ho kevin-ho commented May 26, 2026

Linked issue

Closes #1183

Why this change

Writing and maintaining long-form text entries — character descriptions, persona definitions, lorebook entries — is tedious. Other RP platforms offer AI-assisted rewriting with natural language instructions ("add more detail about their childhood," "convert to XML format," "make this more token-efficient"). Currently Marinara has no built-in mechanism for this. A third-party extension exists as a proof of concept but requires users to manually enter API keys. This PR ships the feature natively, reusing Marinara's existing connection infrastructure.

What changed

  • packages/server/src/routes/magic-rewrite.routes.ts (new): POST /api/magic-rewrite/generate — accepts text and instruction, resolves an LLM connection through the existing default → default agent fallback chain, returns rewritten text. No new DB columns, no migrations.
  • packages/client/src/components/ui/MagicRewritePanel.tsx (new): Instruction textarea, generate button, word-level LCS diff view (green additions, red deletions). Falls back to plain text for inputs over 3 000 words. Includes HelpTooltip noting agent connection usage.
  • packages/client/src/components/ui/ExpandedTextarea.tsx (modified): Rewrite button in fullscreen editor header, Apply/Back controls. Escape key suppressed during rewrite mode.
  • packages/client/src/components/lorebooks/LorebookFormFields.tsx (modified): Same rewrite integration in lorebook expanded content modal. Modal widened to max-w-5xl.
  • packages/server/src/routes/index.ts (modified): Registered magic-rewrite routes under /api/magic-rewrite.

Intentionally omitted (follow-up PRs)

Per maintainer feedback on #1184, V1 is scoped to the core rewrite flow:

  • Rewrite-specific default connection selection (defaultForRewrite flag)
  • DB migration / schema changes
  • Connection editor toggle UI
  • Character card / lorebook context injection
  • Chat history context selection

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

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Screenshot 2026-05-25 193644

Xelvanis and others added 3 commits May 24, 2026 18:46
Resolve tracker characters through active-chat names, aliases, title/comment aliases, and bracketed aliases so group chats can match card names that differ from tracker names.

Preserve uploaded NPC tracker avatars and portrait focus across agent refreshes, including first snapshot writes, without copying manual avatars onto real character-card IDs.

Reuse the shared temperature display helpers in the roleplay HUD so the tracker temperature unit setting applies there too.

Backfill changelog entries for recent Xel PRs and record the tracker hotfix under 1.6.1.
Slim V1 of Magic Rewrite: AI-assisted text rewriting for lorebook,
character, and persona editors.

- POST /api/magic-rewrite/generate endpoint using existing default
  agent connection fallback
- MagicRewritePanel: instruction textarea, word-level diff view,
  HelpTooltip noting agent connection usage
- Integrated into ExpandedTextarea and LorebookFormFields modals
  with Apply/Back flow

Addresses Pasta-Devs#1183 (scoped V1 per maintainer feedback).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2cea3f2e-a682-47ba-a2dc-4ad2561a854a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cha1latte
Copy link
Copy Markdown
Collaborator

v1 ported in #1260 !

@cha1latte cha1latte closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client docs feature New feature or enhancement server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants