[PR #6040] [MERGED] fix(chat): guard Echo reactions and preserve native text selection #7036

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

📋 Pull Request Information

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

Base: staging ← Head: fix/mobile-selection-echo-crash


📝 Commits (3)

  • 3904f21 fix(roleplay): clarify editing existing character notes
  • cb1a794 fix(chat): validate Echo reactions and respect native text selection
  • 4f3be26 fix(chat): cover deferred scrolling and selection review edge cases

📊 Changes

20 files changed (+393 additions, -34 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 e2e/assigned-chat-sweep.e2e.ts (+199 -0)
📝 e2e/core-flows.e2e.ts (+12 -6)
📝 packages/client/src/components/chat/ChatArea.tsx (+11 -1)
📝 packages/client/src/components/chat/ChatInput.tsx (+2 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+6 -0)
📝 packages/client/src/components/chat/ConversationInput.tsx (+2 -0)
📝 packages/client/src/components/chat/ConversationMessage.tsx (+2 -0)
📝 packages/client/src/components/chat/ConversationView.tsx (+13 -4)
📝 packages/client/src/components/chat/EchoChamberPanel.tsx (+3 -1)
📝 packages/client/src/hooks/use-generate.ts (+5 -6)
📝 packages/client/src/hooks/use-visual-viewport-chat-bottom.ts (+2 -1)
📝 packages/client/src/lib/echo-chamber-queue.ts (+26 -7)
📝 packages/client/src/lib/text-selection.ts (+15 -0)
📝 packages/client/src/stores/agent.store.ts (+4 -3)
📝 packages/server/src/services/generation/roleplay-commands.ts (+1 -1)
📝 packages/server/src/services/storage/agents.storage.ts (+7 -2)
📝 scripts/regressions/assigned-chat-sweep.regression.ts (+35 -0)
📝 scripts/regressions/roleplay-commands.regression.ts (+4 -0)
📝 scripts/regressions/roleplay-streaming.regression.ts (+41 -2)

📄 Description

Linked issue

Closes #6039

Why this change

A nameless Echo Chamber reaction could crash the entire chat at characterName.length. Native iPhone text selection could also lose its position to automatic scrolling or be mistaken for a message-editing gesture. The Roleplay notes prompt needed a clearer explanation of updating an existing note.

What changed

  • Validate Echo reactions at the existing client queue boundary, reuse that validation for activity bubbles, and reject malformed persisted entries individually so valid reactions still appear.
  • Use the existing text-selection utility to pause automatic chat/keyboard scrolling while text is selected. Message touch shortcuts, multi-select handling, and composer-shell focus handling leave native selections alone. Opening a chat waits for an existing selection to clear before scrolling to the latest message; delayed Echo scrolling also checks at execution time.
  • Explicitly tell characters to edit notes by sending their full updated contents, which replace the previous note. Existing note storage and character privacy rules are unchanged.
  • Add focused browser, queue, storage, and prompt regressions plus changelog entries.

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

Completed locally: pnpm check (including localization, types, lint, and production build), pnpm regression:prompt, and the roleplay-streaming, assigned-chat-sweep, and roleplay-commands Node regressions. Nine focused Playwright cases pass across desktop Chromium, mobile Chromium, and iPhone-sized WebKit, including opening another chat during a selection. The existing mobile Chromium composer focus/history test also passes after bounding its missing-textarea retry waits (10 passed, 2 existing project skips). Five additional mobile keyboard, viewport-menu, and older-message-editing checks passed in the surrounding smoke run.

Before the fix, the browser regression reproduced a 260 px jump during selection and selection being replaced by message editing. The same checks now preserve the selection and scroll position; normal bottom-follow resumes after returning to the latest message. Missing names, non-string names/reactions, null entries, malformed containers, and valid siblings are covered for saved/live Echo data.

Manual verification notes

Browser screenshots were inspected. Manually verify the physical iPhone selection handles and Copy/Cut menu in messages, composers, and message editors, including during streaming and keyboard opening. Desktop WebKit automation cannot reproduce the native iOS selection-handle UI. No physical iPhone was available here. Final-commit build validation, container build, CodeQL, CodeRabbit review, and the complete Node/browser regression matrix passed. One unchanged Game dice-history test timed out on the first WebKit attempt; both variants passed locally, and the affected CI shard passed on one retry (80 passed, 5 existing skips). The original failure and baseline comparison are recorded in the PR comments. Container boot was not tested locally.

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
  • Version/release files updated (only if this PR includes a version bump)

Changelog updated. No user-facing labels, translated documentation, dependencies, or release versions changed.

UI evidence (if applicable)

WebKit selection regression screenshots. These show browser selection ranges, not physical iOS handles.

Roleplay message selection and Conversation draft selection during streaming Roleplay message selection stays in place during streaming Conversation draft selection remains active during streaming

🔄 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/6040 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/10/2026 **Status:** ✅ Merged **Merged:** 9/10/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/mobile-selection-echo-crash` --- ### 📝 Commits (3) - [`3904f21`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3904f2158dc870edb75ef81618473ffd07743be5) fix(roleplay): clarify editing existing character notes - [`cb1a794`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cb1a794cd00d2c8292ebed10acaa8af283319a16) fix(chat): validate Echo reactions and respect native text selection - [`4f3be26`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4f3be2670c6c624268dc814d345dece91e13a8a1) fix(chat): cover deferred scrolling and selection review edge cases ### 📊 Changes **20 files changed** (+393 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `e2e/assigned-chat-sweep.e2e.ts` (+199 -0) 📝 `e2e/core-flows.e2e.ts` (+12 -6) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+11 -1) 📝 `packages/client/src/components/chat/ChatInput.tsx` (+2 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+6 -0) 📝 `packages/client/src/components/chat/ConversationInput.tsx` (+2 -0) 📝 `packages/client/src/components/chat/ConversationMessage.tsx` (+2 -0) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+13 -4) 📝 `packages/client/src/components/chat/EchoChamberPanel.tsx` (+3 -1) 📝 `packages/client/src/hooks/use-generate.ts` (+5 -6) 📝 `packages/client/src/hooks/use-visual-viewport-chat-bottom.ts` (+2 -1) 📝 `packages/client/src/lib/echo-chamber-queue.ts` (+26 -7) 📝 `packages/client/src/lib/text-selection.ts` (+15 -0) 📝 `packages/client/src/stores/agent.store.ts` (+4 -3) 📝 `packages/server/src/services/generation/roleplay-commands.ts` (+1 -1) 📝 `packages/server/src/services/storage/agents.storage.ts` (+7 -2) 📝 `scripts/regressions/assigned-chat-sweep.regression.ts` (+35 -0) 📝 `scripts/regressions/roleplay-commands.regression.ts` (+4 -0) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+41 -2) </details> ### 📄 Description ## Linked issue Closes #6039 ## Why this change A nameless Echo Chamber reaction could crash the entire chat at `characterName.length`. Native iPhone text selection could also lose its position to automatic scrolling or be mistaken for a message-editing gesture. The Roleplay notes prompt needed a clearer explanation of updating an existing note. ## What changed - Validate Echo reactions at the existing client queue boundary, reuse that validation for activity bubbles, and reject malformed persisted entries individually so valid reactions still appear. - Use the existing text-selection utility to pause automatic chat/keyboard scrolling while text is selected. Message touch shortcuts, multi-select handling, and composer-shell focus handling leave native selections alone. Opening a chat waits for an existing selection to clear before scrolling to the latest message; delayed Echo scrolling also checks at execution time. - Explicitly tell characters to edit notes by sending their full updated contents, which replace the previous note. Existing note storage and character privacy rules are unchanged. - Add focused browser, queue, storage, and prompt regressions plus changelog entries. ## 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` Completed locally: `pnpm check` (including localization, types, lint, and production build), `pnpm regression:prompt`, and the `roleplay-streaming`, `assigned-chat-sweep`, and `roleplay-commands` Node regressions. Nine focused Playwright cases pass across desktop Chromium, mobile Chromium, and iPhone-sized WebKit, including opening another chat during a selection. The existing mobile Chromium composer focus/history test also passes after bounding its missing-textarea retry waits (10 passed, 2 existing project skips). Five additional mobile keyboard, viewport-menu, and older-message-editing checks passed in the surrounding smoke run. Before the fix, the browser regression reproduced a 260 px jump during selection and selection being replaced by message editing. The same checks now preserve the selection and scroll position; normal bottom-follow resumes after returning to the latest message. Missing names, non-string names/reactions, null entries, malformed containers, and valid siblings are covered for saved/live Echo data. ### Manual verification notes Browser screenshots were inspected. Manually verify the physical iPhone selection handles and Copy/Cut menu in messages, composers, and message editors, including during streaming and keyboard opening. Desktop WebKit automation cannot reproduce the native iOS selection-handle UI. No physical iPhone was available here. Final-commit build validation, container build, CodeQL, CodeRabbit review, and the complete Node/browser regression matrix passed. One unchanged Game dice-history test timed out on the first WebKit attempt; both variants passed locally, and the affected CI shard passed on one retry (80 passed, 5 existing skips). The original failure and baseline comparison are recorded in the PR comments. Container boot was not tested locally. ## 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 - [ ] Version/release files updated (only if this PR includes a version bump) Changelog updated. No user-facing labels, translated documentation, dependencies, or release versions changed. ## UI evidence (if applicable) [WebKit selection regression screenshots](https://gist.github.com/SpicyMarinara/96424bc5afa8e824c148058128e7a577). These show browser selection ranges, not physical iOS handles. <details> <summary>Roleplay message selection and Conversation draft selection during streaming</summary> <img width="320" alt="Roleplay message selection stays in place during streaming" src="https://gist.githubusercontent.com/SpicyMarinara/96424bc5afa8e824c148058128e7a577/raw/f7835b420e64bc5cb2dc444c70f4eb5d0ea3b13e/roleplay-message-selection.png"> <img width="320" alt="Conversation draft selection remains active during streaming" src="https://gist.githubusercontent.com/SpicyMarinara/96424bc5afa8e824c148058128e7a577/raw/3bf57414bddfc1b94e5fb4b1d6170ba7a6448cc7/conversation-composer-selection.png"> </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:15:57 +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#7036
No description provided.