Skip to content

fix(session): sort messages by creation time instead of id#21572

Open
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:fix/message-ordering
Open

fix(session): sort messages by creation time instead of id#21572
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:fix/message-ordering

Conversation

@sjawhar
Copy link
Copy Markdown

@sjawhar sjawhar commented Apr 8, 2026

Issue for this PR

Closes #15657
Closes #17012
Closes #21569

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes session logic that assumed message IDs were chronologically ordered.

The branch sorts session messages by creation time instead of raw ID order, updates revert paths to use index-based selection instead of ID comparisons, and updates the web session page so deep-linked sessions do not crash during initial message loading.

How did you verify your code works?

  • cd packages/util && bun test src/message.test.ts
  • cd packages/util && bun typecheck
  • cd packages/opencode && bun typecheck
  • cd packages/app && bun typecheck
  • cd packages/ui && bun typecheck
  • Built-binary smoke test from this branch:
    • deep-linked session page loaded instead of hitting the app error boundary
    • imported/live skewed-message session API returned messages in chronological order

Screenshots / recordings

Built web session page smoke-tested locally with Playwright after the deep-link crash fix.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@sjawhar sjawhar requested a review from adamdotdevin as a code owner April 8, 2026 21:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

The following comment was made by an LLM, it may be inaccurate:

I found a potentially related PR:

Related PR:

This PR (#17149) appears to address the same issue of ordering session messages by creation time rather than ID order. It's likely either a related/prior attempt at the same fix or a duplicate effort targeting the same underlying problem with message chronological ordering in sessions.

@sjawhar sjawhar force-pushed the fix/message-ordering branch 2 times, most recently from 82ab4fa to f727938 Compare April 9, 2026 01:37
@sjawhar sjawhar force-pushed the fix/message-ordering branch from f727938 to b77fd65 Compare April 9, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant