Skip to content

feat: add session-bound WebSocket server helper - #734

Merged
brendanjryan merged 2 commits into
brendanjryan/fix-streaming-session-settlementfrom
brendanjryan/bind-session-websocket-server
Aug 1, 2026
Merged

feat: add session-bound WebSocket server helper#734
brendanjryan merged 2 commits into
brendanjryan/fix-streaming-session-settlementfrom
brendanjryan/bind-session-websocket-server

Conversation

@brendanjryan

Copy link
Copy Markdown
Collaborator

Motivation

WebSocket session servers should reuse the store and scheduled-settlement policy already configured on the session method instead of requiring callers to thread those dependencies through every route.

Summary

  • Added mppx.session.serveWebSocket(...) with the configured store and settlement callback bound automatically
  • Kept the lower-level WebSocket server API available with a generic post-commit callback
  • Updated the WebSocket example and documented HTTP, SSE, WebSocket, and mixed server configurations
  • Added integration and type coverage for the bound helper

Key design considerations

  • The session method remains the single owner of shared session state and settlement policy
  • The bound helper accepts only route-specific WebSocket options
  • HTTP and SSE behavior remains unchanged

@brendanjryan
brendanjryan marked this pull request as ready for review July 31, 2026 23:18
@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@pkg-pr-new

pkg-pr-new Bot commented Jul 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/mppx@734

commit: 9c43087

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93e5fbf2e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,5 @@
---
'mppx': patch

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the replaced APIs or use a minor bump

This changeset declares a patch release, but the commit removes the public mppx.session.settleScheduled extension and renames the public tempo.Ws.serve option from settleScheduled to onChargeCommitted. Existing TypeScript consumers will require source changes, while already-built JavaScript integrations can silently lose scheduled settlement because the old option is ignored. Retain backward-compatible aliases, or classify this consumer migration as a minor bump.

AGENTS.md reference: AGENTS.md:L152-L154

Useful? React with 👍 / 👎.

Comment on lines +298 to +299
Each route can choose its own price and unit type. Verification, channel state,
and settlement policy remain shared through the single session method.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Route mixed POST charges through the settlement policy

This shared-settlement claim is false for a billable POST route configured with sse: true that returns a plain Response: applyVerifiedHttpAccounting exits early for every such POST (src/tempo/session/server/Settlement.ts:295), and the plain-response path in Transport.sse.respondReceipt only calls ChannelStore.deductFromChannel without invoking settleCharged (src/tempo/server/internal/transport.ts:185-224). Consequently the documented mixed configuration records HTTP spend but skips its configured automatic settlement schedule; either wire that deduction through the settlement callback or document the limitation rather than recommending this configuration as fully shared.

Useful? React with 👍 / 👎.

@brendanjryan
brendanjryan merged commit b32907f into brendanjryan/fix-streaming-session-settlement Aug 1, 2026
14 checks passed
@brendanjryan
brendanjryan deleted the brendanjryan/bind-session-websocket-server branch August 1, 2026 17:21
brendanjryan added a commit that referenced this pull request Aug 3, 2026
* fix: settle streaming session charges on schedule

* feat: add session-bound WebSocket server helper (#734)

* feat: add session-bound websocket server helper

* fix: preserve settlement APIs for mixed transports

* test: expand streaming settlement coverage
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.

1 participant