Skip to content

fix(session): keep history when tool ids collide across sessions - #560

Merged
vastsa merged 2 commits into
mainfrom
fix/outbox-unique-message-id
Sep 17, 2026
Merged

vastsa merged 2 commits into
mainfrom
fix/outbox-unique-message-id

Conversation

@vastsa

@vastsa vastsa commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #523: closing and reopening dropped later conversation turns.

Provider toolCallIds (e.g. call_421522) were used as globally unique messages.id. A cross-session collision failed SQLite after the JSONL write, paused the FIFO persistence outbox, and later assistant/tool rows from every session never landed.

  • Host remaps a colliding id to {sessionId}:{id} before writing JSONL
  • Leftover JSONL from a failed UNIQUE is acknowledged without appending a second line
  • Orphan restore remaps colliding ids before rebuilding the index
  • Outbox treats UNIQUE constraint failed: messages.id as an ack and keeps draining

Test

  • cargo test -p host-core append_message_
  • cargo test -p host-core orphaned
  • node --test apps/desktop/test/persistence-outbox.test.mjs

Provider toolCallIds were used as globally unique messages.id. A
collision failed SQLite after the JSONL write, paused the FIFO
persistence outbox, and dropped later assistant/tool rows after quit.

Remap a colliding id to {sessionId}:{id} before the transcript write,
and treat UNIQUE constraint failed: messages.id as an outbox ack so
one poison entry cannot stall every later session.

Fixes #523
A failed UNIQUE append already wrote the original id to JSONL. Replaying
it must not append a remapped second line. Orphan restore remaps
colliding ids before rebuilding the index so D318 cannot UNIQUE-fail
and stall the outbox.
Copilot AI lite review requested due to automatic review settings September 17, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vastsa
vastsa merged commit 0aef791 into main Sep 17, 2026
4 checks passed
@vastsa
vastsa deleted the fix/outbox-unique-message-id branch September 17, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 关闭再次打开,前期的对话历史记录丢失

2 participants