[GH-ISSUE #3198] [Issue]: Chat textarea loses focus when generation starts #1719

Closed
opened 2026-10-21 05:42:00 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Jul 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3198

Originally assigned to: @SpicyMarinara on GitHub.

Summary

In RP chat, sending a message causes the chat input textarea to lose focus when generation begins. After generation finishes and the input is re-enabled, focus is not restored, requiring the user to click the input manually.

Expected behavior

After generation finishes and the chat input is re-enabled, the textarea should regain focus so the user can continue typing without clicking it.

Actual behavior

When generation starts, the textarea becomes disabled and the browser drops focus. When generation ends, the textarea is re-enabled but focus is not restored.

Steps to reproduce

  1. Open any RP chat.
  2. Type a message and press Enter to send it.
  3. Wait for generation to start.
  4. Observe that the textarea becomes disabled/greyed out and loses focus.
  5. Wait for generation to finish.
  6. Observe that the textarea is re-enabled but focus is not restored.
  7. Click the input manually to type again.

Environment

  • Marinara Engine version: 2.0.9
  • Install type: other
  • OS + version: Windows 11
  • Browser or app shell: Microsoft Edge, webpage installed as app

Logs, screenshots, or video

No logs, screenshots, or video provided. Report points to packages/client/src/components/chat/ChatInput.tsx around line 1625: disabled={!activeChatId || isInputBusy}. Suggested focus restore effect: useEffect(() => { if (!isInputBusy && textareaRef.current && !shouldShowMobileCollapsedComposer) { textareaRef.current.focus({ preventScroll: true }); } }, [isInputBusy, shouldShowMobileCollapsedComposer]);

Additional context

User reports this did not happen before updating to v2.0.9. Suspected cause: when isInputBusy becomes true, the textarea is disabled and browsers automatically remove focus from disabled elements. Existing focus calls reportedly handle text insertion, speech transcript, translate draft, and mobile collapse restore, but not the isInputBusy transition.

Discord thread: Bug: Chat textarea loses focus when generation starts
Discord thread link: https://discord.com/channels/1417099416812392641/1522808522453291188
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (1 message)
[2026-07-04T03:37:24.167Z] TheDarkPreacher: Description:
After sending a message in RP (hitting Enter), the chat input textarea loses focus entirely once generation begins. When generation finishes, the textarea is re-enabled but focus is not restored — you have to manually click the input to type again.

Steps to reproduce:
Open any RP chat
Type a message and hit Enter to send
Wait for generation to start — the textarea becomes disabled (greyed out, opacity-40)
Browser drops focus from the textarea because it's now disabled
When generation ends, textarea is re-enabled but nothing re-focuses it
You must manually click the input to regain focus

Root cause:
packages/client/src/components/chat/ChatInput.tsx line ~1625:
tsxdisabled={!activeChatId || isInputBusy}
When isInputBusy flips to true (on generation start), the textarea gets disabled={true}. Browsers automatically strip focus from disabled elements. When isInputBusy returns to false (generation ends), there's no useEffect watching that transition to call textareaRef.current.focus().

The existing focus() calls in the component only handle: text insertion, speech transcript, translate draft, and mobile collapse restore — none react to isInputBusy.

Suggested fix:
Add a useEffect to restore focus when the input becomes available again:
tsxuseEffect(() => {
  if (!isInputBusy && textareaRef.current && !shouldShowMobileCollapsedComposer) {
    textareaRef.current.focus({ preventScroll: true });
  }
}, [isInputBusy, shouldShowMobileCollapsedComposer]);

Impact: Minor UX annoyance — breaks flow for users who type immediately after generation ends.

Had Prof Mari help me write this up. Minor annoyance, just have to click on the text input area after each generation. Didn't have this problem before updating to v. 2.0.9, Windows 11, Edge browser, webpage installed as App.
[Discord message: https://discord.com/channels/1417099416812392641/1522808522453291188/1522808522453291188]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Jul 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3198 Originally assigned to: @SpicyMarinara on GitHub. ## Summary In RP chat, sending a message causes the chat input textarea to lose focus when generation begins. After generation finishes and the input is re-enabled, focus is not restored, requiring the user to click the input manually. ## Expected behavior After generation finishes and the chat input is re-enabled, the textarea should regain focus so the user can continue typing without clicking it. ## Actual behavior When generation starts, the textarea becomes disabled and the browser drops focus. When generation ends, the textarea is re-enabled but focus is not restored. ## Steps to reproduce 1. Open any RP chat. 2. Type a message and press Enter to send it. 3. Wait for generation to start. 4. Observe that the textarea becomes disabled/greyed out and loses focus. 5. Wait for generation to finish. 6. Observe that the textarea is re-enabled but focus is not restored. 7. Click the input manually to type again. ## Environment - Marinara Engine version: 2.0.9 - Install type: other - OS + version: Windows 11 - Browser or app shell: Microsoft Edge, webpage installed as app ## Logs, screenshots, or video No logs, screenshots, or video provided. Report points to packages/client/src/components/chat/ChatInput.tsx around line 1625: disabled={!activeChatId || isInputBusy}. Suggested focus restore effect: useEffect(() => { if (!isInputBusy && textareaRef.current && !shouldShowMobileCollapsedComposer) { textareaRef.current.focus({ preventScroll: true }); } }, [isInputBusy, shouldShowMobileCollapsedComposer]); ## Additional context User reports this did not happen before updating to v2.0.9. Suspected cause: when isInputBusy becomes true, the textarea is disabled and browsers automatically remove focus from disabled elements. Existing focus calls reportedly handle text insertion, speech transcript, translate draft, and mobile collapse restore, but not the isInputBusy transition. Discord thread: Bug: Chat textarea loses focus when generation starts Discord thread link: https://discord.com/channels/1417099416812392641/1522808522453291188 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (1 message)</summary> ```text [2026-07-04T03:37:24.167Z] TheDarkPreacher: Description: After sending a message in RP (hitting Enter), the chat input textarea loses focus entirely once generation begins. When generation finishes, the textarea is re-enabled but focus is not restored — you have to manually click the input to type again. Steps to reproduce: Open any RP chat Type a message and hit Enter to send Wait for generation to start — the textarea becomes disabled (greyed out, opacity-40) Browser drops focus from the textarea because it's now disabled When generation ends, textarea is re-enabled but nothing re-focuses it You must manually click the input to regain focus Root cause: packages/client/src/components/chat/ChatInput.tsx line ~1625: tsxdisabled={!activeChatId || isInputBusy} When isInputBusy flips to true (on generation start), the textarea gets disabled={true}. Browsers automatically strip focus from disabled elements. When isInputBusy returns to false (generation ends), there's no useEffect watching that transition to call textareaRef.current.focus(). The existing focus() calls in the component only handle: text insertion, speech transcript, translate draft, and mobile collapse restore — none react to isInputBusy. Suggested fix: Add a useEffect to restore focus when the input becomes available again: tsxuseEffect(() => { if (!isInputBusy && textareaRef.current && !shouldShowMobileCollapsedComposer) { textareaRef.current.focus({ preventScroll: true }); } }, [isInputBusy, shouldShowMobileCollapsedComposer]); Impact: Minor UX annoyance — breaks flow for users who type immediately after generation ends. Had Prof Mari help me write this up. Minor annoyance, just have to click on the text input area after each generation. Didn't have this problem before updating to v. 2.0.9, Windows 11, Edge browser, webpage installed as App. [Discord message: https://discord.com/channels/1417099416812392641/1522808522453291188/1522808522453291188] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:42:00 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jul 4, 2026):

Addressed in draft PR #3199.

<!-- gh-comment-id:4881612444 --> @SpicyMarinara commented on GitHub (Jul 4, 2026): Addressed in draft PR #3199.
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#1719
No description provided.