[Feature] Add Real-Time Cost Ticker for Transparency in Workshop Interactions #68
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Description
Users interacting with the Timmy Tower Workshop, especially those utilizing Lightning payments, currently lack real-time visibility into the cost of their ongoing interactions. This can lead to uncertainty and a lack of transparency regarding the financial implications of using the service.
To build user confidence and provide a clearer understanding of resource consumption, a real-time cost ticker is needed.
Reproduction Steps (Current Behavior)
Expected Behavior
During an active, paid interaction with Timmy, a small, dynamic ticker should display the accumulating cost in real-time (e.g., in sats). This ticker should update as the job executes, providing immediate feedback to the user.
Technical Details
replit/timmy-towerthe-matrix/js/ui.js: This file handles UI updates and already includes logic for a cost preview (_ensureCostPreview,_showCostPreview,_hideCostPreview). This existing infrastructure can be leveraged.the-matrix/js/websocket.js: The WebSocket connection is the primary channel for receiving real-time updates from the backend. ThehandleMessagefunction would need to process new message types related to cost updates.artifacts/api-server/src/routes/events.ts: The backend WebSocket bridge would need to be extended to emit real-time cost updates during job execution.artifacts/api-server/src/routes/estimate.ts: This route already provides cost estimation, which could inform the initial display of the ticker.Proposed Solution
artifacts/api-server/src/routes/events.ts) to emit incremental cost updates via the WebSocket connection during the execution of a job. This could be a new message type (e.g.,cost_update).the-matrix/js/websocket.js, add a new case to thehandleMessagefunction to processcost_updatemessages.the-matrix/js/ui.js, implement a new UI element (or adapt the existing cost preview) to display the real-time cost. This element should update dynamically based on thecost_updatemessages received from the WebSocket.Labels
feature,frontend,backend,ux,payment,real-timePR created: http://143.198.27.163:3000/replit/timmy-tower/pulls/82
Summary of changes:
CostEventtype to the EventBus (cost:updatewith jobId, sats, phase, isFinal)cost:updateevents: estimated cost when a work invoice is issued, actual cost when work completes (paid jobs only); session requests also publish on completionevents.tsWebSocket bridge translatescost:update→cost_updateWS messagesui.jsgains three new exports:showCostTicker,updateCostTicker,hideCostTicker— a fixed HUD badge positioned top-right (below connection status) showing⚡ ~N sats→⚡ N sats chargedwebsocket.jshandlescost_updatemessages and drives the ticker; auto-hides 5s after the final charge is shown