Skip to content

Bug: "Session Zombie" queue lock and UI state leaks during session switching in Desktop App #62823

Description

@Thewind777

Bug Description

There are two critical state-handling bugs present in the Hermes Desktop App:

  1. Session Zombie Queue Lock: When a concurrent session limit is enforced (e.g., set to 2), stopping or finishing a task fails to clear the backend slot. The app continues to treat stale sessions as active, locking the queue and blocking new prompts.
  2. Session Visual Merging / State Leak: When switching between tabs in the left sidebar—especially while a session is busy or a follow-up is queued—the chat interface glitches and "merges" the sessions. The active message view from one session leaks directly into the other. This requires multiple refreshes or completely restarting the desktop application to get the views isolated again.

Steps to Reproduce

  1. Go to Settings in the Hermes Desktop App and set the concurrent session limit to 2.
  2. Open and run two separate sessions with active prompts.
  3. While Session A is busy or actively handling an output/follow-up, click on Session B in the left sidebar.
  4. Observe the interface glitch: Session B's view will incorrectly display or blend with Session A's chat content.
  5. Stop both sessions and attempt to start a third; observe that the concurrent limit acts as though both slots are still fully occupied.

Expected Behavior

When a session is stopped, finished, or idle with no active background processes running, the gateway should release its slot immediately, updating the concurrent session counter so that new slots open up for execution.

Actual Behavior

The desktop app frontend locks up and refuses new input due to ghost session counters. Concurrently, session context boundaries break down in the UI layer during sidebar navigation. The chat history from separate sessions visually merges together, forcing the user to repeatedly restart the application and force-refresh to fix the UI rendering.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Debug Report

Report       https://paste.rs/4OPiZ
  agent.log    https://paste.rs/jMG8C
  gateway.log  (Logs have been temporarily removed to redact exposed plain-text API credentials.)
  gui.log      https://paste.rs/B0koo
  desktop.log  (Logs have been temporarily removed to redact exposed plain-text API credentials.)

Operating System

Windows 11

Python Version

3.11.15

Hermes Version

0.18.2

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

This points to an issue where session-scoped UI rendering and background workers are not keyed strongly enough by the unique session_id in the Electron layer (specifically around use-prompt-actions.ts or the active streaming subscriptions). When a user switches sessions or hits "stop," stale asynchronous stream updates continue pushing data to the active viewport, and dropped WebSocket signals leave dirty "active" flags inside ~/.hermes/state.db.

Proposed Fix (optional)

  1. Queue Sticking: Implement a definitive cleanup hook or timeout handler within the desktop client's IPC/WebSocket wrapper (use-prompt-actions.ts) that catches termination, error, or idle signals. If a user interrupts a running turn, it must explicitly dispatch a state cleanup mutation to ensure the active session flags in the local SQLite database (~/.hermes/state.db) drop back down to 0 immediately.

  2. UI Visual Merging: Scope the chat viewport context strictly to the selected session_id. When switching sidebar tabs, immediately unmount or purge the state of the active message thread/composer component rather than letting background asynchronous streaming events continuously append updates to a shared, dirty UI viewport.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/sessionsSession lifecycle, resume, persistence, historycomp/desktopElectron desktop app (apps/desktop/*)needs-reproBug needs reproduction stepssweeper:risk-session-stateSweeper risk: may lose/corrupt/mis-associate session or context statetype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions