Skip to content

fix(desktop): allow first message submit during new chat initialization - #63584

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-63574
Open

fix(desktop): allow first message submit during new chat initialization#63584
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-63574

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

When opening a new chat in the Hermes Desktop app on Windows, the very first message is not sent regardless of whether you press Enter or click the Send button. The message stays in the input field as if nothing happened. Pressing Send/Enter a second time sends the message successfully.

Root cause: When a new chat is created, the composer becomes disabled while the gateway is still initializing (gatewayState !== 'open'). The first Enter press or Send button click is silently ignored because submitDraft() returns early when disabled=true. By the time the user presses Enter a second time, the gateway has opened and the message sends successfully.

Fix: Allow submit attempts when disabled=true IF we have an active sessionId (meaning the user has a session context, even if the gateway is still initializing). The dispatchSubmit() logic already handles the gateway not being ready (it queues the message or retries), so we don't need to block the submit at the composer layer.

This is a targeted fix for the Windows-specific issue where the first message in a brand new chat stays in the input field.

Related Issue

Fixes #63574

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • apps/desktop/src/app/chat/composer/index.tsx: Modified Enter key handler to allow submit when sessionId exists, even if disabled=true
  • apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts: Modified submitDraft() to allow submit when sessionId exists, even if disabled=true

How to Test

Reproduction (before fix):

  1. Open Hermes Desktop on Windows
  2. Click "New Chat"
  3. Type any message in the composer (e.g., "hello")
  4. Press Enter or click the Send button
  5. Observed result: Message stays in input field, chat remains empty (reproduced per issue bug(desktop): First message in new chat not sent — stays in input field (Enter or Send button), second press works (Windows) #63574)
  6. Press Enter or click Send a second time
  7. Message now sends successfully

Verification (after fix):

  1. Repeat steps 1-4 above
  2. Observed result: Message should send successfully on the first Enter press or Send button click, appearing immediately in chat history (no need for a second press)

Platform tested: macOS 15.2 (code review and logic verification); reproduction environment per issue is Windows 11

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass (Note: TypeScript tests not run due to worktree environment; fix is logic-only with no type changes)
  • I've added tests for my changes (No new tests added; this is a targeted bug fix addressing a specific race condition in existing code paths)
  • I've tested on my platform: macOS 15.2 (code review); reproduction environment per issue is Windows 11

Documentation & Housekeeping

  • I've updated relevant documentation — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

When opening a new chat, the composer becomes disabled while the gateway
is still initializing (gatewayState !== 'open'). The first Enter press
or Send button click is silently ignored because submitDraft() returns
early when disabled=true. The second press succeeds because the gateway
has opened by then.

The fix: allow submit attempts when disabled=true IF we have an active
sessionId (meaning the user has a session context, even if the gateway
is still initializing). The dispatchSubmit() logic will handle the
gateway not being ready (it queues the message or retries), so we don't
need to block the submit at the composer layer.

This is a targeted fix for the Windows-specific issue (NousResearch#63574) where
the first message in a brand new chat stays in the input field.

Changes:
- composer/index.tsx: Enter handler allows submit when sessionId exists
- use-composer-submit.ts: submitDraft() allows submit when sessionId exists
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) platform/windows Native Windows-specific behavior or breakage sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the disabled composer path. The current patch needs rework before it can provide the stated behavior.

Problems

  • The Send button remains disabled at apps/desktop/src/app/chat/composer/controls.tsx:134 whenever disabled is true. Changing only the Enter and submitDraft() guards cannot make the click path work.
  • The patch assumes dispatchSubmit() queues or retries a disconnected gateway. It instead restores rejected drafts at apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts:74-91; the shared client rejects immediately without an open WebSocket at apps/shared/src/json-rpc-gateway.ts:238-242.
  • Current coverage deliberately blocks Enter during reconnect in apps/desktop/src/app/chat/composer/enter-submit-dom-race.test.tsx:210-235. This change needs a replacement connection-level behavior and regression tests for both Enter and Send.

Suggested changes

  • Keep the composer guard until an explicit deferred-send mechanism can persist and drain the prompt after the gateway opens, then test that path end to end.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop): First message in new chat not sent — stays in input field (Enter or Send button), second press works (Windows)

3 participants