[PR #8485] [MERGED] fix(chat): keep translation prompt edits stable until commit #8629

Closed
opened 2026-11-07 16:46:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8485
Author: @SpicyMarinara
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/8475-translator-prompt-editing


📝 Commits (9)

  • 9136b7e test(chat): cover translation prompt editing and ownership
  • 3aceebb fix: buffer translator prompts until blur
  • 5ebb666 test: match the RP settings close label
  • 206777b test: frame the edited translation prompts
  • ee5396a Merge remote-tracking branch 'origin/staging' into fix/8475-translator-prompt-editing
  • a5a4a41 fix: await complete prompt saves before translator defaults
  • 7113257 fix: retain both prompt intents for explicit save retries
  • 6f245fa fix: retain pending prompt text and live token estimates
  • 1b81844 test: defer translator live counters to browser proof

📊 Changes

4 files changed (+397 additions, -24 deletions)

View changed files

📝 e2e/chat-sweep.e2e.ts (+105 -1)
➕ e2e/translation-prompt-editing.e2e.ts (+212 -0)
📝 packages/client/src/features/chat-settings/sections/TranslationSection.tsx (+79 -19)
📝 scripts/regressions/prompt-token-counters.regression.ts (+1 -4)

📄 Description

Linked issue

Closes #8475.

Why this change

RP Translation prompt textboxes sent a metadata mutation on every keystroke and rendered the persisted value. A middle insertion could lose a character and jump to the end; clearing a field immediately restored its default. Buffering the edit also requires Save translator defaults to wait for the complete prompt commit, including asynchronous query preparation, so it cannot save an older value.

What changed

  • Reuse DraftTextarea for both prompt fields, keyed by chat and direction. Focused typing stays local; blur and unmount commit through the existing metadata API and preserve the existing blank/default normalization.
  • Register each complete prompt mutation in the existing queue before its preparation can yield. Save defaults awaits both fields' actual completions, including errors, without changing the generic metadata hook or save barrier.
  • Keep the latest queued prompt text visible across blur/refocus until its commit settles, including when earlier serialized saves delay its optimistic cache update. Token estimates use each field's live draft in local state and update before blur, including a cleared field; shared DraftTextarea remains unchanged.
  • Retain failed prompt text visibly. A new explicit Save action retries each known failed field once; a successful edit in the other field cannot hide its failure. A fresh edit replaces that field's previous intent. Use the existing localized pending, success and error messages.
  • Add one focused real-app editing case and strengthen the existing translator-defaults case. Remove only the obsolete literal source-expression assertion for the translation counter; its replacement proof is the existing real-browser live-counter assertion, rather than another implementation-text match. All other source guards remain. The PR changes TranslationSection.tsx, two E2E files and that one regression guard; it includes staging 1403a98185060ab2dc18b466299d9b220a838e45.

Validation

Final candidate: 1b81844838108eebeaa9691cab21162c140a9f4b. Its runtime and browser files are byte-identical to tested/reviewed 6f245fa00f6c9864fb5bf2ad2a072e3fbd4e2359; the final commit only removes the obsolete source-text assertion.

  • Standard pnpm check passed, including localization, formatting, lint/types, E2E types and both production builds. The one existing HomeProfessorMariChat.tsx Hook warning is in an unchanged file. Final outputs are retained; this successful run used no phased cleanup or modified command.

  • Six focused browser cases passed: the editing case and strengthened defaults case across desktop Chromium, mobile Chromium and mobile WebKit, with one worker. Guards cover caret insertion, replacement, clear/save/reload, correct-chat unmount flush, synthetic composition/native CJK insertion, Restore, preparation-before-PATCH, held PATCH, failed writes, both-field failure handling, explicit retry without retyping and fresh-edit recovery. The editing spec also holds an earlier real serialized save, blurs/refocuses two queued prompt edits, verifies their visible values and final persisted latest text, and checks both live counters before blur, including zero for a focused cleared field. All final assertions are hard; the original RED aggregated the two counter failures before the pending-value failure.

  • pnpm smoke:ui passed all seven desktop cases. Browser runs used the same assertions and budgets with video/trace disabled in a temporary artifact-only config; screenshots, error contexts and raw logs remain. Desktop light and phone dark captures were checked. Browser emulation/synthetic composition do not establish physical-device or OS IME behavior.

  • Local CodeRabbit first found one major save-ordering defect and then one minor retry defect; both were fixed. Hosted Dottore review on 711325773944f6429ab56d1481779645591a4d7c then reported two LOW contracts: e531592b0b81415e (pending text reset) and f0ec6be7d121d7bb (live token estimate). Both were reproduced on that exact runtime and repaired. The final genuine local incremental review passed with 0 findings across both changed files, against reviewed candidate 711325773944f6429ab56d1481779645591a4d7c. This is not a claim that the earlier reviews had zero findings.

  • The previously unrun token-counter guard reproduced RED on 6f245fa because it required the old exact source expression. After removing only that obsolete assertion, the token-counter and tracker-gallery regression files both pass. Existing browser live-counter assertions and every other source guard remain unchanged. No runtime rebuild or browser repeat was needed for this test-only follow-up. Final test-only local CodeRabbit completed with 0 findings across its one changed file, against 6f245fa00f6c9864fb5bf2ad2a072e3fbd4e2359. The focused source-guard RED and final GREEN logs are /tmp/engine-8485-6f-token-guard-red.log, /tmp/engine-8485-token-guard-final-green.log and /tmp/engine-8485-tracker-gallery-final-green.log; the incremental review log is /tmp/engine-8485-token-guard-coderabbit.log.

  • Preserved RED proofs reproduce the original caret bug, Save completing while prompt preparation/PATCH was held, and one stale defaults write when a different field succeeded after a held failure. The original caret trace has a documented ENOSPC network-capture limitation; its direct failure log and DOM context remain valid. Later control failures and final successful checks are preserved separately.

  • Current evidence: /tmp/engine-8485-dottore-both-low-red.log, /tmp/engine-8485-dottore-low-green.log, /tmp/engine-8485-dottore-repair-smoke.log, /tmp/engine-8485-dottore-repair-pnpm-check.log, /tmp/engine-8485-dottore-repair-coderabbit.log. Earlier receipts and failed traces remain preserved. Hosted Dottore on runtime head 6f245fa concluded Viable With Notes (0 defects, one optional note); the final test-only head still requires its own hosted verdict and required checks before merge.

  • Manually verify middle insertion, rapid typing and deleting/replacing both prompts in RP chat.

  • Manually verify failed prompt text, explicit Save retry and Save translator defaults after changing both fields.

  • Manually verify native OS IME composition and desktop/mobile focus while switching chats or closing settings.

Docs and release impact

UI bugfix using existing controls and localized messages. No release metadata, dependencies, provider integration or generation-prompt change.


🔄 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/8485 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/8475-translator-prompt-editing` --- ### 📝 Commits (9) - [`9136b7e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9136b7ef01d83d8036fafa77530f2e5934c42511) test(chat): cover translation prompt editing and ownership - [`3aceebb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3aceebb816e95003727bc993ec3fa1bf200ab800) fix: buffer translator prompts until blur - [`5ebb666`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5ebb666fe80f15bc1c6134ef6655f43fd589f266) test: match the RP settings close label - [`206777b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/206777b62b2765a0dce73ce7591e0e2e16aad1cb) test: frame the edited translation prompts - [`ee5396a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ee5396aa044e42b7ecc91a5ff33a76e3b04a46f4) Merge remote-tracking branch 'origin/staging' into fix/8475-translator-prompt-editing - [`a5a4a41`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a5a4a41571ac4683149382bfb0fc7fea4c17e844) fix: await complete prompt saves before translator defaults - [`7113257`](https://github.com/Pasta-Devs/Marinara-Engine/commit/711325773944f6429ab56d1481779645591a4d7c) fix: retain both prompt intents for explicit save retries - [`6f245fa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6f245fa00f6c9864fb5bf2ad2a072e3fbd4e2359) fix: retain pending prompt text and live token estimates - [`1b81844`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1b81844838108eebeaa9691cab21162c140a9f4b) test: defer translator live counters to browser proof ### 📊 Changes **4 files changed** (+397 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `e2e/chat-sweep.e2e.ts` (+105 -1) ➕ `e2e/translation-prompt-editing.e2e.ts` (+212 -0) 📝 `packages/client/src/features/chat-settings/sections/TranslationSection.tsx` (+79 -19) 📝 `scripts/regressions/prompt-token-counters.regression.ts` (+1 -4) </details> ### 📄 Description ## Linked issue Closes #8475. ## Why this change RP Translation prompt textboxes sent a metadata mutation on every keystroke and rendered the persisted value. A middle insertion could lose a character and jump to the end; clearing a field immediately restored its default. Buffering the edit also requires Save translator defaults to wait for the complete prompt commit, including asynchronous query preparation, so it cannot save an older value. ## What changed - Reuse `DraftTextarea` for both prompt fields, keyed by chat and direction. Focused typing stays local; blur and unmount commit through the existing metadata API and preserve the existing blank/default normalization. - Register each complete prompt mutation in the existing queue before its preparation can yield. Save defaults awaits both fields' actual completions, including errors, without changing the generic metadata hook or save barrier. - Keep the latest queued prompt text visible across blur/refocus until its commit settles, including when earlier serialized saves delay its optimistic cache update. Token estimates use each field's live draft in local state and update before blur, including a cleared field; shared `DraftTextarea` remains unchanged. - Retain failed prompt text visibly. A new explicit Save action retries each known failed field once; a successful edit in the other field cannot hide its failure. A fresh edit replaces that field's previous intent. Use the existing localized pending, success and error messages. - Add one focused real-app editing case and strengthen the existing translator-defaults case. Remove only the obsolete literal source-expression assertion for the translation counter; its replacement proof is the existing real-browser live-counter assertion, rather than another implementation-text match. All other source guards remain. The PR changes `TranslationSection.tsx`, two E2E files and that one regression guard; it includes staging `1403a98185060ab2dc18b466299d9b220a838e45`. ## Validation Final candidate: `1b81844838108eebeaa9691cab21162c140a9f4b`. Its runtime and browser files are byte-identical to tested/reviewed `6f245fa00f6c9864fb5bf2ad2a072e3fbd4e2359`; the final commit only removes the obsolete source-text assertion. - Standard `pnpm check` passed, including localization, formatting, lint/types, E2E types and both production builds. The one existing `HomeProfessorMariChat.tsx` Hook warning is in an unchanged file. Final outputs are retained; this successful run used no phased cleanup or modified command. - Six focused browser cases passed: the editing case and strengthened defaults case across desktop Chromium, mobile Chromium and mobile WebKit, with one worker. Guards cover caret insertion, replacement, clear/save/reload, correct-chat unmount flush, synthetic composition/native CJK insertion, Restore, preparation-before-PATCH, held PATCH, failed writes, both-field failure handling, explicit retry without retyping and fresh-edit recovery. The editing spec also holds an earlier real serialized save, blurs/refocuses two queued prompt edits, verifies their visible values and final persisted latest text, and checks both live counters before blur, including zero for a focused cleared field. All final assertions are hard; the original RED aggregated the two counter failures before the pending-value failure. - `pnpm smoke:ui` passed all seven desktop cases. Browser runs used the same assertions and budgets with video/trace disabled in a temporary artifact-only config; screenshots, error contexts and raw logs remain. Desktop light and phone dark captures were checked. Browser emulation/synthetic composition do not establish physical-device or OS IME behavior. - Local CodeRabbit first found one major save-ordering defect and then one minor retry defect; both were fixed. Hosted Dottore review on `711325773944f6429ab56d1481779645591a4d7c` then reported two LOW contracts: `e531592b0b81415e` (pending text reset) and `f0ec6be7d121d7bb` (live token estimate). Both were reproduced on that exact runtime and repaired. The final genuine local incremental review passed with **0 findings across both changed files**, against reviewed candidate `711325773944f6429ab56d1481779645591a4d7c`. This is not a claim that the earlier reviews had zero findings. - The previously unrun token-counter guard reproduced RED on `6f245fa` because it required the old exact source expression. After removing only that obsolete assertion, the token-counter and tracker-gallery regression files both pass. Existing browser live-counter assertions and every other source guard remain unchanged. No runtime rebuild or browser repeat was needed for this test-only follow-up. Final test-only local CodeRabbit completed with 0 findings across its one changed file, against `6f245fa00f6c9864fb5bf2ad2a072e3fbd4e2359`. The focused source-guard RED and final GREEN logs are `/tmp/engine-8485-6f-token-guard-red.log`, `/tmp/engine-8485-token-guard-final-green.log` and `/tmp/engine-8485-tracker-gallery-final-green.log`; the incremental review log is `/tmp/engine-8485-token-guard-coderabbit.log`. - Preserved RED proofs reproduce the original caret bug, Save completing while prompt preparation/PATCH was held, and one stale defaults write when a different field succeeded after a held failure. The original caret trace has a documented ENOSPC network-capture limitation; its direct failure log and DOM context remain valid. Later control failures and final successful checks are preserved separately. - Current evidence: `/tmp/engine-8485-dottore-both-low-red.log`, `/tmp/engine-8485-dottore-low-green.log`, `/tmp/engine-8485-dottore-repair-smoke.log`, `/tmp/engine-8485-dottore-repair-pnpm-check.log`, `/tmp/engine-8485-dottore-repair-coderabbit.log`. Earlier receipts and failed traces remain preserved. Hosted Dottore on runtime head `6f245fa` concluded Viable With Notes (0 defects, one optional note); the final test-only head still requires its own hosted verdict and required checks before merge. - [ ] Manually verify middle insertion, rapid typing and deleting/replacing both prompts in RP chat. - [ ] Manually verify failed prompt text, explicit Save retry and Save translator defaults after changing both fields. - [ ] Manually verify native OS IME composition and desktop/mobile focus while switching chats or closing settings. ## Docs and release impact UI bugfix using existing controls and localized messages. No release metadata, dependencies, provider integration or generation-prompt change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:46:05 +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#8629
No description provided.