[PR #6849] [CLOSED] feat(characters): Generate / Improve buttons for character card fields #7354

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6849
Author: @jochst
Created: 9/29/2026
Status: ❌ Closed

Base: staging ← Head: feat/6848-character-field-generation


📝 Commits (3)

  • 612918a feat(characters): add Generate / Improve buttons to character card fields
  • aaadf6c Merge branch 'staging' into feat/6848-character-field-generation
  • e9b0549 Merge branch 'staging' into feat/6848-character-field-generation

📊 Changes

7 files changed (+516 additions, -15 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+174 -15)
📝 packages/client/src/hooks/use-characters.ts (+45 -0)
📝 packages/client/src/localization/locales/en.json (+10 -0)
📝 packages/server/src/routes/characters.routes.ts (+84 -0)
➕ packages/server/src/services/generation/character-field-prompt.ts (+124 -0)
➕ scripts/regressions/character-field-generation.regression.ts (+78 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6848

Why this change

  • In the character editor's Card tab only Summary can be written by the model. Every other card field has to be written by hand, and there is no way to have the model tidy or expand text the author already started. Authors end up round-tripping text through a separate chat. This adds the per-field assist the Summary field already has, to every field that shapes the character.

What changed

  • UI: a wand button on Description, Personality, Backstory, Appearance, Scenario, First Message, each Alternate Greeting, and Example Dialogue (CharacterEditor.tsx). One shared CharacterFieldGenerateButton component; TextareaTab takes an optional generate prop so the four plain fields opt in with one line each.
    • Empty field → Generate (write from the rest of the unsaved card). Field with text → Improve (keep every fact the author wrote, fix wording, expand thin parts).
    • Result replaces the field; the success toast has an Undo action.
    • Same stale-result guards as the Summary button: a result is discarded if the author edited that field or switched characters while it was generating. Alternate greetings track the latest value/setter via refs so reordering mid-request writes to the right greeting.
    • Disabled with a "save first" tooltip until the character has an id (same constraint as Summary).
  • Server: POST /characters/:id/field/generate in characters.routes.ts. Field names are whitelisted; the unsaved draft is merged over the stored card; connection resolution is the same resolveChatSummaryConnection path as /summary/generate and /convo-profile/generate; prompt is logged through logDebugOverride (UI debugMode / DEBUG_AGENTS); max tokens 1024 (respecting the connection override).
  • Prompt builder: services/generation/character-field-prompt.ts — per-field instructions (Example Dialogue asks for <START> / {{user}}: / {{char}}:; Alternate Greeting must differ from the First Message), the target field is never repeated as context, and code fences are stripped from the output.
  • Hook: useGenerateCharacterField in use-characters.ts.
  • Localization: new ui.characters.fieldGenerate.* keys in en.json only (community packs fall back to English).
  • Regression: scripts/regressions/character-field-generation.regression.ts — field whitelist (rejects summary, name, __proto__, non-strings), Generate vs Improve prompt content, blank-Improve fallback, target-field exclusion, greeting context, fence cleanup.
  • CHANGELOG: [Unreleased] entry.

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 runs by the AI assistant on this branch (rebased on staging @ 808b5739a): pnpm check (exit 0; the only lint warning is a pre-existing one in GameNarration.tsx), pnpm localization:check, pnpm version:check, and node scripts/run-regressions.mjs --filter character (14/14 passed, including the new regression). Container build and real-browser / real-model checks have not been done yet.

To verify manually:

  • Manually verify in the browser that each listed field shows Generate when empty and Improve when it has text, and that the result lands in the right field.
  • Manually verify Undo on the success toast restores the previous text.
  • Manually verify typing in a field while it is generating keeps your text (the result is discarded).
  • Manually verify reordering or removing an alternate greeting mid-generation does not write to the wrong greeting.
  • Manually verify a brand-new, unsaved character shows the buttons disabled with the "save first" tooltip.
  • Manually verify with no usable connection configured that a clear error toast appears.
  • Manually verify with debug mode on that the [debug/characters/<id>-field-<field>] prompt is logged.
  • Manually verify button layout in light and dark mode and on a mobile viewport (the Dialogue rows use the compact variant beside the reorder/delete buttons).

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)

No files under docs/ changed; CHANGELOG has an [Unreleased] entry.

UI evidence (if applicable)

Screenshots to be added after manual browser verification.


Drafted with an AI coding assistant. Checkboxes are intentionally left unchecked for the human contributor.


🔄 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/6849 **Author:** [@jochst](https://github.com/jochst) **Created:** 9/29/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `feat/6848-character-field-generation` --- ### 📝 Commits (3) - [`612918a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/612918a51ff44ca5b6451bbaf33f96aa125742ad) feat(characters): add Generate / Improve buttons to character card fields - [`aaadf6c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aaadf6ceca61722c9da7ade559b8f593b9211fea) Merge branch 'staging' into feat/6848-character-field-generation - [`e9b0549`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e9b0549596950714ed6671c87e4b97245a44aef0) Merge branch 'staging' into feat/6848-character-field-generation ### 📊 Changes **7 files changed** (+516 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+174 -15) 📝 `packages/client/src/hooks/use-characters.ts` (+45 -0) 📝 `packages/client/src/localization/locales/en.json` (+10 -0) 📝 `packages/server/src/routes/characters.routes.ts` (+84 -0) ➕ `packages/server/src/services/generation/character-field-prompt.ts` (+124 -0) ➕ `scripts/regressions/character-field-generation.regression.ts` (+78 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #6848 ## Why this change - In the character editor's **Card** tab only **Summary** can be written by the model. Every other card field has to be written by hand, and there is no way to have the model tidy or expand text the author already started. Authors end up round-tripping text through a separate chat. This adds the per-field assist the Summary field already has, to every field that shapes the character. ## What changed - **UI:** a wand button on **Description, Personality, Backstory, Appearance, Scenario, First Message, each Alternate Greeting, and Example Dialogue** (`CharacterEditor.tsx`). One shared `CharacterFieldGenerateButton` component; `TextareaTab` takes an optional `generate` prop so the four plain fields opt in with one line each. - Empty field → **Generate** (write from the rest of the unsaved card). Field with text → **Improve** (keep every fact the author wrote, fix wording, expand thin parts). - Result replaces the field; the success toast has an **Undo** action. - Same stale-result guards as the Summary button: a result is discarded if the author edited that field or switched characters while it was generating. Alternate greetings track the latest value/setter via refs so reordering mid-request writes to the right greeting. - Disabled with a "save first" tooltip until the character has an id (same constraint as Summary). - **Server:** `POST /characters/:id/field/generate` in `characters.routes.ts`. Field names are whitelisted; the unsaved draft is merged over the stored card; connection resolution is the same `resolveChatSummaryConnection` path as `/summary/generate` and `/convo-profile/generate`; prompt is logged through `logDebugOverride` (UI `debugMode` / `DEBUG_AGENTS`); max tokens 1024 (respecting the connection override). - **Prompt builder:** `services/generation/character-field-prompt.ts` — per-field instructions (Example Dialogue asks for `<START>` / `{{user}}:` / `{{char}}:`; Alternate Greeting must differ from the First Message), the target field is never repeated as context, and code fences are stripped from the output. - **Hook:** `useGenerateCharacterField` in `use-characters.ts`. - **Localization:** new `ui.characters.fieldGenerate.*` keys in `en.json` only (community packs fall back to English). - **Regression:** `scripts/regressions/character-field-generation.regression.ts` — field whitelist (rejects `summary`, `name`, `__proto__`, non-strings), Generate vs Improve prompt content, blank-Improve fallback, target-field exclusion, greeting context, fence cleanup. - **CHANGELOG:** `[Unreleased]` entry. ## 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 runs by the AI assistant on this branch (rebased on `staging` @ 808b5739a): `pnpm check` (exit 0; the only lint warning is a pre-existing one in `GameNarration.tsx`), `pnpm localization:check`, `pnpm version:check`, and `node scripts/run-regressions.mjs --filter character` (14/14 passed, including the new regression). Container build and real-browser / real-model checks have **not** been done yet. To verify manually: - Manually verify in the browser that each listed field shows **Generate** when empty and **Improve** when it has text, and that the result lands in the right field. - Manually verify **Undo** on the success toast restores the previous text. - Manually verify typing in a field while it is generating keeps your text (the result is discarded). - Manually verify reordering or removing an alternate greeting mid-generation does not write to the wrong greeting. - Manually verify a brand-new, unsaved character shows the buttons disabled with the "save first" tooltip. - Manually verify with no usable connection configured that a clear error toast appears. - Manually verify with debug mode on that the `[debug/characters/<id>-field-<field>]` prompt is logged. - Manually verify button layout in light and dark mode and on a mobile viewport (the Dialogue rows use the compact variant beside the reorder/delete buttons). ## 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) No files under `docs/` changed; CHANGELOG has an `[Unreleased]` entry. ## UI evidence (if applicable) Screenshots to be added after manual browser verification. --- Drafted with an AI coding assistant. Checkboxes are intentionally left unchecked for the human contributor. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:56 +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#7354
No description provided.