Skip to content

fix: slash command message ordering in timeline - #38612

Closed
lileilei-camera wants to merge 1 commit into
anomalyco:devfrom
lileilei-camera:fix/slash-command-race-condition
Closed

fix: slash command message ordering in timeline#38612
lileilei-camera wants to merge 1 commit into
anomalyco:devfrom
lileilei-camera:fix/slash-command-race-condition

Conversation

@lileilei-camera

@lileilei-cameralileilei-camera commented Jul 24, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes#38613

Type of change

  • Bug fix

What does this PR do?

Fix the WebChat slash command message ordering bug where command output appears at the wrong position in the timeline.

Root cause: event-stream race condition — when slash command output messages arrive before the previous turn's final flush events, the sync data array contains messages in the wrong order. Both model.ts and message-timeline.tsx use the unsorted sync array directly.

Fix:

  • model.ts: sort messages by time.created in the messages memo (id as tiebreaker), fixing ordering at the data source
  • message-timeline.tsx: add orderedMessages memo as defensive layer, passing sorted messages to createTimelineProjection instead of raw sessionMessages

Note: the submission-side race (setBusy/setIdle) has been independently addressed upstream via the serverSync() API refactor.

How did you verify your code works?

  1. Rebuilt binary with WebChat frontend embedded
  2. Tested on WebChat over multiple days:
    • Slash command output appears in correct chronological order
    • No visible side effects on normal message flow
  3. Smoke test: binary launches and responds normally

Screenshots / recordings

Not applicable — behavioral fix, no UI changes.

Checklist

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

@github-actionsgithub-actionsBot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@lileilei-camera
lileilei-cameraforce-pushed the fix/slash-command-race-condition branch 2 times, most recently from 382d543 to 7b4aa5eCompareJuly 24, 2026 04:14
Sort messages by time.created in both model.ts and message-timeline.tsx
to fix event-stream race condition where slash command output
arrives before previous turn final events, causing incorrect
timeline positioning.
- model.ts: sort messages in the messages memo by time.created
(id as tiebreaker), fixing ordering at the data source
- message-timeline.tsx: add orderedMessages memo as defensive
layer, passing sorted messages to createTimelineProjection
@lileilei-camera
lileilei-cameraforce-pushed the fix/slash-command-race-condition branch from 7b4aa5e to c18980eCompareJuly 24, 2026 04:15
@lileilei-cameralileilei-camera changed the title fix: slash command race condition and message orderingfix: slash command message ordering in timelineJul 24, 2026
@github-actionsgithub-actionsBot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebChat: slash command output appears at wrong position in timeline

1 participant

@lileilei-camera