[PR #936] [MERGED] fix(chat): allow clearing translation connection via placeholder option #4847

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/936
Author: @Romuromylus
Created: 5/17/2026
Status: ✅ Merged
Merged: 5/17/2026
Merged by: @Romuromylus

Base: staging ← Head: fix/935-translation-connection-clear


📝 Commits (1)

  • d45fb9a fix(chat): allow clearing translation connection via placeholder option

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+1 -1)

📄 Description

Linked issue

Closes #935

Why this change

  • Sister bug to #914 / PR #934. In Chat Settings → Translation → Provider: AI, picking the empty "Select connection…" placeholder option in the Connection dropdown looks like it clears the binding, but the prior connection silently reappears after closing/reopening the drawer.
  • Root cause is the same || undefined → JSON.stringify-drops-key → server-side spread merge chain that #934 fixed. The translation Connection <select> dispatched translationConnectionId: e.target.value || undefined, so an empty value became undefined, dropped out of the PATCH body entirely, and the server's { ...existing, ...incoming } at packages/server/src/routes/chats.routes.ts:369 preserved the old value.

What changed

  • packages/client/src/components/chat/ChatSettingsDrawer.tsx:5000 — drop the || undefined. The <select>'s placeholder option has value="", and the empty string now flows through verbatim. JSON.stringify keeps the key, the server merge overwrites the prior connection, and the cleared state persists.
  • Server-side is unchanged: the AI-translation guard at packages/server/src/routes/translate.routes.ts:59 (if (!input.connectionId)) treats empty string the same as undefined, so AI translation behavior with no connection bound is identical to before.

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

  • On a fork build deployed to my private EasyPanel instance, set the chat's translation Provider to AI and pick any AI connection — the value persisted (afterSet.translationConnectionId === <connId>).
  • Picked the empty "Select connection…" placeholder; the buggy onChange path (pre-fix) dispatched JSON.stringify({translationConnectionId: undefined}) which serialized to "{}" and the server PATCH returned 200 but kept the old value (afterClear.translationConnectionId === <connId> still).
  • With the fix deployed, the same onChange now sends {"translationConnectionId":""}, the server merge writes "", and a re-fetch confirms the value is cleared (afterClear.translationConnectionId === "").
  • Inspected the deployed minified bundle to confirm the patched onChange is in the build: onChange:t=>o.mutate({id:r.id,translationConnectionId:t.target.value}) — no ||void 0 remains.

Things I'd appreciate the maintainers double-checking, on the normal install:

  • Toggle a chat's translation Provider to AI, select any connection, then pick the placeholder. Close and reopen the drawer (or reload) — the Connection dropdown should land on the placeholder, not the previously-selected entry.
  • Confirm subsequent AI translations on that chat fall back to the "no connection bound" 400 (Connection ID is required for AI translation) instead of silently using the cleared connection.

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)

🔄 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/936 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/17/2026 **Status:** ✅ Merged **Merged:** 5/17/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `staging` ← **Head:** `fix/935-translation-connection-clear` --- ### 📝 Commits (1) - [`d45fb9a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d45fb9a319e75894dfa0834c98de6ddc0d1aa7b6) fix(chat): allow clearing translation connection via placeholder option ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+1 -1) </details> ### 📄 Description ## Linked issue Closes #935 ## Why this change - Sister bug to #914 / PR #934. In **Chat Settings → Translation → Provider: AI**, picking the empty "Select connection…" placeholder option in the **Connection** dropdown looks like it clears the binding, but the prior connection silently reappears after closing/reopening the drawer. - Root cause is the same `|| undefined` → `JSON.stringify`-drops-key → server-side spread merge chain that #934 fixed. The translation Connection `<select>` dispatched `translationConnectionId: e.target.value || undefined`, so an empty value became `undefined`, dropped out of the PATCH body entirely, and the server's `{ ...existing, ...incoming }` at `packages/server/src/routes/chats.routes.ts:369` preserved the old value. ## What changed - `packages/client/src/components/chat/ChatSettingsDrawer.tsx:5000` — drop the `|| undefined`. The `<select>`'s placeholder option has `value=""`, and the empty string now flows through verbatim. JSON.stringify keeps the key, the server merge overwrites the prior connection, and the cleared state persists. - Server-side is unchanged: the AI-translation guard at `packages/server/src/routes/translate.routes.ts:59` (`if (!input.connectionId)`) treats empty string the same as undefined, so AI translation behavior with no connection bound is identical to before. ## 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 - On a fork build deployed to my private EasyPanel instance, set the chat's translation Provider to AI and pick any AI connection — the value persisted (`afterSet.translationConnectionId === <connId>`). - Picked the empty "Select connection…" placeholder; the buggy onChange path (pre-fix) dispatched `JSON.stringify({translationConnectionId: undefined})` which serialized to `"{}"` and the server PATCH returned 200 but kept the old value (`afterClear.translationConnectionId === <connId>` still). - With the fix deployed, the same onChange now sends `{"translationConnectionId":""}`, the server merge writes `""`, and a re-fetch confirms the value is cleared (`afterClear.translationConnectionId === ""`). - Inspected the deployed minified bundle to confirm the patched onChange is in the build: `onChange:t=>o.mutate({id:r.id,translationConnectionId:t.target.value})` — no `||void 0` remains. Things I'd appreciate the maintainers double-checking, on the normal install: - Toggle a chat's translation Provider to AI, select any connection, then pick the placeholder. Close and reopen the drawer (or reload) — the Connection dropdown should land on the placeholder, not the previously-selected entry. - Confirm subsequent AI translations on that chat fall back to the "no connection bound" 400 (`Connection ID is required for AI translation`) instead of silently using the cleared connection. ## Docs and release impact - [x] 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:11:09 +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#4847
No description provided.