Bug Report: Desktop chat timeline shows messages out of chronological order (concurrent sessions on same profile)
Environment
- Hermes desktop app (Electron), Windows 10
- Provider: DeepSeek (deepseek-v4-pro), profile: default
- Multiple concurrent sessions on the same profile (main chat + other chat sessions + cron jobs)
Symptom
In the desktop chat view, messages appear out of chronological order. A message the user just sent appears ABOVE older messages ("刚才问的,怎么排在上面了"). The user reports this happens repeatedly ("老是时间线对不上"), and as a workaround they re-send messages — which produces duplicates in the DB.
Evidence gathered from state.db + logs (2026-08-15)
-
Duplicate user messages from UI confusion: in one session (20260808_162500_414ff7), the same user message appears many times: 再次审计 x18, 报告发下 x5, 审计下carbrands x5. The user confirms they re-sent messages because the UI displayed them at wrong positions.
-
Empty session_id in terminal events: desktop.log contains 2,305 JSON-RPC events of type agent.terminal.output with "session_id": "" (empty string). Terminal output from background processes is emitted without session attribution; if the renderer keys its message store by session_id, these events can land in whichever session view is active/rendered, causing messages from other sessions (and their tool outputs) to appear inside the current conversation.
-
Concurrent interleaved sessions: at 17:16–18:00, three sessions were writing to the shared messages table simultaneously (20260623_233846_232bb8, 20260808_162500_414ff7, 20260708_225453_563966). One of them received a [CONTEXT COMPACTION] event at 17:16:53 while the user was chatting in another. The DB itself is correctly ordered by rowid/timestamp — the disorder is in the desktop renderer's view, not the store.
-
The session in question (20260623_233846_232bb8) is a long-running session (June 23 → Aug 15) with multiple compactions; the wrong-order symptoms correlate with compaction events and concurrent session activity.
Likely root cause areas (to investigate)
agent.terminal.output events with empty session_id being dispatched to the active session view (or a shared store) instead of being dropped or routed by process_id.
- Renderer re-sorting messages by timestamp where second-level precision ties are broken unstably (several message pairs share the same second: e.g. rows 282813/282814 at 18:05:40, 282815/282816 at 18:05:50).
- Compaction notifications from one session triggering re-render/replay in another session's view.
- Out-of-band user messages (delivered mid-turn while the agent is streaming) being re-inserted at the wrong index on history replay.
Impact
- User cannot trust the conversation timeline; repeated re-sending pollutes sessions with duplicates.
- Risk of the model answering based on a wrongly-ordered context (e.g. stale "PV不准" appearing before a later question), degrading multi-session workflows.
Repro steps (approximate)
- Open 2+ sessions on the same profile in the desktop app, one running long tool chains (background terminal processes emitting output).
- Let one session trigger a context compaction while the other is streaming.
- Send messages in quick succession (<1s apart) in the active session.
- Observe messages landing above older ones / tool output from the other session appearing in the wrong view.
Bug Report: Desktop chat timeline shows messages out of chronological order (concurrent sessions on same profile)
Environment
Symptom
In the desktop chat view, messages appear out of chronological order. A message the user just sent appears ABOVE older messages ("刚才问的,怎么排在上面了"). The user reports this happens repeatedly ("老是时间线对不上"), and as a workaround they re-send messages — which produces duplicates in the DB.
Evidence gathered from state.db + logs (2026-08-15)
Duplicate user messages from UI confusion: in one session (
20260808_162500_414ff7), the same user message appears many times:再次审计x18,报告发下x5,审计下carbrandsx5. The user confirms they re-sent messages because the UI displayed them at wrong positions.Empty
session_idin terminal events:desktop.logcontains 2,305 JSON-RPC events of typeagent.terminal.outputwith"session_id": ""(empty string). Terminal output from background processes is emitted without session attribution; if the renderer keys its message store by session_id, these events can land in whichever session view is active/rendered, causing messages from other sessions (and their tool outputs) to appear inside the current conversation.Concurrent interleaved sessions: at 17:16–18:00, three sessions were writing to the shared
messagestable simultaneously (20260623_233846_232bb8,20260808_162500_414ff7,20260708_225453_563966). One of them received a[CONTEXT COMPACTION]event at 17:16:53 while the user was chatting in another. The DB itself is correctly ordered by rowid/timestamp — the disorder is in the desktop renderer's view, not the store.The session in question (
20260623_233846_232bb8) is a long-running session (June 23 → Aug 15) with multiple compactions; the wrong-order symptoms correlate with compaction events and concurrent session activity.Likely root cause areas (to investigate)
agent.terminal.outputevents with emptysession_idbeing dispatched to the active session view (or a shared store) instead of being dropped or routed byprocess_id.Impact
Repro steps (approximate)