Debugger UI and correlation API
The debugger is a live view of paid HTTP traffic. Its server captures completed requests, groups payment challenges and retries into flows, and sends those flows to a React interface that shows status, timing, payment evidence, and delivery results. It also supports an inference view for unmetered model requests and can link a completed payment to an on-chain receipt.
See the Payment debugger web UI page for the wider product context.
System boundary
The system joins three concerns: a demo or proxied API produces request traffic, the serverless API turns that traffic into correlation events, and the browser presents the current state. The browser does not discover payment state from the chain; it uses the headers and bodies captured at the HTTP boundary.
This diagram shows how a request becomes a live flow in the interface.
flowchart LR
A[Client request] --> B[Express route or proxy]
B --> C[Request log entry]
C --> D[Flow correlation]
D --> E[Flow snapshot or SSE event]
E --> F[React reducer]
F --> G[Flow list and detail view]
F --> H[Provider and connection view]
The server keeps the log and correlation state in memory. A warm process can serve both the API and the UI, while a new serverless process starts with a new state set.
References: web-ui/…/index.ts• L18-34 web-ui/…/index.ts• L72-84 web-ui/…/index.ts• L86-90
React state model
The React app has one state path for configuration and one live state path for traffic. Configuration supplies the operating context. The live state holds flows, the viewer address, connection health, providers, and inference connection summaries.
Live flow state
useFlows opens a server-sent events (SSE) stream, which is a one-way HTTP stream from the server to the browser. It maps each message to a reducer action so that a snapshot replaces the current list while later create and update events change only the affected flow.
The reducer also keeps provider data and connection groups separate from payment flows. Configuration can seed providers before the first live provider event arrives. Once live provider data exists, it becomes the source of truth.
References: web-ui/…/useFlows.ts• L10-32 web-ui/…/useFlows.ts• L34-75 web-ui/…/useFlows.ts• L87-151 web-ui/…/types.ts• L142-151
Display modes
ConfigProvider reads /__402/pdb/api/config and defaults to debugger mode when no mode is supplied. The app then derives either a flat payment-flow list or a connection-grouped inference list from the same live state.
Debugger mode supports path and protocol search plus device, error, and all-flow filters. Inference mode searches model names and reports connection counts instead of flow counts. The selected flow and sidebar state remain local browser state, so a new stream snapshot does not change the user’s display choices.
References: web-ui/…/useConfig.tsx• L5-29 web-ui/…/useConfig.tsx• L41-44 web-ui/…/App.tsx• L11-73 web-ui/…/Toolbar.tsx• L15-64
Flow presentation
The main view presents a compact row for each flow and expands one row into a detail view. The row gives the fast signal. The detail view explains the request sequence and preserves the raw evidence needed to inspect a result.
Flow list
The flow list is flat in debugger mode and grouped by connection in inference mode. A new flow is selected automatically until the user makes a selection. In grouped mode, the newest connection starts open and the user can override each group’s expanded state.
Each row identifies the protocol or model, resource path, status, amount or throughput, duration, and start time. An open session channel replaces the normal status marker with an open indicator.
References: web-ui/…/App.tsx• L26-41 web-ui/…/FlowList.tsx• L27-44 web-ui/…/FlowList.tsx• L46-123 web-ui/…/FlowRow.tsx• L44-86
Flow detail
The detail view has three related parts: a sequence diagram for progress, a protocol-specific information panel, and a timestamped event log. This keeps the visual summary separate from the evidence that explains why a flow reached its current state.
Payment flows use request, challenge, payment, and delivery steps. Unmetered inference flows use request, first token, and completed steps unless they also carry payment data. Long event details can be expanded and JSON responses are formatted for inspection.
References: web-ui/…/FlowDetail.tsx• L16-41 web-ui/…/SequenceDiagram.tsx• L25-121 web-ui/…/EventLog.tsx• L13-67 web-ui/…/inference.ts• L39-99
Context sidebars
The sidebar changes with the app mode. Debugger mode shows the configured MPP, x402, and OAuth endpoints along with network, recipient, and currency context. Inference mode shows detected providers and their model lists.
The sidebar also gives a practical path from a displayed endpoint or recipient to a request or explorer page. This makes the UI useful both for watching traffic and for starting a small local or sandbox check.
References: web-ui/…/Sidebar.tsx• L45-149 web-ui/…/Sidebar.tsx• L152-199 web-ui/…/ProviderSidebar.tsx• L79-89 web-ui/…/ProviderSidebar.tsx• L9-75
Payment and inference views
The detail panels adapt the same flow record to the kind of work it represents. Payment views explain who receives funds and what was accepted. Session views explain ongoing channel capacity. Inference views explain model work without pretending that an unmetered request has a payment sequence.
Payment evidence
The payment view reads the challenge from the captured www-authenticate header. It draws the payer-to-recipient split for a charge and shows a signed-message access card for authentication or subscription access, where no per-request payment should be shown.
After a successful flow, receipt utilities inspect payment response headers and choose the best available settlement reference. The UI prefers a direct receipt URL, then builds a pay.sh receipt URL from the configured or receipt network. It omits the link when there is no usable signature or known network.
References: web-ui/…/PaymentSplits.tsx• L41-123 web-ui/…/PaymentSplits.tsx• L215-281 web-ui/…/receipt.ts• L48-103 web-ui/…/ReceiptLink.tsx• L10-61
Session channels
A session channel represents a payment authorization that can support more than one request. The panel shows the channel state, cap, cumulative watermark, remaining capacity, voucher count, and recipient split so an engineer can see both authorization and use.
The server derives session information from the challenge, authorization, and commit response. The browser then turns that information into a progress view. Missing or non-numeric capacity data remains unknown instead of being displayed as a false percentage.
References: web-ui/…/types.ts• L32-64 web-ui/…/correlation.ts• L451-533 web-ui/…/SessionChannel.tsx• L311-524
Inference connections
Inference mode groups requests into a connection summary. A connection is the UI’s aggregate view of a client identity, its recent models, request counts, token counts, failures, paid amount, and activity time.
The grouping prefers an exact payer match. When a payer is not available, it uses the client address and keeps unmatched flows in an other group. Provider colors and model badges make model identity primary while keeping the provider as supporting context.
References: web-ui/…/types.ts• L66-113 web-ui/…/connections.ts• L25-90 web-ui/…/ConnectionGroup.tsx• L17-98 web-ui/…/InferencePanel.tsx• L20-68
Proxy context
The payment debugger proxy configuration describes the paid demo surface that the debugger is meant to inspect. It names the service and sandbox network, sets USDC as the supported currency, identifies the vendor recipient, and declares metered report and checkout routes.
The checkout route includes a ten-percent vendor payout split. This configuration gives the traffic a stable business shape: one usage report route demonstrates a charge, while checkout demonstrates a charge with a downstream payout.
References: web-ui/…/payment-debugger.yml• L1-13 web-ui/…/payment-debugger.yml• L15-51
Correlation API
The serverless API is the bridge between HTTP payment activity and the browser. Express middleware records the request and response context, the correlation engine classifies the completed exchange, and the API exposes both a live stream and a point-in-time snapshot.
Request correlation
The correlation engine treats a payment flow as a related challenge and follow-up exchange. It recognizes MPP through payment authentication and receipt headers, x402 through its payment headers or response shape, and session traffic through its session intent and authorization. Facilitator calls are attached to a recent x402 flow by time.
A challenge starts a flow in the payment-required state. A matching paid retry completes or fails the flow. If the challenge is missing, the engine records a standalone delivered flow when it can identify a paid response. A pending flow becomes failed after one minute without a payment retry.
The engine matches a retry by client address and resource path first. It falls back to the newest pending flow for that path, which allows a flow to survive small differences in the observed client address but can be ambiguous when several clients use the same path at once.
References: web-ui/…/correlation.ts• L27-69 web-ui/…/correlation.ts• L71-89 web-ui/…/correlation.ts• L94-135 web-ui/…/correlation.ts• L188-265 web-ui/…/correlation.ts• L267-341
Stream endpoints
The stream endpoint sends the viewer address first, then a current flow snapshot, and then flow updates as the correlation engine emits them. The viewer address lets the browser support a “This device” filter without asking the server to hide other traffic.
The snapshot endpoint returns the same current correlated flow set as JSON. Both endpoints expose correlation state rather than raw request logs, so consumers can render the product-level flow model directly.
| Endpoint | Purpose |
|---|---|
GET /__402/pdb/logs/stream | Open the live SSE stream. |
GET /__402/pdb/logs | Read the current correlated flow snapshot. |
GET /__402/pdb/api/config | Read UI title, network, recipient, RPC, and endpoint metadata. |
References: web-ui/…/index.ts• L187-213 web-ui/…/index.ts• L215-277 web-ui/…/types.ts• L144-151
Support endpoints
The same serverless handler exposes the demo payment routes and the x402 facilitator that produce the events being inspected. MPP routes return a payment challenge before data and attach a receipt after payment. x402 routes use middleware plus facilitator verification and settlement. A health route reports the current network and recipient.
Vercel rewrites the debugger, payment, facilitator, and health paths to the one API function. Local development uses the same Express app, while the browser assets are served separately by the development UI server.
References: web-ui/…/index.ts• L280-352 web-ui/…/index.ts• L354-415 web-ui/…/index.ts• L417-471 web-ui/vercel.json• L1-10
Change checklist
When these files or sections are changed, remember to consider these:
- Update
SSEMessage, the backend broadcast path, and theuseFlowsreducer together when a live event changes. A new event that is not handled by the reducer will not reach the UI. - Keep payment header detection in api/correlation.ts aligned with receipt parsing in src/…/receipt.ts and challenge parsing in PaymentSplits.tsx. A header shape can affect both flow creation and the receipt link.
- Treat
PaymentFlow,SessionInfo, andConnectionSummaryas browser-facing contracts. Changes to their fields can affect the row, detail panel, grouping, and raw-data views. - When adding an app mode, update config defaults and the mode branches in
App,FlowList,FlowDetail,Toolbar, and the sidebar. Otherwise one view can show a mode that another view does not understand. - Keep endpoint names and rewrite paths aligned across the config response, sidebar links, demo routes, and vercel.json. A route can remain visible while its link or deployment rewrite is stale.
- When changing network names or receipt fields, update the network mapping and receipt-signature fallback order together. Unknown network values must not create misleading explorer links.
- When changing flow matching or timeout rules, check concurrent requests from the same client and resource. The path-only fallback can join the wrong pending flow if the correlation rule becomes less specific.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| SSE connection fails | The list stops receiving new flow and provider events. | The UI marks the stream disconnected and the browser’s EventSource can retry the connection. |
| A payment header or body has an unsupported shape | The exchange may not become a flow, or its payment and session fields may be incomplete. | Correlation and receipt parsing fail closed and keep the raw captured headers and body available for inspection. |
| A retry has no matching pending challenge | The UI shows a standalone delivered flow instead of a challenge-to-delivery sequence. | Inspect the client address, resource path, and captured request headers before treating the flow as a server error. |
| No payment retry arrives for 60 seconds | The pending flow changes to failed and records a timeout event. | Use the event timestamp and the flow’s status to distinguish a timeout from an upstream payment error. |
| A response has no usable receipt signature or known network | The successful flow has no “View receipt” link. | Check the captured response headers and the receipt network before treating the missing link as a settlement failure. |
| A serverless instance goes cold or traffic reaches another instance | In-memory flows and logs are not shared with the new process. | Treat the stream snapshot as process-local and reproduce the request when historical state is absent. |
| Configuration fetch fails | The app falls back to debugger mode and may have no endpoint or provider context. | Check /__402/pdb/api/config before diagnosing missing sidebar data as a correlation issue. |
Key files
| File | Why to read it |
|---|---|
| web-ui/…/index.ts | Shows the request capture boundary, SSE and snapshot endpoints, config contract, demo payment routes, and serverless handler. |
| web-ui/…/correlation.ts | Defines how HTTP evidence becomes a payment flow and how flow state changes over time. |
| web-ui/…/types.ts | Defines the shared flow, session, inference, connection, and SSE message contracts. |
| web-ui/…/App.tsx | Shows the top-level React state composition, filters, mode split, selection, and sidebar choice. |
| web-ui/…/useFlows.ts | Shows how live server events become reducer state in the browser. |
| web-ui/…/FlowList.tsx | Shows flat payment rows, grouped inference connections, selection, and expansion behavior. |
| web-ui/…/FlowDetail.tsx | Shows how one flow selects the sequence, payment, session, or inference view. |
| web-ui/…/receipt.ts and web-ui/…/ReceiptLink.tsx | Explain how response evidence becomes a settlement receipt link. |
| web-ui/…/inference.ts and web-ui/…/connections.ts | Explain inference-only step display, provider identity, and connection grouping. |
| web-ui/…/payment-debugger.yml | Describes the sandbox payment routes and payout split used as proxy context for the debugger. |
| web-ui/vercel.json | Shows how browser-facing paths reach the serverless API in deployment. |