Skip to content

refactor(session): eliminate Effect.promise roundtrips for sync MessageV2.stream#21973

Merged
kitlangton merged 1 commit intodevfrom
kit/eliminate-message-v2-roundtrips
Apr 11, 2026
Merged

refactor(session): eliminate Effect.promise roundtrips for sync MessageV2.stream#21973
kitlangton merged 1 commit intodevfrom
kit/eliminate-message-v2-roundtrips

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Replace Effect.promise(async () => { for await ... MessageV2.stream() }) with Effect.sync(() => { for ... MessageV2.stream() }) in two places in prompt.ts
  • MessageV2.stream is a synchronous generator, so wrapping it in Effect.promise with for await creates an unnecessary async roundtrip

Changed callers

  • lastModel — finds the most recent user message's model config
  • lastAssistant — finds the most recent assistant message

What was NOT changed

  • All other MessageV2 facade calls are either already using Effect versions (toModelMessagesEffect, filterCompactedEffect), already wrapped in Effect.sync, or called from non-Effect context (CLI, server routes, tests)
  • No facade functions were deleted

Test plan

  • bun run typecheck passes (no new errors)
  • Session tests (blocked by unrelated @opentui/solid/preload issue)

@kitlangton kitlangton force-pushed the kit/eliminate-message-v2-roundtrips branch 2 times, most recently from ca9e775 to 9b77f8e Compare April 11, 2026 03:07
…essageV2.stream calls

MessageV2.stream is a synchronous generator, so wrapping it in
Effect.promise with `for await` is an unnecessary async roundtrip.
Use Effect.sync with a plain `for` loop instead.
@kitlangton kitlangton force-pushed the kit/eliminate-message-v2-roundtrips branch from 9b77f8e to a28fc76 Compare April 11, 2026 03:12
@kitlangton kitlangton merged commit cd004cf into dev Apr 11, 2026
7 of 9 checks passed
@kitlangton kitlangton deleted the kit/eliminate-message-v2-roundtrips branch April 11, 2026 03:18
mrsimpson pushed a commit to mrsimpson/opencode that referenced this pull request Apr 14, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Sign up for free to 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.

1 participant