fix(opencode): order legacy message loop by time

Merged
OP
4mo ago
+120-10

Summary

  • select the latest user, assistant, and completed assistant by creation time with ID as a same-millisecond tie-breaker
  • apply the same ordering to pending compaction and subtask work
  • end a completed response loop when the assistant points to the latest user through parentID
  • preserve existing tool-call continuation behavior

Testing

  • bun test test/session/message-v2.test.ts --timeout 30000 --only-failures (39 passed)
  • bun test test/session/prompt.test.ts --test-name-pattern "loop exits for a completed parent turn" --timeout 30000 --only-failures (1 passed)
  • Full prompt test file in implementation worktree (57 passed, 1 skipped)
  • Prettier
  • git diff --check

Requested by: @thdxr (Dax Raad via Slack)